babylon.module.d.ts 5.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857
  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. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/observable" {
  50. import { Nullable } from "babylonjs/types";
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * 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.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * 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).
  162. * 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.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. readonly observers: Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @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.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module "babylonjs/Misc/domManagement" {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Extracts text content from a DOM element hierarchy
  289. * @param element defines the root element
  290. * @returns a string
  291. */
  292. static GetDOMTextContent(element: HTMLElement): string;
  293. }
  294. }
  295. declare module "babylonjs/Misc/logger" {
  296. /**
  297. * Logger used througouht the application to allow configuration of
  298. * the log level required for the messages.
  299. */
  300. export class Logger {
  301. /**
  302. * No log
  303. */
  304. static readonly NoneLogLevel: number;
  305. /**
  306. * Only message logs
  307. */
  308. static readonly MessageLogLevel: number;
  309. /**
  310. * Only warning logs
  311. */
  312. static readonly WarningLogLevel: number;
  313. /**
  314. * Only error logs
  315. */
  316. static readonly ErrorLogLevel: number;
  317. /**
  318. * All logs
  319. */
  320. static readonly AllLogLevel: number;
  321. private static _LogCache;
  322. /**
  323. * Gets a value indicating the number of loading errors
  324. * @ignorenaming
  325. */
  326. static errorsCount: number;
  327. /**
  328. * Callback called when a new log is added
  329. */
  330. static OnNewCacheEntry: (entry: string) => void;
  331. private static _AddLogEntry;
  332. private static _FormatMessage;
  333. private static _LogDisabled;
  334. private static _LogEnabled;
  335. private static _WarnDisabled;
  336. private static _WarnEnabled;
  337. private static _ErrorDisabled;
  338. private static _ErrorEnabled;
  339. /**
  340. * Log a message to the console
  341. */
  342. static Log: (message: string) => void;
  343. /**
  344. * Write a warning message to the console
  345. */
  346. static Warn: (message: string) => void;
  347. /**
  348. * Write an error message to the console
  349. */
  350. static Error: (message: string) => void;
  351. /**
  352. * Gets current log cache (list of logs)
  353. */
  354. static readonly LogCache: string;
  355. /**
  356. * Clears the log cache
  357. */
  358. static ClearLogCache(): void;
  359. /**
  360. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  361. */
  362. static LogLevels: number;
  363. }
  364. }
  365. declare module "babylonjs/Misc/typeStore" {
  366. /** @hidden */
  367. export class _TypeStore {
  368. /** @hidden */
  369. static RegisteredTypes: {
  370. [key: string]: Object;
  371. };
  372. /** @hidden */
  373. static GetClass(fqdn: string): any;
  374. }
  375. }
  376. declare module "babylonjs/Misc/deepCopier" {
  377. /**
  378. * Class containing a set of static utilities functions for deep copy.
  379. */
  380. export class DeepCopier {
  381. /**
  382. * Tries to copy an object by duplicating every property
  383. * @param source defines the source object
  384. * @param destination defines the target object
  385. * @param doNotCopyList defines a list of properties to avoid
  386. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  387. */
  388. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  389. }
  390. }
  391. declare module "babylonjs/Misc/precisionDate" {
  392. /**
  393. * Class containing a set of static utilities functions for precision date
  394. */
  395. export class PrecisionDate {
  396. /**
  397. * Gets either window.performance.now() if supported or Date.now() else
  398. */
  399. static readonly Now: number;
  400. }
  401. }
  402. declare module "babylonjs/Misc/devTools" {
  403. /** @hidden */
  404. export class _DevTools {
  405. static WarnImport(name: string): string;
  406. }
  407. }
  408. declare module "babylonjs/Misc/webRequest" {
  409. /**
  410. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  411. */
  412. export class WebRequest {
  413. private _xhr;
  414. /**
  415. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  416. * i.e. when loading files, where the server/service expects an Authorization header
  417. */
  418. static CustomRequestHeaders: {
  419. [key: string]: string;
  420. };
  421. /**
  422. * Add callback functions in this array to update all the requests before they get sent to the network
  423. */
  424. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  425. private _injectCustomRequestHeaders;
  426. /**
  427. * Gets or sets a function to be called when loading progress changes
  428. */
  429. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  430. /**
  431. * Returns client's state
  432. */
  433. readonly readyState: number;
  434. /**
  435. * Returns client's status
  436. */
  437. readonly status: number;
  438. /**
  439. * Returns client's status as a text
  440. */
  441. readonly statusText: string;
  442. /**
  443. * Returns client's response
  444. */
  445. readonly response: any;
  446. /**
  447. * Returns client's response url
  448. */
  449. readonly responseURL: string;
  450. /**
  451. * Returns client's response as text
  452. */
  453. readonly responseText: string;
  454. /**
  455. * Gets or sets the expected response type
  456. */
  457. responseType: XMLHttpRequestResponseType;
  458. /** @hidden */
  459. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  460. /** @hidden */
  461. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  462. /**
  463. * Cancels any network activity
  464. */
  465. abort(): void;
  466. /**
  467. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  468. * @param body defines an optional request body
  469. */
  470. send(body?: Document | BodyInit | null): void;
  471. /**
  472. * Sets the request method, request URL
  473. * @param method defines the method to use (GET, POST, etc..)
  474. * @param url defines the url to connect with
  475. */
  476. open(method: string, url: string): void;
  477. }
  478. }
  479. declare module "babylonjs/Misc/fileRequest" {
  480. import { Observable } from "babylonjs/Misc/observable";
  481. /**
  482. * File request interface
  483. */
  484. export interface IFileRequest {
  485. /**
  486. * Raised when the request is complete (success or error).
  487. */
  488. onCompleteObservable: Observable<IFileRequest>;
  489. /**
  490. * Aborts the request for a file.
  491. */
  492. abort: () => void;
  493. }
  494. }
  495. declare module "babylonjs/Misc/performanceMonitor" {
  496. /**
  497. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  498. */
  499. export class PerformanceMonitor {
  500. private _enabled;
  501. private _rollingFrameTime;
  502. private _lastFrameTimeMs;
  503. /**
  504. * constructor
  505. * @param frameSampleSize The number of samples required to saturate the sliding window
  506. */
  507. constructor(frameSampleSize?: number);
  508. /**
  509. * Samples current frame
  510. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  511. */
  512. sampleFrame(timeMs?: number): void;
  513. /**
  514. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  515. */
  516. readonly averageFrameTime: number;
  517. /**
  518. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  519. */
  520. readonly averageFrameTimeVariance: number;
  521. /**
  522. * Returns the frame time of the most recent frame
  523. */
  524. readonly instantaneousFrameTime: number;
  525. /**
  526. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  527. */
  528. readonly averageFPS: number;
  529. /**
  530. * Returns the average framerate in frames per second using the most recent frame time
  531. */
  532. readonly instantaneousFPS: number;
  533. /**
  534. * Returns true if enough samples have been taken to completely fill the sliding window
  535. */
  536. readonly isSaturated: boolean;
  537. /**
  538. * Enables contributions to the sliding window sample set
  539. */
  540. enable(): void;
  541. /**
  542. * Disables contributions to the sliding window sample set
  543. * Samples will not be interpolated over the disabled period
  544. */
  545. disable(): void;
  546. /**
  547. * Returns true if sampling is enabled
  548. */
  549. readonly isEnabled: boolean;
  550. /**
  551. * Resets performance monitor
  552. */
  553. reset(): void;
  554. }
  555. /**
  556. * RollingAverage
  557. *
  558. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  559. */
  560. export class RollingAverage {
  561. /**
  562. * Current average
  563. */
  564. average: number;
  565. /**
  566. * Current variance
  567. */
  568. variance: number;
  569. protected _samples: Array<number>;
  570. protected _sampleCount: number;
  571. protected _pos: number;
  572. protected _m2: number;
  573. /**
  574. * constructor
  575. * @param length The number of samples required to saturate the sliding window
  576. */
  577. constructor(length: number);
  578. /**
  579. * Adds a sample to the sample set
  580. * @param v The sample value
  581. */
  582. add(v: number): void;
  583. /**
  584. * Returns previously added values or null if outside of history or outside the sliding window domain
  585. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  586. * @return Value previously recorded with add() or null if outside of range
  587. */
  588. history(i: number): number;
  589. /**
  590. * Returns true if enough samples have been taken to completely fill the sliding window
  591. * @return true if sample-set saturated
  592. */
  593. isSaturated(): boolean;
  594. /**
  595. * Resets the rolling average (equivalent to 0 samples taken so far)
  596. */
  597. reset(): void;
  598. /**
  599. * Wraps a value around the sample range boundaries
  600. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  601. * @return Wrapped position in sample range
  602. */
  603. protected _wrapPosition(i: number): number;
  604. }
  605. }
  606. declare module "babylonjs/Misc/stringDictionary" {
  607. import { Nullable } from "babylonjs/types";
  608. /**
  609. * This class implement a typical dictionary using a string as key and the generic type T as value.
  610. * The underlying implementation relies on an associative array to ensure the best performances.
  611. * The value can be anything including 'null' but except 'undefined'
  612. */
  613. export class StringDictionary<T> {
  614. /**
  615. * This will clear this dictionary and copy the content from the 'source' one.
  616. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  617. * @param source the dictionary to take the content from and copy to this dictionary
  618. */
  619. copyFrom(source: StringDictionary<T>): void;
  620. /**
  621. * Get a value based from its key
  622. * @param key the given key to get the matching value from
  623. * @return the value if found, otherwise undefined is returned
  624. */
  625. get(key: string): T | undefined;
  626. /**
  627. * Get a value from its key or add it if it doesn't exist.
  628. * This method will ensure you that a given key/data will be present in the dictionary.
  629. * @param key the given key to get the matching value from
  630. * @param factory the factory that will create the value if the key is not present in the dictionary.
  631. * The factory will only be invoked if there's no data for the given key.
  632. * @return the value corresponding to the key.
  633. */
  634. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  635. /**
  636. * Get a value from its key if present in the dictionary otherwise add it
  637. * @param key the key to get the value from
  638. * @param val if there's no such key/value pair in the dictionary add it with this value
  639. * @return the value corresponding to the key
  640. */
  641. getOrAdd(key: string, val: T): T;
  642. /**
  643. * Check if there's a given key in the dictionary
  644. * @param key the key to check for
  645. * @return true if the key is present, false otherwise
  646. */
  647. contains(key: string): boolean;
  648. /**
  649. * Add a new key and its corresponding value
  650. * @param key the key to add
  651. * @param value the value corresponding to the key
  652. * @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
  653. */
  654. add(key: string, value: T): boolean;
  655. /**
  656. * Update a specific value associated to a key
  657. * @param key defines the key to use
  658. * @param value defines the value to store
  659. * @returns true if the value was updated (or false if the key was not found)
  660. */
  661. set(key: string, value: T): boolean;
  662. /**
  663. * Get the element of the given key and remove it from the dictionary
  664. * @param key defines the key to search
  665. * @returns the value associated with the key or null if not found
  666. */
  667. getAndRemove(key: string): Nullable<T>;
  668. /**
  669. * Remove a key/value from the dictionary.
  670. * @param key the key to remove
  671. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  672. */
  673. remove(key: string): boolean;
  674. /**
  675. * Clear the whole content of the dictionary
  676. */
  677. clear(): void;
  678. /**
  679. * Gets the current count
  680. */
  681. readonly count: number;
  682. /**
  683. * Execute a callback on each key/val of the dictionary.
  684. * Note that you can remove any element in this dictionary in the callback implementation
  685. * @param callback the callback to execute on a given key/value pair
  686. */
  687. forEach(callback: (key: string, val: T) => void): void;
  688. /**
  689. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  690. * If the callback returns null or undefined the method will iterate to the next key/value pair
  691. * Note that you can remove any element in this dictionary in the callback implementation
  692. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  693. * @returns the first item
  694. */
  695. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  696. private _count;
  697. private _data;
  698. }
  699. }
  700. declare module "babylonjs/Meshes/dataBuffer" {
  701. /**
  702. * Class used to store gfx data (like WebGLBuffer)
  703. */
  704. export class DataBuffer {
  705. /**
  706. * Gets or sets the number of objects referencing this buffer
  707. */
  708. references: number;
  709. /** Gets or sets the size of the underlying buffer */
  710. capacity: number;
  711. /**
  712. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  713. */
  714. is32Bits: boolean;
  715. /**
  716. * Gets the underlying buffer
  717. */
  718. readonly underlyingResource: any;
  719. }
  720. }
  721. declare module "babylonjs/Meshes/buffer" {
  722. import { Nullable, DataArray } from "babylonjs/types";
  723. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  724. /**
  725. * Class used to store data that will be store in GPU memory
  726. */
  727. export class Buffer {
  728. private _engine;
  729. private _buffer;
  730. /** @hidden */
  731. _data: Nullable<DataArray>;
  732. private _updatable;
  733. private _instanced;
  734. /**
  735. * Gets the byte stride.
  736. */
  737. readonly byteStride: number;
  738. /**
  739. * Constructor
  740. * @param engine the engine
  741. * @param data the data to use for this buffer
  742. * @param updatable whether the data is updatable
  743. * @param stride the stride (optional)
  744. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  745. * @param instanced whether the buffer is instanced (optional)
  746. * @param useBytes set to true if the stride in in bytes (optional)
  747. */
  748. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  749. /**
  750. * Create a new VertexBuffer based on the current buffer
  751. * @param kind defines the vertex buffer kind (position, normal, etc.)
  752. * @param offset defines offset in the buffer (0 by default)
  753. * @param size defines the size in floats of attributes (position is 3 for instance)
  754. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  755. * @param instanced defines if the vertex buffer contains indexed data
  756. * @param useBytes defines if the offset and stride are in bytes
  757. * @returns the new vertex buffer
  758. */
  759. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  760. /**
  761. * Gets a boolean indicating if the Buffer is updatable?
  762. * @returns true if the buffer is updatable
  763. */
  764. isUpdatable(): boolean;
  765. /**
  766. * Gets current buffer's data
  767. * @returns a DataArray or null
  768. */
  769. getData(): Nullable<DataArray>;
  770. /**
  771. * Gets underlying native buffer
  772. * @returns underlying native buffer
  773. */
  774. getBuffer(): Nullable<DataBuffer>;
  775. /**
  776. * Gets the stride in float32 units (i.e. byte stride / 4).
  777. * May not be an integer if the byte stride is not divisible by 4.
  778. * DEPRECATED. Use byteStride instead.
  779. * @returns the stride in float32 units
  780. */
  781. getStrideSize(): number;
  782. /**
  783. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  784. * @param data defines the data to store
  785. */
  786. create(data?: Nullable<DataArray>): void;
  787. /** @hidden */
  788. _rebuild(): void;
  789. /**
  790. * Update current buffer data
  791. * @param data defines the data to store
  792. */
  793. update(data: DataArray): void;
  794. /**
  795. * Updates the data directly.
  796. * @param data the new data
  797. * @param offset the new offset
  798. * @param vertexCount the vertex count (optional)
  799. * @param useBytes set to true if the offset is in bytes
  800. */
  801. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  802. /**
  803. * Release all resources
  804. */
  805. dispose(): void;
  806. }
  807. /**
  808. * Specialized buffer used to store vertex data
  809. */
  810. export class VertexBuffer {
  811. /** @hidden */
  812. _buffer: Buffer;
  813. private _kind;
  814. private _size;
  815. private _ownsBuffer;
  816. private _instanced;
  817. private _instanceDivisor;
  818. /**
  819. * The byte type.
  820. */
  821. static readonly BYTE: number;
  822. /**
  823. * The unsigned byte type.
  824. */
  825. static readonly UNSIGNED_BYTE: number;
  826. /**
  827. * The short type.
  828. */
  829. static readonly SHORT: number;
  830. /**
  831. * The unsigned short type.
  832. */
  833. static readonly UNSIGNED_SHORT: number;
  834. /**
  835. * The integer type.
  836. */
  837. static readonly INT: number;
  838. /**
  839. * The unsigned integer type.
  840. */
  841. static readonly UNSIGNED_INT: number;
  842. /**
  843. * The float type.
  844. */
  845. static readonly FLOAT: number;
  846. /**
  847. * Gets or sets the instance divisor when in instanced mode
  848. */
  849. instanceDivisor: number;
  850. /**
  851. * Gets the byte stride.
  852. */
  853. readonly byteStride: number;
  854. /**
  855. * Gets the byte offset.
  856. */
  857. readonly byteOffset: number;
  858. /**
  859. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  860. */
  861. readonly normalized: boolean;
  862. /**
  863. * Gets the data type of each component in the array.
  864. */
  865. readonly type: number;
  866. /**
  867. * Constructor
  868. * @param engine the engine
  869. * @param data the data to use for this vertex buffer
  870. * @param kind the vertex buffer kind
  871. * @param updatable whether the data is updatable
  872. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  873. * @param stride the stride (optional)
  874. * @param instanced whether the buffer is instanced (optional)
  875. * @param offset the offset of the data (optional)
  876. * @param size the number of components (optional)
  877. * @param type the type of the component (optional)
  878. * @param normalized whether the data contains normalized data (optional)
  879. * @param useBytes set to true if stride and offset are in bytes (optional)
  880. */
  881. 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);
  882. /** @hidden */
  883. _rebuild(): void;
  884. /**
  885. * Returns the kind of the VertexBuffer (string)
  886. * @returns a string
  887. */
  888. getKind(): string;
  889. /**
  890. * Gets a boolean indicating if the VertexBuffer is updatable?
  891. * @returns true if the buffer is updatable
  892. */
  893. isUpdatable(): boolean;
  894. /**
  895. * Gets current buffer's data
  896. * @returns a DataArray or null
  897. */
  898. getData(): Nullable<DataArray>;
  899. /**
  900. * Gets underlying native buffer
  901. * @returns underlying native buffer
  902. */
  903. getBuffer(): Nullable<DataBuffer>;
  904. /**
  905. * Gets the stride in float32 units (i.e. byte stride / 4).
  906. * May not be an integer if the byte stride is not divisible by 4.
  907. * DEPRECATED. Use byteStride instead.
  908. * @returns the stride in float32 units
  909. */
  910. getStrideSize(): number;
  911. /**
  912. * Returns the offset as a multiple of the type byte length.
  913. * DEPRECATED. Use byteOffset instead.
  914. * @returns the offset in bytes
  915. */
  916. getOffset(): number;
  917. /**
  918. * Returns the number of components per vertex attribute (integer)
  919. * @returns the size in float
  920. */
  921. getSize(): number;
  922. /**
  923. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  924. * @returns true if this buffer is instanced
  925. */
  926. getIsInstanced(): boolean;
  927. /**
  928. * Returns the instancing divisor, zero for non-instanced (integer).
  929. * @returns a number
  930. */
  931. getInstanceDivisor(): number;
  932. /**
  933. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  934. * @param data defines the data to store
  935. */
  936. create(data?: DataArray): void;
  937. /**
  938. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  939. * This function will create a new buffer if the current one is not updatable
  940. * @param data defines the data to store
  941. */
  942. update(data: DataArray): void;
  943. /**
  944. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  945. * Returns the directly updated WebGLBuffer.
  946. * @param data the new data
  947. * @param offset the new offset
  948. * @param useBytes set to true if the offset is in bytes
  949. */
  950. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  951. /**
  952. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  953. */
  954. dispose(): void;
  955. /**
  956. * Enumerates each value of this vertex buffer as numbers.
  957. * @param count the number of values to enumerate
  958. * @param callback the callback function called for each value
  959. */
  960. forEach(count: number, callback: (value: number, index: number) => void): void;
  961. /**
  962. * Positions
  963. */
  964. static readonly PositionKind: string;
  965. /**
  966. * Normals
  967. */
  968. static readonly NormalKind: string;
  969. /**
  970. * Tangents
  971. */
  972. static readonly TangentKind: string;
  973. /**
  974. * Texture coordinates
  975. */
  976. static readonly UVKind: string;
  977. /**
  978. * Texture coordinates 2
  979. */
  980. static readonly UV2Kind: string;
  981. /**
  982. * Texture coordinates 3
  983. */
  984. static readonly UV3Kind: string;
  985. /**
  986. * Texture coordinates 4
  987. */
  988. static readonly UV4Kind: string;
  989. /**
  990. * Texture coordinates 5
  991. */
  992. static readonly UV5Kind: string;
  993. /**
  994. * Texture coordinates 6
  995. */
  996. static readonly UV6Kind: string;
  997. /**
  998. * Colors
  999. */
  1000. static readonly ColorKind: string;
  1001. /**
  1002. * Matrix indices (for bones)
  1003. */
  1004. static readonly MatricesIndicesKind: string;
  1005. /**
  1006. * Matrix weights (for bones)
  1007. */
  1008. static readonly MatricesWeightsKind: string;
  1009. /**
  1010. * Additional matrix indices (for bones)
  1011. */
  1012. static readonly MatricesIndicesExtraKind: string;
  1013. /**
  1014. * Additional matrix weights (for bones)
  1015. */
  1016. static readonly MatricesWeightsExtraKind: string;
  1017. /**
  1018. * Deduces the stride given a kind.
  1019. * @param kind The kind string to deduce
  1020. * @returns The deduced stride
  1021. */
  1022. static DeduceStride(kind: string): number;
  1023. /**
  1024. * Gets the byte length of the given type.
  1025. * @param type the type
  1026. * @returns the number of bytes
  1027. */
  1028. static GetTypeByteLength(type: number): number;
  1029. /**
  1030. * Enumerates each value of the given parameters as numbers.
  1031. * @param data the data to enumerate
  1032. * @param byteOffset the byte offset of the data
  1033. * @param byteStride the byte stride of the data
  1034. * @param componentCount the number of components per element
  1035. * @param componentType the type of the component
  1036. * @param count the number of values to enumerate
  1037. * @param normalized whether the data is normalized
  1038. * @param callback the callback function called for each value
  1039. */
  1040. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1041. private static _GetFloatValue;
  1042. }
  1043. }
  1044. declare module "babylonjs/Maths/math.scalar" {
  1045. /**
  1046. * Scalar computation library
  1047. */
  1048. export class Scalar {
  1049. /**
  1050. * Two pi constants convenient for computation.
  1051. */
  1052. static TwoPi: number;
  1053. /**
  1054. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1055. * @param a number
  1056. * @param b number
  1057. * @param epsilon (default = 1.401298E-45)
  1058. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1059. */
  1060. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1061. /**
  1062. * Returns a string : the upper case translation of the number i to hexadecimal.
  1063. * @param i number
  1064. * @returns the upper case translation of the number i to hexadecimal.
  1065. */
  1066. static ToHex(i: number): string;
  1067. /**
  1068. * Returns -1 if value is negative and +1 is value is positive.
  1069. * @param value the value
  1070. * @returns the value itself if it's equal to zero.
  1071. */
  1072. static Sign(value: number): number;
  1073. /**
  1074. * Returns the value itself if it's between min and max.
  1075. * Returns min if the value is lower than min.
  1076. * Returns max if the value is greater than max.
  1077. * @param value the value to clmap
  1078. * @param min the min value to clamp to (default: 0)
  1079. * @param max the max value to clamp to (default: 1)
  1080. * @returns the clamped value
  1081. */
  1082. static Clamp(value: number, min?: number, max?: number): number;
  1083. /**
  1084. * the log2 of value.
  1085. * @param value the value to compute log2 of
  1086. * @returns the log2 of value.
  1087. */
  1088. static Log2(value: number): number;
  1089. /**
  1090. * Loops the value, so that it is never larger than length and never smaller than 0.
  1091. *
  1092. * This is similar to the modulo operator but it works with floating point numbers.
  1093. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1094. * With t = 5 and length = 2.5, the result would be 0.0.
  1095. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1096. * @param value the value
  1097. * @param length the length
  1098. * @returns the looped value
  1099. */
  1100. static Repeat(value: number, length: number): number;
  1101. /**
  1102. * Normalize the value between 0.0 and 1.0 using min and max values
  1103. * @param value value to normalize
  1104. * @param min max to normalize between
  1105. * @param max min to normalize between
  1106. * @returns the normalized value
  1107. */
  1108. static Normalize(value: number, min: number, max: number): number;
  1109. /**
  1110. * Denormalize the value from 0.0 and 1.0 using min and max values
  1111. * @param normalized value to denormalize
  1112. * @param min max to denormalize between
  1113. * @param max min to denormalize between
  1114. * @returns the denormalized value
  1115. */
  1116. static Denormalize(normalized: number, min: number, max: number): number;
  1117. /**
  1118. * Calculates the shortest difference between two given angles given in degrees.
  1119. * @param current current angle in degrees
  1120. * @param target target angle in degrees
  1121. * @returns the delta
  1122. */
  1123. static DeltaAngle(current: number, target: number): number;
  1124. /**
  1125. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1126. * @param tx value
  1127. * @param length length
  1128. * @returns The returned value will move back and forth between 0 and length
  1129. */
  1130. static PingPong(tx: number, length: number): number;
  1131. /**
  1132. * Interpolates between min and max with smoothing at the limits.
  1133. *
  1134. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1135. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1136. * @param from from
  1137. * @param to to
  1138. * @param tx value
  1139. * @returns the smooth stepped value
  1140. */
  1141. static SmoothStep(from: number, to: number, tx: number): number;
  1142. /**
  1143. * Moves a value current towards target.
  1144. *
  1145. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1146. * Negative values of maxDelta pushes the value away from target.
  1147. * @param current current value
  1148. * @param target target value
  1149. * @param maxDelta max distance to move
  1150. * @returns resulting value
  1151. */
  1152. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1153. /**
  1154. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1155. *
  1156. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1157. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1158. * @param current current value
  1159. * @param target target value
  1160. * @param maxDelta max distance to move
  1161. * @returns resulting angle
  1162. */
  1163. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1164. /**
  1165. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1166. * @param start start value
  1167. * @param end target value
  1168. * @param amount amount to lerp between
  1169. * @returns the lerped value
  1170. */
  1171. static Lerp(start: number, end: number, amount: number): number;
  1172. /**
  1173. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1174. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1175. * @param start start value
  1176. * @param end target value
  1177. * @param amount amount to lerp between
  1178. * @returns the lerped value
  1179. */
  1180. static LerpAngle(start: number, end: number, amount: number): number;
  1181. /**
  1182. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1183. * @param a start value
  1184. * @param b target value
  1185. * @param value value between a and b
  1186. * @returns the inverseLerp value
  1187. */
  1188. static InverseLerp(a: number, b: number, value: number): number;
  1189. /**
  1190. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1191. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1192. * @param value1 spline value
  1193. * @param tangent1 spline value
  1194. * @param value2 spline value
  1195. * @param tangent2 spline value
  1196. * @param amount input value
  1197. * @returns hermite result
  1198. */
  1199. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1200. /**
  1201. * Returns a random float number between and min and max values
  1202. * @param min min value of random
  1203. * @param max max value of random
  1204. * @returns random value
  1205. */
  1206. static RandomRange(min: number, max: number): number;
  1207. /**
  1208. * This function returns percentage of a number in a given range.
  1209. *
  1210. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1211. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1212. * @param number to convert to percentage
  1213. * @param min min range
  1214. * @param max max range
  1215. * @returns the percentage
  1216. */
  1217. static RangeToPercent(number: number, min: number, max: number): number;
  1218. /**
  1219. * This function returns number that corresponds to the percentage in a given range.
  1220. *
  1221. * PercentToRange(0.34,0,100) will return 34.
  1222. * @param percent to convert to number
  1223. * @param min min range
  1224. * @param max max range
  1225. * @returns the number
  1226. */
  1227. static PercentToRange(percent: number, min: number, max: number): number;
  1228. /**
  1229. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1230. * @param angle The angle to normalize in radian.
  1231. * @return The converted angle.
  1232. */
  1233. static NormalizeRadians(angle: number): number;
  1234. }
  1235. }
  1236. declare module "babylonjs/Maths/math.constants" {
  1237. /**
  1238. * Constant used to convert a value to gamma space
  1239. * @ignorenaming
  1240. */
  1241. export const ToGammaSpace: number;
  1242. /**
  1243. * Constant used to convert a value to linear space
  1244. * @ignorenaming
  1245. */
  1246. export const ToLinearSpace = 2.2;
  1247. /**
  1248. * Constant used to define the minimal number value in Babylon.js
  1249. * @ignorenaming
  1250. */
  1251. let Epsilon: number;
  1252. export { Epsilon };
  1253. }
  1254. declare module "babylonjs/Maths/math.viewport" {
  1255. /**
  1256. * Class used to represent a viewport on screen
  1257. */
  1258. export class Viewport {
  1259. /** viewport left coordinate */
  1260. x: number;
  1261. /** viewport top coordinate */
  1262. y: number;
  1263. /**viewport width */
  1264. width: number;
  1265. /** viewport height */
  1266. height: number;
  1267. /**
  1268. * Creates a Viewport object located at (x, y) and sized (width, height)
  1269. * @param x defines viewport left coordinate
  1270. * @param y defines viewport top coordinate
  1271. * @param width defines the viewport width
  1272. * @param height defines the viewport height
  1273. */
  1274. constructor(
  1275. /** viewport left coordinate */
  1276. x: number,
  1277. /** viewport top coordinate */
  1278. y: number,
  1279. /**viewport width */
  1280. width: number,
  1281. /** viewport height */
  1282. height: number);
  1283. /**
  1284. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1285. * @param renderWidth defines the rendering width
  1286. * @param renderHeight defines the rendering height
  1287. * @returns a new Viewport
  1288. */
  1289. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1290. /**
  1291. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1292. * @param renderWidth defines the rendering width
  1293. * @param renderHeight defines the rendering height
  1294. * @param ref defines the target viewport
  1295. * @returns the current viewport
  1296. */
  1297. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1298. /**
  1299. * Returns a new Viewport copied from the current one
  1300. * @returns a new Viewport
  1301. */
  1302. clone(): Viewport;
  1303. }
  1304. }
  1305. declare module "babylonjs/Misc/arrayTools" {
  1306. /**
  1307. * Class containing a set of static utilities functions for arrays.
  1308. */
  1309. export class ArrayTools {
  1310. /**
  1311. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1312. * @param size the number of element to construct and put in the array
  1313. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1314. * @returns a new array filled with new objects
  1315. */
  1316. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1317. }
  1318. }
  1319. declare module "babylonjs/Maths/math.like" {
  1320. import { float, int, DeepImmutable } from "babylonjs/types";
  1321. /**
  1322. * @hidden
  1323. */
  1324. export interface IColor4Like {
  1325. r: float;
  1326. g: float;
  1327. b: float;
  1328. a: float;
  1329. }
  1330. /**
  1331. * @hidden
  1332. */
  1333. export interface IColor3Like {
  1334. r: float;
  1335. g: float;
  1336. b: float;
  1337. }
  1338. /**
  1339. * @hidden
  1340. */
  1341. export interface IVector4Like {
  1342. x: float;
  1343. y: float;
  1344. z: float;
  1345. w: float;
  1346. }
  1347. /**
  1348. * @hidden
  1349. */
  1350. export interface IVector3Like {
  1351. x: float;
  1352. y: float;
  1353. z: float;
  1354. }
  1355. /**
  1356. * @hidden
  1357. */
  1358. export interface IVector2Like {
  1359. x: float;
  1360. y: float;
  1361. }
  1362. /**
  1363. * @hidden
  1364. */
  1365. export interface IMatrixLike {
  1366. toArray(): DeepImmutable<Float32Array>;
  1367. updateFlag: int;
  1368. }
  1369. /**
  1370. * @hidden
  1371. */
  1372. export interface IViewportLike {
  1373. x: float;
  1374. y: float;
  1375. width: float;
  1376. height: float;
  1377. }
  1378. /**
  1379. * @hidden
  1380. */
  1381. export interface IPlaneLike {
  1382. normal: IVector3Like;
  1383. d: float;
  1384. normalize(): void;
  1385. }
  1386. }
  1387. declare module "babylonjs/Maths/math.vector" {
  1388. import { Viewport } from "babylonjs/Maths/math.viewport";
  1389. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1390. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1391. /**
  1392. * Class representing a vector containing 2 coordinates
  1393. */
  1394. export class Vector2 {
  1395. /** defines the first coordinate */
  1396. x: number;
  1397. /** defines the second coordinate */
  1398. y: number;
  1399. /**
  1400. * Creates a new Vector2 from the given x and y coordinates
  1401. * @param x defines the first coordinate
  1402. * @param y defines the second coordinate
  1403. */
  1404. constructor(
  1405. /** defines the first coordinate */
  1406. x?: number,
  1407. /** defines the second coordinate */
  1408. y?: number);
  1409. /**
  1410. * Gets a string with the Vector2 coordinates
  1411. * @returns a string with the Vector2 coordinates
  1412. */
  1413. toString(): string;
  1414. /**
  1415. * Gets class name
  1416. * @returns the string "Vector2"
  1417. */
  1418. getClassName(): string;
  1419. /**
  1420. * Gets current vector hash code
  1421. * @returns the Vector2 hash code as a number
  1422. */
  1423. getHashCode(): number;
  1424. /**
  1425. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1426. * @param array defines the source array
  1427. * @param index defines the offset in source array
  1428. * @returns the current Vector2
  1429. */
  1430. toArray(array: FloatArray, index?: number): Vector2;
  1431. /**
  1432. * Copy the current vector to an array
  1433. * @returns a new array with 2 elements: the Vector2 coordinates.
  1434. */
  1435. asArray(): number[];
  1436. /**
  1437. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1438. * @param source defines the source Vector2
  1439. * @returns the current updated Vector2
  1440. */
  1441. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1442. /**
  1443. * Sets the Vector2 coordinates with the given floats
  1444. * @param x defines the first coordinate
  1445. * @param y defines the second coordinate
  1446. * @returns the current updated Vector2
  1447. */
  1448. copyFromFloats(x: number, y: number): Vector2;
  1449. /**
  1450. * Sets the Vector2 coordinates with the given floats
  1451. * @param x defines the first coordinate
  1452. * @param y defines the second coordinate
  1453. * @returns the current updated Vector2
  1454. */
  1455. set(x: number, y: number): Vector2;
  1456. /**
  1457. * Add another vector with the current one
  1458. * @param otherVector defines the other vector
  1459. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1460. */
  1461. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1462. /**
  1463. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1464. * @param otherVector defines the other vector
  1465. * @param result defines the target vector
  1466. * @returns the unmodified current Vector2
  1467. */
  1468. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1469. /**
  1470. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1471. * @param otherVector defines the other vector
  1472. * @returns the current updated Vector2
  1473. */
  1474. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1475. /**
  1476. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1477. * @param otherVector defines the other vector
  1478. * @returns a new Vector2
  1479. */
  1480. addVector3(otherVector: Vector3): Vector2;
  1481. /**
  1482. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1483. * @param otherVector defines the other vector
  1484. * @returns a new Vector2
  1485. */
  1486. subtract(otherVector: Vector2): Vector2;
  1487. /**
  1488. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1489. * @param otherVector defines the other vector
  1490. * @param result defines the target vector
  1491. * @returns the unmodified current Vector2
  1492. */
  1493. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1494. /**
  1495. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1496. * @param otherVector defines the other vector
  1497. * @returns the current updated Vector2
  1498. */
  1499. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1500. /**
  1501. * Multiplies in place the current Vector2 coordinates by the given ones
  1502. * @param otherVector defines the other vector
  1503. * @returns the current updated Vector2
  1504. */
  1505. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1506. /**
  1507. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1508. * @param otherVector defines the other vector
  1509. * @returns a new Vector2
  1510. */
  1511. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1512. /**
  1513. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1514. * @param otherVector defines the other vector
  1515. * @param result defines the target vector
  1516. * @returns the unmodified current Vector2
  1517. */
  1518. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1519. /**
  1520. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1521. * @param x defines the first coordinate
  1522. * @param y defines the second coordinate
  1523. * @returns a new Vector2
  1524. */
  1525. multiplyByFloats(x: number, y: number): Vector2;
  1526. /**
  1527. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1528. * @param otherVector defines the other vector
  1529. * @returns a new Vector2
  1530. */
  1531. divide(otherVector: Vector2): Vector2;
  1532. /**
  1533. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1534. * @param otherVector defines the other vector
  1535. * @param result defines the target vector
  1536. * @returns the unmodified current Vector2
  1537. */
  1538. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1539. /**
  1540. * Divides the current Vector2 coordinates by the given ones
  1541. * @param otherVector defines the other vector
  1542. * @returns the current updated Vector2
  1543. */
  1544. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1545. /**
  1546. * Gets a new Vector2 with current Vector2 negated coordinates
  1547. * @returns a new Vector2
  1548. */
  1549. negate(): Vector2;
  1550. /**
  1551. * Multiply the Vector2 coordinates by scale
  1552. * @param scale defines the scaling factor
  1553. * @returns the current updated Vector2
  1554. */
  1555. scaleInPlace(scale: number): Vector2;
  1556. /**
  1557. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1558. * @param scale defines the scaling factor
  1559. * @returns a new Vector2
  1560. */
  1561. scale(scale: number): Vector2;
  1562. /**
  1563. * Scale the current Vector2 values by a factor to a given Vector2
  1564. * @param scale defines the scale factor
  1565. * @param result defines the Vector2 object where to store the result
  1566. * @returns the unmodified current Vector2
  1567. */
  1568. scaleToRef(scale: number, result: Vector2): Vector2;
  1569. /**
  1570. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1571. * @param scale defines the scale factor
  1572. * @param result defines the Vector2 object where to store the result
  1573. * @returns the unmodified current Vector2
  1574. */
  1575. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1576. /**
  1577. * Gets a boolean if two vectors are equals
  1578. * @param otherVector defines the other vector
  1579. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1580. */
  1581. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1582. /**
  1583. * Gets a boolean if two vectors are equals (using an epsilon value)
  1584. * @param otherVector defines the other vector
  1585. * @param epsilon defines the minimal distance to consider equality
  1586. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1587. */
  1588. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1589. /**
  1590. * Gets a new Vector2 from current Vector2 floored values
  1591. * @returns a new Vector2
  1592. */
  1593. floor(): Vector2;
  1594. /**
  1595. * Gets a new Vector2 from current Vector2 floored values
  1596. * @returns a new Vector2
  1597. */
  1598. fract(): Vector2;
  1599. /**
  1600. * Gets the length of the vector
  1601. * @returns the vector length (float)
  1602. */
  1603. length(): number;
  1604. /**
  1605. * Gets the vector squared length
  1606. * @returns the vector squared length (float)
  1607. */
  1608. lengthSquared(): number;
  1609. /**
  1610. * Normalize the vector
  1611. * @returns the current updated Vector2
  1612. */
  1613. normalize(): Vector2;
  1614. /**
  1615. * Gets a new Vector2 copied from the Vector2
  1616. * @returns a new Vector2
  1617. */
  1618. clone(): Vector2;
  1619. /**
  1620. * Gets a new Vector2(0, 0)
  1621. * @returns a new Vector2
  1622. */
  1623. static Zero(): Vector2;
  1624. /**
  1625. * Gets a new Vector2(1, 1)
  1626. * @returns a new Vector2
  1627. */
  1628. static One(): Vector2;
  1629. /**
  1630. * Gets a new Vector2 set from the given index element of the given array
  1631. * @param array defines the data source
  1632. * @param offset defines the offset in the data source
  1633. * @returns a new Vector2
  1634. */
  1635. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1636. /**
  1637. * Sets "result" from the given index element of the given array
  1638. * @param array defines the data source
  1639. * @param offset defines the offset in the data source
  1640. * @param result defines the target vector
  1641. */
  1642. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1643. /**
  1644. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1645. * @param value1 defines 1st point of control
  1646. * @param value2 defines 2nd point of control
  1647. * @param value3 defines 3rd point of control
  1648. * @param value4 defines 4th point of control
  1649. * @param amount defines the interpolation factor
  1650. * @returns a new Vector2
  1651. */
  1652. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1653. /**
  1654. * 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".
  1655. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1656. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1657. * @param value defines the value to clamp
  1658. * @param min defines the lower limit
  1659. * @param max defines the upper limit
  1660. * @returns a new Vector2
  1661. */
  1662. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1663. /**
  1664. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1665. * @param value1 defines the 1st control point
  1666. * @param tangent1 defines the outgoing tangent
  1667. * @param value2 defines the 2nd control point
  1668. * @param tangent2 defines the incoming tangent
  1669. * @param amount defines the interpolation factor
  1670. * @returns a new Vector2
  1671. */
  1672. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1673. /**
  1674. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1675. * @param start defines the start vector
  1676. * @param end defines the end vector
  1677. * @param amount defines the interpolation factor
  1678. * @returns a new Vector2
  1679. */
  1680. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1681. /**
  1682. * Gets the dot product of the vector "left" and the vector "right"
  1683. * @param left defines first vector
  1684. * @param right defines second vector
  1685. * @returns the dot product (float)
  1686. */
  1687. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1688. /**
  1689. * Returns a new Vector2 equal to the normalized given vector
  1690. * @param vector defines the vector to normalize
  1691. * @returns a new Vector2
  1692. */
  1693. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1694. /**
  1695. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1696. * @param left defines 1st vector
  1697. * @param right defines 2nd vector
  1698. * @returns a new Vector2
  1699. */
  1700. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1701. /**
  1702. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1703. * @param left defines 1st vector
  1704. * @param right defines 2nd vector
  1705. * @returns a new Vector2
  1706. */
  1707. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1708. /**
  1709. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1710. * @param vector defines the vector to transform
  1711. * @param transformation defines the matrix to apply
  1712. * @returns a new Vector2
  1713. */
  1714. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1715. /**
  1716. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1717. * @param vector defines the vector to transform
  1718. * @param transformation defines the matrix to apply
  1719. * @param result defines the target vector
  1720. */
  1721. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1722. /**
  1723. * Determines if a given vector is included in a triangle
  1724. * @param p defines the vector to test
  1725. * @param p0 defines 1st triangle point
  1726. * @param p1 defines 2nd triangle point
  1727. * @param p2 defines 3rd triangle point
  1728. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1729. */
  1730. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1731. /**
  1732. * Gets the distance between the vectors "value1" and "value2"
  1733. * @param value1 defines first vector
  1734. * @param value2 defines second vector
  1735. * @returns the distance between vectors
  1736. */
  1737. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1738. /**
  1739. * Returns the squared distance between the vectors "value1" and "value2"
  1740. * @param value1 defines first vector
  1741. * @param value2 defines second vector
  1742. * @returns the squared distance between vectors
  1743. */
  1744. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1745. /**
  1746. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1747. * @param value1 defines first vector
  1748. * @param value2 defines second vector
  1749. * @returns a new Vector2
  1750. */
  1751. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1752. /**
  1753. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1754. * @param p defines the middle point
  1755. * @param segA defines one point of the segment
  1756. * @param segB defines the other point of the segment
  1757. * @returns the shortest distance
  1758. */
  1759. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1760. }
  1761. /**
  1762. * Classed used to store (x,y,z) vector representation
  1763. * A Vector3 is the main object used in 3D geometry
  1764. * It can represent etiher the coordinates of a point the space, either a direction
  1765. * Reminder: js uses a left handed forward facing system
  1766. */
  1767. export class Vector3 {
  1768. /**
  1769. * Defines the first coordinates (on X axis)
  1770. */
  1771. x: number;
  1772. /**
  1773. * Defines the second coordinates (on Y axis)
  1774. */
  1775. y: number;
  1776. /**
  1777. * Defines the third coordinates (on Z axis)
  1778. */
  1779. z: number;
  1780. private static _UpReadOnly;
  1781. private static _ZeroReadOnly;
  1782. /**
  1783. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1784. * @param x defines the first coordinates (on X axis)
  1785. * @param y defines the second coordinates (on Y axis)
  1786. * @param z defines the third coordinates (on Z axis)
  1787. */
  1788. constructor(
  1789. /**
  1790. * Defines the first coordinates (on X axis)
  1791. */
  1792. x?: number,
  1793. /**
  1794. * Defines the second coordinates (on Y axis)
  1795. */
  1796. y?: number,
  1797. /**
  1798. * Defines the third coordinates (on Z axis)
  1799. */
  1800. z?: number);
  1801. /**
  1802. * Creates a string representation of the Vector3
  1803. * @returns a string with the Vector3 coordinates.
  1804. */
  1805. toString(): string;
  1806. /**
  1807. * Gets the class name
  1808. * @returns the string "Vector3"
  1809. */
  1810. getClassName(): string;
  1811. /**
  1812. * Creates the Vector3 hash code
  1813. * @returns a number which tends to be unique between Vector3 instances
  1814. */
  1815. getHashCode(): number;
  1816. /**
  1817. * Creates an array containing three elements : the coordinates of the Vector3
  1818. * @returns a new array of numbers
  1819. */
  1820. asArray(): number[];
  1821. /**
  1822. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1823. * @param array defines the destination array
  1824. * @param index defines the offset in the destination array
  1825. * @returns the current Vector3
  1826. */
  1827. toArray(array: FloatArray, index?: number): Vector3;
  1828. /**
  1829. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1830. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1831. */
  1832. toQuaternion(): Quaternion;
  1833. /**
  1834. * Adds the given vector to the current Vector3
  1835. * @param otherVector defines the second operand
  1836. * @returns the current updated Vector3
  1837. */
  1838. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1839. /**
  1840. * Adds the given coordinates to the current Vector3
  1841. * @param x defines the x coordinate of the operand
  1842. * @param y defines the y coordinate of the operand
  1843. * @param z defines the z coordinate of the operand
  1844. * @returns the current updated Vector3
  1845. */
  1846. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1847. /**
  1848. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1849. * @param otherVector defines the second operand
  1850. * @returns the resulting Vector3
  1851. */
  1852. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1853. /**
  1854. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1855. * @param otherVector defines the second operand
  1856. * @param result defines the Vector3 object where to store the result
  1857. * @returns the current Vector3
  1858. */
  1859. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1860. /**
  1861. * Subtract the given vector from the current Vector3
  1862. * @param otherVector defines the second operand
  1863. * @returns the current updated Vector3
  1864. */
  1865. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1866. /**
  1867. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1868. * @param otherVector defines the second operand
  1869. * @returns the resulting Vector3
  1870. */
  1871. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1872. /**
  1873. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1874. * @param otherVector defines the second operand
  1875. * @param result defines the Vector3 object where to store the result
  1876. * @returns the current Vector3
  1877. */
  1878. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1879. /**
  1880. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1881. * @param x defines the x coordinate of the operand
  1882. * @param y defines the y coordinate of the operand
  1883. * @param z defines the z coordinate of the operand
  1884. * @returns the resulting Vector3
  1885. */
  1886. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1887. /**
  1888. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1889. * @param x defines the x coordinate of the operand
  1890. * @param y defines the y coordinate of the operand
  1891. * @param z defines the z coordinate of the operand
  1892. * @param result defines the Vector3 object where to store the result
  1893. * @returns the current Vector3
  1894. */
  1895. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1896. /**
  1897. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1898. * @returns a new Vector3
  1899. */
  1900. negate(): Vector3;
  1901. /**
  1902. * Multiplies the Vector3 coordinates by the float "scale"
  1903. * @param scale defines the multiplier factor
  1904. * @returns the current updated Vector3
  1905. */
  1906. scaleInPlace(scale: number): Vector3;
  1907. /**
  1908. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1909. * @param scale defines the multiplier factor
  1910. * @returns a new Vector3
  1911. */
  1912. scale(scale: number): Vector3;
  1913. /**
  1914. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1915. * @param scale defines the multiplier factor
  1916. * @param result defines the Vector3 object where to store the result
  1917. * @returns the current Vector3
  1918. */
  1919. scaleToRef(scale: number, result: Vector3): Vector3;
  1920. /**
  1921. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1922. * @param scale defines the scale factor
  1923. * @param result defines the Vector3 object where to store the result
  1924. * @returns the unmodified current Vector3
  1925. */
  1926. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1927. /**
  1928. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1929. * @param otherVector defines the second operand
  1930. * @returns true if both vectors are equals
  1931. */
  1932. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1933. /**
  1934. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1935. * @param otherVector defines the second operand
  1936. * @param epsilon defines the minimal distance to define values as equals
  1937. * @returns true if both vectors are distant less than epsilon
  1938. */
  1939. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1940. /**
  1941. * Returns true if the current Vector3 coordinates equals the given floats
  1942. * @param x defines the x coordinate of the operand
  1943. * @param y defines the y coordinate of the operand
  1944. * @param z defines the z coordinate of the operand
  1945. * @returns true if both vectors are equals
  1946. */
  1947. equalsToFloats(x: number, y: number, z: number): boolean;
  1948. /**
  1949. * Multiplies the current Vector3 coordinates by the given ones
  1950. * @param otherVector defines the second operand
  1951. * @returns the current updated Vector3
  1952. */
  1953. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1954. /**
  1955. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1956. * @param otherVector defines the second operand
  1957. * @returns the new Vector3
  1958. */
  1959. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1960. /**
  1961. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1962. * @param otherVector defines the second operand
  1963. * @param result defines the Vector3 object where to store the result
  1964. * @returns the current Vector3
  1965. */
  1966. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1967. /**
  1968. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1969. * @param x defines the x coordinate of the operand
  1970. * @param y defines the y coordinate of the operand
  1971. * @param z defines the z coordinate of the operand
  1972. * @returns the new Vector3
  1973. */
  1974. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1975. /**
  1976. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1977. * @param otherVector defines the second operand
  1978. * @returns the new Vector3
  1979. */
  1980. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1981. /**
  1982. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1983. * @param otherVector defines the second operand
  1984. * @param result defines the Vector3 object where to store the result
  1985. * @returns the current Vector3
  1986. */
  1987. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1988. /**
  1989. * Divides the current Vector3 coordinates by the given ones.
  1990. * @param otherVector defines the second operand
  1991. * @returns the current updated Vector3
  1992. */
  1993. divideInPlace(otherVector: Vector3): Vector3;
  1994. /**
  1995. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1996. * @param other defines the second operand
  1997. * @returns the current updated Vector3
  1998. */
  1999. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2000. /**
  2001. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2002. * @param other defines the second operand
  2003. * @returns the current updated Vector3
  2004. */
  2005. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2006. /**
  2007. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2008. * @param x defines the x coordinate of the operand
  2009. * @param y defines the y coordinate of the operand
  2010. * @param z defines the z coordinate of the operand
  2011. * @returns the current updated Vector3
  2012. */
  2013. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2014. /**
  2015. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2016. * @param x defines the x coordinate of the operand
  2017. * @param y defines the y coordinate of the operand
  2018. * @param z defines the z coordinate of the operand
  2019. * @returns the current updated Vector3
  2020. */
  2021. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2022. /**
  2023. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2024. * Check if is non uniform within a certain amount of decimal places to account for this
  2025. * @param epsilon the amount the values can differ
  2026. * @returns if the the vector is non uniform to a certain number of decimal places
  2027. */
  2028. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2029. /**
  2030. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2031. */
  2032. readonly isNonUniform: boolean;
  2033. /**
  2034. * Gets a new Vector3 from current Vector3 floored values
  2035. * @returns a new Vector3
  2036. */
  2037. floor(): Vector3;
  2038. /**
  2039. * Gets a new Vector3 from current Vector3 floored values
  2040. * @returns a new Vector3
  2041. */
  2042. fract(): Vector3;
  2043. /**
  2044. * Gets the length of the Vector3
  2045. * @returns the length of the Vector3
  2046. */
  2047. length(): number;
  2048. /**
  2049. * Gets the squared length of the Vector3
  2050. * @returns squared length of the Vector3
  2051. */
  2052. lengthSquared(): number;
  2053. /**
  2054. * Normalize the current Vector3.
  2055. * Please note that this is an in place operation.
  2056. * @returns the current updated Vector3
  2057. */
  2058. normalize(): Vector3;
  2059. /**
  2060. * Reorders the x y z properties of the vector in place
  2061. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2062. * @returns the current updated vector
  2063. */
  2064. reorderInPlace(order: string): this;
  2065. /**
  2066. * Rotates the vector around 0,0,0 by a quaternion
  2067. * @param quaternion the rotation quaternion
  2068. * @param result vector to store the result
  2069. * @returns the resulting vector
  2070. */
  2071. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2072. /**
  2073. * Rotates a vector around a given point
  2074. * @param quaternion the rotation quaternion
  2075. * @param point the point to rotate around
  2076. * @param result vector to store the result
  2077. * @returns the resulting vector
  2078. */
  2079. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2080. /**
  2081. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2082. * The cross product is then orthogonal to both current and "other"
  2083. * @param other defines the right operand
  2084. * @returns the cross product
  2085. */
  2086. cross(other: Vector3): Vector3;
  2087. /**
  2088. * Normalize the current Vector3 with the given input length.
  2089. * Please note that this is an in place operation.
  2090. * @param len the length of the vector
  2091. * @returns the current updated Vector3
  2092. */
  2093. normalizeFromLength(len: number): Vector3;
  2094. /**
  2095. * Normalize the current Vector3 to a new vector
  2096. * @returns the new Vector3
  2097. */
  2098. normalizeToNew(): Vector3;
  2099. /**
  2100. * Normalize the current Vector3 to the reference
  2101. * @param reference define the Vector3 to update
  2102. * @returns the updated Vector3
  2103. */
  2104. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2105. /**
  2106. * Creates a new Vector3 copied from the current Vector3
  2107. * @returns the new Vector3
  2108. */
  2109. clone(): Vector3;
  2110. /**
  2111. * Copies the given vector coordinates to the current Vector3 ones
  2112. * @param source defines the source Vector3
  2113. * @returns the current updated Vector3
  2114. */
  2115. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2116. /**
  2117. * Copies the given floats to the current Vector3 coordinates
  2118. * @param x defines the x coordinate of the operand
  2119. * @param y defines the y coordinate of the operand
  2120. * @param z defines the z coordinate of the operand
  2121. * @returns the current updated Vector3
  2122. */
  2123. copyFromFloats(x: number, y: number, z: number): Vector3;
  2124. /**
  2125. * Copies the given floats to the current Vector3 coordinates
  2126. * @param x defines the x coordinate of the operand
  2127. * @param y defines the y coordinate of the operand
  2128. * @param z defines the z coordinate of the operand
  2129. * @returns the current updated Vector3
  2130. */
  2131. set(x: number, y: number, z: number): Vector3;
  2132. /**
  2133. * Copies the given float to the current Vector3 coordinates
  2134. * @param v defines the x, y and z coordinates of the operand
  2135. * @returns the current updated Vector3
  2136. */
  2137. setAll(v: number): Vector3;
  2138. /**
  2139. * Get the clip factor between two vectors
  2140. * @param vector0 defines the first operand
  2141. * @param vector1 defines the second operand
  2142. * @param axis defines the axis to use
  2143. * @param size defines the size along the axis
  2144. * @returns the clip factor
  2145. */
  2146. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2147. /**
  2148. * Get angle between two vectors
  2149. * @param vector0 angle between vector0 and vector1
  2150. * @param vector1 angle between vector0 and vector1
  2151. * @param normal direction of the normal
  2152. * @return the angle between vector0 and vector1
  2153. */
  2154. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2155. /**
  2156. * Returns a new Vector3 set from the index "offset" of the given array
  2157. * @param array defines the source array
  2158. * @param offset defines the offset in the source array
  2159. * @returns the new Vector3
  2160. */
  2161. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2162. /**
  2163. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2164. * This function is deprecated. Use FromArray instead
  2165. * @param array defines the source array
  2166. * @param offset defines the offset in the source array
  2167. * @returns the new Vector3
  2168. */
  2169. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2170. /**
  2171. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2172. * @param array defines the source array
  2173. * @param offset defines the offset in the source array
  2174. * @param result defines the Vector3 where to store the result
  2175. */
  2176. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2177. /**
  2178. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2179. * This function is deprecated. Use FromArrayToRef instead.
  2180. * @param array defines the source array
  2181. * @param offset defines the offset in the source array
  2182. * @param result defines the Vector3 where to store the result
  2183. */
  2184. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2185. /**
  2186. * Sets the given vector "result" with the given floats.
  2187. * @param x defines the x coordinate of the source
  2188. * @param y defines the y coordinate of the source
  2189. * @param z defines the z coordinate of the source
  2190. * @param result defines the Vector3 where to store the result
  2191. */
  2192. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2193. /**
  2194. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2195. * @returns a new empty Vector3
  2196. */
  2197. static Zero(): Vector3;
  2198. /**
  2199. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2200. * @returns a new unit Vector3
  2201. */
  2202. static One(): Vector3;
  2203. /**
  2204. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2205. * @returns a new up Vector3
  2206. */
  2207. static Up(): Vector3;
  2208. /**
  2209. * Gets a up Vector3 that must not be updated
  2210. */
  2211. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2212. /**
  2213. * Gets a zero Vector3 that must not be updated
  2214. */
  2215. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2216. /**
  2217. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2218. * @returns a new down Vector3
  2219. */
  2220. static Down(): Vector3;
  2221. /**
  2222. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2223. * @returns a new forward Vector3
  2224. */
  2225. static Forward(): Vector3;
  2226. /**
  2227. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2228. * @returns a new forward Vector3
  2229. */
  2230. static Backward(): Vector3;
  2231. /**
  2232. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2233. * @returns a new right Vector3
  2234. */
  2235. static Right(): Vector3;
  2236. /**
  2237. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2238. * @returns a new left Vector3
  2239. */
  2240. static Left(): Vector3;
  2241. /**
  2242. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2243. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2244. * @param vector defines the Vector3 to transform
  2245. * @param transformation defines the transformation matrix
  2246. * @returns the transformed Vector3
  2247. */
  2248. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2249. /**
  2250. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2251. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2252. * @param vector defines the Vector3 to transform
  2253. * @param transformation defines the transformation matrix
  2254. * @param result defines the Vector3 where to store the result
  2255. */
  2256. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2257. /**
  2258. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2259. * This method computes tranformed coordinates only, not transformed direction vectors
  2260. * @param x define the x coordinate of the source vector
  2261. * @param y define the y coordinate of the source vector
  2262. * @param z define the z coordinate of the source vector
  2263. * @param transformation defines the transformation matrix
  2264. * @param result defines the Vector3 where to store the result
  2265. */
  2266. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2267. /**
  2268. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2269. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2270. * @param vector defines the Vector3 to transform
  2271. * @param transformation defines the transformation matrix
  2272. * @returns the new Vector3
  2273. */
  2274. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2275. /**
  2276. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2277. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2278. * @param vector defines the Vector3 to transform
  2279. * @param transformation defines the transformation matrix
  2280. * @param result defines the Vector3 where to store the result
  2281. */
  2282. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2283. /**
  2284. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2285. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2286. * @param x define the x coordinate of the source vector
  2287. * @param y define the y coordinate of the source vector
  2288. * @param z define the z coordinate of the source vector
  2289. * @param transformation defines the transformation matrix
  2290. * @param result defines the Vector3 where to store the result
  2291. */
  2292. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2293. /**
  2294. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2295. * @param value1 defines the first control point
  2296. * @param value2 defines the second control point
  2297. * @param value3 defines the third control point
  2298. * @param value4 defines the fourth control point
  2299. * @param amount defines the amount on the spline to use
  2300. * @returns the new Vector3
  2301. */
  2302. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2303. /**
  2304. * 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"
  2305. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2306. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2307. * @param value defines the current value
  2308. * @param min defines the lower range value
  2309. * @param max defines the upper range value
  2310. * @returns the new Vector3
  2311. */
  2312. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2313. /**
  2314. * 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"
  2315. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2316. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2317. * @param value defines the current value
  2318. * @param min defines the lower range value
  2319. * @param max defines the upper range value
  2320. * @param result defines the Vector3 where to store the result
  2321. */
  2322. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2323. /**
  2324. * Checks if a given vector is inside a specific range
  2325. * @param v defines the vector to test
  2326. * @param min defines the minimum range
  2327. * @param max defines the maximum range
  2328. */
  2329. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2330. /**
  2331. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2332. * @param value1 defines the first control point
  2333. * @param tangent1 defines the first tangent vector
  2334. * @param value2 defines the second control point
  2335. * @param tangent2 defines the second tangent vector
  2336. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2337. * @returns the new Vector3
  2338. */
  2339. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2340. /**
  2341. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2342. * @param start defines the start value
  2343. * @param end defines the end value
  2344. * @param amount max defines amount between both (between 0 and 1)
  2345. * @returns the new Vector3
  2346. */
  2347. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2348. /**
  2349. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2350. * @param start defines the start value
  2351. * @param end defines the end value
  2352. * @param amount max defines amount between both (between 0 and 1)
  2353. * @param result defines the Vector3 where to store the result
  2354. */
  2355. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2356. /**
  2357. * Returns the dot product (float) between the vectors "left" and "right"
  2358. * @param left defines the left operand
  2359. * @param right defines the right operand
  2360. * @returns the dot product
  2361. */
  2362. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2363. /**
  2364. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2365. * The cross product is then orthogonal to both "left" and "right"
  2366. * @param left defines the left operand
  2367. * @param right defines the right operand
  2368. * @returns the cross product
  2369. */
  2370. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2371. /**
  2372. * Sets the given vector "result" with the cross product of "left" and "right"
  2373. * The cross product is then orthogonal to both "left" and "right"
  2374. * @param left defines the left operand
  2375. * @param right defines the right operand
  2376. * @param result defines the Vector3 where to store the result
  2377. */
  2378. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2379. /**
  2380. * Returns a new Vector3 as the normalization of the given vector
  2381. * @param vector defines the Vector3 to normalize
  2382. * @returns the new Vector3
  2383. */
  2384. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2385. /**
  2386. * Sets the given vector "result" with the normalization of the given first vector
  2387. * @param vector defines the Vector3 to normalize
  2388. * @param result defines the Vector3 where to store the result
  2389. */
  2390. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2391. /**
  2392. * Project a Vector3 onto screen space
  2393. * @param vector defines the Vector3 to project
  2394. * @param world defines the world matrix to use
  2395. * @param transform defines the transform (view x projection) matrix to use
  2396. * @param viewport defines the screen viewport to use
  2397. * @returns the new Vector3
  2398. */
  2399. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2400. /** @hidden */
  2401. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2402. /**
  2403. * Unproject from screen space to object space
  2404. * @param source defines the screen space Vector3 to use
  2405. * @param viewportWidth defines the current width of the viewport
  2406. * @param viewportHeight defines the current height of the viewport
  2407. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2408. * @param transform defines the transform (view x projection) matrix to use
  2409. * @returns the new Vector3
  2410. */
  2411. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2412. /**
  2413. * Unproject from screen space to object space
  2414. * @param source defines the screen space Vector3 to use
  2415. * @param viewportWidth defines the current width of the viewport
  2416. * @param viewportHeight defines the current height of the viewport
  2417. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2418. * @param view defines the view matrix to use
  2419. * @param projection defines the projection matrix to use
  2420. * @returns the new Vector3
  2421. */
  2422. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2423. /**
  2424. * Unproject from screen space to object space
  2425. * @param source defines the screen space Vector3 to use
  2426. * @param viewportWidth defines the current width of the viewport
  2427. * @param viewportHeight defines the current height of the viewport
  2428. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2429. * @param view defines the view matrix to use
  2430. * @param projection defines the projection matrix to use
  2431. * @param result defines the Vector3 where to store the result
  2432. */
  2433. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2434. /**
  2435. * Unproject from screen space to object space
  2436. * @param sourceX defines the screen space x coordinate to use
  2437. * @param sourceY defines the screen space y coordinate to use
  2438. * @param sourceZ defines the screen space z coordinate to use
  2439. * @param viewportWidth defines the current width of the viewport
  2440. * @param viewportHeight defines the current height of the viewport
  2441. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2442. * @param view defines the view matrix to use
  2443. * @param projection defines the projection matrix to use
  2444. * @param result defines the Vector3 where to store the result
  2445. */
  2446. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2447. /**
  2448. * Gets the minimal coordinate values between two Vector3
  2449. * @param left defines the first operand
  2450. * @param right defines the second operand
  2451. * @returns the new Vector3
  2452. */
  2453. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2454. /**
  2455. * Gets the maximal coordinate values between two Vector3
  2456. * @param left defines the first operand
  2457. * @param right defines the second operand
  2458. * @returns the new Vector3
  2459. */
  2460. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2461. /**
  2462. * Returns the distance between the vectors "value1" and "value2"
  2463. * @param value1 defines the first operand
  2464. * @param value2 defines the second operand
  2465. * @returns the distance
  2466. */
  2467. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2468. /**
  2469. * Returns the squared distance between the vectors "value1" and "value2"
  2470. * @param value1 defines the first operand
  2471. * @param value2 defines the second operand
  2472. * @returns the squared distance
  2473. */
  2474. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2475. /**
  2476. * Returns a new Vector3 located at the center between "value1" and "value2"
  2477. * @param value1 defines the first operand
  2478. * @param value2 defines the second operand
  2479. * @returns the new Vector3
  2480. */
  2481. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2482. /**
  2483. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2484. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2485. * to something in order to rotate it from its local system to the given target system
  2486. * Note: axis1, axis2 and axis3 are normalized during this operation
  2487. * @param axis1 defines the first axis
  2488. * @param axis2 defines the second axis
  2489. * @param axis3 defines the third axis
  2490. * @returns a new Vector3
  2491. */
  2492. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2493. /**
  2494. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2495. * @param axis1 defines the first axis
  2496. * @param axis2 defines the second axis
  2497. * @param axis3 defines the third axis
  2498. * @param ref defines the Vector3 where to store the result
  2499. */
  2500. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2501. }
  2502. /**
  2503. * Vector4 class created for EulerAngle class conversion to Quaternion
  2504. */
  2505. export class Vector4 {
  2506. /** x value of the vector */
  2507. x: number;
  2508. /** y value of the vector */
  2509. y: number;
  2510. /** z value of the vector */
  2511. z: number;
  2512. /** w value of the vector */
  2513. w: number;
  2514. /**
  2515. * Creates a Vector4 object from the given floats.
  2516. * @param x x value of the vector
  2517. * @param y y value of the vector
  2518. * @param z z value of the vector
  2519. * @param w w value of the vector
  2520. */
  2521. constructor(
  2522. /** x value of the vector */
  2523. x: number,
  2524. /** y value of the vector */
  2525. y: number,
  2526. /** z value of the vector */
  2527. z: number,
  2528. /** w value of the vector */
  2529. w: number);
  2530. /**
  2531. * Returns the string with the Vector4 coordinates.
  2532. * @returns a string containing all the vector values
  2533. */
  2534. toString(): string;
  2535. /**
  2536. * Returns the string "Vector4".
  2537. * @returns "Vector4"
  2538. */
  2539. getClassName(): string;
  2540. /**
  2541. * Returns the Vector4 hash code.
  2542. * @returns a unique hash code
  2543. */
  2544. getHashCode(): number;
  2545. /**
  2546. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2547. * @returns the resulting array
  2548. */
  2549. asArray(): number[];
  2550. /**
  2551. * Populates the given array from the given index with the Vector4 coordinates.
  2552. * @param array array to populate
  2553. * @param index index of the array to start at (default: 0)
  2554. * @returns the Vector4.
  2555. */
  2556. toArray(array: FloatArray, index?: number): Vector4;
  2557. /**
  2558. * Adds the given vector to the current Vector4.
  2559. * @param otherVector the vector to add
  2560. * @returns the updated Vector4.
  2561. */
  2562. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2563. /**
  2564. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2565. * @param otherVector the vector to add
  2566. * @returns the resulting vector
  2567. */
  2568. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2569. /**
  2570. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2571. * @param otherVector the vector to add
  2572. * @param result the vector to store the result
  2573. * @returns the current Vector4.
  2574. */
  2575. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2576. /**
  2577. * Subtract in place the given vector from the current Vector4.
  2578. * @param otherVector the vector to subtract
  2579. * @returns the updated Vector4.
  2580. */
  2581. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2582. /**
  2583. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2584. * @param otherVector the vector to add
  2585. * @returns the new vector with the result
  2586. */
  2587. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2588. /**
  2589. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2590. * @param otherVector the vector to subtract
  2591. * @param result the vector to store the result
  2592. * @returns the current Vector4.
  2593. */
  2594. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2595. /**
  2596. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2597. */
  2598. /**
  2599. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2600. * @param x value to subtract
  2601. * @param y value to subtract
  2602. * @param z value to subtract
  2603. * @param w value to subtract
  2604. * @returns new vector containing the result
  2605. */
  2606. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2607. /**
  2608. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2609. * @param x value to subtract
  2610. * @param y value to subtract
  2611. * @param z value to subtract
  2612. * @param w value to subtract
  2613. * @param result the vector to store the result in
  2614. * @returns the current Vector4.
  2615. */
  2616. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2617. /**
  2618. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2619. * @returns a new vector with the negated values
  2620. */
  2621. negate(): Vector4;
  2622. /**
  2623. * Multiplies the current Vector4 coordinates by scale (float).
  2624. * @param scale the number to scale with
  2625. * @returns the updated Vector4.
  2626. */
  2627. scaleInPlace(scale: number): Vector4;
  2628. /**
  2629. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2630. * @param scale the number to scale with
  2631. * @returns a new vector with the result
  2632. */
  2633. scale(scale: number): Vector4;
  2634. /**
  2635. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2636. * @param scale the number to scale with
  2637. * @param result a vector to store the result in
  2638. * @returns the current Vector4.
  2639. */
  2640. scaleToRef(scale: number, result: Vector4): Vector4;
  2641. /**
  2642. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2643. * @param scale defines the scale factor
  2644. * @param result defines the Vector4 object where to store the result
  2645. * @returns the unmodified current Vector4
  2646. */
  2647. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2648. /**
  2649. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2650. * @param otherVector the vector to compare against
  2651. * @returns true if they are equal
  2652. */
  2653. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2654. /**
  2655. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2656. * @param otherVector vector to compare against
  2657. * @param epsilon (Default: very small number)
  2658. * @returns true if they are equal
  2659. */
  2660. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2661. /**
  2662. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2663. * @param x x value to compare against
  2664. * @param y y value to compare against
  2665. * @param z z value to compare against
  2666. * @param w w value to compare against
  2667. * @returns true if equal
  2668. */
  2669. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2670. /**
  2671. * Multiplies in place the current Vector4 by the given one.
  2672. * @param otherVector vector to multiple with
  2673. * @returns the updated Vector4.
  2674. */
  2675. multiplyInPlace(otherVector: Vector4): Vector4;
  2676. /**
  2677. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2678. * @param otherVector vector to multiple with
  2679. * @returns resulting new vector
  2680. */
  2681. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2682. /**
  2683. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2684. * @param otherVector vector to multiple with
  2685. * @param result vector to store the result
  2686. * @returns the current Vector4.
  2687. */
  2688. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2689. /**
  2690. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2691. * @param x x value multiply with
  2692. * @param y y value multiply with
  2693. * @param z z value multiply with
  2694. * @param w w value multiply with
  2695. * @returns resulting new vector
  2696. */
  2697. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2698. /**
  2699. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2700. * @param otherVector vector to devide with
  2701. * @returns resulting new vector
  2702. */
  2703. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2704. /**
  2705. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2706. * @param otherVector vector to devide with
  2707. * @param result vector to store the result
  2708. * @returns the current Vector4.
  2709. */
  2710. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2711. /**
  2712. * Divides the current Vector3 coordinates by the given ones.
  2713. * @param otherVector vector to devide with
  2714. * @returns the updated Vector3.
  2715. */
  2716. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2717. /**
  2718. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2719. * @param other defines the second operand
  2720. * @returns the current updated Vector4
  2721. */
  2722. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2723. /**
  2724. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2725. * @param other defines the second operand
  2726. * @returns the current updated Vector4
  2727. */
  2728. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2729. /**
  2730. * Gets a new Vector4 from current Vector4 floored values
  2731. * @returns a new Vector4
  2732. */
  2733. floor(): Vector4;
  2734. /**
  2735. * Gets a new Vector4 from current Vector3 floored values
  2736. * @returns a new Vector4
  2737. */
  2738. fract(): Vector4;
  2739. /**
  2740. * Returns the Vector4 length (float).
  2741. * @returns the length
  2742. */
  2743. length(): number;
  2744. /**
  2745. * Returns the Vector4 squared length (float).
  2746. * @returns the length squared
  2747. */
  2748. lengthSquared(): number;
  2749. /**
  2750. * Normalizes in place the Vector4.
  2751. * @returns the updated Vector4.
  2752. */
  2753. normalize(): Vector4;
  2754. /**
  2755. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2756. * @returns this converted to a new vector3
  2757. */
  2758. toVector3(): Vector3;
  2759. /**
  2760. * Returns a new Vector4 copied from the current one.
  2761. * @returns the new cloned vector
  2762. */
  2763. clone(): Vector4;
  2764. /**
  2765. * Updates the current Vector4 with the given one coordinates.
  2766. * @param source the source vector to copy from
  2767. * @returns the updated Vector4.
  2768. */
  2769. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2770. /**
  2771. * Updates the current Vector4 coordinates with the given floats.
  2772. * @param x float to copy from
  2773. * @param y float to copy from
  2774. * @param z float to copy from
  2775. * @param w float to copy from
  2776. * @returns the updated Vector4.
  2777. */
  2778. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2779. /**
  2780. * Updates the current Vector4 coordinates with the given floats.
  2781. * @param x float to set from
  2782. * @param y float to set from
  2783. * @param z float to set from
  2784. * @param w float to set from
  2785. * @returns the updated Vector4.
  2786. */
  2787. set(x: number, y: number, z: number, w: number): Vector4;
  2788. /**
  2789. * Copies the given float to the current Vector3 coordinates
  2790. * @param v defines the x, y, z and w coordinates of the operand
  2791. * @returns the current updated Vector3
  2792. */
  2793. setAll(v: number): Vector4;
  2794. /**
  2795. * Returns a new Vector4 set from the starting index of the given array.
  2796. * @param array the array to pull values from
  2797. * @param offset the offset into the array to start at
  2798. * @returns the new vector
  2799. */
  2800. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2801. /**
  2802. * Updates the given vector "result" from the starting index of the given array.
  2803. * @param array the array to pull values from
  2804. * @param offset the offset into the array to start at
  2805. * @param result the vector to store the result in
  2806. */
  2807. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2808. /**
  2809. * Updates the given vector "result" from the starting index of the given Float32Array.
  2810. * @param array the array to pull values from
  2811. * @param offset the offset into the array to start at
  2812. * @param result the vector to store the result in
  2813. */
  2814. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2815. /**
  2816. * Updates the given vector "result" coordinates from the given floats.
  2817. * @param x float to set from
  2818. * @param y float to set from
  2819. * @param z float to set from
  2820. * @param w float to set from
  2821. * @param result the vector to the floats in
  2822. */
  2823. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2824. /**
  2825. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2826. * @returns the new vector
  2827. */
  2828. static Zero(): Vector4;
  2829. /**
  2830. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2831. * @returns the new vector
  2832. */
  2833. static One(): Vector4;
  2834. /**
  2835. * Returns a new normalized Vector4 from the given one.
  2836. * @param vector the vector to normalize
  2837. * @returns the vector
  2838. */
  2839. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2840. /**
  2841. * Updates the given vector "result" from the normalization of the given one.
  2842. * @param vector the vector to normalize
  2843. * @param result the vector to store the result in
  2844. */
  2845. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2846. /**
  2847. * Returns a vector with the minimum values from the left and right vectors
  2848. * @param left left vector to minimize
  2849. * @param right right vector to minimize
  2850. * @returns a new vector with the minimum of the left and right vector values
  2851. */
  2852. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2853. /**
  2854. * Returns a vector with the maximum values from the left and right vectors
  2855. * @param left left vector to maximize
  2856. * @param right right vector to maximize
  2857. * @returns a new vector with the maximum of the left and right vector values
  2858. */
  2859. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2860. /**
  2861. * Returns the distance (float) between the vectors "value1" and "value2".
  2862. * @param value1 value to calulate the distance between
  2863. * @param value2 value to calulate the distance between
  2864. * @return the distance between the two vectors
  2865. */
  2866. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2867. /**
  2868. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2869. * @param value1 value to calulate the distance between
  2870. * @param value2 value to calulate the distance between
  2871. * @return the distance between the two vectors squared
  2872. */
  2873. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2874. /**
  2875. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2876. * @param value1 value to calulate the center between
  2877. * @param value2 value to calulate the center between
  2878. * @return the center between the two vectors
  2879. */
  2880. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2881. /**
  2882. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2883. * This methods computes transformed normalized direction vectors only.
  2884. * @param vector the vector to transform
  2885. * @param transformation the transformation matrix to apply
  2886. * @returns the new vector
  2887. */
  2888. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2889. /**
  2890. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2891. * This methods computes transformed normalized direction vectors only.
  2892. * @param vector the vector to transform
  2893. * @param transformation the transformation matrix to apply
  2894. * @param result the vector to store the result in
  2895. */
  2896. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2897. /**
  2898. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2899. * This methods computes transformed normalized direction vectors only.
  2900. * @param x value to transform
  2901. * @param y value to transform
  2902. * @param z value to transform
  2903. * @param w value to transform
  2904. * @param transformation the transformation matrix to apply
  2905. * @param result the vector to store the results in
  2906. */
  2907. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2908. /**
  2909. * Creates a new Vector4 from a Vector3
  2910. * @param source defines the source data
  2911. * @param w defines the 4th component (default is 0)
  2912. * @returns a new Vector4
  2913. */
  2914. static FromVector3(source: Vector3, w?: number): Vector4;
  2915. }
  2916. /**
  2917. * Class used to store quaternion data
  2918. * @see https://en.wikipedia.org/wiki/Quaternion
  2919. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2920. */
  2921. export class Quaternion {
  2922. /** defines the first component (0 by default) */
  2923. x: number;
  2924. /** defines the second component (0 by default) */
  2925. y: number;
  2926. /** defines the third component (0 by default) */
  2927. z: number;
  2928. /** defines the fourth component (1.0 by default) */
  2929. w: number;
  2930. /**
  2931. * Creates a new Quaternion from the given floats
  2932. * @param x defines the first component (0 by default)
  2933. * @param y defines the second component (0 by default)
  2934. * @param z defines the third component (0 by default)
  2935. * @param w defines the fourth component (1.0 by default)
  2936. */
  2937. constructor(
  2938. /** defines the first component (0 by default) */
  2939. x?: number,
  2940. /** defines the second component (0 by default) */
  2941. y?: number,
  2942. /** defines the third component (0 by default) */
  2943. z?: number,
  2944. /** defines the fourth component (1.0 by default) */
  2945. w?: number);
  2946. /**
  2947. * Gets a string representation for the current quaternion
  2948. * @returns a string with the Quaternion coordinates
  2949. */
  2950. toString(): string;
  2951. /**
  2952. * Gets the class name of the quaternion
  2953. * @returns the string "Quaternion"
  2954. */
  2955. getClassName(): string;
  2956. /**
  2957. * Gets a hash code for this quaternion
  2958. * @returns the quaternion hash code
  2959. */
  2960. getHashCode(): number;
  2961. /**
  2962. * Copy the quaternion to an array
  2963. * @returns a new array populated with 4 elements from the quaternion coordinates
  2964. */
  2965. asArray(): number[];
  2966. /**
  2967. * Check if two quaternions are equals
  2968. * @param otherQuaternion defines the second operand
  2969. * @return true if the current quaternion and the given one coordinates are strictly equals
  2970. */
  2971. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2972. /**
  2973. * Clone the current quaternion
  2974. * @returns a new quaternion copied from the current one
  2975. */
  2976. clone(): Quaternion;
  2977. /**
  2978. * Copy a quaternion to the current one
  2979. * @param other defines the other quaternion
  2980. * @returns the updated current quaternion
  2981. */
  2982. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2983. /**
  2984. * Updates the current quaternion with the given float coordinates
  2985. * @param x defines the x coordinate
  2986. * @param y defines the y coordinate
  2987. * @param z defines the z coordinate
  2988. * @param w defines the w coordinate
  2989. * @returns the updated current quaternion
  2990. */
  2991. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2992. /**
  2993. * Updates the current quaternion from the given float coordinates
  2994. * @param x defines the x coordinate
  2995. * @param y defines the y coordinate
  2996. * @param z defines the z coordinate
  2997. * @param w defines the w coordinate
  2998. * @returns the updated current quaternion
  2999. */
  3000. set(x: number, y: number, z: number, w: number): Quaternion;
  3001. /**
  3002. * Adds two quaternions
  3003. * @param other defines the second operand
  3004. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3005. */
  3006. add(other: DeepImmutable<Quaternion>): Quaternion;
  3007. /**
  3008. * Add a quaternion to the current one
  3009. * @param other defines the quaternion to add
  3010. * @returns the current quaternion
  3011. */
  3012. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3013. /**
  3014. * Subtract two quaternions
  3015. * @param other defines the second operand
  3016. * @returns a new quaternion as the subtraction result of the given one from the current one
  3017. */
  3018. subtract(other: Quaternion): Quaternion;
  3019. /**
  3020. * Multiplies the current quaternion by a scale factor
  3021. * @param value defines the scale factor
  3022. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3023. */
  3024. scale(value: number): Quaternion;
  3025. /**
  3026. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3027. * @param scale defines the scale factor
  3028. * @param result defines the Quaternion object where to store the result
  3029. * @returns the unmodified current quaternion
  3030. */
  3031. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3032. /**
  3033. * Multiplies in place the current quaternion by a scale factor
  3034. * @param value defines the scale factor
  3035. * @returns the current modified quaternion
  3036. */
  3037. scaleInPlace(value: number): Quaternion;
  3038. /**
  3039. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3040. * @param scale defines the scale factor
  3041. * @param result defines the Quaternion object where to store the result
  3042. * @returns the unmodified current quaternion
  3043. */
  3044. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3045. /**
  3046. * Multiplies two quaternions
  3047. * @param q1 defines the second operand
  3048. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3049. */
  3050. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3051. /**
  3052. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3053. * @param q1 defines the second operand
  3054. * @param result defines the target quaternion
  3055. * @returns the current quaternion
  3056. */
  3057. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3058. /**
  3059. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3060. * @param q1 defines the second operand
  3061. * @returns the currentupdated quaternion
  3062. */
  3063. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3064. /**
  3065. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3066. * @param ref defines the target quaternion
  3067. * @returns the current quaternion
  3068. */
  3069. conjugateToRef(ref: Quaternion): Quaternion;
  3070. /**
  3071. * Conjugates in place (1-q) the current quaternion
  3072. * @returns the current updated quaternion
  3073. */
  3074. conjugateInPlace(): Quaternion;
  3075. /**
  3076. * Conjugates in place (1-q) the current quaternion
  3077. * @returns a new quaternion
  3078. */
  3079. conjugate(): Quaternion;
  3080. /**
  3081. * Gets length of current quaternion
  3082. * @returns the quaternion length (float)
  3083. */
  3084. length(): number;
  3085. /**
  3086. * Normalize in place the current quaternion
  3087. * @returns the current updated quaternion
  3088. */
  3089. normalize(): Quaternion;
  3090. /**
  3091. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3092. * @param order is a reserved parameter and is ignore for now
  3093. * @returns a new Vector3 containing the Euler angles
  3094. */
  3095. toEulerAngles(order?: string): Vector3;
  3096. /**
  3097. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3098. * @param result defines the vector which will be filled with the Euler angles
  3099. * @param order is a reserved parameter and is ignore for now
  3100. * @returns the current unchanged quaternion
  3101. */
  3102. toEulerAnglesToRef(result: Vector3): Quaternion;
  3103. /**
  3104. * Updates the given rotation matrix with the current quaternion values
  3105. * @param result defines the target matrix
  3106. * @returns the current unchanged quaternion
  3107. */
  3108. toRotationMatrix(result: Matrix): Quaternion;
  3109. /**
  3110. * Updates the current quaternion from the given rotation matrix values
  3111. * @param matrix defines the source matrix
  3112. * @returns the current updated quaternion
  3113. */
  3114. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3115. /**
  3116. * Creates a new quaternion from a rotation matrix
  3117. * @param matrix defines the source matrix
  3118. * @returns a new quaternion created from the given rotation matrix values
  3119. */
  3120. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3121. /**
  3122. * Updates the given quaternion with the given rotation matrix values
  3123. * @param matrix defines the source matrix
  3124. * @param result defines the target quaternion
  3125. */
  3126. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3127. /**
  3128. * Returns the dot product (float) between the quaternions "left" and "right"
  3129. * @param left defines the left operand
  3130. * @param right defines the right operand
  3131. * @returns the dot product
  3132. */
  3133. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3134. /**
  3135. * Checks if the two quaternions are close to each other
  3136. * @param quat0 defines the first quaternion to check
  3137. * @param quat1 defines the second quaternion to check
  3138. * @returns true if the two quaternions are close to each other
  3139. */
  3140. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3141. /**
  3142. * Creates an empty quaternion
  3143. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3144. */
  3145. static Zero(): Quaternion;
  3146. /**
  3147. * Inverse a given quaternion
  3148. * @param q defines the source quaternion
  3149. * @returns a new quaternion as the inverted current quaternion
  3150. */
  3151. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3152. /**
  3153. * Inverse a given quaternion
  3154. * @param q defines the source quaternion
  3155. * @param result the quaternion the result will be stored in
  3156. * @returns the result quaternion
  3157. */
  3158. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3159. /**
  3160. * Creates an identity quaternion
  3161. * @returns the identity quaternion
  3162. */
  3163. static Identity(): Quaternion;
  3164. /**
  3165. * Gets a boolean indicating if the given quaternion is identity
  3166. * @param quaternion defines the quaternion to check
  3167. * @returns true if the quaternion is identity
  3168. */
  3169. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3170. /**
  3171. * Creates a quaternion from a rotation around an axis
  3172. * @param axis defines the axis to use
  3173. * @param angle defines the angle to use
  3174. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3175. */
  3176. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3177. /**
  3178. * Creates a rotation around an axis and stores it into the given quaternion
  3179. * @param axis defines the axis to use
  3180. * @param angle defines the angle to use
  3181. * @param result defines the target quaternion
  3182. * @returns the target quaternion
  3183. */
  3184. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3185. /**
  3186. * Creates a new quaternion from data stored into an array
  3187. * @param array defines the data source
  3188. * @param offset defines the offset in the source array where the data starts
  3189. * @returns a new quaternion
  3190. */
  3191. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3192. /**
  3193. * Create a quaternion from Euler rotation angles
  3194. * @param x Pitch
  3195. * @param y Yaw
  3196. * @param z Roll
  3197. * @returns the new Quaternion
  3198. */
  3199. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3200. /**
  3201. * Updates a quaternion from Euler rotation angles
  3202. * @param x Pitch
  3203. * @param y Yaw
  3204. * @param z Roll
  3205. * @param result the quaternion to store the result
  3206. * @returns the updated quaternion
  3207. */
  3208. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3209. /**
  3210. * Create a quaternion from Euler rotation vector
  3211. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3212. * @returns the new Quaternion
  3213. */
  3214. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3215. /**
  3216. * Updates a quaternion from Euler rotation vector
  3217. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3218. * @param result the quaternion to store the result
  3219. * @returns the updated quaternion
  3220. */
  3221. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3222. /**
  3223. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3224. * @param yaw defines the rotation around Y axis
  3225. * @param pitch defines the rotation around X axis
  3226. * @param roll defines the rotation around Z axis
  3227. * @returns the new quaternion
  3228. */
  3229. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3230. /**
  3231. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3232. * @param yaw defines the rotation around Y axis
  3233. * @param pitch defines the rotation around X axis
  3234. * @param roll defines the rotation around Z axis
  3235. * @param result defines the target quaternion
  3236. */
  3237. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3238. /**
  3239. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3240. * @param alpha defines the rotation around first axis
  3241. * @param beta defines the rotation around second axis
  3242. * @param gamma defines the rotation around third axis
  3243. * @returns the new quaternion
  3244. */
  3245. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3246. /**
  3247. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3248. * @param alpha defines the rotation around first axis
  3249. * @param beta defines the rotation around second axis
  3250. * @param gamma defines the rotation around third axis
  3251. * @param result defines the target quaternion
  3252. */
  3253. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3254. /**
  3255. * 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)
  3256. * @param axis1 defines the first axis
  3257. * @param axis2 defines the second axis
  3258. * @param axis3 defines the third axis
  3259. * @returns the new quaternion
  3260. */
  3261. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3262. /**
  3263. * 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
  3264. * @param axis1 defines the first axis
  3265. * @param axis2 defines the second axis
  3266. * @param axis3 defines the third axis
  3267. * @param ref defines the target quaternion
  3268. */
  3269. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3270. /**
  3271. * Interpolates between two quaternions
  3272. * @param left defines first quaternion
  3273. * @param right defines second quaternion
  3274. * @param amount defines the gradient to use
  3275. * @returns the new interpolated quaternion
  3276. */
  3277. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3278. /**
  3279. * Interpolates between two quaternions and stores it into a target quaternion
  3280. * @param left defines first quaternion
  3281. * @param right defines second quaternion
  3282. * @param amount defines the gradient to use
  3283. * @param result defines the target quaternion
  3284. */
  3285. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3286. /**
  3287. * Interpolate between two quaternions using Hermite interpolation
  3288. * @param value1 defines first quaternion
  3289. * @param tangent1 defines the incoming tangent
  3290. * @param value2 defines second quaternion
  3291. * @param tangent2 defines the outgoing tangent
  3292. * @param amount defines the target quaternion
  3293. * @returns the new interpolated quaternion
  3294. */
  3295. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3296. }
  3297. /**
  3298. * Class used to store matrix data (4x4)
  3299. */
  3300. export class Matrix {
  3301. private static _updateFlagSeed;
  3302. private static _identityReadOnly;
  3303. private _isIdentity;
  3304. private _isIdentityDirty;
  3305. private _isIdentity3x2;
  3306. private _isIdentity3x2Dirty;
  3307. /**
  3308. * Gets the update flag of the matrix which is an unique number for the matrix.
  3309. * It will be incremented every time the matrix data change.
  3310. * You can use it to speed the comparison between two versions of the same matrix.
  3311. */
  3312. updateFlag: number;
  3313. private readonly _m;
  3314. /**
  3315. * Gets the internal data of the matrix
  3316. */
  3317. readonly m: DeepImmutable<Float32Array>;
  3318. /** @hidden */
  3319. _markAsUpdated(): void;
  3320. /** @hidden */
  3321. private _updateIdentityStatus;
  3322. /**
  3323. * Creates an empty matrix (filled with zeros)
  3324. */
  3325. constructor();
  3326. /**
  3327. * Check if the current matrix is identity
  3328. * @returns true is the matrix is the identity matrix
  3329. */
  3330. isIdentity(): boolean;
  3331. /**
  3332. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3333. * @returns true is the matrix is the identity matrix
  3334. */
  3335. isIdentityAs3x2(): boolean;
  3336. /**
  3337. * Gets the determinant of the matrix
  3338. * @returns the matrix determinant
  3339. */
  3340. determinant(): number;
  3341. /**
  3342. * Returns the matrix as a Float32Array
  3343. * @returns the matrix underlying array
  3344. */
  3345. toArray(): DeepImmutable<Float32Array>;
  3346. /**
  3347. * Returns the matrix as a Float32Array
  3348. * @returns the matrix underlying array.
  3349. */
  3350. asArray(): DeepImmutable<Float32Array>;
  3351. /**
  3352. * Inverts the current matrix in place
  3353. * @returns the current inverted matrix
  3354. */
  3355. invert(): Matrix;
  3356. /**
  3357. * Sets all the matrix elements to zero
  3358. * @returns the current matrix
  3359. */
  3360. reset(): Matrix;
  3361. /**
  3362. * Adds the current matrix with a second one
  3363. * @param other defines the matrix to add
  3364. * @returns a new matrix as the addition of the current matrix and the given one
  3365. */
  3366. add(other: DeepImmutable<Matrix>): Matrix;
  3367. /**
  3368. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3369. * @param other defines the matrix to add
  3370. * @param result defines the target matrix
  3371. * @returns the current matrix
  3372. */
  3373. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3374. /**
  3375. * Adds in place the given matrix to the current matrix
  3376. * @param other defines the second operand
  3377. * @returns the current updated matrix
  3378. */
  3379. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3380. /**
  3381. * Sets the given matrix to the current inverted Matrix
  3382. * @param other defines the target matrix
  3383. * @returns the unmodified current matrix
  3384. */
  3385. invertToRef(other: Matrix): Matrix;
  3386. /**
  3387. * add a value at the specified position in the current Matrix
  3388. * @param index the index of the value within the matrix. between 0 and 15.
  3389. * @param value the value to be added
  3390. * @returns the current updated matrix
  3391. */
  3392. addAtIndex(index: number, value: number): Matrix;
  3393. /**
  3394. * mutiply the specified position in the current Matrix by a value
  3395. * @param index the index of the value within the matrix. between 0 and 15.
  3396. * @param value the value to be added
  3397. * @returns the current updated matrix
  3398. */
  3399. multiplyAtIndex(index: number, value: number): Matrix;
  3400. /**
  3401. * Inserts the translation vector (using 3 floats) in the current matrix
  3402. * @param x defines the 1st component of the translation
  3403. * @param y defines the 2nd component of the translation
  3404. * @param z defines the 3rd component of the translation
  3405. * @returns the current updated matrix
  3406. */
  3407. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3408. /**
  3409. * Adds the translation vector (using 3 floats) in the current matrix
  3410. * @param x defines the 1st component of the translation
  3411. * @param y defines the 2nd component of the translation
  3412. * @param z defines the 3rd component of the translation
  3413. * @returns the current updated matrix
  3414. */
  3415. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3416. /**
  3417. * Inserts the translation vector in the current matrix
  3418. * @param vector3 defines the translation to insert
  3419. * @returns the current updated matrix
  3420. */
  3421. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3422. /**
  3423. * Gets the translation value of the current matrix
  3424. * @returns a new Vector3 as the extracted translation from the matrix
  3425. */
  3426. getTranslation(): Vector3;
  3427. /**
  3428. * Fill a Vector3 with the extracted translation from the matrix
  3429. * @param result defines the Vector3 where to store the translation
  3430. * @returns the current matrix
  3431. */
  3432. getTranslationToRef(result: Vector3): Matrix;
  3433. /**
  3434. * Remove rotation and scaling part from the matrix
  3435. * @returns the updated matrix
  3436. */
  3437. removeRotationAndScaling(): Matrix;
  3438. /**
  3439. * Multiply two matrices
  3440. * @param other defines the second operand
  3441. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3442. */
  3443. multiply(other: DeepImmutable<Matrix>): Matrix;
  3444. /**
  3445. * Copy the current matrix from the given one
  3446. * @param other defines the source matrix
  3447. * @returns the current updated matrix
  3448. */
  3449. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3450. /**
  3451. * Populates the given array from the starting index with the current matrix values
  3452. * @param array defines the target array
  3453. * @param offset defines the offset in the target array where to start storing values
  3454. * @returns the current matrix
  3455. */
  3456. copyToArray(array: Float32Array, offset?: number): Matrix;
  3457. /**
  3458. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3459. * @param other defines the second operand
  3460. * @param result defines the matrix where to store the multiplication
  3461. * @returns the current matrix
  3462. */
  3463. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3464. /**
  3465. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3466. * @param other defines the second operand
  3467. * @param result defines the array where to store the multiplication
  3468. * @param offset defines the offset in the target array where to start storing values
  3469. * @returns the current matrix
  3470. */
  3471. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3472. /**
  3473. * Check equality between this matrix and a second one
  3474. * @param value defines the second matrix to compare
  3475. * @returns true is the current matrix and the given one values are strictly equal
  3476. */
  3477. equals(value: DeepImmutable<Matrix>): boolean;
  3478. /**
  3479. * Clone the current matrix
  3480. * @returns a new matrix from the current matrix
  3481. */
  3482. clone(): Matrix;
  3483. /**
  3484. * Returns the name of the current matrix class
  3485. * @returns the string "Matrix"
  3486. */
  3487. getClassName(): string;
  3488. /**
  3489. * Gets the hash code of the current matrix
  3490. * @returns the hash code
  3491. */
  3492. getHashCode(): number;
  3493. /**
  3494. * Decomposes the current Matrix into a translation, rotation and scaling components
  3495. * @param scale defines the scale vector3 given as a reference to update
  3496. * @param rotation defines the rotation quaternion given as a reference to update
  3497. * @param translation defines the translation vector3 given as a reference to update
  3498. * @returns true if operation was successful
  3499. */
  3500. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3501. /**
  3502. * Gets specific row of the matrix
  3503. * @param index defines the number of the row to get
  3504. * @returns the index-th row of the current matrix as a new Vector4
  3505. */
  3506. getRow(index: number): Nullable<Vector4>;
  3507. /**
  3508. * Sets the index-th row of the current matrix to the vector4 values
  3509. * @param index defines the number of the row to set
  3510. * @param row defines the target vector4
  3511. * @returns the updated current matrix
  3512. */
  3513. setRow(index: number, row: Vector4): Matrix;
  3514. /**
  3515. * Compute the transpose of the matrix
  3516. * @returns the new transposed matrix
  3517. */
  3518. transpose(): Matrix;
  3519. /**
  3520. * Compute the transpose of the matrix and store it in a given matrix
  3521. * @param result defines the target matrix
  3522. * @returns the current matrix
  3523. */
  3524. transposeToRef(result: Matrix): Matrix;
  3525. /**
  3526. * Sets the index-th row of the current matrix with the given 4 x float values
  3527. * @param index defines the row index
  3528. * @param x defines the x component to set
  3529. * @param y defines the y component to set
  3530. * @param z defines the z component to set
  3531. * @param w defines the w component to set
  3532. * @returns the updated current matrix
  3533. */
  3534. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3535. /**
  3536. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3537. * @param scale defines the scale factor
  3538. * @returns a new matrix
  3539. */
  3540. scale(scale: number): Matrix;
  3541. /**
  3542. * Scale the current matrix values by a factor to a given result matrix
  3543. * @param scale defines the scale factor
  3544. * @param result defines the matrix to store the result
  3545. * @returns the current matrix
  3546. */
  3547. scaleToRef(scale: number, result: Matrix): Matrix;
  3548. /**
  3549. * Scale the current matrix values by a factor and add the result to a given matrix
  3550. * @param scale defines the scale factor
  3551. * @param result defines the Matrix to store the result
  3552. * @returns the current matrix
  3553. */
  3554. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3555. /**
  3556. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3557. * @param ref matrix to store the result
  3558. */
  3559. toNormalMatrix(ref: Matrix): void;
  3560. /**
  3561. * Gets only rotation part of the current matrix
  3562. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3563. */
  3564. getRotationMatrix(): Matrix;
  3565. /**
  3566. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3567. * @param result defines the target matrix to store data to
  3568. * @returns the current matrix
  3569. */
  3570. getRotationMatrixToRef(result: Matrix): Matrix;
  3571. /**
  3572. * Toggles model matrix from being right handed to left handed in place and vice versa
  3573. */
  3574. toggleModelMatrixHandInPlace(): void;
  3575. /**
  3576. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3577. */
  3578. toggleProjectionMatrixHandInPlace(): void;
  3579. /**
  3580. * Creates a matrix from an array
  3581. * @param array defines the source array
  3582. * @param offset defines an offset in the source array
  3583. * @returns a new Matrix set from the starting index of the given array
  3584. */
  3585. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3586. /**
  3587. * Copy the content of an array into a given matrix
  3588. * @param array defines the source array
  3589. * @param offset defines an offset in the source array
  3590. * @param result defines the target matrix
  3591. */
  3592. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3593. /**
  3594. * Stores an array into a matrix after having multiplied each component by a given factor
  3595. * @param array defines the source array
  3596. * @param offset defines the offset in the source array
  3597. * @param scale defines the scaling factor
  3598. * @param result defines the target matrix
  3599. */
  3600. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3601. /**
  3602. * Gets an identity matrix that must not be updated
  3603. */
  3604. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3605. /**
  3606. * Stores a list of values (16) inside a given matrix
  3607. * @param initialM11 defines 1st value of 1st row
  3608. * @param initialM12 defines 2nd value of 1st row
  3609. * @param initialM13 defines 3rd value of 1st row
  3610. * @param initialM14 defines 4th value of 1st row
  3611. * @param initialM21 defines 1st value of 2nd row
  3612. * @param initialM22 defines 2nd value of 2nd row
  3613. * @param initialM23 defines 3rd value of 2nd row
  3614. * @param initialM24 defines 4th value of 2nd row
  3615. * @param initialM31 defines 1st value of 3rd row
  3616. * @param initialM32 defines 2nd value of 3rd row
  3617. * @param initialM33 defines 3rd value of 3rd row
  3618. * @param initialM34 defines 4th value of 3rd row
  3619. * @param initialM41 defines 1st value of 4th row
  3620. * @param initialM42 defines 2nd value of 4th row
  3621. * @param initialM43 defines 3rd value of 4th row
  3622. * @param initialM44 defines 4th value of 4th row
  3623. * @param result defines the target matrix
  3624. */
  3625. 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;
  3626. /**
  3627. * Creates new matrix from a list of values (16)
  3628. * @param initialM11 defines 1st value of 1st row
  3629. * @param initialM12 defines 2nd value of 1st row
  3630. * @param initialM13 defines 3rd value of 1st row
  3631. * @param initialM14 defines 4th value of 1st row
  3632. * @param initialM21 defines 1st value of 2nd row
  3633. * @param initialM22 defines 2nd value of 2nd row
  3634. * @param initialM23 defines 3rd value of 2nd row
  3635. * @param initialM24 defines 4th value of 2nd row
  3636. * @param initialM31 defines 1st value of 3rd row
  3637. * @param initialM32 defines 2nd value of 3rd row
  3638. * @param initialM33 defines 3rd value of 3rd row
  3639. * @param initialM34 defines 4th value of 3rd row
  3640. * @param initialM41 defines 1st value of 4th row
  3641. * @param initialM42 defines 2nd value of 4th row
  3642. * @param initialM43 defines 3rd value of 4th row
  3643. * @param initialM44 defines 4th value of 4th row
  3644. * @returns the new matrix
  3645. */
  3646. 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;
  3647. /**
  3648. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3649. * @param scale defines the scale vector3
  3650. * @param rotation defines the rotation quaternion
  3651. * @param translation defines the translation vector3
  3652. * @returns a new matrix
  3653. */
  3654. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3655. /**
  3656. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3657. * @param scale defines the scale vector3
  3658. * @param rotation defines the rotation quaternion
  3659. * @param translation defines the translation vector3
  3660. * @param result defines the target matrix
  3661. */
  3662. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3663. /**
  3664. * Creates a new identity matrix
  3665. * @returns a new identity matrix
  3666. */
  3667. static Identity(): Matrix;
  3668. /**
  3669. * Creates a new identity matrix and stores the result in a given matrix
  3670. * @param result defines the target matrix
  3671. */
  3672. static IdentityToRef(result: Matrix): void;
  3673. /**
  3674. * Creates a new zero matrix
  3675. * @returns a new zero matrix
  3676. */
  3677. static Zero(): Matrix;
  3678. /**
  3679. * Creates a new rotation matrix for "angle" radians around the X axis
  3680. * @param angle defines the angle (in radians) to use
  3681. * @return the new matrix
  3682. */
  3683. static RotationX(angle: number): Matrix;
  3684. /**
  3685. * Creates a new matrix as the invert of a given matrix
  3686. * @param source defines the source matrix
  3687. * @returns the new matrix
  3688. */
  3689. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3690. /**
  3691. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3692. * @param angle defines the angle (in radians) to use
  3693. * @param result defines the target matrix
  3694. */
  3695. static RotationXToRef(angle: number, result: Matrix): void;
  3696. /**
  3697. * Creates a new rotation matrix for "angle" radians around the Y axis
  3698. * @param angle defines the angle (in radians) to use
  3699. * @return the new matrix
  3700. */
  3701. static RotationY(angle: number): Matrix;
  3702. /**
  3703. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3704. * @param angle defines the angle (in radians) to use
  3705. * @param result defines the target matrix
  3706. */
  3707. static RotationYToRef(angle: number, result: Matrix): void;
  3708. /**
  3709. * Creates a new rotation matrix for "angle" radians around the Z axis
  3710. * @param angle defines the angle (in radians) to use
  3711. * @return the new matrix
  3712. */
  3713. static RotationZ(angle: number): Matrix;
  3714. /**
  3715. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3716. * @param angle defines the angle (in radians) to use
  3717. * @param result defines the target matrix
  3718. */
  3719. static RotationZToRef(angle: number, result: Matrix): void;
  3720. /**
  3721. * Creates a new rotation matrix for "angle" radians around the given axis
  3722. * @param axis defines the axis to use
  3723. * @param angle defines the angle (in radians) to use
  3724. * @return the new matrix
  3725. */
  3726. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3727. /**
  3728. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3729. * @param axis defines the axis to use
  3730. * @param angle defines the angle (in radians) to use
  3731. * @param result defines the target matrix
  3732. */
  3733. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3734. /**
  3735. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3736. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3737. * @param from defines the vector to align
  3738. * @param to defines the vector to align to
  3739. * @param result defines the target matrix
  3740. */
  3741. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3742. /**
  3743. * Creates a rotation matrix
  3744. * @param yaw defines the yaw angle in radians (Y axis)
  3745. * @param pitch defines the pitch angle in radians (X axis)
  3746. * @param roll defines the roll angle in radians (X axis)
  3747. * @returns the new rotation matrix
  3748. */
  3749. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3750. /**
  3751. * Creates a rotation matrix and stores it in a given matrix
  3752. * @param yaw defines the yaw angle in radians (Y axis)
  3753. * @param pitch defines the pitch angle in radians (X axis)
  3754. * @param roll defines the roll angle in radians (X axis)
  3755. * @param result defines the target matrix
  3756. */
  3757. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3758. /**
  3759. * Creates a scaling matrix
  3760. * @param x defines the scale factor on X axis
  3761. * @param y defines the scale factor on Y axis
  3762. * @param z defines the scale factor on Z axis
  3763. * @returns the new matrix
  3764. */
  3765. static Scaling(x: number, y: number, z: number): Matrix;
  3766. /**
  3767. * Creates a scaling matrix and stores it in a given matrix
  3768. * @param x defines the scale factor on X axis
  3769. * @param y defines the scale factor on Y axis
  3770. * @param z defines the scale factor on Z axis
  3771. * @param result defines the target matrix
  3772. */
  3773. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3774. /**
  3775. * Creates a translation matrix
  3776. * @param x defines the translation on X axis
  3777. * @param y defines the translation on Y axis
  3778. * @param z defines the translationon Z axis
  3779. * @returns the new matrix
  3780. */
  3781. static Translation(x: number, y: number, z: number): Matrix;
  3782. /**
  3783. * Creates a translation matrix and stores it in a given matrix
  3784. * @param x defines the translation on X axis
  3785. * @param y defines the translation on Y axis
  3786. * @param z defines the translationon Z axis
  3787. * @param result defines the target matrix
  3788. */
  3789. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3790. /**
  3791. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3792. * @param startValue defines the start value
  3793. * @param endValue defines the end value
  3794. * @param gradient defines the gradient factor
  3795. * @returns the new matrix
  3796. */
  3797. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3798. /**
  3799. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3800. * @param startValue defines the start value
  3801. * @param endValue defines the end value
  3802. * @param gradient defines the gradient factor
  3803. * @param result defines the Matrix object where to store data
  3804. */
  3805. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3806. /**
  3807. * Builds a new matrix whose values are computed by:
  3808. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3809. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3810. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3811. * @param startValue defines the first matrix
  3812. * @param endValue defines the second matrix
  3813. * @param gradient defines the gradient between the two matrices
  3814. * @returns the new matrix
  3815. */
  3816. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3817. /**
  3818. * Update a matrix to values which are computed by:
  3819. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3820. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3821. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3822. * @param startValue defines the first matrix
  3823. * @param endValue defines the second matrix
  3824. * @param gradient defines the gradient between the two matrices
  3825. * @param result defines the target matrix
  3826. */
  3827. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3828. /**
  3829. * 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"
  3830. * This function works in left handed mode
  3831. * @param eye defines the final position of the entity
  3832. * @param target defines where the entity should look at
  3833. * @param up defines the up vector for the entity
  3834. * @returns the new matrix
  3835. */
  3836. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3837. /**
  3838. * 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".
  3839. * This function works in left handed mode
  3840. * @param eye defines the final position of the entity
  3841. * @param target defines where the entity should look at
  3842. * @param up defines the up vector for the entity
  3843. * @param result defines the target matrix
  3844. */
  3845. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3846. /**
  3847. * 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"
  3848. * This function works in right handed mode
  3849. * @param eye defines the final position of the entity
  3850. * @param target defines where the entity should look at
  3851. * @param up defines the up vector for the entity
  3852. * @returns the new matrix
  3853. */
  3854. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3855. /**
  3856. * 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".
  3857. * This function works in right handed mode
  3858. * @param eye defines the final position of the entity
  3859. * @param target defines where the entity should look at
  3860. * @param up defines the up vector for the entity
  3861. * @param result defines the target matrix
  3862. */
  3863. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3864. /**
  3865. * Create a left-handed orthographic projection matrix
  3866. * @param width defines the viewport width
  3867. * @param height defines the viewport height
  3868. * @param znear defines the near clip plane
  3869. * @param zfar defines the far clip plane
  3870. * @returns a new matrix as a left-handed orthographic projection matrix
  3871. */
  3872. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3873. /**
  3874. * Store a left-handed orthographic projection to a given matrix
  3875. * @param width defines the viewport width
  3876. * @param height defines the viewport height
  3877. * @param znear defines the near clip plane
  3878. * @param zfar defines the far clip plane
  3879. * @param result defines the target matrix
  3880. */
  3881. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3882. /**
  3883. * Create a left-handed orthographic projection matrix
  3884. * @param left defines the viewport left coordinate
  3885. * @param right defines the viewport right coordinate
  3886. * @param bottom defines the viewport bottom coordinate
  3887. * @param top defines the viewport top coordinate
  3888. * @param znear defines the near clip plane
  3889. * @param zfar defines the far clip plane
  3890. * @returns a new matrix as a left-handed orthographic projection matrix
  3891. */
  3892. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3893. /**
  3894. * Stores a left-handed orthographic projection into a given matrix
  3895. * @param left defines the viewport left coordinate
  3896. * @param right defines the viewport right coordinate
  3897. * @param bottom defines the viewport bottom coordinate
  3898. * @param top defines the viewport top coordinate
  3899. * @param znear defines the near clip plane
  3900. * @param zfar defines the far clip plane
  3901. * @param result defines the target matrix
  3902. */
  3903. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3904. /**
  3905. * Creates a right-handed orthographic projection matrix
  3906. * @param left defines the viewport left coordinate
  3907. * @param right defines the viewport right coordinate
  3908. * @param bottom defines the viewport bottom coordinate
  3909. * @param top defines the viewport top coordinate
  3910. * @param znear defines the near clip plane
  3911. * @param zfar defines the far clip plane
  3912. * @returns a new matrix as a right-handed orthographic projection matrix
  3913. */
  3914. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3915. /**
  3916. * Stores a right-handed orthographic projection into a given matrix
  3917. * @param left defines the viewport left coordinate
  3918. * @param right defines the viewport right coordinate
  3919. * @param bottom defines the viewport bottom coordinate
  3920. * @param top defines the viewport top coordinate
  3921. * @param znear defines the near clip plane
  3922. * @param zfar defines the far clip plane
  3923. * @param result defines the target matrix
  3924. */
  3925. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3926. /**
  3927. * Creates a left-handed perspective projection matrix
  3928. * @param width defines the viewport width
  3929. * @param height defines the viewport height
  3930. * @param znear defines the near clip plane
  3931. * @param zfar defines the far clip plane
  3932. * @returns a new matrix as a left-handed perspective projection matrix
  3933. */
  3934. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3935. /**
  3936. * Creates a left-handed perspective projection matrix
  3937. * @param fov defines the horizontal field of view
  3938. * @param aspect defines the aspect ratio
  3939. * @param znear defines the near clip plane
  3940. * @param zfar defines the far clip plane
  3941. * @returns a new matrix as a left-handed perspective projection matrix
  3942. */
  3943. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3944. /**
  3945. * Stores a left-handed perspective projection into a given matrix
  3946. * @param fov defines the horizontal field of view
  3947. * @param aspect defines the aspect ratio
  3948. * @param znear defines the near clip plane
  3949. * @param zfar defines the far clip plane
  3950. * @param result defines the target matrix
  3951. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3952. */
  3953. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3954. /**
  3955. * Creates a right-handed perspective projection matrix
  3956. * @param fov defines the horizontal field of view
  3957. * @param aspect defines the aspect ratio
  3958. * @param znear defines the near clip plane
  3959. * @param zfar defines the far clip plane
  3960. * @returns a new matrix as a right-handed perspective projection matrix
  3961. */
  3962. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3963. /**
  3964. * Stores a right-handed perspective projection into a given matrix
  3965. * @param fov defines the horizontal field of view
  3966. * @param aspect defines the aspect ratio
  3967. * @param znear defines the near clip plane
  3968. * @param zfar defines the far clip plane
  3969. * @param result defines the target matrix
  3970. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3971. */
  3972. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3973. /**
  3974. * Stores a perspective projection for WebVR info a given matrix
  3975. * @param fov defines the field of view
  3976. * @param znear defines the near clip plane
  3977. * @param zfar defines the far clip plane
  3978. * @param result defines the target matrix
  3979. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3980. */
  3981. static PerspectiveFovWebVRToRef(fov: {
  3982. upDegrees: number;
  3983. downDegrees: number;
  3984. leftDegrees: number;
  3985. rightDegrees: number;
  3986. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3987. /**
  3988. * Computes a complete transformation matrix
  3989. * @param viewport defines the viewport to use
  3990. * @param world defines the world matrix
  3991. * @param view defines the view matrix
  3992. * @param projection defines the projection matrix
  3993. * @param zmin defines the near clip plane
  3994. * @param zmax defines the far clip plane
  3995. * @returns the transformation matrix
  3996. */
  3997. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3998. /**
  3999. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4000. * @param matrix defines the matrix to use
  4001. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4002. */
  4003. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4004. /**
  4005. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4006. * @param matrix defines the matrix to use
  4007. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4008. */
  4009. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4010. /**
  4011. * Compute the transpose of a given matrix
  4012. * @param matrix defines the matrix to transpose
  4013. * @returns the new matrix
  4014. */
  4015. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4016. /**
  4017. * Compute the transpose of a matrix and store it in a target matrix
  4018. * @param matrix defines the matrix to transpose
  4019. * @param result defines the target matrix
  4020. */
  4021. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4022. /**
  4023. * Computes a reflection matrix from a plane
  4024. * @param plane defines the reflection plane
  4025. * @returns a new matrix
  4026. */
  4027. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4028. /**
  4029. * Computes a reflection matrix from a plane
  4030. * @param plane defines the reflection plane
  4031. * @param result defines the target matrix
  4032. */
  4033. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4034. /**
  4035. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4036. * @param xaxis defines the value of the 1st axis
  4037. * @param yaxis defines the value of the 2nd axis
  4038. * @param zaxis defines the value of the 3rd axis
  4039. * @param result defines the target matrix
  4040. */
  4041. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4042. /**
  4043. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4044. * @param quat defines the quaternion to use
  4045. * @param result defines the target matrix
  4046. */
  4047. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4048. }
  4049. /**
  4050. * @hidden
  4051. */
  4052. export class TmpVectors {
  4053. static Vector2: Vector2[];
  4054. static Vector3: Vector3[];
  4055. static Vector4: Vector4[];
  4056. static Quaternion: Quaternion[];
  4057. static Matrix: Matrix[];
  4058. }
  4059. }
  4060. declare module "babylonjs/Engines/constants" {
  4061. /** Defines the cross module used constants to avoid circular dependncies */
  4062. export class Constants {
  4063. /** Defines that alpha blending is disabled */
  4064. static readonly ALPHA_DISABLE: number;
  4065. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4066. static readonly ALPHA_ADD: number;
  4067. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4068. static readonly ALPHA_COMBINE: number;
  4069. /** Defines that alpha blending to DEST - SRC * DEST */
  4070. static readonly ALPHA_SUBTRACT: number;
  4071. /** Defines that alpha blending to SRC * DEST */
  4072. static readonly ALPHA_MULTIPLY: number;
  4073. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4074. static readonly ALPHA_MAXIMIZED: number;
  4075. /** Defines that alpha blending to SRC + DEST */
  4076. static readonly ALPHA_ONEONE: number;
  4077. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4078. static readonly ALPHA_PREMULTIPLIED: number;
  4079. /**
  4080. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4081. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4082. */
  4083. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4084. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4085. static readonly ALPHA_INTERPOLATE: number;
  4086. /**
  4087. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4088. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4089. */
  4090. static readonly ALPHA_SCREENMODE: number;
  4091. /**
  4092. * Defines that alpha blending to SRC + DST
  4093. * Alpha will be set to SRC ALPHA + DST ALPHA
  4094. */
  4095. static readonly ALPHA_ONEONE_ONEONE: number;
  4096. /**
  4097. * Defines that alpha blending to SRC * DST ALPHA + DST
  4098. * Alpha will be set to 0
  4099. */
  4100. static readonly ALPHA_ALPHATOCOLOR: number;
  4101. /**
  4102. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  4103. */
  4104. static readonly ALPHA_REVERSEONEMINUS: number;
  4105. /**
  4106. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  4107. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  4108. */
  4109. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  4110. /**
  4111. * Defines that alpha blending to SRC + DST
  4112. * Alpha will be set to SRC ALPHA
  4113. */
  4114. static readonly ALPHA_ONEONE_ONEZERO: number;
  4115. /** Defines that alpha blending equation a SUM */
  4116. static readonly ALPHA_EQUATION_ADD: number;
  4117. /** Defines that alpha blending equation a SUBSTRACTION */
  4118. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  4119. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  4120. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  4121. /** Defines that alpha blending equation a MAX operation */
  4122. static readonly ALPHA_EQUATION_MAX: number;
  4123. /** Defines that alpha blending equation a MIN operation */
  4124. static readonly ALPHA_EQUATION_MIN: number;
  4125. /**
  4126. * Defines that alpha blending equation a DARKEN operation:
  4127. * It takes the min of the src and sums the alpha channels.
  4128. */
  4129. static readonly ALPHA_EQUATION_DARKEN: number;
  4130. /** Defines that the ressource is not delayed*/
  4131. static readonly DELAYLOADSTATE_NONE: number;
  4132. /** Defines that the ressource was successfully delay loaded */
  4133. static readonly DELAYLOADSTATE_LOADED: number;
  4134. /** Defines that the ressource is currently delay loading */
  4135. static readonly DELAYLOADSTATE_LOADING: number;
  4136. /** Defines that the ressource is delayed and has not started loading */
  4137. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4138. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4139. static readonly NEVER: number;
  4140. /** 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 */
  4141. static readonly ALWAYS: number;
  4142. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4143. static readonly LESS: number;
  4144. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4145. static readonly EQUAL: number;
  4146. /** 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 */
  4147. static readonly LEQUAL: number;
  4148. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4149. static readonly GREATER: number;
  4150. /** 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 */
  4151. static readonly GEQUAL: number;
  4152. /** 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 */
  4153. static readonly NOTEQUAL: number;
  4154. /** Passed to stencilOperation to specify that stencil value must be kept */
  4155. static readonly KEEP: number;
  4156. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4157. static readonly REPLACE: number;
  4158. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4159. static readonly INCR: number;
  4160. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4161. static readonly DECR: number;
  4162. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4163. static readonly INVERT: number;
  4164. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4165. static readonly INCR_WRAP: number;
  4166. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4167. static readonly DECR_WRAP: number;
  4168. /** Texture is not repeating outside of 0..1 UVs */
  4169. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4170. /** Texture is repeating outside of 0..1 UVs */
  4171. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4172. /** Texture is repeating and mirrored */
  4173. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4174. /** ALPHA */
  4175. static readonly TEXTUREFORMAT_ALPHA: number;
  4176. /** LUMINANCE */
  4177. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4178. /** LUMINANCE_ALPHA */
  4179. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4180. /** RGB */
  4181. static readonly TEXTUREFORMAT_RGB: number;
  4182. /** RGBA */
  4183. static readonly TEXTUREFORMAT_RGBA: number;
  4184. /** RED */
  4185. static readonly TEXTUREFORMAT_RED: number;
  4186. /** RED (2nd reference) */
  4187. static readonly TEXTUREFORMAT_R: number;
  4188. /** RG */
  4189. static readonly TEXTUREFORMAT_RG: number;
  4190. /** RED_INTEGER */
  4191. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4192. /** RED_INTEGER (2nd reference) */
  4193. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4194. /** RG_INTEGER */
  4195. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4196. /** RGB_INTEGER */
  4197. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4198. /** RGBA_INTEGER */
  4199. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4200. /** UNSIGNED_BYTE */
  4201. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4202. /** UNSIGNED_BYTE (2nd reference) */
  4203. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4204. /** FLOAT */
  4205. static readonly TEXTURETYPE_FLOAT: number;
  4206. /** HALF_FLOAT */
  4207. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4208. /** BYTE */
  4209. static readonly TEXTURETYPE_BYTE: number;
  4210. /** SHORT */
  4211. static readonly TEXTURETYPE_SHORT: number;
  4212. /** UNSIGNED_SHORT */
  4213. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4214. /** INT */
  4215. static readonly TEXTURETYPE_INT: number;
  4216. /** UNSIGNED_INT */
  4217. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4218. /** UNSIGNED_SHORT_4_4_4_4 */
  4219. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4220. /** UNSIGNED_SHORT_5_5_5_1 */
  4221. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4222. /** UNSIGNED_SHORT_5_6_5 */
  4223. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4224. /** UNSIGNED_INT_2_10_10_10_REV */
  4225. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4226. /** UNSIGNED_INT_24_8 */
  4227. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4228. /** UNSIGNED_INT_10F_11F_11F_REV */
  4229. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4230. /** UNSIGNED_INT_5_9_9_9_REV */
  4231. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4232. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4233. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4234. /** nearest is mag = nearest and min = nearest and mip = linear */
  4235. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4236. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4237. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4238. /** Trilinear is mag = linear and min = linear and mip = linear */
  4239. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4240. /** nearest is mag = nearest and min = nearest and mip = linear */
  4241. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4242. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4243. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4244. /** Trilinear is mag = linear and min = linear and mip = linear */
  4245. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4246. /** mag = nearest and min = nearest and mip = nearest */
  4247. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4248. /** mag = nearest and min = linear and mip = nearest */
  4249. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4250. /** mag = nearest and min = linear and mip = linear */
  4251. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4252. /** mag = nearest and min = linear and mip = none */
  4253. static readonly TEXTURE_NEAREST_LINEAR: number;
  4254. /** mag = nearest and min = nearest and mip = none */
  4255. static readonly TEXTURE_NEAREST_NEAREST: number;
  4256. /** mag = linear and min = nearest and mip = nearest */
  4257. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4258. /** mag = linear and min = nearest and mip = linear */
  4259. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4260. /** mag = linear and min = linear and mip = none */
  4261. static readonly TEXTURE_LINEAR_LINEAR: number;
  4262. /** mag = linear and min = nearest and mip = none */
  4263. static readonly TEXTURE_LINEAR_NEAREST: number;
  4264. /** Explicit coordinates mode */
  4265. static readonly TEXTURE_EXPLICIT_MODE: number;
  4266. /** Spherical coordinates mode */
  4267. static readonly TEXTURE_SPHERICAL_MODE: number;
  4268. /** Planar coordinates mode */
  4269. static readonly TEXTURE_PLANAR_MODE: number;
  4270. /** Cubic coordinates mode */
  4271. static readonly TEXTURE_CUBIC_MODE: number;
  4272. /** Projection coordinates mode */
  4273. static readonly TEXTURE_PROJECTION_MODE: number;
  4274. /** Skybox coordinates mode */
  4275. static readonly TEXTURE_SKYBOX_MODE: number;
  4276. /** Inverse Cubic coordinates mode */
  4277. static readonly TEXTURE_INVCUBIC_MODE: number;
  4278. /** Equirectangular coordinates mode */
  4279. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4280. /** Equirectangular Fixed coordinates mode */
  4281. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4282. /** Equirectangular Fixed Mirrored coordinates mode */
  4283. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4284. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4285. static readonly SCALEMODE_FLOOR: number;
  4286. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4287. static readonly SCALEMODE_NEAREST: number;
  4288. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4289. static readonly SCALEMODE_CEILING: number;
  4290. /**
  4291. * The dirty texture flag value
  4292. */
  4293. static readonly MATERIAL_TextureDirtyFlag: number;
  4294. /**
  4295. * The dirty light flag value
  4296. */
  4297. static readonly MATERIAL_LightDirtyFlag: number;
  4298. /**
  4299. * The dirty fresnel flag value
  4300. */
  4301. static readonly MATERIAL_FresnelDirtyFlag: number;
  4302. /**
  4303. * The dirty attribute flag value
  4304. */
  4305. static readonly MATERIAL_AttributesDirtyFlag: number;
  4306. /**
  4307. * The dirty misc flag value
  4308. */
  4309. static readonly MATERIAL_MiscDirtyFlag: number;
  4310. /**
  4311. * The all dirty flag value
  4312. */
  4313. static readonly MATERIAL_AllDirtyFlag: number;
  4314. /**
  4315. * Returns the triangle fill mode
  4316. */
  4317. static readonly MATERIAL_TriangleFillMode: number;
  4318. /**
  4319. * Returns the wireframe mode
  4320. */
  4321. static readonly MATERIAL_WireFrameFillMode: number;
  4322. /**
  4323. * Returns the point fill mode
  4324. */
  4325. static readonly MATERIAL_PointFillMode: number;
  4326. /**
  4327. * Returns the point list draw mode
  4328. */
  4329. static readonly MATERIAL_PointListDrawMode: number;
  4330. /**
  4331. * Returns the line list draw mode
  4332. */
  4333. static readonly MATERIAL_LineListDrawMode: number;
  4334. /**
  4335. * Returns the line loop draw mode
  4336. */
  4337. static readonly MATERIAL_LineLoopDrawMode: number;
  4338. /**
  4339. * Returns the line strip draw mode
  4340. */
  4341. static readonly MATERIAL_LineStripDrawMode: number;
  4342. /**
  4343. * Returns the triangle strip draw mode
  4344. */
  4345. static readonly MATERIAL_TriangleStripDrawMode: number;
  4346. /**
  4347. * Returns the triangle fan draw mode
  4348. */
  4349. static readonly MATERIAL_TriangleFanDrawMode: number;
  4350. /**
  4351. * Stores the clock-wise side orientation
  4352. */
  4353. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4354. /**
  4355. * Stores the counter clock-wise side orientation
  4356. */
  4357. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4358. /**
  4359. * Nothing
  4360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4361. */
  4362. static readonly ACTION_NothingTrigger: number;
  4363. /**
  4364. * On pick
  4365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4366. */
  4367. static readonly ACTION_OnPickTrigger: number;
  4368. /**
  4369. * On left pick
  4370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4371. */
  4372. static readonly ACTION_OnLeftPickTrigger: number;
  4373. /**
  4374. * On right pick
  4375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4376. */
  4377. static readonly ACTION_OnRightPickTrigger: number;
  4378. /**
  4379. * On center pick
  4380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4381. */
  4382. static readonly ACTION_OnCenterPickTrigger: number;
  4383. /**
  4384. * On pick down
  4385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4386. */
  4387. static readonly ACTION_OnPickDownTrigger: number;
  4388. /**
  4389. * On double pick
  4390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4391. */
  4392. static readonly ACTION_OnDoublePickTrigger: number;
  4393. /**
  4394. * On pick up
  4395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4396. */
  4397. static readonly ACTION_OnPickUpTrigger: number;
  4398. /**
  4399. * On pick out.
  4400. * This trigger will only be raised if you also declared a OnPickDown
  4401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4402. */
  4403. static readonly ACTION_OnPickOutTrigger: number;
  4404. /**
  4405. * On long press
  4406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4407. */
  4408. static readonly ACTION_OnLongPressTrigger: number;
  4409. /**
  4410. * On pointer over
  4411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4412. */
  4413. static readonly ACTION_OnPointerOverTrigger: number;
  4414. /**
  4415. * On pointer out
  4416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4417. */
  4418. static readonly ACTION_OnPointerOutTrigger: number;
  4419. /**
  4420. * On every frame
  4421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4422. */
  4423. static readonly ACTION_OnEveryFrameTrigger: number;
  4424. /**
  4425. * On intersection enter
  4426. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4427. */
  4428. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4429. /**
  4430. * On intersection exit
  4431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4432. */
  4433. static readonly ACTION_OnIntersectionExitTrigger: number;
  4434. /**
  4435. * On key down
  4436. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4437. */
  4438. static readonly ACTION_OnKeyDownTrigger: number;
  4439. /**
  4440. * On key up
  4441. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4442. */
  4443. static readonly ACTION_OnKeyUpTrigger: number;
  4444. /**
  4445. * Billboard mode will only apply to Y axis
  4446. */
  4447. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4448. /**
  4449. * Billboard mode will apply to all axes
  4450. */
  4451. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4452. /**
  4453. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4454. */
  4455. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4456. /**
  4457. * Gets or sets base Assets URL
  4458. */
  4459. static PARTICLES_BaseAssetsUrl: string;
  4460. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4461. * Test order :
  4462. * Is the bounding sphere outside the frustum ?
  4463. * If not, are the bounding box vertices outside the frustum ?
  4464. * It not, then the cullable object is in the frustum.
  4465. */
  4466. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4467. /** Culling strategy : Bounding Sphere Only.
  4468. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4469. * It's also less accurate than the standard because some not visible objects can still be selected.
  4470. * Test : is the bounding sphere outside the frustum ?
  4471. * If not, then the cullable object is in the frustum.
  4472. */
  4473. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4474. /** Culling strategy : Optimistic Inclusion.
  4475. * This in an inclusion test first, then the standard exclusion test.
  4476. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4477. * 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.
  4478. * Anyway, it's as accurate as the standard strategy.
  4479. * Test :
  4480. * Is the cullable object bounding sphere center in the frustum ?
  4481. * If not, apply the default culling strategy.
  4482. */
  4483. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4484. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4485. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4486. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4487. * 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.
  4488. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4489. * Test :
  4490. * Is the cullable object bounding sphere center in the frustum ?
  4491. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4492. */
  4493. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4494. /**
  4495. * No logging while loading
  4496. */
  4497. static readonly SCENELOADER_NO_LOGGING: number;
  4498. /**
  4499. * Minimal logging while loading
  4500. */
  4501. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4502. /**
  4503. * Summary logging while loading
  4504. */
  4505. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4506. /**
  4507. * Detailled logging while loading
  4508. */
  4509. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4510. }
  4511. }
  4512. declare module "babylonjs/Engines/IPipelineContext" {
  4513. /**
  4514. * Class used to store and describe the pipeline context associated with an effect
  4515. */
  4516. export interface IPipelineContext {
  4517. /**
  4518. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4519. */
  4520. isAsync: boolean;
  4521. /**
  4522. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4523. */
  4524. isReady: boolean;
  4525. /** @hidden */
  4526. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4527. }
  4528. }
  4529. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4530. /** @hidden */
  4531. export interface IShaderProcessor {
  4532. attributeProcessor?: (attribute: string) => string;
  4533. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4534. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4535. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4536. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4537. lineProcessor?: (line: string, isFragment: boolean) => string;
  4538. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4539. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4540. }
  4541. }
  4542. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4543. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4544. /** @hidden */
  4545. export interface ProcessingOptions {
  4546. defines: string[];
  4547. indexParameters: any;
  4548. isFragment: boolean;
  4549. shouldUseHighPrecisionShader: boolean;
  4550. supportsUniformBuffers: boolean;
  4551. shadersRepository: string;
  4552. includesShadersStore: {
  4553. [key: string]: string;
  4554. };
  4555. processor?: IShaderProcessor;
  4556. version: string;
  4557. platformName: string;
  4558. lookForClosingBracketForUniformBuffer?: boolean;
  4559. }
  4560. }
  4561. declare module "babylonjs/Misc/stringTools" {
  4562. /**
  4563. * Helper to manipulate strings
  4564. */
  4565. export class StringTools {
  4566. /**
  4567. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4568. * @param str Source string
  4569. * @param suffix Suffix to search for in the source string
  4570. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4571. */
  4572. static EndsWith(str: string, suffix: string): boolean;
  4573. /**
  4574. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4575. * @param str Source string
  4576. * @param suffix Suffix to search for in the source string
  4577. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4578. */
  4579. static StartsWith(str: string, suffix: string): boolean;
  4580. }
  4581. }
  4582. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4583. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4584. /** @hidden */
  4585. export class ShaderCodeNode {
  4586. line: string;
  4587. children: ShaderCodeNode[];
  4588. additionalDefineKey?: string;
  4589. additionalDefineValue?: string;
  4590. isValid(preprocessors: {
  4591. [key: string]: string;
  4592. }): boolean;
  4593. process(preprocessors: {
  4594. [key: string]: string;
  4595. }, options: ProcessingOptions): string;
  4596. }
  4597. }
  4598. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4599. /** @hidden */
  4600. export class ShaderCodeCursor {
  4601. private _lines;
  4602. lineIndex: number;
  4603. readonly currentLine: string;
  4604. readonly canRead: boolean;
  4605. lines: string[];
  4606. }
  4607. }
  4608. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4609. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4610. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4611. /** @hidden */
  4612. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4613. process(preprocessors: {
  4614. [key: string]: string;
  4615. }, options: ProcessingOptions): string;
  4616. }
  4617. }
  4618. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4619. /** @hidden */
  4620. export class ShaderDefineExpression {
  4621. isTrue(preprocessors: {
  4622. [key: string]: string;
  4623. }): boolean;
  4624. }
  4625. }
  4626. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4627. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4628. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4629. /** @hidden */
  4630. export class ShaderCodeTestNode extends ShaderCodeNode {
  4631. testExpression: ShaderDefineExpression;
  4632. isValid(preprocessors: {
  4633. [key: string]: string;
  4634. }): boolean;
  4635. }
  4636. }
  4637. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4638. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4639. /** @hidden */
  4640. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4641. define: string;
  4642. not: boolean;
  4643. constructor(define: string, not?: boolean);
  4644. isTrue(preprocessors: {
  4645. [key: string]: string;
  4646. }): boolean;
  4647. }
  4648. }
  4649. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4650. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4651. /** @hidden */
  4652. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4653. leftOperand: ShaderDefineExpression;
  4654. rightOperand: ShaderDefineExpression;
  4655. isTrue(preprocessors: {
  4656. [key: string]: string;
  4657. }): boolean;
  4658. }
  4659. }
  4660. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4661. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4662. /** @hidden */
  4663. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4664. leftOperand: ShaderDefineExpression;
  4665. rightOperand: ShaderDefineExpression;
  4666. isTrue(preprocessors: {
  4667. [key: string]: string;
  4668. }): boolean;
  4669. }
  4670. }
  4671. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  4672. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4673. /** @hidden */
  4674. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4675. define: string;
  4676. operand: string;
  4677. testValue: string;
  4678. constructor(define: string, operand: string, testValue: string);
  4679. isTrue(preprocessors: {
  4680. [key: string]: string;
  4681. }): boolean;
  4682. }
  4683. }
  4684. declare module "babylonjs/Misc/loadFileError" {
  4685. import { WebRequest } from "babylonjs/Misc/webRequest";
  4686. /**
  4687. * @ignore
  4688. * Application error to support additional information when loading a file
  4689. */
  4690. export class LoadFileError extends Error {
  4691. /** defines the optional web request */
  4692. request?: WebRequest | undefined;
  4693. private static _setPrototypeOf;
  4694. /**
  4695. * Creates a new LoadFileError
  4696. * @param message defines the message of the error
  4697. * @param request defines the optional web request
  4698. */
  4699. constructor(message: string,
  4700. /** defines the optional web request */
  4701. request?: WebRequest | undefined);
  4702. }
  4703. }
  4704. declare module "babylonjs/Offline/IOfflineProvider" {
  4705. /**
  4706. * Class used to enable access to offline support
  4707. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4708. */
  4709. export interface IOfflineProvider {
  4710. /**
  4711. * Gets a boolean indicating if scene must be saved in the database
  4712. */
  4713. enableSceneOffline: boolean;
  4714. /**
  4715. * Gets a boolean indicating if textures must be saved in the database
  4716. */
  4717. enableTexturesOffline: boolean;
  4718. /**
  4719. * Open the offline support and make it available
  4720. * @param successCallback defines the callback to call on success
  4721. * @param errorCallback defines the callback to call on error
  4722. */
  4723. open(successCallback: () => void, errorCallback: () => void): void;
  4724. /**
  4725. * Loads an image from the offline support
  4726. * @param url defines the url to load from
  4727. * @param image defines the target DOM image
  4728. */
  4729. loadImage(url: string, image: HTMLImageElement): void;
  4730. /**
  4731. * Loads a file from offline support
  4732. * @param url defines the URL to load from
  4733. * @param sceneLoaded defines a callback to call on success
  4734. * @param progressCallBack defines a callback to call when progress changed
  4735. * @param errorCallback defines a callback to call on error
  4736. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4737. */
  4738. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4739. }
  4740. }
  4741. declare module "babylonjs/Misc/filesInputStore" {
  4742. /**
  4743. * Class used to help managing file picking and drag'n'drop
  4744. * File Storage
  4745. */
  4746. export class FilesInputStore {
  4747. /**
  4748. * List of files ready to be loaded
  4749. */
  4750. static FilesToLoad: {
  4751. [key: string]: File;
  4752. };
  4753. }
  4754. }
  4755. declare module "babylonjs/Misc/retryStrategy" {
  4756. import { WebRequest } from "babylonjs/Misc/webRequest";
  4757. /**
  4758. * Class used to define a retry strategy when error happens while loading assets
  4759. */
  4760. export class RetryStrategy {
  4761. /**
  4762. * Function used to defines an exponential back off strategy
  4763. * @param maxRetries defines the maximum number of retries (3 by default)
  4764. * @param baseInterval defines the interval between retries
  4765. * @returns the strategy function to use
  4766. */
  4767. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4768. }
  4769. }
  4770. declare module "babylonjs/Misc/fileTools" {
  4771. import { WebRequest } from "babylonjs/Misc/webRequest";
  4772. import { Nullable } from "babylonjs/types";
  4773. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  4774. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  4775. /**
  4776. * @hidden
  4777. */
  4778. export class FileTools {
  4779. /**
  4780. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4781. */
  4782. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4783. /**
  4784. * Gets or sets the base URL to use to load assets
  4785. */
  4786. static BaseUrl: string;
  4787. /**
  4788. * Default behaviour for cors in the application.
  4789. * It can be a string if the expected behavior is identical in the entire app.
  4790. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4791. */
  4792. static CorsBehavior: string | ((url: string | string[]) => string);
  4793. /**
  4794. * Gets or sets a function used to pre-process url before using them to load assets
  4795. */
  4796. static PreprocessUrl: (url: string) => string;
  4797. /**
  4798. * Removes unwanted characters from an url
  4799. * @param url defines the url to clean
  4800. * @returns the cleaned url
  4801. */
  4802. private static _CleanUrl;
  4803. /**
  4804. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4805. * @param url define the url we are trying
  4806. * @param element define the dom element where to configure the cors policy
  4807. */
  4808. static SetCorsBehavior(url: string | string[], element: {
  4809. crossOrigin: string | null;
  4810. }): void;
  4811. /**
  4812. * Loads an image as an HTMLImageElement.
  4813. * @param input url string, ArrayBuffer, or Blob to load
  4814. * @param onLoad callback called when the image successfully loads
  4815. * @param onError callback called when the image fails to load
  4816. * @param offlineProvider offline provider for caching
  4817. * @returns the HTMLImageElement of the loaded image
  4818. */
  4819. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4820. /**
  4821. * Loads a file
  4822. * @param fileToLoad defines the file to load
  4823. * @param callback defines the callback to call when data is loaded
  4824. * @param progressCallBack defines the callback to call during loading process
  4825. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4826. * @returns a file request object
  4827. */
  4828. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4829. /**
  4830. * Loads a file
  4831. * @param url url string, ArrayBuffer, or Blob to load
  4832. * @param onSuccess callback called when the file successfully loads
  4833. * @param onProgress callback called while file is loading (if the server supports this mode)
  4834. * @param offlineProvider defines the offline provider for caching
  4835. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4836. * @param onError callback called when the file fails to load
  4837. * @returns a file request object
  4838. */
  4839. 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;
  4840. /**
  4841. * Checks if the loaded document was accessed via `file:`-Protocol.
  4842. * @returns boolean
  4843. */
  4844. static IsFileURL(): boolean;
  4845. }
  4846. }
  4847. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  4848. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4849. /** @hidden */
  4850. export class ShaderProcessor {
  4851. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4852. private static _ProcessPrecision;
  4853. private static _ExtractOperation;
  4854. private static _BuildSubExpression;
  4855. private static _BuildExpression;
  4856. private static _MoveCursorWithinIf;
  4857. private static _MoveCursor;
  4858. private static _EvaluatePreProcessors;
  4859. private static _PreparePreProcessors;
  4860. private static _ProcessShaderConversion;
  4861. private static _ProcessIncludes;
  4862. }
  4863. }
  4864. declare module "babylonjs/Maths/math.color" {
  4865. import { DeepImmutable, FloatArray } from "babylonjs/types";
  4866. /**
  4867. * Class used to hold a RBG color
  4868. */
  4869. export class Color3 {
  4870. /**
  4871. * Defines the red component (between 0 and 1, default is 0)
  4872. */
  4873. r: number;
  4874. /**
  4875. * Defines the green component (between 0 and 1, default is 0)
  4876. */
  4877. g: number;
  4878. /**
  4879. * Defines the blue component (between 0 and 1, default is 0)
  4880. */
  4881. b: number;
  4882. /**
  4883. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4884. * @param r defines the red component (between 0 and 1, default is 0)
  4885. * @param g defines the green component (between 0 and 1, default is 0)
  4886. * @param b defines the blue component (between 0 and 1, default is 0)
  4887. */
  4888. constructor(
  4889. /**
  4890. * Defines the red component (between 0 and 1, default is 0)
  4891. */
  4892. r?: number,
  4893. /**
  4894. * Defines the green component (between 0 and 1, default is 0)
  4895. */
  4896. g?: number,
  4897. /**
  4898. * Defines the blue component (between 0 and 1, default is 0)
  4899. */
  4900. b?: number);
  4901. /**
  4902. * Creates a string with the Color3 current values
  4903. * @returns the string representation of the Color3 object
  4904. */
  4905. toString(): string;
  4906. /**
  4907. * Returns the string "Color3"
  4908. * @returns "Color3"
  4909. */
  4910. getClassName(): string;
  4911. /**
  4912. * Compute the Color3 hash code
  4913. * @returns an unique number that can be used to hash Color3 objects
  4914. */
  4915. getHashCode(): number;
  4916. /**
  4917. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4918. * @param array defines the array where to store the r,g,b components
  4919. * @param index defines an optional index in the target array to define where to start storing values
  4920. * @returns the current Color3 object
  4921. */
  4922. toArray(array: FloatArray, index?: number): Color3;
  4923. /**
  4924. * Returns a new Color4 object from the current Color3 and the given alpha
  4925. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4926. * @returns a new Color4 object
  4927. */
  4928. toColor4(alpha?: number): Color4;
  4929. /**
  4930. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4931. * @returns the new array
  4932. */
  4933. asArray(): number[];
  4934. /**
  4935. * Returns the luminance value
  4936. * @returns a float value
  4937. */
  4938. toLuminance(): number;
  4939. /**
  4940. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4941. * @param otherColor defines the second operand
  4942. * @returns the new Color3 object
  4943. */
  4944. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4945. /**
  4946. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4947. * @param otherColor defines the second operand
  4948. * @param result defines the Color3 object where to store the result
  4949. * @returns the current Color3
  4950. */
  4951. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4952. /**
  4953. * Determines equality between Color3 objects
  4954. * @param otherColor defines the second operand
  4955. * @returns true if the rgb values are equal to the given ones
  4956. */
  4957. equals(otherColor: DeepImmutable<Color3>): boolean;
  4958. /**
  4959. * Determines equality between the current Color3 object and a set of r,b,g values
  4960. * @param r defines the red component to check
  4961. * @param g defines the green component to check
  4962. * @param b defines the blue component to check
  4963. * @returns true if the rgb values are equal to the given ones
  4964. */
  4965. equalsFloats(r: number, g: number, b: number): boolean;
  4966. /**
  4967. * Multiplies in place each rgb value by scale
  4968. * @param scale defines the scaling factor
  4969. * @returns the updated Color3
  4970. */
  4971. scale(scale: number): Color3;
  4972. /**
  4973. * Multiplies the rgb values by scale and stores the result into "result"
  4974. * @param scale defines the scaling factor
  4975. * @param result defines the Color3 object where to store the result
  4976. * @returns the unmodified current Color3
  4977. */
  4978. scaleToRef(scale: number, result: Color3): Color3;
  4979. /**
  4980. * Scale the current Color3 values by a factor and add the result to a given Color3
  4981. * @param scale defines the scale factor
  4982. * @param result defines color to store the result into
  4983. * @returns the unmodified current Color3
  4984. */
  4985. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4986. /**
  4987. * Clamps the rgb values by the min and max values and stores the result into "result"
  4988. * @param min defines minimum clamping value (default is 0)
  4989. * @param max defines maximum clamping value (default is 1)
  4990. * @param result defines color to store the result into
  4991. * @returns the original Color3
  4992. */
  4993. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4994. /**
  4995. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4996. * @param otherColor defines the second operand
  4997. * @returns the new Color3
  4998. */
  4999. add(otherColor: DeepImmutable<Color3>): Color3;
  5000. /**
  5001. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5002. * @param otherColor defines the second operand
  5003. * @param result defines Color3 object to store the result into
  5004. * @returns the unmodified current Color3
  5005. */
  5006. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5007. /**
  5008. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5009. * @param otherColor defines the second operand
  5010. * @returns the new Color3
  5011. */
  5012. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5013. /**
  5014. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5015. * @param otherColor defines the second operand
  5016. * @param result defines Color3 object to store the result into
  5017. * @returns the unmodified current Color3
  5018. */
  5019. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5020. /**
  5021. * Copy the current object
  5022. * @returns a new Color3 copied the current one
  5023. */
  5024. clone(): Color3;
  5025. /**
  5026. * Copies the rgb values from the source in the current Color3
  5027. * @param source defines the source Color3 object
  5028. * @returns the updated Color3 object
  5029. */
  5030. copyFrom(source: DeepImmutable<Color3>): Color3;
  5031. /**
  5032. * Updates the Color3 rgb values from the given floats
  5033. * @param r defines the red component to read from
  5034. * @param g defines the green component to read from
  5035. * @param b defines the blue component to read from
  5036. * @returns the current Color3 object
  5037. */
  5038. copyFromFloats(r: number, g: number, b: number): Color3;
  5039. /**
  5040. * Updates the Color3 rgb values from the given floats
  5041. * @param r defines the red component to read from
  5042. * @param g defines the green component to read from
  5043. * @param b defines the blue component to read from
  5044. * @returns the current Color3 object
  5045. */
  5046. set(r: number, g: number, b: number): Color3;
  5047. /**
  5048. * Compute the Color3 hexadecimal code as a string
  5049. * @returns a string containing the hexadecimal representation of the Color3 object
  5050. */
  5051. toHexString(): string;
  5052. /**
  5053. * Computes a new Color3 converted from the current one to linear space
  5054. * @returns a new Color3 object
  5055. */
  5056. toLinearSpace(): Color3;
  5057. /**
  5058. * Converts current color in rgb space to HSV values
  5059. * @returns a new color3 representing the HSV values
  5060. */
  5061. toHSV(): Color3;
  5062. /**
  5063. * Converts current color in rgb space to HSV values
  5064. * @param result defines the Color3 where to store the HSV values
  5065. */
  5066. toHSVToRef(result: Color3): void;
  5067. /**
  5068. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5069. * @param convertedColor defines the Color3 object where to store the linear space version
  5070. * @returns the unmodified Color3
  5071. */
  5072. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5073. /**
  5074. * Computes a new Color3 converted from the current one to gamma space
  5075. * @returns a new Color3 object
  5076. */
  5077. toGammaSpace(): Color3;
  5078. /**
  5079. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5080. * @param convertedColor defines the Color3 object where to store the gamma space version
  5081. * @returns the unmodified Color3
  5082. */
  5083. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5084. private static _BlackReadOnly;
  5085. /**
  5086. * Convert Hue, saturation and value to a Color3 (RGB)
  5087. * @param hue defines the hue
  5088. * @param saturation defines the saturation
  5089. * @param value defines the value
  5090. * @param result defines the Color3 where to store the RGB values
  5091. */
  5092. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5093. /**
  5094. * Creates a new Color3 from the string containing valid hexadecimal values
  5095. * @param hex defines a string containing valid hexadecimal values
  5096. * @returns a new Color3 object
  5097. */
  5098. static FromHexString(hex: string): Color3;
  5099. /**
  5100. * Creates a new Color3 from the starting index of the given array
  5101. * @param array defines the source array
  5102. * @param offset defines an offset in the source array
  5103. * @returns a new Color3 object
  5104. */
  5105. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5106. /**
  5107. * Creates a new Color3 from integer values (< 256)
  5108. * @param r defines the red component to read from (value between 0 and 255)
  5109. * @param g defines the green component to read from (value between 0 and 255)
  5110. * @param b defines the blue component to read from (value between 0 and 255)
  5111. * @returns a new Color3 object
  5112. */
  5113. static FromInts(r: number, g: number, b: number): Color3;
  5114. /**
  5115. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5116. * @param start defines the start Color3 value
  5117. * @param end defines the end Color3 value
  5118. * @param amount defines the gradient value between start and end
  5119. * @returns a new Color3 object
  5120. */
  5121. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5122. /**
  5123. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5124. * @param left defines the start value
  5125. * @param right defines the end value
  5126. * @param amount defines the gradient factor
  5127. * @param result defines the Color3 object where to store the result
  5128. */
  5129. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5130. /**
  5131. * Returns a Color3 value containing a red color
  5132. * @returns a new Color3 object
  5133. */
  5134. static Red(): Color3;
  5135. /**
  5136. * Returns a Color3 value containing a green color
  5137. * @returns a new Color3 object
  5138. */
  5139. static Green(): Color3;
  5140. /**
  5141. * Returns a Color3 value containing a blue color
  5142. * @returns a new Color3 object
  5143. */
  5144. static Blue(): Color3;
  5145. /**
  5146. * Returns a Color3 value containing a black color
  5147. * @returns a new Color3 object
  5148. */
  5149. static Black(): Color3;
  5150. /**
  5151. * Gets a Color3 value containing a black color that must not be updated
  5152. */
  5153. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5154. /**
  5155. * Returns a Color3 value containing a white color
  5156. * @returns a new Color3 object
  5157. */
  5158. static White(): Color3;
  5159. /**
  5160. * Returns a Color3 value containing a purple color
  5161. * @returns a new Color3 object
  5162. */
  5163. static Purple(): Color3;
  5164. /**
  5165. * Returns a Color3 value containing a magenta color
  5166. * @returns a new Color3 object
  5167. */
  5168. static Magenta(): Color3;
  5169. /**
  5170. * Returns a Color3 value containing a yellow color
  5171. * @returns a new Color3 object
  5172. */
  5173. static Yellow(): Color3;
  5174. /**
  5175. * Returns a Color3 value containing a gray color
  5176. * @returns a new Color3 object
  5177. */
  5178. static Gray(): Color3;
  5179. /**
  5180. * Returns a Color3 value containing a teal color
  5181. * @returns a new Color3 object
  5182. */
  5183. static Teal(): Color3;
  5184. /**
  5185. * Returns a Color3 value containing a random color
  5186. * @returns a new Color3 object
  5187. */
  5188. static Random(): Color3;
  5189. }
  5190. /**
  5191. * Class used to hold a RBGA color
  5192. */
  5193. export class Color4 {
  5194. /**
  5195. * Defines the red component (between 0 and 1, default is 0)
  5196. */
  5197. r: number;
  5198. /**
  5199. * Defines the green component (between 0 and 1, default is 0)
  5200. */
  5201. g: number;
  5202. /**
  5203. * Defines the blue component (between 0 and 1, default is 0)
  5204. */
  5205. b: number;
  5206. /**
  5207. * Defines the alpha component (between 0 and 1, default is 1)
  5208. */
  5209. a: number;
  5210. /**
  5211. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5212. * @param r defines the red component (between 0 and 1, default is 0)
  5213. * @param g defines the green component (between 0 and 1, default is 0)
  5214. * @param b defines the blue component (between 0 and 1, default is 0)
  5215. * @param a defines the alpha component (between 0 and 1, default is 1)
  5216. */
  5217. constructor(
  5218. /**
  5219. * Defines the red component (between 0 and 1, default is 0)
  5220. */
  5221. r?: number,
  5222. /**
  5223. * Defines the green component (between 0 and 1, default is 0)
  5224. */
  5225. g?: number,
  5226. /**
  5227. * Defines the blue component (between 0 and 1, default is 0)
  5228. */
  5229. b?: number,
  5230. /**
  5231. * Defines the alpha component (between 0 and 1, default is 1)
  5232. */
  5233. a?: number);
  5234. /**
  5235. * Adds in place the given Color4 values to the current Color4 object
  5236. * @param right defines the second operand
  5237. * @returns the current updated Color4 object
  5238. */
  5239. addInPlace(right: DeepImmutable<Color4>): Color4;
  5240. /**
  5241. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5242. * @returns the new array
  5243. */
  5244. asArray(): number[];
  5245. /**
  5246. * Stores from the starting index in the given array the Color4 successive values
  5247. * @param array defines the array where to store the r,g,b components
  5248. * @param index defines an optional index in the target array to define where to start storing values
  5249. * @returns the current Color4 object
  5250. */
  5251. toArray(array: number[], index?: number): Color4;
  5252. /**
  5253. * Determines equality between Color4 objects
  5254. * @param otherColor defines the second operand
  5255. * @returns true if the rgba values are equal to the given ones
  5256. */
  5257. equals(otherColor: DeepImmutable<Color4>): boolean;
  5258. /**
  5259. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5260. * @param right defines the second operand
  5261. * @returns a new Color4 object
  5262. */
  5263. add(right: DeepImmutable<Color4>): Color4;
  5264. /**
  5265. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5266. * @param right defines the second operand
  5267. * @returns a new Color4 object
  5268. */
  5269. subtract(right: DeepImmutable<Color4>): Color4;
  5270. /**
  5271. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5272. * @param right defines the second operand
  5273. * @param result defines the Color4 object where to store the result
  5274. * @returns the current Color4 object
  5275. */
  5276. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5277. /**
  5278. * Creates a new Color4 with the current Color4 values multiplied by scale
  5279. * @param scale defines the scaling factor to apply
  5280. * @returns a new Color4 object
  5281. */
  5282. scale(scale: number): Color4;
  5283. /**
  5284. * Multiplies the current Color4 values by scale and stores the result in "result"
  5285. * @param scale defines the scaling factor to apply
  5286. * @param result defines the Color4 object where to store the result
  5287. * @returns the current unmodified Color4
  5288. */
  5289. scaleToRef(scale: number, result: Color4): Color4;
  5290. /**
  5291. * Scale the current Color4 values by a factor and add the result to a given Color4
  5292. * @param scale defines the scale factor
  5293. * @param result defines the Color4 object where to store the result
  5294. * @returns the unmodified current Color4
  5295. */
  5296. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5297. /**
  5298. * Clamps the rgb values by the min and max values and stores the result into "result"
  5299. * @param min defines minimum clamping value (default is 0)
  5300. * @param max defines maximum clamping value (default is 1)
  5301. * @param result defines color to store the result into.
  5302. * @returns the cuurent Color4
  5303. */
  5304. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5305. /**
  5306. * Multipy an Color4 value by another and return a new Color4 object
  5307. * @param color defines the Color4 value to multiply by
  5308. * @returns a new Color4 object
  5309. */
  5310. multiply(color: Color4): Color4;
  5311. /**
  5312. * Multipy a Color4 value by another and push the result in a reference value
  5313. * @param color defines the Color4 value to multiply by
  5314. * @param result defines the Color4 to fill the result in
  5315. * @returns the result Color4
  5316. */
  5317. multiplyToRef(color: Color4, result: Color4): Color4;
  5318. /**
  5319. * Creates a string with the Color4 current values
  5320. * @returns the string representation of the Color4 object
  5321. */
  5322. toString(): string;
  5323. /**
  5324. * Returns the string "Color4"
  5325. * @returns "Color4"
  5326. */
  5327. getClassName(): string;
  5328. /**
  5329. * Compute the Color4 hash code
  5330. * @returns an unique number that can be used to hash Color4 objects
  5331. */
  5332. getHashCode(): number;
  5333. /**
  5334. * Creates a new Color4 copied from the current one
  5335. * @returns a new Color4 object
  5336. */
  5337. clone(): Color4;
  5338. /**
  5339. * Copies the given Color4 values into the current one
  5340. * @param source defines the source Color4 object
  5341. * @returns the current updated Color4 object
  5342. */
  5343. copyFrom(source: Color4): Color4;
  5344. /**
  5345. * Copies the given float values into the current one
  5346. * @param r defines the red component to read from
  5347. * @param g defines the green component to read from
  5348. * @param b defines the blue component to read from
  5349. * @param a defines the alpha component to read from
  5350. * @returns the current updated Color4 object
  5351. */
  5352. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5353. /**
  5354. * Copies the given float values into the current one
  5355. * @param r defines the red component to read from
  5356. * @param g defines the green component to read from
  5357. * @param b defines the blue component to read from
  5358. * @param a defines the alpha component to read from
  5359. * @returns the current updated Color4 object
  5360. */
  5361. set(r: number, g: number, b: number, a: number): Color4;
  5362. /**
  5363. * Compute the Color4 hexadecimal code as a string
  5364. * @returns a string containing the hexadecimal representation of the Color4 object
  5365. */
  5366. toHexString(): string;
  5367. /**
  5368. * Computes a new Color4 converted from the current one to linear space
  5369. * @returns a new Color4 object
  5370. */
  5371. toLinearSpace(): Color4;
  5372. /**
  5373. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5374. * @param convertedColor defines the Color4 object where to store the linear space version
  5375. * @returns the unmodified Color4
  5376. */
  5377. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5378. /**
  5379. * Computes a new Color4 converted from the current one to gamma space
  5380. * @returns a new Color4 object
  5381. */
  5382. toGammaSpace(): Color4;
  5383. /**
  5384. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5385. * @param convertedColor defines the Color4 object where to store the gamma space version
  5386. * @returns the unmodified Color4
  5387. */
  5388. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5389. /**
  5390. * Creates a new Color4 from the string containing valid hexadecimal values
  5391. * @param hex defines a string containing valid hexadecimal values
  5392. * @returns a new Color4 object
  5393. */
  5394. static FromHexString(hex: string): Color4;
  5395. /**
  5396. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5397. * @param left defines the start value
  5398. * @param right defines the end value
  5399. * @param amount defines the gradient factor
  5400. * @returns a new Color4 object
  5401. */
  5402. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5403. /**
  5404. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5405. * @param left defines the start value
  5406. * @param right defines the end value
  5407. * @param amount defines the gradient factor
  5408. * @param result defines the Color4 object where to store data
  5409. */
  5410. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5411. /**
  5412. * Creates a new Color4 from a Color3 and an alpha value
  5413. * @param color3 defines the source Color3 to read from
  5414. * @param alpha defines the alpha component (1.0 by default)
  5415. * @returns a new Color4 object
  5416. */
  5417. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5418. /**
  5419. * Creates a new Color4 from the starting index element of the given array
  5420. * @param array defines the source array to read from
  5421. * @param offset defines the offset in the source array
  5422. * @returns a new Color4 object
  5423. */
  5424. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5425. /**
  5426. * Creates a new Color3 from integer values (< 256)
  5427. * @param r defines the red component to read from (value between 0 and 255)
  5428. * @param g defines the green component to read from (value between 0 and 255)
  5429. * @param b defines the blue component to read from (value between 0 and 255)
  5430. * @param a defines the alpha component to read from (value between 0 and 255)
  5431. * @returns a new Color3 object
  5432. */
  5433. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5434. /**
  5435. * Check the content of a given array and convert it to an array containing RGBA data
  5436. * If the original array was already containing count * 4 values then it is returned directly
  5437. * @param colors defines the array to check
  5438. * @param count defines the number of RGBA data to expect
  5439. * @returns an array containing count * 4 values (RGBA)
  5440. */
  5441. static CheckColors4(colors: number[], count: number): number[];
  5442. }
  5443. /**
  5444. * @hidden
  5445. */
  5446. export class TmpColors {
  5447. static Color3: Color3[];
  5448. static Color4: Color4[];
  5449. }
  5450. }
  5451. declare module "babylonjs/Maths/sphericalPolynomial" {
  5452. import { Vector3 } from "babylonjs/Maths/math.vector";
  5453. import { Color3 } from "babylonjs/Maths/math.color";
  5454. /**
  5455. * Class representing spherical harmonics coefficients to the 3rd degree
  5456. */
  5457. export class SphericalHarmonics {
  5458. /**
  5459. * Defines whether or not the harmonics have been prescaled for rendering.
  5460. */
  5461. preScaled: boolean;
  5462. /**
  5463. * The l0,0 coefficients of the spherical harmonics
  5464. */
  5465. l00: Vector3;
  5466. /**
  5467. * The l1,-1 coefficients of the spherical harmonics
  5468. */
  5469. l1_1: Vector3;
  5470. /**
  5471. * The l1,0 coefficients of the spherical harmonics
  5472. */
  5473. l10: Vector3;
  5474. /**
  5475. * The l1,1 coefficients of the spherical harmonics
  5476. */
  5477. l11: Vector3;
  5478. /**
  5479. * The l2,-2 coefficients of the spherical harmonics
  5480. */
  5481. l2_2: Vector3;
  5482. /**
  5483. * The l2,-1 coefficients of the spherical harmonics
  5484. */
  5485. l2_1: Vector3;
  5486. /**
  5487. * The l2,0 coefficients of the spherical harmonics
  5488. */
  5489. l20: Vector3;
  5490. /**
  5491. * The l2,1 coefficients of the spherical harmonics
  5492. */
  5493. l21: Vector3;
  5494. /**
  5495. * The l2,2 coefficients of the spherical harmonics
  5496. */
  5497. l22: Vector3;
  5498. /**
  5499. * Adds a light to the spherical harmonics
  5500. * @param direction the direction of the light
  5501. * @param color the color of the light
  5502. * @param deltaSolidAngle the delta solid angle of the light
  5503. */
  5504. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5505. /**
  5506. * Scales the spherical harmonics by the given amount
  5507. * @param scale the amount to scale
  5508. */
  5509. scaleInPlace(scale: number): void;
  5510. /**
  5511. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5512. *
  5513. * ```
  5514. * E_lm = A_l * L_lm
  5515. * ```
  5516. *
  5517. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5518. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5519. * the scaling factors are given in equation 9.
  5520. */
  5521. convertIncidentRadianceToIrradiance(): void;
  5522. /**
  5523. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5524. *
  5525. * ```
  5526. * L = (1/pi) * E * rho
  5527. * ```
  5528. *
  5529. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5530. */
  5531. convertIrradianceToLambertianRadiance(): void;
  5532. /**
  5533. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5534. * required operations at run time.
  5535. *
  5536. * This is simply done by scaling back the SH with Ylm constants parameter.
  5537. * The trigonometric part being applied by the shader at run time.
  5538. */
  5539. preScaleForRendering(): void;
  5540. /**
  5541. * Constructs a spherical harmonics from an array.
  5542. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5543. * @returns the spherical harmonics
  5544. */
  5545. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5546. /**
  5547. * Gets the spherical harmonics from polynomial
  5548. * @param polynomial the spherical polynomial
  5549. * @returns the spherical harmonics
  5550. */
  5551. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5552. }
  5553. /**
  5554. * Class representing spherical polynomial coefficients to the 3rd degree
  5555. */
  5556. export class SphericalPolynomial {
  5557. private _harmonics;
  5558. /**
  5559. * The spherical harmonics used to create the polynomials.
  5560. */
  5561. readonly preScaledHarmonics: SphericalHarmonics;
  5562. /**
  5563. * The x coefficients of the spherical polynomial
  5564. */
  5565. x: Vector3;
  5566. /**
  5567. * The y coefficients of the spherical polynomial
  5568. */
  5569. y: Vector3;
  5570. /**
  5571. * The z coefficients of the spherical polynomial
  5572. */
  5573. z: Vector3;
  5574. /**
  5575. * The xx coefficients of the spherical polynomial
  5576. */
  5577. xx: Vector3;
  5578. /**
  5579. * The yy coefficients of the spherical polynomial
  5580. */
  5581. yy: Vector3;
  5582. /**
  5583. * The zz coefficients of the spherical polynomial
  5584. */
  5585. zz: Vector3;
  5586. /**
  5587. * The xy coefficients of the spherical polynomial
  5588. */
  5589. xy: Vector3;
  5590. /**
  5591. * The yz coefficients of the spherical polynomial
  5592. */
  5593. yz: Vector3;
  5594. /**
  5595. * The zx coefficients of the spherical polynomial
  5596. */
  5597. zx: Vector3;
  5598. /**
  5599. * Adds an ambient color to the spherical polynomial
  5600. * @param color the color to add
  5601. */
  5602. addAmbient(color: Color3): void;
  5603. /**
  5604. * Scales the spherical polynomial by the given amount
  5605. * @param scale the amount to scale
  5606. */
  5607. scaleInPlace(scale: number): void;
  5608. /**
  5609. * Gets the spherical polynomial from harmonics
  5610. * @param harmonics the spherical harmonics
  5611. * @returns the spherical polynomial
  5612. */
  5613. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5614. /**
  5615. * Constructs a spherical polynomial from an array.
  5616. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5617. * @returns the spherical polynomial
  5618. */
  5619. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5620. }
  5621. }
  5622. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5623. /**
  5624. * Define options used to create a render target texture
  5625. */
  5626. export class RenderTargetCreationOptions {
  5627. /**
  5628. * Specifies is mipmaps must be generated
  5629. */
  5630. generateMipMaps?: boolean;
  5631. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5632. generateDepthBuffer?: boolean;
  5633. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5634. generateStencilBuffer?: boolean;
  5635. /** Defines texture type (int by default) */
  5636. type?: number;
  5637. /** Defines sampling mode (trilinear by default) */
  5638. samplingMode?: number;
  5639. /** Defines format (RGBA by default) */
  5640. format?: number;
  5641. }
  5642. }
  5643. declare module "babylonjs/States/alphaCullingState" {
  5644. /**
  5645. * @hidden
  5646. **/
  5647. export class _AlphaState {
  5648. private _isAlphaBlendDirty;
  5649. private _isBlendFunctionParametersDirty;
  5650. private _isBlendEquationParametersDirty;
  5651. private _isBlendConstantsDirty;
  5652. private _alphaBlend;
  5653. private _blendFunctionParameters;
  5654. private _blendEquationParameters;
  5655. private _blendConstants;
  5656. /**
  5657. * Initializes the state.
  5658. */
  5659. constructor();
  5660. readonly isDirty: boolean;
  5661. alphaBlend: boolean;
  5662. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5663. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5664. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5665. reset(): void;
  5666. apply(gl: WebGLRenderingContext): void;
  5667. }
  5668. }
  5669. declare module "babylonjs/States/depthCullingState" {
  5670. import { Nullable } from "babylonjs/types";
  5671. /**
  5672. * @hidden
  5673. **/
  5674. export class _DepthCullingState {
  5675. private _isDepthTestDirty;
  5676. private _isDepthMaskDirty;
  5677. private _isDepthFuncDirty;
  5678. private _isCullFaceDirty;
  5679. private _isCullDirty;
  5680. private _isZOffsetDirty;
  5681. private _isFrontFaceDirty;
  5682. private _depthTest;
  5683. private _depthMask;
  5684. private _depthFunc;
  5685. private _cull;
  5686. private _cullFace;
  5687. private _zOffset;
  5688. private _frontFace;
  5689. /**
  5690. * Initializes the state.
  5691. */
  5692. constructor();
  5693. readonly isDirty: boolean;
  5694. zOffset: number;
  5695. cullFace: Nullable<number>;
  5696. cull: Nullable<boolean>;
  5697. depthFunc: Nullable<number>;
  5698. depthMask: boolean;
  5699. depthTest: boolean;
  5700. frontFace: Nullable<number>;
  5701. reset(): void;
  5702. apply(gl: WebGLRenderingContext): void;
  5703. }
  5704. }
  5705. declare module "babylonjs/States/stencilState" {
  5706. /**
  5707. * @hidden
  5708. **/
  5709. export class _StencilState {
  5710. /** 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 */
  5711. static readonly ALWAYS: number;
  5712. /** Passed to stencilOperation to specify that stencil value must be kept */
  5713. static readonly KEEP: number;
  5714. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5715. static readonly REPLACE: number;
  5716. private _isStencilTestDirty;
  5717. private _isStencilMaskDirty;
  5718. private _isStencilFuncDirty;
  5719. private _isStencilOpDirty;
  5720. private _stencilTest;
  5721. private _stencilMask;
  5722. private _stencilFunc;
  5723. private _stencilFuncRef;
  5724. private _stencilFuncMask;
  5725. private _stencilOpStencilFail;
  5726. private _stencilOpDepthFail;
  5727. private _stencilOpStencilDepthPass;
  5728. readonly isDirty: boolean;
  5729. stencilFunc: number;
  5730. stencilFuncRef: number;
  5731. stencilFuncMask: number;
  5732. stencilOpStencilFail: number;
  5733. stencilOpDepthFail: number;
  5734. stencilOpStencilDepthPass: number;
  5735. stencilMask: number;
  5736. stencilTest: boolean;
  5737. constructor();
  5738. reset(): void;
  5739. apply(gl: WebGLRenderingContext): void;
  5740. }
  5741. }
  5742. declare module "babylonjs/States/index" {
  5743. export * from "babylonjs/States/alphaCullingState";
  5744. export * from "babylonjs/States/depthCullingState";
  5745. export * from "babylonjs/States/stencilState";
  5746. }
  5747. declare module "babylonjs/Instrumentation/timeToken" {
  5748. import { Nullable } from "babylonjs/types";
  5749. /**
  5750. * @hidden
  5751. **/
  5752. export class _TimeToken {
  5753. _startTimeQuery: Nullable<WebGLQuery>;
  5754. _endTimeQuery: Nullable<WebGLQuery>;
  5755. _timeElapsedQuery: Nullable<WebGLQuery>;
  5756. _timeElapsedQueryEnded: boolean;
  5757. }
  5758. }
  5759. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5760. /**
  5761. * Class used to evalaute queries containing `and` and `or` operators
  5762. */
  5763. export class AndOrNotEvaluator {
  5764. /**
  5765. * Evaluate a query
  5766. * @param query defines the query to evaluate
  5767. * @param evaluateCallback defines the callback used to filter result
  5768. * @returns true if the query matches
  5769. */
  5770. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5771. private static _HandleParenthesisContent;
  5772. private static _SimplifyNegation;
  5773. }
  5774. }
  5775. declare module "babylonjs/Misc/tags" {
  5776. /**
  5777. * Class used to store custom tags
  5778. */
  5779. export class Tags {
  5780. /**
  5781. * Adds support for tags on the given object
  5782. * @param obj defines the object to use
  5783. */
  5784. static EnableFor(obj: any): void;
  5785. /**
  5786. * Removes tags support
  5787. * @param obj defines the object to use
  5788. */
  5789. static DisableFor(obj: any): void;
  5790. /**
  5791. * Gets a boolean indicating if the given object has tags
  5792. * @param obj defines the object to use
  5793. * @returns a boolean
  5794. */
  5795. static HasTags(obj: any): boolean;
  5796. /**
  5797. * Gets the tags available on a given object
  5798. * @param obj defines the object to use
  5799. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5800. * @returns the tags
  5801. */
  5802. static GetTags(obj: any, asString?: boolean): any;
  5803. /**
  5804. * Adds tags to an object
  5805. * @param obj defines the object to use
  5806. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5807. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5808. */
  5809. static AddTagsTo(obj: any, tagsString: string): void;
  5810. /**
  5811. * @hidden
  5812. */
  5813. static _AddTagTo(obj: any, tag: string): void;
  5814. /**
  5815. * Removes specific tags from a specific object
  5816. * @param obj defines the object to use
  5817. * @param tagsString defines the tags to remove
  5818. */
  5819. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5820. /**
  5821. * @hidden
  5822. */
  5823. static _RemoveTagFrom(obj: any, tag: string): void;
  5824. /**
  5825. * Defines if tags hosted on an object match a given query
  5826. * @param obj defines the object to use
  5827. * @param tagsQuery defines the tag query
  5828. * @returns a boolean
  5829. */
  5830. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5831. }
  5832. }
  5833. declare module "babylonjs/Maths/math.path" {
  5834. import { DeepImmutable, Nullable } from "babylonjs/types";
  5835. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5836. /**
  5837. * Defines potential orientation for back face culling
  5838. */
  5839. export enum Orientation {
  5840. /**
  5841. * Clockwise
  5842. */
  5843. CW = 0,
  5844. /** Counter clockwise */
  5845. CCW = 1
  5846. }
  5847. /** Class used to represent a Bezier curve */
  5848. export class BezierCurve {
  5849. /**
  5850. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5851. * @param t defines the time
  5852. * @param x1 defines the left coordinate on X axis
  5853. * @param y1 defines the left coordinate on Y axis
  5854. * @param x2 defines the right coordinate on X axis
  5855. * @param y2 defines the right coordinate on Y axis
  5856. * @returns the interpolated value
  5857. */
  5858. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5859. }
  5860. /**
  5861. * Defines angle representation
  5862. */
  5863. export class Angle {
  5864. private _radians;
  5865. /**
  5866. * Creates an Angle object of "radians" radians (float).
  5867. * @param radians the angle in radians
  5868. */
  5869. constructor(radians: number);
  5870. /**
  5871. * Get value in degrees
  5872. * @returns the Angle value in degrees (float)
  5873. */
  5874. degrees(): number;
  5875. /**
  5876. * Get value in radians
  5877. * @returns the Angle value in radians (float)
  5878. */
  5879. radians(): number;
  5880. /**
  5881. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5882. * @param a defines first vector
  5883. * @param b defines second vector
  5884. * @returns a new Angle
  5885. */
  5886. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5887. /**
  5888. * Gets a new Angle object from the given float in radians
  5889. * @param radians defines the angle value in radians
  5890. * @returns a new Angle
  5891. */
  5892. static FromRadians(radians: number): Angle;
  5893. /**
  5894. * Gets a new Angle object from the given float in degrees
  5895. * @param degrees defines the angle value in degrees
  5896. * @returns a new Angle
  5897. */
  5898. static FromDegrees(degrees: number): Angle;
  5899. }
  5900. /**
  5901. * This represents an arc in a 2d space.
  5902. */
  5903. export class Arc2 {
  5904. /** Defines the start point of the arc */
  5905. startPoint: Vector2;
  5906. /** Defines the mid point of the arc */
  5907. midPoint: Vector2;
  5908. /** Defines the end point of the arc */
  5909. endPoint: Vector2;
  5910. /**
  5911. * Defines the center point of the arc.
  5912. */
  5913. centerPoint: Vector2;
  5914. /**
  5915. * Defines the radius of the arc.
  5916. */
  5917. radius: number;
  5918. /**
  5919. * Defines the angle of the arc (from mid point to end point).
  5920. */
  5921. angle: Angle;
  5922. /**
  5923. * Defines the start angle of the arc (from start point to middle point).
  5924. */
  5925. startAngle: Angle;
  5926. /**
  5927. * Defines the orientation of the arc (clock wise/counter clock wise).
  5928. */
  5929. orientation: Orientation;
  5930. /**
  5931. * Creates an Arc object from the three given points : start, middle and end.
  5932. * @param startPoint Defines the start point of the arc
  5933. * @param midPoint Defines the midlle point of the arc
  5934. * @param endPoint Defines the end point of the arc
  5935. */
  5936. constructor(
  5937. /** Defines the start point of the arc */
  5938. startPoint: Vector2,
  5939. /** Defines the mid point of the arc */
  5940. midPoint: Vector2,
  5941. /** Defines the end point of the arc */
  5942. endPoint: Vector2);
  5943. }
  5944. /**
  5945. * Represents a 2D path made up of multiple 2D points
  5946. */
  5947. export class Path2 {
  5948. private _points;
  5949. private _length;
  5950. /**
  5951. * If the path start and end point are the same
  5952. */
  5953. closed: boolean;
  5954. /**
  5955. * Creates a Path2 object from the starting 2D coordinates x and y.
  5956. * @param x the starting points x value
  5957. * @param y the starting points y value
  5958. */
  5959. constructor(x: number, y: number);
  5960. /**
  5961. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5962. * @param x the added points x value
  5963. * @param y the added points y value
  5964. * @returns the updated Path2.
  5965. */
  5966. addLineTo(x: number, y: number): Path2;
  5967. /**
  5968. * 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.
  5969. * @param midX middle point x value
  5970. * @param midY middle point y value
  5971. * @param endX end point x value
  5972. * @param endY end point y value
  5973. * @param numberOfSegments (default: 36)
  5974. * @returns the updated Path2.
  5975. */
  5976. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5977. /**
  5978. * Closes the Path2.
  5979. * @returns the Path2.
  5980. */
  5981. close(): Path2;
  5982. /**
  5983. * Gets the sum of the distance between each sequential point in the path
  5984. * @returns the Path2 total length (float).
  5985. */
  5986. length(): number;
  5987. /**
  5988. * Gets the points which construct the path
  5989. * @returns the Path2 internal array of points.
  5990. */
  5991. getPoints(): Vector2[];
  5992. /**
  5993. * Retreives the point at the distance aways from the starting point
  5994. * @param normalizedLengthPosition the length along the path to retreive the point from
  5995. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5996. */
  5997. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5998. /**
  5999. * Creates a new path starting from an x and y position
  6000. * @param x starting x value
  6001. * @param y starting y value
  6002. * @returns a new Path2 starting at the coordinates (x, y).
  6003. */
  6004. static StartingAt(x: number, y: number): Path2;
  6005. }
  6006. /**
  6007. * Represents a 3D path made up of multiple 3D points
  6008. */
  6009. export class Path3D {
  6010. /**
  6011. * an array of Vector3, the curve axis of the Path3D
  6012. */
  6013. path: Vector3[];
  6014. private _curve;
  6015. private _distances;
  6016. private _tangents;
  6017. private _normals;
  6018. private _binormals;
  6019. private _raw;
  6020. /**
  6021. * new Path3D(path, normal, raw)
  6022. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  6023. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  6024. * @param path an array of Vector3, the curve axis of the Path3D
  6025. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  6026. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  6027. */
  6028. constructor(
  6029. /**
  6030. * an array of Vector3, the curve axis of the Path3D
  6031. */
  6032. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  6033. /**
  6034. * Returns the Path3D array of successive Vector3 designing its curve.
  6035. * @returns the Path3D array of successive Vector3 designing its curve.
  6036. */
  6037. getCurve(): Vector3[];
  6038. /**
  6039. * Returns an array populated with tangent vectors on each Path3D curve point.
  6040. * @returns an array populated with tangent vectors on each Path3D curve point.
  6041. */
  6042. getTangents(): Vector3[];
  6043. /**
  6044. * Returns an array populated with normal vectors on each Path3D curve point.
  6045. * @returns an array populated with normal vectors on each Path3D curve point.
  6046. */
  6047. getNormals(): Vector3[];
  6048. /**
  6049. * Returns an array populated with binormal vectors on each Path3D curve point.
  6050. * @returns an array populated with binormal vectors on each Path3D curve point.
  6051. */
  6052. getBinormals(): Vector3[];
  6053. /**
  6054. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  6055. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  6056. */
  6057. getDistances(): number[];
  6058. /**
  6059. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  6060. * @param path path which all values are copied into the curves points
  6061. * @param firstNormal which should be projected onto the curve
  6062. * @returns the same object updated.
  6063. */
  6064. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  6065. private _compute;
  6066. private _getFirstNonNullVector;
  6067. private _getLastNonNullVector;
  6068. private _normalVector;
  6069. }
  6070. /**
  6071. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6072. * A Curve3 is designed from a series of successive Vector3.
  6073. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  6074. */
  6075. export class Curve3 {
  6076. private _points;
  6077. private _length;
  6078. /**
  6079. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  6080. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  6081. * @param v1 (Vector3) the control point
  6082. * @param v2 (Vector3) the end point of the Quadratic Bezier
  6083. * @param nbPoints (integer) the wanted number of points in the curve
  6084. * @returns the created Curve3
  6085. */
  6086. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6087. /**
  6088. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  6089. * @param v0 (Vector3) the origin point of the Cubic Bezier
  6090. * @param v1 (Vector3) the first control point
  6091. * @param v2 (Vector3) the second control point
  6092. * @param v3 (Vector3) the end point of the Cubic Bezier
  6093. * @param nbPoints (integer) the wanted number of points in the curve
  6094. * @returns the created Curve3
  6095. */
  6096. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6097. /**
  6098. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  6099. * @param p1 (Vector3) the origin point of the Hermite Spline
  6100. * @param t1 (Vector3) the tangent vector at the origin point
  6101. * @param p2 (Vector3) the end point of the Hermite Spline
  6102. * @param t2 (Vector3) the tangent vector at the end point
  6103. * @param nbPoints (integer) the wanted number of points in the curve
  6104. * @returns the created Curve3
  6105. */
  6106. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6107. /**
  6108. * Returns a Curve3 object along a CatmullRom Spline curve :
  6109. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6110. * @param nbPoints (integer) the wanted number of points between each curve control points
  6111. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6112. * @returns the created Curve3
  6113. */
  6114. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6115. /**
  6116. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6117. * A Curve3 is designed from a series of successive Vector3.
  6118. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6119. * @param points points which make up the curve
  6120. */
  6121. constructor(points: Vector3[]);
  6122. /**
  6123. * @returns the Curve3 stored array of successive Vector3
  6124. */
  6125. getPoints(): Vector3[];
  6126. /**
  6127. * @returns the computed length (float) of the curve.
  6128. */
  6129. length(): number;
  6130. /**
  6131. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6132. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6133. * curveA and curveB keep unchanged.
  6134. * @param curve the curve to continue from this curve
  6135. * @returns the newly constructed curve
  6136. */
  6137. continue(curve: DeepImmutable<Curve3>): Curve3;
  6138. private _computeLength;
  6139. }
  6140. }
  6141. declare module "babylonjs/Animations/easing" {
  6142. /**
  6143. * This represents the main contract an easing function should follow.
  6144. * Easing functions are used throughout the animation system.
  6145. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6146. */
  6147. export interface IEasingFunction {
  6148. /**
  6149. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6150. * of the easing function.
  6151. * The link below provides some of the most common examples of easing functions.
  6152. * @see https://easings.net/
  6153. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6154. * @returns the corresponding value on the curve defined by the easing function
  6155. */
  6156. ease(gradient: number): number;
  6157. }
  6158. /**
  6159. * Base class used for every default easing function.
  6160. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6161. */
  6162. export class EasingFunction implements IEasingFunction {
  6163. /**
  6164. * Interpolation follows the mathematical formula associated with the easing function.
  6165. */
  6166. static readonly EASINGMODE_EASEIN: number;
  6167. /**
  6168. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6169. */
  6170. static readonly EASINGMODE_EASEOUT: number;
  6171. /**
  6172. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6173. */
  6174. static readonly EASINGMODE_EASEINOUT: number;
  6175. private _easingMode;
  6176. /**
  6177. * Sets the easing mode of the current function.
  6178. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6179. */
  6180. setEasingMode(easingMode: number): void;
  6181. /**
  6182. * Gets the current easing mode.
  6183. * @returns the easing mode
  6184. */
  6185. getEasingMode(): number;
  6186. /**
  6187. * @hidden
  6188. */
  6189. easeInCore(gradient: number): number;
  6190. /**
  6191. * Given an input gradient between 0 and 1, this returns the corresponding value
  6192. * of the easing function.
  6193. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6194. * @returns the corresponding value on the curve defined by the easing function
  6195. */
  6196. ease(gradient: number): number;
  6197. }
  6198. /**
  6199. * Easing function with a circle shape (see link below).
  6200. * @see https://easings.net/#easeInCirc
  6201. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6202. */
  6203. export class CircleEase extends EasingFunction implements IEasingFunction {
  6204. /** @hidden */
  6205. easeInCore(gradient: number): number;
  6206. }
  6207. /**
  6208. * Easing function with a ease back shape (see link below).
  6209. * @see https://easings.net/#easeInBack
  6210. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6211. */
  6212. export class BackEase extends EasingFunction implements IEasingFunction {
  6213. /** Defines the amplitude of the function */
  6214. amplitude: number;
  6215. /**
  6216. * Instantiates a back ease easing
  6217. * @see https://easings.net/#easeInBack
  6218. * @param amplitude Defines the amplitude of the function
  6219. */
  6220. constructor(
  6221. /** Defines the amplitude of the function */
  6222. amplitude?: number);
  6223. /** @hidden */
  6224. easeInCore(gradient: number): number;
  6225. }
  6226. /**
  6227. * Easing function with a bouncing shape (see link below).
  6228. * @see https://easings.net/#easeInBounce
  6229. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6230. */
  6231. export class BounceEase extends EasingFunction implements IEasingFunction {
  6232. /** Defines the number of bounces */
  6233. bounces: number;
  6234. /** Defines the amplitude of the bounce */
  6235. bounciness: number;
  6236. /**
  6237. * Instantiates a bounce easing
  6238. * @see https://easings.net/#easeInBounce
  6239. * @param bounces Defines the number of bounces
  6240. * @param bounciness Defines the amplitude of the bounce
  6241. */
  6242. constructor(
  6243. /** Defines the number of bounces */
  6244. bounces?: number,
  6245. /** Defines the amplitude of the bounce */
  6246. bounciness?: number);
  6247. /** @hidden */
  6248. easeInCore(gradient: number): number;
  6249. }
  6250. /**
  6251. * Easing function with a power of 3 shape (see link below).
  6252. * @see https://easings.net/#easeInCubic
  6253. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6254. */
  6255. export class CubicEase extends EasingFunction implements IEasingFunction {
  6256. /** @hidden */
  6257. easeInCore(gradient: number): number;
  6258. }
  6259. /**
  6260. * Easing function with an elastic shape (see link below).
  6261. * @see https://easings.net/#easeInElastic
  6262. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6263. */
  6264. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6265. /** Defines the number of oscillations*/
  6266. oscillations: number;
  6267. /** Defines the amplitude of the oscillations*/
  6268. springiness: number;
  6269. /**
  6270. * Instantiates an elastic easing function
  6271. * @see https://easings.net/#easeInElastic
  6272. * @param oscillations Defines the number of oscillations
  6273. * @param springiness Defines the amplitude of the oscillations
  6274. */
  6275. constructor(
  6276. /** Defines the number of oscillations*/
  6277. oscillations?: number,
  6278. /** Defines the amplitude of the oscillations*/
  6279. springiness?: number);
  6280. /** @hidden */
  6281. easeInCore(gradient: number): number;
  6282. }
  6283. /**
  6284. * Easing function with an exponential shape (see link below).
  6285. * @see https://easings.net/#easeInExpo
  6286. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6287. */
  6288. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6289. /** Defines the exponent of the function */
  6290. exponent: number;
  6291. /**
  6292. * Instantiates an exponential easing function
  6293. * @see https://easings.net/#easeInExpo
  6294. * @param exponent Defines the exponent of the function
  6295. */
  6296. constructor(
  6297. /** Defines the exponent of the function */
  6298. exponent?: number);
  6299. /** @hidden */
  6300. easeInCore(gradient: number): number;
  6301. }
  6302. /**
  6303. * Easing function with a power shape (see link below).
  6304. * @see https://easings.net/#easeInQuad
  6305. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6306. */
  6307. export class PowerEase extends EasingFunction implements IEasingFunction {
  6308. /** Defines the power of the function */
  6309. power: number;
  6310. /**
  6311. * Instantiates an power base easing function
  6312. * @see https://easings.net/#easeInQuad
  6313. * @param power Defines the power of the function
  6314. */
  6315. constructor(
  6316. /** Defines the power of the function */
  6317. power?: number);
  6318. /** @hidden */
  6319. easeInCore(gradient: number): number;
  6320. }
  6321. /**
  6322. * Easing function with a power of 2 shape (see link below).
  6323. * @see https://easings.net/#easeInQuad
  6324. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6325. */
  6326. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6327. /** @hidden */
  6328. easeInCore(gradient: number): number;
  6329. }
  6330. /**
  6331. * Easing function with a power of 4 shape (see link below).
  6332. * @see https://easings.net/#easeInQuart
  6333. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6334. */
  6335. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6336. /** @hidden */
  6337. easeInCore(gradient: number): number;
  6338. }
  6339. /**
  6340. * Easing function with a power of 5 shape (see link below).
  6341. * @see https://easings.net/#easeInQuint
  6342. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6343. */
  6344. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6345. /** @hidden */
  6346. easeInCore(gradient: number): number;
  6347. }
  6348. /**
  6349. * Easing function with a sin shape (see link below).
  6350. * @see https://easings.net/#easeInSine
  6351. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6352. */
  6353. export class SineEase extends EasingFunction implements IEasingFunction {
  6354. /** @hidden */
  6355. easeInCore(gradient: number): number;
  6356. }
  6357. /**
  6358. * Easing function with a bezier shape (see link below).
  6359. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6360. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6361. */
  6362. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6363. /** Defines the x component of the start tangent in the bezier curve */
  6364. x1: number;
  6365. /** Defines the y component of the start tangent in the bezier curve */
  6366. y1: number;
  6367. /** Defines the x component of the end tangent in the bezier curve */
  6368. x2: number;
  6369. /** Defines the y component of the end tangent in the bezier curve */
  6370. y2: number;
  6371. /**
  6372. * Instantiates a bezier function
  6373. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6374. * @param x1 Defines the x component of the start tangent in the bezier curve
  6375. * @param y1 Defines the y component of the start tangent in the bezier curve
  6376. * @param x2 Defines the x component of the end tangent in the bezier curve
  6377. * @param y2 Defines the y component of the end tangent in the bezier curve
  6378. */
  6379. constructor(
  6380. /** Defines the x component of the start tangent in the bezier curve */
  6381. x1?: number,
  6382. /** Defines the y component of the start tangent in the bezier curve */
  6383. y1?: number,
  6384. /** Defines the x component of the end tangent in the bezier curve */
  6385. x2?: number,
  6386. /** Defines the y component of the end tangent in the bezier curve */
  6387. y2?: number);
  6388. /** @hidden */
  6389. easeInCore(gradient: number): number;
  6390. }
  6391. }
  6392. declare module "babylonjs/Animations/animationKey" {
  6393. /**
  6394. * Defines an interface which represents an animation key frame
  6395. */
  6396. export interface IAnimationKey {
  6397. /**
  6398. * Frame of the key frame
  6399. */
  6400. frame: number;
  6401. /**
  6402. * Value at the specifies key frame
  6403. */
  6404. value: any;
  6405. /**
  6406. * The input tangent for the cubic hermite spline
  6407. */
  6408. inTangent?: any;
  6409. /**
  6410. * The output tangent for the cubic hermite spline
  6411. */
  6412. outTangent?: any;
  6413. /**
  6414. * The animation interpolation type
  6415. */
  6416. interpolation?: AnimationKeyInterpolation;
  6417. }
  6418. /**
  6419. * Enum for the animation key frame interpolation type
  6420. */
  6421. export enum AnimationKeyInterpolation {
  6422. /**
  6423. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6424. */
  6425. STEP = 1
  6426. }
  6427. }
  6428. declare module "babylonjs/Animations/animationRange" {
  6429. /**
  6430. * Represents the range of an animation
  6431. */
  6432. export class AnimationRange {
  6433. /**The name of the animation range**/
  6434. name: string;
  6435. /**The starting frame of the animation */
  6436. from: number;
  6437. /**The ending frame of the animation*/
  6438. to: number;
  6439. /**
  6440. * Initializes the range of an animation
  6441. * @param name The name of the animation range
  6442. * @param from The starting frame of the animation
  6443. * @param to The ending frame of the animation
  6444. */
  6445. constructor(
  6446. /**The name of the animation range**/
  6447. name: string,
  6448. /**The starting frame of the animation */
  6449. from: number,
  6450. /**The ending frame of the animation*/
  6451. to: number);
  6452. /**
  6453. * Makes a copy of the animation range
  6454. * @returns A copy of the animation range
  6455. */
  6456. clone(): AnimationRange;
  6457. }
  6458. }
  6459. declare module "babylonjs/Animations/animationEvent" {
  6460. /**
  6461. * Composed of a frame, and an action function
  6462. */
  6463. export class AnimationEvent {
  6464. /** The frame for which the event is triggered **/
  6465. frame: number;
  6466. /** The event to perform when triggered **/
  6467. action: (currentFrame: number) => void;
  6468. /** Specifies if the event should be triggered only once**/
  6469. onlyOnce?: boolean | undefined;
  6470. /**
  6471. * Specifies if the animation event is done
  6472. */
  6473. isDone: boolean;
  6474. /**
  6475. * Initializes the animation event
  6476. * @param frame The frame for which the event is triggered
  6477. * @param action The event to perform when triggered
  6478. * @param onlyOnce Specifies if the event should be triggered only once
  6479. */
  6480. constructor(
  6481. /** The frame for which the event is triggered **/
  6482. frame: number,
  6483. /** The event to perform when triggered **/
  6484. action: (currentFrame: number) => void,
  6485. /** Specifies if the event should be triggered only once**/
  6486. onlyOnce?: boolean | undefined);
  6487. /** @hidden */
  6488. _clone(): AnimationEvent;
  6489. }
  6490. }
  6491. declare module "babylonjs/Behaviors/behavior" {
  6492. import { Nullable } from "babylonjs/types";
  6493. /**
  6494. * Interface used to define a behavior
  6495. */
  6496. export interface Behavior<T> {
  6497. /** gets or sets behavior's name */
  6498. name: string;
  6499. /**
  6500. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6501. */
  6502. init(): void;
  6503. /**
  6504. * Called when the behavior is attached to a target
  6505. * @param target defines the target where the behavior is attached to
  6506. */
  6507. attach(target: T): void;
  6508. /**
  6509. * Called when the behavior is detached from its target
  6510. */
  6511. detach(): void;
  6512. }
  6513. /**
  6514. * Interface implemented by classes supporting behaviors
  6515. */
  6516. export interface IBehaviorAware<T> {
  6517. /**
  6518. * Attach a behavior
  6519. * @param behavior defines the behavior to attach
  6520. * @returns the current host
  6521. */
  6522. addBehavior(behavior: Behavior<T>): T;
  6523. /**
  6524. * Remove a behavior from the current object
  6525. * @param behavior defines the behavior to detach
  6526. * @returns the current host
  6527. */
  6528. removeBehavior(behavior: Behavior<T>): T;
  6529. /**
  6530. * Gets a behavior using its name to search
  6531. * @param name defines the name to search
  6532. * @returns the behavior or null if not found
  6533. */
  6534. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6535. }
  6536. }
  6537. declare module "babylonjs/Misc/smartArray" {
  6538. /**
  6539. * Defines an array and its length.
  6540. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6541. */
  6542. export interface ISmartArrayLike<T> {
  6543. /**
  6544. * The data of the array.
  6545. */
  6546. data: Array<T>;
  6547. /**
  6548. * The active length of the array.
  6549. */
  6550. length: number;
  6551. }
  6552. /**
  6553. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6554. */
  6555. export class SmartArray<T> implements ISmartArrayLike<T> {
  6556. /**
  6557. * The full set of data from the array.
  6558. */
  6559. data: Array<T>;
  6560. /**
  6561. * The active length of the array.
  6562. */
  6563. length: number;
  6564. protected _id: number;
  6565. /**
  6566. * Instantiates a Smart Array.
  6567. * @param capacity defines the default capacity of the array.
  6568. */
  6569. constructor(capacity: number);
  6570. /**
  6571. * Pushes a value at the end of the active data.
  6572. * @param value defines the object to push in the array.
  6573. */
  6574. push(value: T): void;
  6575. /**
  6576. * Iterates over the active data and apply the lambda to them.
  6577. * @param func defines the action to apply on each value.
  6578. */
  6579. forEach(func: (content: T) => void): void;
  6580. /**
  6581. * Sorts the full sets of data.
  6582. * @param compareFn defines the comparison function to apply.
  6583. */
  6584. sort(compareFn: (a: T, b: T) => number): void;
  6585. /**
  6586. * Resets the active data to an empty array.
  6587. */
  6588. reset(): void;
  6589. /**
  6590. * Releases all the data from the array as well as the array.
  6591. */
  6592. dispose(): void;
  6593. /**
  6594. * Concats the active data with a given array.
  6595. * @param array defines the data to concatenate with.
  6596. */
  6597. concat(array: any): void;
  6598. /**
  6599. * Returns the position of a value in the active data.
  6600. * @param value defines the value to find the index for
  6601. * @returns the index if found in the active data otherwise -1
  6602. */
  6603. indexOf(value: T): number;
  6604. /**
  6605. * Returns whether an element is part of the active data.
  6606. * @param value defines the value to look for
  6607. * @returns true if found in the active data otherwise false
  6608. */
  6609. contains(value: T): boolean;
  6610. private static _GlobalId;
  6611. }
  6612. /**
  6613. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6614. * The data in this array can only be present once
  6615. */
  6616. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6617. private _duplicateId;
  6618. /**
  6619. * Pushes a value at the end of the active data.
  6620. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6621. * @param value defines the object to push in the array.
  6622. */
  6623. push(value: T): void;
  6624. /**
  6625. * Pushes a value at the end of the active data.
  6626. * If the data is already present, it won t be added again
  6627. * @param value defines the object to push in the array.
  6628. * @returns true if added false if it was already present
  6629. */
  6630. pushNoDuplicate(value: T): boolean;
  6631. /**
  6632. * Resets the active data to an empty array.
  6633. */
  6634. reset(): void;
  6635. /**
  6636. * Concats the active data with a given array.
  6637. * This ensures no dupplicate will be present in the result.
  6638. * @param array defines the data to concatenate with.
  6639. */
  6640. concatWithNoDuplicate(array: any): void;
  6641. }
  6642. }
  6643. declare module "babylonjs/Cameras/cameraInputsManager" {
  6644. import { Nullable } from "babylonjs/types";
  6645. import { Camera } from "babylonjs/Cameras/camera";
  6646. /**
  6647. * @ignore
  6648. * This is a list of all the different input types that are available in the application.
  6649. * Fo instance: ArcRotateCameraGamepadInput...
  6650. */
  6651. export var CameraInputTypes: {};
  6652. /**
  6653. * This is the contract to implement in order to create a new input class.
  6654. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6655. */
  6656. export interface ICameraInput<TCamera extends Camera> {
  6657. /**
  6658. * Defines the camera the input is attached to.
  6659. */
  6660. camera: Nullable<TCamera>;
  6661. /**
  6662. * Gets the class name of the current intput.
  6663. * @returns the class name
  6664. */
  6665. getClassName(): string;
  6666. /**
  6667. * Get the friendly name associated with the input class.
  6668. * @returns the input friendly name
  6669. */
  6670. getSimpleName(): string;
  6671. /**
  6672. * Attach the input controls to a specific dom element to get the input from.
  6673. * @param element Defines the element the controls should be listened from
  6674. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6675. */
  6676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6677. /**
  6678. * Detach the current controls from the specified dom element.
  6679. * @param element Defines the element to stop listening the inputs from
  6680. */
  6681. detachControl(element: Nullable<HTMLElement>): void;
  6682. /**
  6683. * Update the current camera state depending on the inputs that have been used this frame.
  6684. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6685. */
  6686. checkInputs?: () => void;
  6687. }
  6688. /**
  6689. * Represents a map of input types to input instance or input index to input instance.
  6690. */
  6691. export interface CameraInputsMap<TCamera extends Camera> {
  6692. /**
  6693. * Accessor to the input by input type.
  6694. */
  6695. [name: string]: ICameraInput<TCamera>;
  6696. /**
  6697. * Accessor to the input by input index.
  6698. */
  6699. [idx: number]: ICameraInput<TCamera>;
  6700. }
  6701. /**
  6702. * This represents the input manager used within a camera.
  6703. * It helps dealing with all the different kind of input attached to a camera.
  6704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6705. */
  6706. export class CameraInputsManager<TCamera extends Camera> {
  6707. /**
  6708. * Defines the list of inputs attahed to the camera.
  6709. */
  6710. attached: CameraInputsMap<TCamera>;
  6711. /**
  6712. * Defines the dom element the camera is collecting inputs from.
  6713. * This is null if the controls have not been attached.
  6714. */
  6715. attachedElement: Nullable<HTMLElement>;
  6716. /**
  6717. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6718. */
  6719. noPreventDefault: boolean;
  6720. /**
  6721. * Defined the camera the input manager belongs to.
  6722. */
  6723. camera: TCamera;
  6724. /**
  6725. * Update the current camera state depending on the inputs that have been used this frame.
  6726. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6727. */
  6728. checkInputs: () => void;
  6729. /**
  6730. * Instantiate a new Camera Input Manager.
  6731. * @param camera Defines the camera the input manager blongs to
  6732. */
  6733. constructor(camera: TCamera);
  6734. /**
  6735. * Add an input method to a camera
  6736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6737. * @param input camera input method
  6738. */
  6739. add(input: ICameraInput<TCamera>): void;
  6740. /**
  6741. * Remove a specific input method from a camera
  6742. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6743. * @param inputToRemove camera input method
  6744. */
  6745. remove(inputToRemove: ICameraInput<TCamera>): void;
  6746. /**
  6747. * Remove a specific input type from a camera
  6748. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6749. * @param inputType the type of the input to remove
  6750. */
  6751. removeByType(inputType: string): void;
  6752. private _addCheckInputs;
  6753. /**
  6754. * Attach the input controls to the currently attached dom element to listen the events from.
  6755. * @param input Defines the input to attach
  6756. */
  6757. attachInput(input: ICameraInput<TCamera>): void;
  6758. /**
  6759. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6760. * @param element Defines the dom element to collect the events from
  6761. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6762. */
  6763. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6764. /**
  6765. * Detach the current manager inputs controls from a specific dom element.
  6766. * @param element Defines the dom element to collect the events from
  6767. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6768. */
  6769. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6770. /**
  6771. * Rebuild the dynamic inputCheck function from the current list of
  6772. * defined inputs in the manager.
  6773. */
  6774. rebuildInputCheck(): void;
  6775. /**
  6776. * Remove all attached input methods from a camera
  6777. */
  6778. clear(): void;
  6779. /**
  6780. * Serialize the current input manager attached to a camera.
  6781. * This ensures than once parsed,
  6782. * the input associated to the camera will be identical to the current ones
  6783. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6784. */
  6785. serialize(serializedCamera: any): void;
  6786. /**
  6787. * Parses an input manager serialized JSON to restore the previous list of inputs
  6788. * and states associated to a camera.
  6789. * @param parsedCamera Defines the JSON to parse
  6790. */
  6791. parse(parsedCamera: any): void;
  6792. }
  6793. }
  6794. declare module "babylonjs/Collisions/intersectionInfo" {
  6795. import { Nullable } from "babylonjs/types";
  6796. /**
  6797. * @hidden
  6798. */
  6799. export class IntersectionInfo {
  6800. bu: Nullable<number>;
  6801. bv: Nullable<number>;
  6802. distance: number;
  6803. faceId: number;
  6804. subMeshId: number;
  6805. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6806. }
  6807. }
  6808. declare module "babylonjs/Maths/math.plane" {
  6809. import { DeepImmutable } from "babylonjs/types";
  6810. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6811. /**
  6812. * Represens a plane by the equation ax + by + cz + d = 0
  6813. */
  6814. export class Plane {
  6815. private static _TmpMatrix;
  6816. /**
  6817. * Normal of the plane (a,b,c)
  6818. */
  6819. normal: Vector3;
  6820. /**
  6821. * d component of the plane
  6822. */
  6823. d: number;
  6824. /**
  6825. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6826. * @param a a component of the plane
  6827. * @param b b component of the plane
  6828. * @param c c component of the plane
  6829. * @param d d component of the plane
  6830. */
  6831. constructor(a: number, b: number, c: number, d: number);
  6832. /**
  6833. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6834. */
  6835. asArray(): number[];
  6836. /**
  6837. * @returns a new plane copied from the current Plane.
  6838. */
  6839. clone(): Plane;
  6840. /**
  6841. * @returns the string "Plane".
  6842. */
  6843. getClassName(): string;
  6844. /**
  6845. * @returns the Plane hash code.
  6846. */
  6847. getHashCode(): number;
  6848. /**
  6849. * Normalize the current Plane in place.
  6850. * @returns the updated Plane.
  6851. */
  6852. normalize(): Plane;
  6853. /**
  6854. * Applies a transformation the plane and returns the result
  6855. * @param transformation the transformation matrix to be applied to the plane
  6856. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6857. */
  6858. transform(transformation: DeepImmutable<Matrix>): Plane;
  6859. /**
  6860. * Calcualtte the dot product between the point and the plane normal
  6861. * @param point point to calculate the dot product with
  6862. * @returns the dot product (float) of the point coordinates and the plane normal.
  6863. */
  6864. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6865. /**
  6866. * Updates the current Plane from the plane defined by the three given points.
  6867. * @param point1 one of the points used to contruct the plane
  6868. * @param point2 one of the points used to contruct the plane
  6869. * @param point3 one of the points used to contruct the plane
  6870. * @returns the updated Plane.
  6871. */
  6872. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6873. /**
  6874. * Checks if the plane is facing a given direction
  6875. * @param direction the direction to check if the plane is facing
  6876. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6877. * @returns True is the vector "direction" is the same side than the plane normal.
  6878. */
  6879. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6880. /**
  6881. * Calculates the distance to a point
  6882. * @param point point to calculate distance to
  6883. * @returns the signed distance (float) from the given point to the Plane.
  6884. */
  6885. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6886. /**
  6887. * Creates a plane from an array
  6888. * @param array the array to create a plane from
  6889. * @returns a new Plane from the given array.
  6890. */
  6891. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6892. /**
  6893. * Creates a plane from three points
  6894. * @param point1 point used to create the plane
  6895. * @param point2 point used to create the plane
  6896. * @param point3 point used to create the plane
  6897. * @returns a new Plane defined by the three given points.
  6898. */
  6899. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6900. /**
  6901. * Creates a plane from an origin point and a normal
  6902. * @param origin origin of the plane to be constructed
  6903. * @param normal normal of the plane to be constructed
  6904. * @returns a new Plane the normal vector to this plane at the given origin point.
  6905. * Note : the vector "normal" is updated because normalized.
  6906. */
  6907. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6908. /**
  6909. * Calculates the distance from a plane and a point
  6910. * @param origin origin of the plane to be constructed
  6911. * @param normal normal of the plane to be constructed
  6912. * @param point point to calculate distance to
  6913. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6914. */
  6915. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6916. }
  6917. }
  6918. declare module "babylonjs/Culling/boundingSphere" {
  6919. import { DeepImmutable } from "babylonjs/types";
  6920. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6921. import { Plane } from "babylonjs/Maths/math.plane";
  6922. /**
  6923. * Class used to store bounding sphere information
  6924. */
  6925. export class BoundingSphere {
  6926. /**
  6927. * Gets the center of the bounding sphere in local space
  6928. */
  6929. readonly center: Vector3;
  6930. /**
  6931. * Radius of the bounding sphere in local space
  6932. */
  6933. radius: number;
  6934. /**
  6935. * Gets the center of the bounding sphere in world space
  6936. */
  6937. readonly centerWorld: Vector3;
  6938. /**
  6939. * Radius of the bounding sphere in world space
  6940. */
  6941. radiusWorld: number;
  6942. /**
  6943. * Gets the minimum vector in local space
  6944. */
  6945. readonly minimum: Vector3;
  6946. /**
  6947. * Gets the maximum vector in local space
  6948. */
  6949. readonly maximum: Vector3;
  6950. private _worldMatrix;
  6951. private static readonly TmpVector3;
  6952. /**
  6953. * Creates a new bounding sphere
  6954. * @param min defines the minimum vector (in local space)
  6955. * @param max defines the maximum vector (in local space)
  6956. * @param worldMatrix defines the new world matrix
  6957. */
  6958. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6959. /**
  6960. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6961. * @param min defines the new minimum vector (in local space)
  6962. * @param max defines the new maximum vector (in local space)
  6963. * @param worldMatrix defines the new world matrix
  6964. */
  6965. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6966. /**
  6967. * Scale the current bounding sphere by applying a scale factor
  6968. * @param factor defines the scale factor to apply
  6969. * @returns the current bounding box
  6970. */
  6971. scale(factor: number): BoundingSphere;
  6972. /**
  6973. * Gets the world matrix of the bounding box
  6974. * @returns a matrix
  6975. */
  6976. getWorldMatrix(): DeepImmutable<Matrix>;
  6977. /** @hidden */
  6978. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6979. /**
  6980. * Tests if the bounding sphere is intersecting the frustum planes
  6981. * @param frustumPlanes defines the frustum planes to test
  6982. * @returns true if there is an intersection
  6983. */
  6984. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6985. /**
  6986. * Tests if the bounding sphere center is in between the frustum planes.
  6987. * Used for optimistic fast inclusion.
  6988. * @param frustumPlanes defines the frustum planes to test
  6989. * @returns true if the sphere center is in between the frustum planes
  6990. */
  6991. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6992. /**
  6993. * Tests if a point is inside the bounding sphere
  6994. * @param point defines the point to test
  6995. * @returns true if the point is inside the bounding sphere
  6996. */
  6997. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6998. /**
  6999. * Checks if two sphere intersct
  7000. * @param sphere0 sphere 0
  7001. * @param sphere1 sphere 1
  7002. * @returns true if the speres intersect
  7003. */
  7004. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7005. }
  7006. }
  7007. declare module "babylonjs/Culling/boundingBox" {
  7008. import { DeepImmutable } from "babylonjs/types";
  7009. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7010. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7011. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7012. import { Plane } from "babylonjs/Maths/math.plane";
  7013. /**
  7014. * Class used to store bounding box information
  7015. */
  7016. export class BoundingBox implements ICullable {
  7017. /**
  7018. * Gets the 8 vectors representing the bounding box in local space
  7019. */
  7020. readonly vectors: Vector3[];
  7021. /**
  7022. * Gets the center of the bounding box in local space
  7023. */
  7024. readonly center: Vector3;
  7025. /**
  7026. * Gets the center of the bounding box in world space
  7027. */
  7028. readonly centerWorld: Vector3;
  7029. /**
  7030. * Gets the extend size in local space
  7031. */
  7032. readonly extendSize: Vector3;
  7033. /**
  7034. * Gets the extend size in world space
  7035. */
  7036. readonly extendSizeWorld: Vector3;
  7037. /**
  7038. * Gets the OBB (object bounding box) directions
  7039. */
  7040. readonly directions: Vector3[];
  7041. /**
  7042. * Gets the 8 vectors representing the bounding box in world space
  7043. */
  7044. readonly vectorsWorld: Vector3[];
  7045. /**
  7046. * Gets the minimum vector in world space
  7047. */
  7048. readonly minimumWorld: Vector3;
  7049. /**
  7050. * Gets the maximum vector in world space
  7051. */
  7052. readonly maximumWorld: Vector3;
  7053. /**
  7054. * Gets the minimum vector in local space
  7055. */
  7056. readonly minimum: Vector3;
  7057. /**
  7058. * Gets the maximum vector in local space
  7059. */
  7060. readonly maximum: Vector3;
  7061. private _worldMatrix;
  7062. private static readonly TmpVector3;
  7063. /**
  7064. * @hidden
  7065. */
  7066. _tag: number;
  7067. /**
  7068. * Creates a new bounding box
  7069. * @param min defines the minimum vector (in local space)
  7070. * @param max defines the maximum vector (in local space)
  7071. * @param worldMatrix defines the new world matrix
  7072. */
  7073. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7074. /**
  7075. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7076. * @param min defines the new minimum vector (in local space)
  7077. * @param max defines the new maximum vector (in local space)
  7078. * @param worldMatrix defines the new world matrix
  7079. */
  7080. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7081. /**
  7082. * Scale the current bounding box by applying a scale factor
  7083. * @param factor defines the scale factor to apply
  7084. * @returns the current bounding box
  7085. */
  7086. scale(factor: number): BoundingBox;
  7087. /**
  7088. * Gets the world matrix of the bounding box
  7089. * @returns a matrix
  7090. */
  7091. getWorldMatrix(): DeepImmutable<Matrix>;
  7092. /** @hidden */
  7093. _update(world: DeepImmutable<Matrix>): void;
  7094. /**
  7095. * Tests if the bounding box is intersecting the frustum planes
  7096. * @param frustumPlanes defines the frustum planes to test
  7097. * @returns true if there is an intersection
  7098. */
  7099. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7100. /**
  7101. * Tests if the bounding box is entirely inside the frustum planes
  7102. * @param frustumPlanes defines the frustum planes to test
  7103. * @returns true if there is an inclusion
  7104. */
  7105. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7106. /**
  7107. * Tests if a point is inside the bounding box
  7108. * @param point defines the point to test
  7109. * @returns true if the point is inside the bounding box
  7110. */
  7111. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7112. /**
  7113. * Tests if the bounding box intersects with a bounding sphere
  7114. * @param sphere defines the sphere to test
  7115. * @returns true if there is an intersection
  7116. */
  7117. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7118. /**
  7119. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7120. * @param min defines the min vector to use
  7121. * @param max defines the max vector to use
  7122. * @returns true if there is an intersection
  7123. */
  7124. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7125. /**
  7126. * Tests if two bounding boxes are intersections
  7127. * @param box0 defines the first box to test
  7128. * @param box1 defines the second box to test
  7129. * @returns true if there is an intersection
  7130. */
  7131. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7132. /**
  7133. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7134. * @param minPoint defines the minimum vector of the bounding box
  7135. * @param maxPoint defines the maximum vector of the bounding box
  7136. * @param sphereCenter defines the sphere center
  7137. * @param sphereRadius defines the sphere radius
  7138. * @returns true if there is an intersection
  7139. */
  7140. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7141. /**
  7142. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7143. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7144. * @param frustumPlanes defines the frustum planes to test
  7145. * @return true if there is an inclusion
  7146. */
  7147. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7148. /**
  7149. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7150. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7151. * @param frustumPlanes defines the frustum planes to test
  7152. * @return true if there is an intersection
  7153. */
  7154. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7155. }
  7156. }
  7157. declare module "babylonjs/Collisions/collider" {
  7158. import { Nullable, IndicesArray } from "babylonjs/types";
  7159. import { Vector3 } from "babylonjs/Maths/math.vector";
  7160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7161. import { Plane } from "babylonjs/Maths/math.plane";
  7162. /** @hidden */
  7163. export class Collider {
  7164. /** Define if a collision was found */
  7165. collisionFound: boolean;
  7166. /**
  7167. * Define last intersection point in local space
  7168. */
  7169. intersectionPoint: Vector3;
  7170. /**
  7171. * Define last collided mesh
  7172. */
  7173. collidedMesh: Nullable<AbstractMesh>;
  7174. private _collisionPoint;
  7175. private _planeIntersectionPoint;
  7176. private _tempVector;
  7177. private _tempVector2;
  7178. private _tempVector3;
  7179. private _tempVector4;
  7180. private _edge;
  7181. private _baseToVertex;
  7182. private _destinationPoint;
  7183. private _slidePlaneNormal;
  7184. private _displacementVector;
  7185. /** @hidden */
  7186. _radius: Vector3;
  7187. /** @hidden */
  7188. _retry: number;
  7189. private _velocity;
  7190. private _basePoint;
  7191. private _epsilon;
  7192. /** @hidden */
  7193. _velocityWorldLength: number;
  7194. /** @hidden */
  7195. _basePointWorld: Vector3;
  7196. private _velocityWorld;
  7197. private _normalizedVelocity;
  7198. /** @hidden */
  7199. _initialVelocity: Vector3;
  7200. /** @hidden */
  7201. _initialPosition: Vector3;
  7202. private _nearestDistance;
  7203. private _collisionMask;
  7204. collisionMask: number;
  7205. /**
  7206. * Gets the plane normal used to compute the sliding response (in local space)
  7207. */
  7208. readonly slidePlaneNormal: Vector3;
  7209. /** @hidden */
  7210. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7211. /** @hidden */
  7212. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7213. /** @hidden */
  7214. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7215. /** @hidden */
  7216. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7217. /** @hidden */
  7218. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7219. /** @hidden */
  7220. _getResponse(pos: Vector3, vel: Vector3): void;
  7221. }
  7222. }
  7223. declare module "babylonjs/Culling/boundingInfo" {
  7224. import { DeepImmutable } from "babylonjs/types";
  7225. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7226. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7227. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7228. import { Plane } from "babylonjs/Maths/math.plane";
  7229. import { Collider } from "babylonjs/Collisions/collider";
  7230. /**
  7231. * Interface for cullable objects
  7232. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7233. */
  7234. export interface ICullable {
  7235. /**
  7236. * Checks if the object or part of the object is in the frustum
  7237. * @param frustumPlanes Camera near/planes
  7238. * @returns true if the object is in frustum otherwise false
  7239. */
  7240. isInFrustum(frustumPlanes: Plane[]): boolean;
  7241. /**
  7242. * Checks if a cullable object (mesh...) is in the camera frustum
  7243. * Unlike isInFrustum this cheks the full bounding box
  7244. * @param frustumPlanes Camera near/planes
  7245. * @returns true if the object is in frustum otherwise false
  7246. */
  7247. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7248. }
  7249. /**
  7250. * Info for a bounding data of a mesh
  7251. */
  7252. export class BoundingInfo implements ICullable {
  7253. /**
  7254. * Bounding box for the mesh
  7255. */
  7256. readonly boundingBox: BoundingBox;
  7257. /**
  7258. * Bounding sphere for the mesh
  7259. */
  7260. readonly boundingSphere: BoundingSphere;
  7261. private _isLocked;
  7262. private static readonly TmpVector3;
  7263. /**
  7264. * Constructs bounding info
  7265. * @param minimum min vector of the bounding box/sphere
  7266. * @param maximum max vector of the bounding box/sphere
  7267. * @param worldMatrix defines the new world matrix
  7268. */
  7269. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7270. /**
  7271. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7272. * @param min defines the new minimum vector (in local space)
  7273. * @param max defines the new maximum vector (in local space)
  7274. * @param worldMatrix defines the new world matrix
  7275. */
  7276. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7277. /**
  7278. * min vector of the bounding box/sphere
  7279. */
  7280. readonly minimum: Vector3;
  7281. /**
  7282. * max vector of the bounding box/sphere
  7283. */
  7284. readonly maximum: Vector3;
  7285. /**
  7286. * If the info is locked and won't be updated to avoid perf overhead
  7287. */
  7288. isLocked: boolean;
  7289. /**
  7290. * Updates the bounding sphere and box
  7291. * @param world world matrix to be used to update
  7292. */
  7293. update(world: DeepImmutable<Matrix>): void;
  7294. /**
  7295. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7296. * @param center New center of the bounding info
  7297. * @param extend New extend of the bounding info
  7298. * @returns the current bounding info
  7299. */
  7300. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7301. /**
  7302. * Scale the current bounding info by applying a scale factor
  7303. * @param factor defines the scale factor to apply
  7304. * @returns the current bounding info
  7305. */
  7306. scale(factor: number): BoundingInfo;
  7307. /**
  7308. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7309. * @param frustumPlanes defines the frustum to test
  7310. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7311. * @returns true if the bounding info is in the frustum planes
  7312. */
  7313. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7314. /**
  7315. * Gets the world distance between the min and max points of the bounding box
  7316. */
  7317. readonly diagonalLength: number;
  7318. /**
  7319. * Checks if a cullable object (mesh...) is in the camera frustum
  7320. * Unlike isInFrustum this cheks the full bounding box
  7321. * @param frustumPlanes Camera near/planes
  7322. * @returns true if the object is in frustum otherwise false
  7323. */
  7324. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7325. /** @hidden */
  7326. _checkCollision(collider: Collider): boolean;
  7327. /**
  7328. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7329. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7330. * @param point the point to check intersection with
  7331. * @returns if the point intersects
  7332. */
  7333. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7334. /**
  7335. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7336. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7337. * @param boundingInfo the bounding info to check intersection with
  7338. * @param precise if the intersection should be done using OBB
  7339. * @returns if the bounding info intersects
  7340. */
  7341. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7342. }
  7343. }
  7344. declare module "babylonjs/Maths/math.functions" {
  7345. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7346. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7347. /**
  7348. * Extracts minimum and maximum values from a list of indexed positions
  7349. * @param positions defines the positions to use
  7350. * @param indices defines the indices to the positions
  7351. * @param indexStart defines the start index
  7352. * @param indexCount defines the end index
  7353. * @param bias defines bias value to add to the result
  7354. * @return minimum and maximum values
  7355. */
  7356. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7357. minimum: Vector3;
  7358. maximum: Vector3;
  7359. };
  7360. /**
  7361. * Extracts minimum and maximum values from a list of positions
  7362. * @param positions defines the positions to use
  7363. * @param start defines the start index in the positions array
  7364. * @param count defines the number of positions to handle
  7365. * @param bias defines bias value to add to the result
  7366. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7367. * @return minimum and maximum values
  7368. */
  7369. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7370. minimum: Vector3;
  7371. maximum: Vector3;
  7372. };
  7373. }
  7374. declare module "babylonjs/Misc/iInspectable" {
  7375. /**
  7376. * Enum that determines the text-wrapping mode to use.
  7377. */
  7378. export enum InspectableType {
  7379. /**
  7380. * Checkbox for booleans
  7381. */
  7382. Checkbox = 0,
  7383. /**
  7384. * Sliders for numbers
  7385. */
  7386. Slider = 1,
  7387. /**
  7388. * Vector3
  7389. */
  7390. Vector3 = 2,
  7391. /**
  7392. * Quaternions
  7393. */
  7394. Quaternion = 3,
  7395. /**
  7396. * Color3
  7397. */
  7398. Color3 = 4,
  7399. /**
  7400. * String
  7401. */
  7402. String = 5
  7403. }
  7404. /**
  7405. * Interface used to define custom inspectable properties.
  7406. * This interface is used by the inspector to display custom property grids
  7407. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7408. */
  7409. export interface IInspectable {
  7410. /**
  7411. * Gets the label to display
  7412. */
  7413. label: string;
  7414. /**
  7415. * Gets the name of the property to edit
  7416. */
  7417. propertyName: string;
  7418. /**
  7419. * Gets the type of the editor to use
  7420. */
  7421. type: InspectableType;
  7422. /**
  7423. * Gets the minimum value of the property when using in "slider" mode
  7424. */
  7425. min?: number;
  7426. /**
  7427. * Gets the maximum value of the property when using in "slider" mode
  7428. */
  7429. max?: number;
  7430. /**
  7431. * Gets the setp to use when using in "slider" mode
  7432. */
  7433. step?: number;
  7434. }
  7435. }
  7436. declare module "babylonjs/Misc/timingTools" {
  7437. /**
  7438. * Class used to provide helper for timing
  7439. */
  7440. export class TimingTools {
  7441. /**
  7442. * Polyfill for setImmediate
  7443. * @param action defines the action to execute after the current execution block
  7444. */
  7445. static SetImmediate(action: () => void): void;
  7446. }
  7447. }
  7448. declare module "babylonjs/Misc/instantiationTools" {
  7449. /**
  7450. * Class used to enable instatition of objects by class name
  7451. */
  7452. export class InstantiationTools {
  7453. /**
  7454. * Use this object to register external classes like custom textures or material
  7455. * to allow the laoders to instantiate them
  7456. */
  7457. static RegisteredExternalClasses: {
  7458. [key: string]: Object;
  7459. };
  7460. /**
  7461. * Tries to instantiate a new object from a given class name
  7462. * @param className defines the class name to instantiate
  7463. * @returns the new object or null if the system was not able to do the instantiation
  7464. */
  7465. static Instantiate(className: string): any;
  7466. }
  7467. }
  7468. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7469. import { Nullable } from "babylonjs/types";
  7470. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7471. /**
  7472. * This represents the required contract to create a new type of texture loader.
  7473. */
  7474. export interface IInternalTextureLoader {
  7475. /**
  7476. * Defines wether the loader supports cascade loading the different faces.
  7477. */
  7478. supportCascades: boolean;
  7479. /**
  7480. * This returns if the loader support the current file information.
  7481. * @param extension defines the file extension of the file being loaded
  7482. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7483. * @param fallback defines the fallback internal texture if any
  7484. * @param isBase64 defines whether the texture is encoded as a base64
  7485. * @param isBuffer defines whether the texture data are stored as a buffer
  7486. * @returns true if the loader can load the specified file
  7487. */
  7488. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7489. /**
  7490. * Transform the url before loading if required.
  7491. * @param rootUrl the url of the texture
  7492. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7493. * @returns the transformed texture
  7494. */
  7495. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7496. /**
  7497. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7498. * @param rootUrl the url of the texture
  7499. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7500. * @returns the fallback texture
  7501. */
  7502. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7503. /**
  7504. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7505. * @param data contains the texture data
  7506. * @param texture defines the BabylonJS internal texture
  7507. * @param createPolynomials will be true if polynomials have been requested
  7508. * @param onLoad defines the callback to trigger once the texture is ready
  7509. * @param onError defines the callback to trigger in case of error
  7510. */
  7511. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7512. /**
  7513. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7514. * @param data contains the texture data
  7515. * @param texture defines the BabylonJS internal texture
  7516. * @param callback defines the method to call once ready to upload
  7517. */
  7518. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7519. }
  7520. }
  7521. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7522. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7523. import { Nullable } from "babylonjs/types";
  7524. import { Scene } from "babylonjs/scene";
  7525. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7526. module "babylonjs/Engines/engine" {
  7527. interface Engine {
  7528. /**
  7529. * Creates a depth stencil cube texture.
  7530. * This is only available in WebGL 2.
  7531. * @param size The size of face edge in the cube texture.
  7532. * @param options The options defining the cube texture.
  7533. * @returns The cube texture
  7534. */
  7535. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7536. /**
  7537. * Creates a cube texture
  7538. * @param rootUrl defines the url where the files to load is located
  7539. * @param scene defines the current scene
  7540. * @param files defines the list of files to load (1 per face)
  7541. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7542. * @param onLoad defines an optional callback raised when the texture is loaded
  7543. * @param onError defines an optional callback raised if there is an issue to load the texture
  7544. * @param format defines the format of the data
  7545. * @param forcedExtension defines the extension to use to pick the right loader
  7546. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7547. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7548. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7549. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7550. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7551. * @returns the cube texture as an InternalTexture
  7552. */
  7553. 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>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7554. /**
  7555. * Creates a cube texture
  7556. * @param rootUrl defines the url where the files to load is located
  7557. * @param scene defines the current scene
  7558. * @param files defines the list of files to load (1 per face)
  7559. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7560. * @param onLoad defines an optional callback raised when the texture is loaded
  7561. * @param onError defines an optional callback raised if there is an issue to load the texture
  7562. * @param format defines the format of the data
  7563. * @param forcedExtension defines the extension to use to pick the right loader
  7564. * @returns the cube texture as an InternalTexture
  7565. */
  7566. 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;
  7567. /**
  7568. * Creates a cube texture
  7569. * @param rootUrl defines the url where the files to load is located
  7570. * @param scene defines the current scene
  7571. * @param files defines the list of files to load (1 per face)
  7572. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7573. * @param onLoad defines an optional callback raised when the texture is loaded
  7574. * @param onError defines an optional callback raised if there is an issue to load the texture
  7575. * @param format defines the format of the data
  7576. * @param forcedExtension defines the extension to use to pick the right loader
  7577. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7578. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7579. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7580. * @returns the cube texture as an InternalTexture
  7581. */
  7582. 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;
  7583. /** @hidden */
  7584. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7585. /** @hidden */
  7586. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7587. /** @hidden */
  7588. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7589. /** @hidden */
  7590. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7591. }
  7592. }
  7593. }
  7594. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7595. import { Nullable } from "babylonjs/types";
  7596. import { Scene } from "babylonjs/scene";
  7597. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7598. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7599. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7600. /**
  7601. * Class for creating a cube texture
  7602. */
  7603. export class CubeTexture extends BaseTexture {
  7604. private _delayedOnLoad;
  7605. /**
  7606. * The url of the texture
  7607. */
  7608. url: string;
  7609. /**
  7610. * Gets or sets the center of the bounding box associated with the cube texture.
  7611. * It must define where the camera used to render the texture was set
  7612. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7613. */
  7614. boundingBoxPosition: Vector3;
  7615. private _boundingBoxSize;
  7616. /**
  7617. * Gets or sets the size of the bounding box associated with the cube texture
  7618. * When defined, the cubemap will switch to local mode
  7619. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7620. * @example https://www.babylonjs-playground.com/#RNASML
  7621. */
  7622. /**
  7623. * Returns the bounding box size
  7624. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7625. */
  7626. boundingBoxSize: Vector3;
  7627. protected _rotationY: number;
  7628. /**
  7629. * Sets texture matrix rotation angle around Y axis in radians.
  7630. */
  7631. /**
  7632. * Gets texture matrix rotation angle around Y axis radians.
  7633. */
  7634. rotationY: number;
  7635. /**
  7636. * Are mip maps generated for this texture or not.
  7637. */
  7638. readonly noMipmap: boolean;
  7639. private _noMipmap;
  7640. private _files;
  7641. private _extensions;
  7642. private _textureMatrix;
  7643. private _format;
  7644. private _createPolynomials;
  7645. /** @hidden */
  7646. _prefiltered: boolean;
  7647. /**
  7648. * Creates a cube texture from an array of image urls
  7649. * @param files defines an array of image urls
  7650. * @param scene defines the hosting scene
  7651. * @param noMipmap specifies if mip maps are not used
  7652. * @returns a cube texture
  7653. */
  7654. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7655. /**
  7656. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7657. * @param url defines the url of the prefiltered texture
  7658. * @param scene defines the scene the texture is attached to
  7659. * @param forcedExtension defines the extension of the file if different from the url
  7660. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7661. * @return the prefiltered texture
  7662. */
  7663. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7664. /**
  7665. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7666. * as prefiltered data.
  7667. * @param rootUrl defines the url of the texture or the root name of the six images
  7668. * @param scene defines the scene the texture is attached to
  7669. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7670. * @param noMipmap defines if mipmaps should be created or not
  7671. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7672. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7673. * @param onError defines a callback triggered in case of error during load
  7674. * @param format defines the internal format to use for the texture once loaded
  7675. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7676. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7677. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7678. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7679. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7680. * @return the cube texture
  7681. */
  7682. constructor(rootUrl: string, scene: Scene, 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);
  7683. /**
  7684. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7685. */
  7686. readonly isPrefiltered: boolean;
  7687. /**
  7688. * Get the current class name of the texture useful for serialization or dynamic coding.
  7689. * @returns "CubeTexture"
  7690. */
  7691. getClassName(): string;
  7692. /**
  7693. * Update the url (and optional buffer) of this texture if url was null during construction.
  7694. * @param url the url of the texture
  7695. * @param forcedExtension defines the extension to use
  7696. * @param onLoad callback called when the texture is loaded (defaults to null)
  7697. */
  7698. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7699. /**
  7700. * Delays loading of the cube texture
  7701. * @param forcedExtension defines the extension to use
  7702. */
  7703. delayLoad(forcedExtension?: string): void;
  7704. /**
  7705. * Returns the reflection texture matrix
  7706. * @returns the reflection texture matrix
  7707. */
  7708. getReflectionTextureMatrix(): Matrix;
  7709. /**
  7710. * Sets the reflection texture matrix
  7711. * @param value Reflection texture matrix
  7712. */
  7713. setReflectionTextureMatrix(value: Matrix): void;
  7714. /**
  7715. * Parses text to create a cube texture
  7716. * @param parsedTexture define the serialized text to read from
  7717. * @param scene defines the hosting scene
  7718. * @param rootUrl defines the root url of the cube texture
  7719. * @returns a cube texture
  7720. */
  7721. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7722. /**
  7723. * Makes a clone, or deep copy, of the cube texture
  7724. * @returns a new cube texture
  7725. */
  7726. clone(): CubeTexture;
  7727. }
  7728. }
  7729. declare module "babylonjs/Materials/materialDefines" {
  7730. /**
  7731. * Manages the defines for the Material
  7732. */
  7733. export class MaterialDefines {
  7734. /** @hidden */
  7735. protected _keys: string[];
  7736. private _isDirty;
  7737. /** @hidden */
  7738. _renderId: number;
  7739. /** @hidden */
  7740. _areLightsDirty: boolean;
  7741. /** @hidden */
  7742. _areLightsDisposed: boolean;
  7743. /** @hidden */
  7744. _areAttributesDirty: boolean;
  7745. /** @hidden */
  7746. _areTexturesDirty: boolean;
  7747. /** @hidden */
  7748. _areFresnelDirty: boolean;
  7749. /** @hidden */
  7750. _areMiscDirty: boolean;
  7751. /** @hidden */
  7752. _areImageProcessingDirty: boolean;
  7753. /** @hidden */
  7754. _normals: boolean;
  7755. /** @hidden */
  7756. _uvs: boolean;
  7757. /** @hidden */
  7758. _needNormals: boolean;
  7759. /** @hidden */
  7760. _needUVs: boolean;
  7761. [id: string]: any;
  7762. /**
  7763. * Specifies if the material needs to be re-calculated
  7764. */
  7765. readonly isDirty: boolean;
  7766. /**
  7767. * Marks the material to indicate that it has been re-calculated
  7768. */
  7769. markAsProcessed(): void;
  7770. /**
  7771. * Marks the material to indicate that it needs to be re-calculated
  7772. */
  7773. markAsUnprocessed(): void;
  7774. /**
  7775. * Marks the material to indicate all of its defines need to be re-calculated
  7776. */
  7777. markAllAsDirty(): void;
  7778. /**
  7779. * Marks the material to indicate that image processing needs to be re-calculated
  7780. */
  7781. markAsImageProcessingDirty(): void;
  7782. /**
  7783. * Marks the material to indicate the lights need to be re-calculated
  7784. * @param disposed Defines whether the light is dirty due to dispose or not
  7785. */
  7786. markAsLightDirty(disposed?: boolean): void;
  7787. /**
  7788. * Marks the attribute state as changed
  7789. */
  7790. markAsAttributesDirty(): void;
  7791. /**
  7792. * Marks the texture state as changed
  7793. */
  7794. markAsTexturesDirty(): void;
  7795. /**
  7796. * Marks the fresnel state as changed
  7797. */
  7798. markAsFresnelDirty(): void;
  7799. /**
  7800. * Marks the misc state as changed
  7801. */
  7802. markAsMiscDirty(): void;
  7803. /**
  7804. * Rebuilds the material defines
  7805. */
  7806. rebuild(): void;
  7807. /**
  7808. * Specifies if two material defines are equal
  7809. * @param other - A material define instance to compare to
  7810. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7811. */
  7812. isEqual(other: MaterialDefines): boolean;
  7813. /**
  7814. * Clones this instance's defines to another instance
  7815. * @param other - material defines to clone values to
  7816. */
  7817. cloneTo(other: MaterialDefines): void;
  7818. /**
  7819. * Resets the material define values
  7820. */
  7821. reset(): void;
  7822. /**
  7823. * Converts the material define values to a string
  7824. * @returns - String of material define information
  7825. */
  7826. toString(): string;
  7827. }
  7828. }
  7829. declare module "babylonjs/Materials/colorCurves" {
  7830. import { Effect } from "babylonjs/Materials/effect";
  7831. /**
  7832. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7833. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7834. * 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;
  7835. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7836. */
  7837. export class ColorCurves {
  7838. private _dirty;
  7839. private _tempColor;
  7840. private _globalCurve;
  7841. private _highlightsCurve;
  7842. private _midtonesCurve;
  7843. private _shadowsCurve;
  7844. private _positiveCurve;
  7845. private _negativeCurve;
  7846. private _globalHue;
  7847. private _globalDensity;
  7848. private _globalSaturation;
  7849. private _globalExposure;
  7850. /**
  7851. * Gets the global Hue value.
  7852. * 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).
  7853. */
  7854. /**
  7855. * Sets the global Hue value.
  7856. * 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).
  7857. */
  7858. globalHue: number;
  7859. /**
  7860. * Gets the global Density value.
  7861. * 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.
  7862. * Values less than zero provide a filter of opposite hue.
  7863. */
  7864. /**
  7865. * Sets the global Density value.
  7866. * 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.
  7867. * Values less than zero provide a filter of opposite hue.
  7868. */
  7869. globalDensity: number;
  7870. /**
  7871. * Gets the global Saturation value.
  7872. * 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.
  7873. */
  7874. /**
  7875. * Sets the global Saturation value.
  7876. * 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.
  7877. */
  7878. globalSaturation: number;
  7879. /**
  7880. * Gets the global Exposure value.
  7881. * 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.
  7882. */
  7883. /**
  7884. * Sets the global Exposure value.
  7885. * 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.
  7886. */
  7887. globalExposure: number;
  7888. private _highlightsHue;
  7889. private _highlightsDensity;
  7890. private _highlightsSaturation;
  7891. private _highlightsExposure;
  7892. /**
  7893. * Gets the highlights Hue value.
  7894. * 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).
  7895. */
  7896. /**
  7897. * Sets the highlights Hue value.
  7898. * 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).
  7899. */
  7900. highlightsHue: number;
  7901. /**
  7902. * Gets the highlights Density value.
  7903. * 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.
  7904. * Values less than zero provide a filter of opposite hue.
  7905. */
  7906. /**
  7907. * Sets the highlights Density value.
  7908. * 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.
  7909. * Values less than zero provide a filter of opposite hue.
  7910. */
  7911. highlightsDensity: number;
  7912. /**
  7913. * Gets the highlights Saturation value.
  7914. * 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.
  7915. */
  7916. /**
  7917. * Sets the highlights Saturation value.
  7918. * 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.
  7919. */
  7920. highlightsSaturation: number;
  7921. /**
  7922. * Gets the highlights Exposure value.
  7923. * 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.
  7924. */
  7925. /**
  7926. * Sets the highlights Exposure value.
  7927. * 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.
  7928. */
  7929. highlightsExposure: number;
  7930. private _midtonesHue;
  7931. private _midtonesDensity;
  7932. private _midtonesSaturation;
  7933. private _midtonesExposure;
  7934. /**
  7935. * Gets the midtones Hue value.
  7936. * 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).
  7937. */
  7938. /**
  7939. * Sets the midtones Hue value.
  7940. * 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).
  7941. */
  7942. midtonesHue: number;
  7943. /**
  7944. * Gets the midtones Density value.
  7945. * 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.
  7946. * Values less than zero provide a filter of opposite hue.
  7947. */
  7948. /**
  7949. * Sets the midtones Density value.
  7950. * 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.
  7951. * Values less than zero provide a filter of opposite hue.
  7952. */
  7953. midtonesDensity: number;
  7954. /**
  7955. * Gets the midtones Saturation value.
  7956. * 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.
  7957. */
  7958. /**
  7959. * Sets the midtones Saturation value.
  7960. * 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.
  7961. */
  7962. midtonesSaturation: number;
  7963. /**
  7964. * Gets the midtones Exposure value.
  7965. * 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.
  7966. */
  7967. /**
  7968. * Sets the midtones Exposure value.
  7969. * 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.
  7970. */
  7971. midtonesExposure: number;
  7972. private _shadowsHue;
  7973. private _shadowsDensity;
  7974. private _shadowsSaturation;
  7975. private _shadowsExposure;
  7976. /**
  7977. * Gets the shadows Hue value.
  7978. * 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).
  7979. */
  7980. /**
  7981. * Sets the shadows Hue value.
  7982. * 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).
  7983. */
  7984. shadowsHue: number;
  7985. /**
  7986. * Gets the shadows Density value.
  7987. * 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.
  7988. * Values less than zero provide a filter of opposite hue.
  7989. */
  7990. /**
  7991. * Sets the shadows Density value.
  7992. * 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.
  7993. * Values less than zero provide a filter of opposite hue.
  7994. */
  7995. shadowsDensity: number;
  7996. /**
  7997. * Gets the shadows Saturation value.
  7998. * 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.
  7999. */
  8000. /**
  8001. * Sets the shadows Saturation value.
  8002. * 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.
  8003. */
  8004. shadowsSaturation: number;
  8005. /**
  8006. * Gets the shadows Exposure value.
  8007. * 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.
  8008. */
  8009. /**
  8010. * Sets the shadows Exposure value.
  8011. * 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.
  8012. */
  8013. shadowsExposure: number;
  8014. /**
  8015. * Returns the class name
  8016. * @returns The class name
  8017. */
  8018. getClassName(): string;
  8019. /**
  8020. * Binds the color curves to the shader.
  8021. * @param colorCurves The color curve to bind
  8022. * @param effect The effect to bind to
  8023. * @param positiveUniform The positive uniform shader parameter
  8024. * @param neutralUniform The neutral uniform shader parameter
  8025. * @param negativeUniform The negative uniform shader parameter
  8026. */
  8027. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8028. /**
  8029. * Prepare the list of uniforms associated with the ColorCurves effects.
  8030. * @param uniformsList The list of uniforms used in the effect
  8031. */
  8032. static PrepareUniforms(uniformsList: string[]): void;
  8033. /**
  8034. * Returns color grading data based on a hue, density, saturation and exposure value.
  8035. * @param filterHue The hue of the color filter.
  8036. * @param filterDensity The density of the color filter.
  8037. * @param saturation The saturation.
  8038. * @param exposure The exposure.
  8039. * @param result The result data container.
  8040. */
  8041. private getColorGradingDataToRef;
  8042. /**
  8043. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8044. * @param value The input slider value in range [-100,100].
  8045. * @returns Adjusted value.
  8046. */
  8047. private static applyColorGradingSliderNonlinear;
  8048. /**
  8049. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8050. * @param hue The hue (H) input.
  8051. * @param saturation The saturation (S) input.
  8052. * @param brightness The brightness (B) input.
  8053. * @result An RGBA color represented as Vector4.
  8054. */
  8055. private static fromHSBToRef;
  8056. /**
  8057. * Returns a value clamped between min and max
  8058. * @param value The value to clamp
  8059. * @param min The minimum of value
  8060. * @param max The maximum of value
  8061. * @returns The clamped value.
  8062. */
  8063. private static clamp;
  8064. /**
  8065. * Clones the current color curve instance.
  8066. * @return The cloned curves
  8067. */
  8068. clone(): ColorCurves;
  8069. /**
  8070. * Serializes the current color curve instance to a json representation.
  8071. * @return a JSON representation
  8072. */
  8073. serialize(): any;
  8074. /**
  8075. * Parses the color curve from a json representation.
  8076. * @param source the JSON source to parse
  8077. * @return The parsed curves
  8078. */
  8079. static Parse(source: any): ColorCurves;
  8080. }
  8081. }
  8082. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8083. import { Observable } from "babylonjs/Misc/observable";
  8084. import { Nullable } from "babylonjs/types";
  8085. import { Color4 } from "babylonjs/Maths/math.color";
  8086. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8087. import { Effect } from "babylonjs/Materials/effect";
  8088. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8089. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8090. /**
  8091. * Interface to follow in your material defines to integrate easily the
  8092. * Image proccessing functions.
  8093. * @hidden
  8094. */
  8095. export interface IImageProcessingConfigurationDefines {
  8096. IMAGEPROCESSING: boolean;
  8097. VIGNETTE: boolean;
  8098. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8099. VIGNETTEBLENDMODEOPAQUE: boolean;
  8100. TONEMAPPING: boolean;
  8101. TONEMAPPING_ACES: boolean;
  8102. CONTRAST: boolean;
  8103. EXPOSURE: boolean;
  8104. COLORCURVES: boolean;
  8105. COLORGRADING: boolean;
  8106. COLORGRADING3D: boolean;
  8107. SAMPLER3DGREENDEPTH: boolean;
  8108. SAMPLER3DBGRMAP: boolean;
  8109. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8110. }
  8111. /**
  8112. * @hidden
  8113. */
  8114. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8115. IMAGEPROCESSING: boolean;
  8116. VIGNETTE: boolean;
  8117. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8118. VIGNETTEBLENDMODEOPAQUE: boolean;
  8119. TONEMAPPING: boolean;
  8120. TONEMAPPING_ACES: boolean;
  8121. CONTRAST: boolean;
  8122. COLORCURVES: boolean;
  8123. COLORGRADING: boolean;
  8124. COLORGRADING3D: boolean;
  8125. SAMPLER3DGREENDEPTH: boolean;
  8126. SAMPLER3DBGRMAP: boolean;
  8127. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8128. EXPOSURE: boolean;
  8129. constructor();
  8130. }
  8131. /**
  8132. * This groups together the common properties used for image processing either in direct forward pass
  8133. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8134. * or not.
  8135. */
  8136. export class ImageProcessingConfiguration {
  8137. /**
  8138. * Default tone mapping applied in BabylonJS.
  8139. */
  8140. static readonly TONEMAPPING_STANDARD: number;
  8141. /**
  8142. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8143. * to other engines rendering to increase portability.
  8144. */
  8145. static readonly TONEMAPPING_ACES: number;
  8146. /**
  8147. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8148. */
  8149. colorCurves: Nullable<ColorCurves>;
  8150. private _colorCurvesEnabled;
  8151. /**
  8152. * Gets wether the color curves effect is enabled.
  8153. */
  8154. /**
  8155. * Sets wether the color curves effect is enabled.
  8156. */
  8157. colorCurvesEnabled: boolean;
  8158. private _colorGradingTexture;
  8159. /**
  8160. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8161. */
  8162. /**
  8163. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8164. */
  8165. colorGradingTexture: Nullable<BaseTexture>;
  8166. private _colorGradingEnabled;
  8167. /**
  8168. * Gets wether the color grading effect is enabled.
  8169. */
  8170. /**
  8171. * Sets wether the color grading effect is enabled.
  8172. */
  8173. colorGradingEnabled: boolean;
  8174. private _colorGradingWithGreenDepth;
  8175. /**
  8176. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8177. */
  8178. /**
  8179. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8180. */
  8181. colorGradingWithGreenDepth: boolean;
  8182. private _colorGradingBGR;
  8183. /**
  8184. * Gets wether the color grading texture contains BGR values.
  8185. */
  8186. /**
  8187. * Sets wether the color grading texture contains BGR values.
  8188. */
  8189. colorGradingBGR: boolean;
  8190. /** @hidden */
  8191. _exposure: number;
  8192. /**
  8193. * Gets the Exposure used in the effect.
  8194. */
  8195. /**
  8196. * Sets the Exposure used in the effect.
  8197. */
  8198. exposure: number;
  8199. private _toneMappingEnabled;
  8200. /**
  8201. * Gets wether the tone mapping effect is enabled.
  8202. */
  8203. /**
  8204. * Sets wether the tone mapping effect is enabled.
  8205. */
  8206. toneMappingEnabled: boolean;
  8207. private _toneMappingType;
  8208. /**
  8209. * Gets the type of tone mapping effect.
  8210. */
  8211. /**
  8212. * Sets the type of tone mapping effect used in BabylonJS.
  8213. */
  8214. toneMappingType: number;
  8215. protected _contrast: number;
  8216. /**
  8217. * Gets the contrast used in the effect.
  8218. */
  8219. /**
  8220. * Sets the contrast used in the effect.
  8221. */
  8222. contrast: number;
  8223. /**
  8224. * Vignette stretch size.
  8225. */
  8226. vignetteStretch: number;
  8227. /**
  8228. * Vignette centre X Offset.
  8229. */
  8230. vignetteCentreX: number;
  8231. /**
  8232. * Vignette centre Y Offset.
  8233. */
  8234. vignetteCentreY: number;
  8235. /**
  8236. * Vignette weight or intensity of the vignette effect.
  8237. */
  8238. vignetteWeight: number;
  8239. /**
  8240. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8241. * if vignetteEnabled is set to true.
  8242. */
  8243. vignetteColor: Color4;
  8244. /**
  8245. * Camera field of view used by the Vignette effect.
  8246. */
  8247. vignetteCameraFov: number;
  8248. private _vignetteBlendMode;
  8249. /**
  8250. * Gets the vignette blend mode allowing different kind of effect.
  8251. */
  8252. /**
  8253. * Sets the vignette blend mode allowing different kind of effect.
  8254. */
  8255. vignetteBlendMode: number;
  8256. private _vignetteEnabled;
  8257. /**
  8258. * Gets wether the vignette effect is enabled.
  8259. */
  8260. /**
  8261. * Sets wether the vignette effect is enabled.
  8262. */
  8263. vignetteEnabled: boolean;
  8264. private _applyByPostProcess;
  8265. /**
  8266. * Gets wether the image processing is applied through a post process or not.
  8267. */
  8268. /**
  8269. * Sets wether the image processing is applied through a post process or not.
  8270. */
  8271. applyByPostProcess: boolean;
  8272. private _isEnabled;
  8273. /**
  8274. * Gets wether the image processing is enabled or not.
  8275. */
  8276. /**
  8277. * Sets wether the image processing is enabled or not.
  8278. */
  8279. isEnabled: boolean;
  8280. /**
  8281. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8282. */
  8283. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8284. /**
  8285. * Method called each time the image processing information changes requires to recompile the effect.
  8286. */
  8287. protected _updateParameters(): void;
  8288. /**
  8289. * Gets the current class name.
  8290. * @return "ImageProcessingConfiguration"
  8291. */
  8292. getClassName(): string;
  8293. /**
  8294. * Prepare the list of uniforms associated with the Image Processing effects.
  8295. * @param uniforms The list of uniforms used in the effect
  8296. * @param defines the list of defines currently in use
  8297. */
  8298. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8299. /**
  8300. * Prepare the list of samplers associated with the Image Processing effects.
  8301. * @param samplersList The list of uniforms used in the effect
  8302. * @param defines the list of defines currently in use
  8303. */
  8304. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8305. /**
  8306. * Prepare the list of defines associated to the shader.
  8307. * @param defines the list of defines to complete
  8308. * @param forPostProcess Define if we are currently in post process mode or not
  8309. */
  8310. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8311. /**
  8312. * Returns true if all the image processing information are ready.
  8313. * @returns True if ready, otherwise, false
  8314. */
  8315. isReady(): boolean;
  8316. /**
  8317. * Binds the image processing to the shader.
  8318. * @param effect The effect to bind to
  8319. * @param aspectRatio Define the current aspect ratio of the effect
  8320. */
  8321. bind(effect: Effect, aspectRatio?: number): void;
  8322. /**
  8323. * Clones the current image processing instance.
  8324. * @return The cloned image processing
  8325. */
  8326. clone(): ImageProcessingConfiguration;
  8327. /**
  8328. * Serializes the current image processing instance to a json representation.
  8329. * @return a JSON representation
  8330. */
  8331. serialize(): any;
  8332. /**
  8333. * Parses the image processing from a json representation.
  8334. * @param source the JSON source to parse
  8335. * @return The parsed image processing
  8336. */
  8337. static Parse(source: any): ImageProcessingConfiguration;
  8338. private static _VIGNETTEMODE_MULTIPLY;
  8339. private static _VIGNETTEMODE_OPAQUE;
  8340. /**
  8341. * Used to apply the vignette as a mix with the pixel color.
  8342. */
  8343. static readonly VIGNETTEMODE_MULTIPLY: number;
  8344. /**
  8345. * Used to apply the vignette as a replacement of the pixel color.
  8346. */
  8347. static readonly VIGNETTEMODE_OPAQUE: number;
  8348. }
  8349. }
  8350. declare module "babylonjs/Shaders/postprocess.vertex" {
  8351. /** @hidden */
  8352. export var postprocessVertexShader: {
  8353. name: string;
  8354. shader: string;
  8355. };
  8356. }
  8357. declare module "babylonjs/Maths/math.axis" {
  8358. import { Vector3 } from "babylonjs/Maths/math.vector";
  8359. /** Defines supported spaces */
  8360. export enum Space {
  8361. /** Local (object) space */
  8362. LOCAL = 0,
  8363. /** World space */
  8364. WORLD = 1,
  8365. /** Bone space */
  8366. BONE = 2
  8367. }
  8368. /** Defines the 3 main axes */
  8369. export class Axis {
  8370. /** X axis */
  8371. static X: Vector3;
  8372. /** Y axis */
  8373. static Y: Vector3;
  8374. /** Z axis */
  8375. static Z: Vector3;
  8376. }
  8377. }
  8378. declare module "babylonjs/Cameras/targetCamera" {
  8379. import { Nullable } from "babylonjs/types";
  8380. import { Camera } from "babylonjs/Cameras/camera";
  8381. import { Scene } from "babylonjs/scene";
  8382. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8383. /**
  8384. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8385. * This is the base of the follow, arc rotate cameras and Free camera
  8386. * @see http://doc.babylonjs.com/features/cameras
  8387. */
  8388. export class TargetCamera extends Camera {
  8389. private static _RigCamTransformMatrix;
  8390. private static _TargetTransformMatrix;
  8391. private static _TargetFocalPoint;
  8392. /**
  8393. * Define the current direction the camera is moving to
  8394. */
  8395. cameraDirection: Vector3;
  8396. /**
  8397. * Define the current rotation the camera is rotating to
  8398. */
  8399. cameraRotation: Vector2;
  8400. /**
  8401. * When set, the up vector of the camera will be updated by the rotation of the camera
  8402. */
  8403. updateUpVectorFromRotation: boolean;
  8404. private _tmpQuaternion;
  8405. /**
  8406. * Define the current rotation of the camera
  8407. */
  8408. rotation: Vector3;
  8409. /**
  8410. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8411. */
  8412. rotationQuaternion: Quaternion;
  8413. /**
  8414. * Define the current speed of the camera
  8415. */
  8416. speed: number;
  8417. /**
  8418. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8419. * around all axis.
  8420. */
  8421. noRotationConstraint: boolean;
  8422. /**
  8423. * Define the current target of the camera as an object or a position.
  8424. */
  8425. lockedTarget: any;
  8426. /** @hidden */
  8427. _currentTarget: Vector3;
  8428. /** @hidden */
  8429. _initialFocalDistance: number;
  8430. /** @hidden */
  8431. _viewMatrix: Matrix;
  8432. /** @hidden */
  8433. _camMatrix: Matrix;
  8434. /** @hidden */
  8435. _cameraTransformMatrix: Matrix;
  8436. /** @hidden */
  8437. _cameraRotationMatrix: Matrix;
  8438. /** @hidden */
  8439. _referencePoint: Vector3;
  8440. /** @hidden */
  8441. _transformedReferencePoint: Vector3;
  8442. protected _globalCurrentTarget: Vector3;
  8443. protected _globalCurrentUpVector: Vector3;
  8444. /** @hidden */
  8445. _reset: () => void;
  8446. private _defaultUp;
  8447. /**
  8448. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8449. * This is the base of the follow, arc rotate cameras and Free camera
  8450. * @see http://doc.babylonjs.com/features/cameras
  8451. * @param name Defines the name of the camera in the scene
  8452. * @param position Defines the start position of the camera in the scene
  8453. * @param scene Defines the scene the camera belongs to
  8454. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8455. */
  8456. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8457. /**
  8458. * Gets the position in front of the camera at a given distance.
  8459. * @param distance The distance from the camera we want the position to be
  8460. * @returns the position
  8461. */
  8462. getFrontPosition(distance: number): Vector3;
  8463. /** @hidden */
  8464. _getLockedTargetPosition(): Nullable<Vector3>;
  8465. private _storedPosition;
  8466. private _storedRotation;
  8467. private _storedRotationQuaternion;
  8468. /**
  8469. * Store current camera state of the camera (fov, position, rotation, etc..)
  8470. * @returns the camera
  8471. */
  8472. storeState(): Camera;
  8473. /**
  8474. * Restored camera state. You must call storeState() first
  8475. * @returns whether it was successful or not
  8476. * @hidden
  8477. */
  8478. _restoreStateValues(): boolean;
  8479. /** @hidden */
  8480. _initCache(): void;
  8481. /** @hidden */
  8482. _updateCache(ignoreParentClass?: boolean): void;
  8483. /** @hidden */
  8484. _isSynchronizedViewMatrix(): boolean;
  8485. /** @hidden */
  8486. _computeLocalCameraSpeed(): number;
  8487. /**
  8488. * Defines the target the camera should look at.
  8489. * @param target Defines the new target as a Vector or a mesh
  8490. */
  8491. setTarget(target: Vector3): void;
  8492. /**
  8493. * Return the current target position of the camera. This value is expressed in local space.
  8494. * @returns the target position
  8495. */
  8496. getTarget(): Vector3;
  8497. /** @hidden */
  8498. _decideIfNeedsToMove(): boolean;
  8499. /** @hidden */
  8500. _updatePosition(): void;
  8501. /** @hidden */
  8502. _checkInputs(): void;
  8503. protected _updateCameraRotationMatrix(): void;
  8504. /**
  8505. * 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)
  8506. * @returns the current camera
  8507. */
  8508. private _rotateUpVectorWithCameraRotationMatrix;
  8509. private _cachedRotationZ;
  8510. private _cachedQuaternionRotationZ;
  8511. /** @hidden */
  8512. _getViewMatrix(): Matrix;
  8513. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8514. /**
  8515. * @hidden
  8516. */
  8517. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8518. /**
  8519. * @hidden
  8520. */
  8521. _updateRigCameras(): void;
  8522. private _getRigCamPositionAndTarget;
  8523. /**
  8524. * Gets the current object class name.
  8525. * @return the class name
  8526. */
  8527. getClassName(): string;
  8528. }
  8529. }
  8530. declare module "babylonjs/Events/keyboardEvents" {
  8531. /**
  8532. * Gather the list of keyboard event types as constants.
  8533. */
  8534. export class KeyboardEventTypes {
  8535. /**
  8536. * The keydown event is fired when a key becomes active (pressed).
  8537. */
  8538. static readonly KEYDOWN: number;
  8539. /**
  8540. * The keyup event is fired when a key has been released.
  8541. */
  8542. static readonly KEYUP: number;
  8543. }
  8544. /**
  8545. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8546. */
  8547. export class KeyboardInfo {
  8548. /**
  8549. * Defines the type of event (KeyboardEventTypes)
  8550. */
  8551. type: number;
  8552. /**
  8553. * Defines the related dom event
  8554. */
  8555. event: KeyboardEvent;
  8556. /**
  8557. * Instantiates a new keyboard info.
  8558. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8559. * @param type Defines the type of event (KeyboardEventTypes)
  8560. * @param event Defines the related dom event
  8561. */
  8562. constructor(
  8563. /**
  8564. * Defines the type of event (KeyboardEventTypes)
  8565. */
  8566. type: number,
  8567. /**
  8568. * Defines the related dom event
  8569. */
  8570. event: KeyboardEvent);
  8571. }
  8572. /**
  8573. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8574. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8575. */
  8576. export class KeyboardInfoPre extends KeyboardInfo {
  8577. /**
  8578. * Defines the type of event (KeyboardEventTypes)
  8579. */
  8580. type: number;
  8581. /**
  8582. * Defines the related dom event
  8583. */
  8584. event: KeyboardEvent;
  8585. /**
  8586. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8587. */
  8588. skipOnPointerObservable: boolean;
  8589. /**
  8590. * Instantiates a new keyboard pre info.
  8591. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8592. * @param type Defines the type of event (KeyboardEventTypes)
  8593. * @param event Defines the related dom event
  8594. */
  8595. constructor(
  8596. /**
  8597. * Defines the type of event (KeyboardEventTypes)
  8598. */
  8599. type: number,
  8600. /**
  8601. * Defines the related dom event
  8602. */
  8603. event: KeyboardEvent);
  8604. }
  8605. }
  8606. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8607. import { Nullable } from "babylonjs/types";
  8608. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8609. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8610. /**
  8611. * Manage the keyboard inputs to control the movement of a free camera.
  8612. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8613. */
  8614. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8615. /**
  8616. * Defines the camera the input is attached to.
  8617. */
  8618. camera: FreeCamera;
  8619. /**
  8620. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8621. */
  8622. keysUp: number[];
  8623. /**
  8624. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8625. */
  8626. keysDown: number[];
  8627. /**
  8628. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8629. */
  8630. keysLeft: number[];
  8631. /**
  8632. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8633. */
  8634. keysRight: number[];
  8635. private _keys;
  8636. private _onCanvasBlurObserver;
  8637. private _onKeyboardObserver;
  8638. private _engine;
  8639. private _scene;
  8640. /**
  8641. * Attach the input controls to a specific dom element to get the input from.
  8642. * @param element Defines the element the controls should be listened from
  8643. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8644. */
  8645. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8646. /**
  8647. * Detach the current controls from the specified dom element.
  8648. * @param element Defines the element to stop listening the inputs from
  8649. */
  8650. detachControl(element: Nullable<HTMLElement>): void;
  8651. /**
  8652. * Update the current camera state depending on the inputs that have been used this frame.
  8653. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8654. */
  8655. checkInputs(): void;
  8656. /**
  8657. * Gets the class name of the current intput.
  8658. * @returns the class name
  8659. */
  8660. getClassName(): string;
  8661. /** @hidden */
  8662. _onLostFocus(): void;
  8663. /**
  8664. * Get the friendly name associated with the input class.
  8665. * @returns the input friendly name
  8666. */
  8667. getSimpleName(): string;
  8668. }
  8669. }
  8670. declare module "babylonjs/Lights/shadowLight" {
  8671. import { Camera } from "babylonjs/Cameras/camera";
  8672. import { Scene } from "babylonjs/scene";
  8673. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8675. import { Light } from "babylonjs/Lights/light";
  8676. /**
  8677. * Interface describing all the common properties and methods a shadow light needs to implement.
  8678. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8679. * as well as binding the different shadow properties to the effects.
  8680. */
  8681. export interface IShadowLight extends Light {
  8682. /**
  8683. * The light id in the scene (used in scene.findLighById for instance)
  8684. */
  8685. id: string;
  8686. /**
  8687. * The position the shdow will be casted from.
  8688. */
  8689. position: Vector3;
  8690. /**
  8691. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8692. */
  8693. direction: Vector3;
  8694. /**
  8695. * The transformed position. Position of the light in world space taking parenting in account.
  8696. */
  8697. transformedPosition: Vector3;
  8698. /**
  8699. * The transformed direction. Direction of the light in world space taking parenting in account.
  8700. */
  8701. transformedDirection: Vector3;
  8702. /**
  8703. * The friendly name of the light in the scene.
  8704. */
  8705. name: string;
  8706. /**
  8707. * Defines the shadow projection clipping minimum z value.
  8708. */
  8709. shadowMinZ: number;
  8710. /**
  8711. * Defines the shadow projection clipping maximum z value.
  8712. */
  8713. shadowMaxZ: number;
  8714. /**
  8715. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8716. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8717. */
  8718. computeTransformedInformation(): boolean;
  8719. /**
  8720. * Gets the scene the light belongs to.
  8721. * @returns The scene
  8722. */
  8723. getScene(): Scene;
  8724. /**
  8725. * Callback defining a custom Projection Matrix Builder.
  8726. * This can be used to override the default projection matrix computation.
  8727. */
  8728. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8729. /**
  8730. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8731. * @param matrix The materix to updated with the projection information
  8732. * @param viewMatrix The transform matrix of the light
  8733. * @param renderList The list of mesh to render in the map
  8734. * @returns The current light
  8735. */
  8736. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8737. /**
  8738. * Gets the current depth scale used in ESM.
  8739. * @returns The scale
  8740. */
  8741. getDepthScale(): number;
  8742. /**
  8743. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8744. * @returns true if a cube texture needs to be use
  8745. */
  8746. needCube(): boolean;
  8747. /**
  8748. * Detects if the projection matrix requires to be recomputed this frame.
  8749. * @returns true if it requires to be recomputed otherwise, false.
  8750. */
  8751. needProjectionMatrixCompute(): boolean;
  8752. /**
  8753. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8754. */
  8755. forceProjectionMatrixCompute(): void;
  8756. /**
  8757. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8758. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8759. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8760. */
  8761. getShadowDirection(faceIndex?: number): Vector3;
  8762. /**
  8763. * Gets the minZ used for shadow according to both the scene and the light.
  8764. * @param activeCamera The camera we are returning the min for
  8765. * @returns the depth min z
  8766. */
  8767. getDepthMinZ(activeCamera: Camera): number;
  8768. /**
  8769. * Gets the maxZ used for shadow according to both the scene and the light.
  8770. * @param activeCamera The camera we are returning the max for
  8771. * @returns the depth max z
  8772. */
  8773. getDepthMaxZ(activeCamera: Camera): number;
  8774. }
  8775. /**
  8776. * Base implementation IShadowLight
  8777. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8778. */
  8779. export abstract class ShadowLight extends Light implements IShadowLight {
  8780. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8781. protected _position: Vector3;
  8782. protected _setPosition(value: Vector3): void;
  8783. /**
  8784. * Sets the position the shadow will be casted from. Also use as the light position for both
  8785. * point and spot lights.
  8786. */
  8787. /**
  8788. * Sets the position the shadow will be casted from. Also use as the light position for both
  8789. * point and spot lights.
  8790. */
  8791. position: Vector3;
  8792. protected _direction: Vector3;
  8793. protected _setDirection(value: Vector3): void;
  8794. /**
  8795. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8796. * Also use as the light direction on spot and directional lights.
  8797. */
  8798. /**
  8799. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8800. * Also use as the light direction on spot and directional lights.
  8801. */
  8802. direction: Vector3;
  8803. private _shadowMinZ;
  8804. /**
  8805. * Gets the shadow projection clipping minimum z value.
  8806. */
  8807. /**
  8808. * Sets the shadow projection clipping minimum z value.
  8809. */
  8810. shadowMinZ: number;
  8811. private _shadowMaxZ;
  8812. /**
  8813. * Sets the shadow projection clipping maximum z value.
  8814. */
  8815. /**
  8816. * Gets the shadow projection clipping maximum z value.
  8817. */
  8818. shadowMaxZ: number;
  8819. /**
  8820. * Callback defining a custom Projection Matrix Builder.
  8821. * This can be used to override the default projection matrix computation.
  8822. */
  8823. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8824. /**
  8825. * The transformed position. Position of the light in world space taking parenting in account.
  8826. */
  8827. transformedPosition: Vector3;
  8828. /**
  8829. * The transformed direction. Direction of the light in world space taking parenting in account.
  8830. */
  8831. transformedDirection: Vector3;
  8832. private _needProjectionMatrixCompute;
  8833. /**
  8834. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8835. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8836. */
  8837. computeTransformedInformation(): boolean;
  8838. /**
  8839. * Return the depth scale used for the shadow map.
  8840. * @returns the depth scale.
  8841. */
  8842. getDepthScale(): number;
  8843. /**
  8844. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8845. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8846. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8847. */
  8848. getShadowDirection(faceIndex?: number): Vector3;
  8849. /**
  8850. * Returns the ShadowLight absolute position in the World.
  8851. * @returns the position vector in world space
  8852. */
  8853. getAbsolutePosition(): Vector3;
  8854. /**
  8855. * Sets the ShadowLight direction toward the passed target.
  8856. * @param target The point to target in local space
  8857. * @returns the updated ShadowLight direction
  8858. */
  8859. setDirectionToTarget(target: Vector3): Vector3;
  8860. /**
  8861. * Returns the light rotation in euler definition.
  8862. * @returns the x y z rotation in local space.
  8863. */
  8864. getRotation(): Vector3;
  8865. /**
  8866. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8867. * @returns true if a cube texture needs to be use
  8868. */
  8869. needCube(): boolean;
  8870. /**
  8871. * Detects if the projection matrix requires to be recomputed this frame.
  8872. * @returns true if it requires to be recomputed otherwise, false.
  8873. */
  8874. needProjectionMatrixCompute(): boolean;
  8875. /**
  8876. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8877. */
  8878. forceProjectionMatrixCompute(): void;
  8879. /** @hidden */
  8880. _initCache(): void;
  8881. /** @hidden */
  8882. _isSynchronized(): boolean;
  8883. /**
  8884. * Computes the world matrix of the node
  8885. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8886. * @returns the world matrix
  8887. */
  8888. computeWorldMatrix(force?: boolean): Matrix;
  8889. /**
  8890. * Gets the minZ used for shadow according to both the scene and the light.
  8891. * @param activeCamera The camera we are returning the min for
  8892. * @returns the depth min z
  8893. */
  8894. getDepthMinZ(activeCamera: Camera): number;
  8895. /**
  8896. * Gets the maxZ used for shadow according to both the scene and the light.
  8897. * @param activeCamera The camera we are returning the max for
  8898. * @returns the depth max z
  8899. */
  8900. getDepthMaxZ(activeCamera: Camera): number;
  8901. /**
  8902. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8903. * @param matrix The materix to updated with the projection information
  8904. * @param viewMatrix The transform matrix of the light
  8905. * @param renderList The list of mesh to render in the map
  8906. * @returns The current light
  8907. */
  8908. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8909. }
  8910. }
  8911. declare module "babylonjs/Materials/materialHelper" {
  8912. import { Nullable } from "babylonjs/types";
  8913. import { Scene } from "babylonjs/scene";
  8914. import { Engine } from "babylonjs/Engines/engine";
  8915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8916. import { Light } from "babylonjs/Lights/light";
  8917. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8918. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  8919. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8920. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8921. /**
  8922. * "Static Class" containing the most commonly used helper while dealing with material for
  8923. * rendering purpose.
  8924. *
  8925. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8926. *
  8927. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8928. */
  8929. export class MaterialHelper {
  8930. /**
  8931. * Bind the current view position to an effect.
  8932. * @param effect The effect to be bound
  8933. * @param scene The scene the eyes position is used from
  8934. */
  8935. static BindEyePosition(effect: Effect, scene: Scene): void;
  8936. /**
  8937. * Helps preparing the defines values about the UVs in used in the effect.
  8938. * UVs are shared as much as we can accross channels in the shaders.
  8939. * @param texture The texture we are preparing the UVs for
  8940. * @param defines The defines to update
  8941. * @param key The channel key "diffuse", "specular"... used in the shader
  8942. */
  8943. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8944. /**
  8945. * Binds a texture matrix value to its corrsponding uniform
  8946. * @param texture The texture to bind the matrix for
  8947. * @param uniformBuffer The uniform buffer receivin the data
  8948. * @param key The channel key "diffuse", "specular"... used in the shader
  8949. */
  8950. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8951. /**
  8952. * Gets the current status of the fog (should it be enabled?)
  8953. * @param mesh defines the mesh to evaluate for fog support
  8954. * @param scene defines the hosting scene
  8955. * @returns true if fog must be enabled
  8956. */
  8957. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8958. /**
  8959. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8960. * @param mesh defines the current mesh
  8961. * @param scene defines the current scene
  8962. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8963. * @param pointsCloud defines if point cloud rendering has to be turned on
  8964. * @param fogEnabled defines if fog has to be turned on
  8965. * @param alphaTest defines if alpha testing has to be turned on
  8966. * @param defines defines the current list of defines
  8967. */
  8968. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8969. /**
  8970. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8971. * @param scene defines the current scene
  8972. * @param engine defines the current engine
  8973. * @param defines specifies the list of active defines
  8974. * @param useInstances defines if instances have to be turned on
  8975. * @param useClipPlane defines if clip plane have to be turned on
  8976. */
  8977. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8978. /**
  8979. * Prepares the defines for bones
  8980. * @param mesh The mesh containing the geometry data we will draw
  8981. * @param defines The defines to update
  8982. */
  8983. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8984. /**
  8985. * Prepares the defines for morph targets
  8986. * @param mesh The mesh containing the geometry data we will draw
  8987. * @param defines The defines to update
  8988. */
  8989. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8990. /**
  8991. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8992. * @param mesh The mesh containing the geometry data we will draw
  8993. * @param defines The defines to update
  8994. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8995. * @param useBones Precise whether bones should be used or not (override mesh info)
  8996. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8997. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8998. * @returns false if defines are considered not dirty and have not been checked
  8999. */
  9000. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9001. /**
  9002. * Prepares the defines related to multiview
  9003. * @param scene The scene we are intending to draw
  9004. * @param defines The defines to update
  9005. */
  9006. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9007. /**
  9008. * Prepares the defines related to the light information passed in parameter
  9009. * @param scene The scene we are intending to draw
  9010. * @param mesh The mesh the effect is compiling for
  9011. * @param light The light the effect is compiling for
  9012. * @param lightIndex The index of the light
  9013. * @param defines The defines to update
  9014. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9015. * @param state Defines the current state regarding what is needed (normals, etc...)
  9016. */
  9017. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9018. needNormals: boolean;
  9019. needRebuild: boolean;
  9020. shadowEnabled: boolean;
  9021. specularEnabled: boolean;
  9022. lightmapMode: boolean;
  9023. }): void;
  9024. /**
  9025. * Prepares the defines related to the light information passed in parameter
  9026. * @param scene The scene we are intending to draw
  9027. * @param mesh The mesh the effect is compiling for
  9028. * @param defines The defines to update
  9029. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9030. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9031. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9032. * @returns true if normals will be required for the rest of the effect
  9033. */
  9034. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9035. /**
  9036. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9037. * @param lightIndex defines the light index
  9038. * @param uniformsList The uniform list
  9039. * @param samplersList The sampler list
  9040. * @param projectedLightTexture defines if projected texture must be used
  9041. * @param uniformBuffersList defines an optional list of uniform buffers
  9042. */
  9043. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9044. /**
  9045. * Prepares the uniforms and samplers list to be used in the effect
  9046. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9047. * @param samplersList The sampler list
  9048. * @param defines The defines helping in the list generation
  9049. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9050. */
  9051. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9052. /**
  9053. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9054. * @param defines The defines to update while falling back
  9055. * @param fallbacks The authorized effect fallbacks
  9056. * @param maxSimultaneousLights The maximum number of lights allowed
  9057. * @param rank the current rank of the Effect
  9058. * @returns The newly affected rank
  9059. */
  9060. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9061. private static _TmpMorphInfluencers;
  9062. /**
  9063. * Prepares the list of attributes required for morph targets according to the effect defines.
  9064. * @param attribs The current list of supported attribs
  9065. * @param mesh The mesh to prepare the morph targets attributes for
  9066. * @param influencers The number of influencers
  9067. */
  9068. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9069. /**
  9070. * Prepares the list of attributes required for morph targets according to the effect defines.
  9071. * @param attribs The current list of supported attribs
  9072. * @param mesh The mesh to prepare the morph targets attributes for
  9073. * @param defines The current Defines of the effect
  9074. */
  9075. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9076. /**
  9077. * Prepares the list of attributes required for bones according to the effect defines.
  9078. * @param attribs The current list of supported attribs
  9079. * @param mesh The mesh to prepare the bones attributes for
  9080. * @param defines The current Defines of the effect
  9081. * @param fallbacks The current efffect fallback strategy
  9082. */
  9083. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9084. /**
  9085. * Check and prepare the list of attributes required for instances according to the effect defines.
  9086. * @param attribs The current list of supported attribs
  9087. * @param defines The current MaterialDefines of the effect
  9088. */
  9089. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9090. /**
  9091. * Add the list of attributes required for instances to the attribs array.
  9092. * @param attribs The current list of supported attribs
  9093. */
  9094. static PushAttributesForInstances(attribs: string[]): void;
  9095. /**
  9096. * Binds the light shadow information to the effect for the given mesh.
  9097. * @param light The light containing the generator
  9098. * @param scene The scene the lights belongs to
  9099. * @param mesh The mesh we are binding the information to render
  9100. * @param lightIndex The light index in the effect used to render the mesh
  9101. * @param effect The effect we are binding the data to
  9102. */
  9103. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9104. /**
  9105. * Binds the light information to the effect.
  9106. * @param light The light containing the generator
  9107. * @param effect The effect we are binding the data to
  9108. * @param lightIndex The light index in the effect used to render
  9109. */
  9110. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9111. /**
  9112. * Binds the lights information from the scene to the effect for the given mesh.
  9113. * @param light Light to bind
  9114. * @param lightIndex Light index
  9115. * @param scene The scene where the light belongs to
  9116. * @param mesh The mesh we are binding the information to render
  9117. * @param effect The effect we are binding the data to
  9118. * @param useSpecular Defines if specular is supported
  9119. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9120. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9121. */
  9122. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9123. /**
  9124. * Binds the lights information from the scene to the effect for the given mesh.
  9125. * @param scene The scene the lights belongs to
  9126. * @param mesh The mesh we are binding the information to render
  9127. * @param effect The effect we are binding the data to
  9128. * @param defines The generated defines for the effect
  9129. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9130. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9131. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9132. */
  9133. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9134. private static _tempFogColor;
  9135. /**
  9136. * Binds the fog information from the scene to the effect for the given mesh.
  9137. * @param scene The scene the lights belongs to
  9138. * @param mesh The mesh we are binding the information to render
  9139. * @param effect The effect we are binding the data to
  9140. * @param linearSpace Defines if the fog effect is applied in linear space
  9141. */
  9142. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9143. /**
  9144. * Binds the bones information from the mesh to the effect.
  9145. * @param mesh The mesh we are binding the information to render
  9146. * @param effect The effect we are binding the data to
  9147. */
  9148. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9149. /**
  9150. * Binds the morph targets information from the mesh to the effect.
  9151. * @param abstractMesh The mesh we are binding the information to render
  9152. * @param effect The effect we are binding the data to
  9153. */
  9154. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9155. /**
  9156. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9157. * @param defines The generated defines used in the effect
  9158. * @param effect The effect we are binding the data to
  9159. * @param scene The scene we are willing to render with logarithmic scale for
  9160. */
  9161. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9162. /**
  9163. * Binds the clip plane information from the scene to the effect.
  9164. * @param scene The scene the clip plane information are extracted from
  9165. * @param effect The effect we are binding the data to
  9166. */
  9167. static BindClipPlane(effect: Effect, scene: Scene): void;
  9168. }
  9169. }
  9170. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9171. /** @hidden */
  9172. export var packingFunctions: {
  9173. name: string;
  9174. shader: string;
  9175. };
  9176. }
  9177. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9178. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9179. /** @hidden */
  9180. export var shadowMapPixelShader: {
  9181. name: string;
  9182. shader: string;
  9183. };
  9184. }
  9185. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9186. /** @hidden */
  9187. export var bonesDeclaration: {
  9188. name: string;
  9189. shader: string;
  9190. };
  9191. }
  9192. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9193. /** @hidden */
  9194. export var morphTargetsVertexGlobalDeclaration: {
  9195. name: string;
  9196. shader: string;
  9197. };
  9198. }
  9199. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9200. /** @hidden */
  9201. export var morphTargetsVertexDeclaration: {
  9202. name: string;
  9203. shader: string;
  9204. };
  9205. }
  9206. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9207. /** @hidden */
  9208. export var instancesDeclaration: {
  9209. name: string;
  9210. shader: string;
  9211. };
  9212. }
  9213. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9214. /** @hidden */
  9215. export var helperFunctions: {
  9216. name: string;
  9217. shader: string;
  9218. };
  9219. }
  9220. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9221. /** @hidden */
  9222. export var morphTargetsVertex: {
  9223. name: string;
  9224. shader: string;
  9225. };
  9226. }
  9227. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9228. /** @hidden */
  9229. export var instancesVertex: {
  9230. name: string;
  9231. shader: string;
  9232. };
  9233. }
  9234. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9235. /** @hidden */
  9236. export var bonesVertex: {
  9237. name: string;
  9238. shader: string;
  9239. };
  9240. }
  9241. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9242. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9243. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9244. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9245. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9246. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9247. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9248. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9249. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9250. /** @hidden */
  9251. export var shadowMapVertexShader: {
  9252. name: string;
  9253. shader: string;
  9254. };
  9255. }
  9256. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9257. /** @hidden */
  9258. export var depthBoxBlurPixelShader: {
  9259. name: string;
  9260. shader: string;
  9261. };
  9262. }
  9263. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9264. import { Nullable } from "babylonjs/types";
  9265. import { Scene } from "babylonjs/scene";
  9266. import { Matrix } from "babylonjs/Maths/math.vector";
  9267. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9269. import { Mesh } from "babylonjs/Meshes/mesh";
  9270. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9271. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9272. import { Effect } from "babylonjs/Materials/effect";
  9273. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9274. import "babylonjs/Shaders/shadowMap.fragment";
  9275. import "babylonjs/Shaders/shadowMap.vertex";
  9276. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9277. import { Observable } from "babylonjs/Misc/observable";
  9278. /**
  9279. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9280. */
  9281. export interface ICustomShaderOptions {
  9282. /**
  9283. * Gets or sets the custom shader name to use
  9284. */
  9285. shaderName: string;
  9286. /**
  9287. * The list of attribute names used in the shader
  9288. */
  9289. attributes?: string[];
  9290. /**
  9291. * The list of unifrom names used in the shader
  9292. */
  9293. uniforms?: string[];
  9294. /**
  9295. * The list of sampler names used in the shader
  9296. */
  9297. samplers?: string[];
  9298. /**
  9299. * The list of defines used in the shader
  9300. */
  9301. defines?: string[];
  9302. }
  9303. /**
  9304. * Interface to implement to create a shadow generator compatible with BJS.
  9305. */
  9306. export interface IShadowGenerator {
  9307. /**
  9308. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9309. * @returns The render target texture if present otherwise, null
  9310. */
  9311. getShadowMap(): Nullable<RenderTargetTexture>;
  9312. /**
  9313. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9314. * @returns The render target texture if the shadow map is present otherwise, null
  9315. */
  9316. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9317. /**
  9318. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9319. * @param subMesh The submesh we want to render in the shadow map
  9320. * @param useInstances Defines wether will draw in the map using instances
  9321. * @returns true if ready otherwise, false
  9322. */
  9323. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9324. /**
  9325. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9326. * @param defines Defines of the material we want to update
  9327. * @param lightIndex Index of the light in the enabled light list of the material
  9328. */
  9329. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9330. /**
  9331. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9332. * defined in the generator but impacting the effect).
  9333. * It implies the unifroms available on the materials are the standard BJS ones.
  9334. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9335. * @param effect The effect we are binfing the information for
  9336. */
  9337. bindShadowLight(lightIndex: string, effect: Effect): void;
  9338. /**
  9339. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9340. * (eq to shadow prjection matrix * light transform matrix)
  9341. * @returns The transform matrix used to create the shadow map
  9342. */
  9343. getTransformMatrix(): Matrix;
  9344. /**
  9345. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9346. * Cube and 2D textures for instance.
  9347. */
  9348. recreateShadowMap(): void;
  9349. /**
  9350. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9351. * @param onCompiled Callback triggered at the and of the effects compilation
  9352. * @param options Sets of optional options forcing the compilation with different modes
  9353. */
  9354. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9355. useInstances: boolean;
  9356. }>): void;
  9357. /**
  9358. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9359. * @param options Sets of optional options forcing the compilation with different modes
  9360. * @returns A promise that resolves when the compilation completes
  9361. */
  9362. forceCompilationAsync(options?: Partial<{
  9363. useInstances: boolean;
  9364. }>): Promise<void>;
  9365. /**
  9366. * Serializes the shadow generator setup to a json object.
  9367. * @returns The serialized JSON object
  9368. */
  9369. serialize(): any;
  9370. /**
  9371. * Disposes the Shadow map and related Textures and effects.
  9372. */
  9373. dispose(): void;
  9374. }
  9375. /**
  9376. * Default implementation IShadowGenerator.
  9377. * This is the main object responsible of generating shadows in the framework.
  9378. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9379. */
  9380. export class ShadowGenerator implements IShadowGenerator {
  9381. /**
  9382. * Shadow generator mode None: no filtering applied.
  9383. */
  9384. static readonly FILTER_NONE: number;
  9385. /**
  9386. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9387. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9388. */
  9389. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9390. /**
  9391. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9392. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9393. */
  9394. static readonly FILTER_POISSONSAMPLING: number;
  9395. /**
  9396. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9397. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9398. */
  9399. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9400. /**
  9401. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9402. * edge artifacts on steep falloff.
  9403. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9404. */
  9405. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9406. /**
  9407. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9408. * edge artifacts on steep falloff.
  9409. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9410. */
  9411. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9412. /**
  9413. * Shadow generator mode PCF: Percentage Closer Filtering
  9414. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9415. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9416. */
  9417. static readonly FILTER_PCF: number;
  9418. /**
  9419. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9420. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9421. * Contact Hardening
  9422. */
  9423. static readonly FILTER_PCSS: number;
  9424. /**
  9425. * Reserved for PCF and PCSS
  9426. * Highest Quality.
  9427. *
  9428. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9429. *
  9430. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9431. */
  9432. static readonly QUALITY_HIGH: number;
  9433. /**
  9434. * Reserved for PCF and PCSS
  9435. * Good tradeoff for quality/perf cross devices
  9436. *
  9437. * Execute PCF on a 3*3 kernel.
  9438. *
  9439. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9440. */
  9441. static readonly QUALITY_MEDIUM: number;
  9442. /**
  9443. * Reserved for PCF and PCSS
  9444. * The lowest quality but the fastest.
  9445. *
  9446. * Execute PCF on a 1*1 kernel.
  9447. *
  9448. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9449. */
  9450. static readonly QUALITY_LOW: number;
  9451. /** Gets or sets the custom shader name to use */
  9452. customShaderOptions: ICustomShaderOptions;
  9453. /**
  9454. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9455. */
  9456. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9457. /**
  9458. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9459. */
  9460. onAfterShadowMapRenderObservable: Observable<Effect>;
  9461. /**
  9462. * Observable triggered before a mesh is rendered in the shadow map.
  9463. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9464. */
  9465. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9466. /**
  9467. * Observable triggered after a mesh is rendered in the shadow map.
  9468. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9469. */
  9470. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9471. private _bias;
  9472. /**
  9473. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9474. */
  9475. /**
  9476. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9477. */
  9478. bias: number;
  9479. private _normalBias;
  9480. /**
  9481. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9482. */
  9483. /**
  9484. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9485. */
  9486. normalBias: number;
  9487. private _blurBoxOffset;
  9488. /**
  9489. * Gets the blur box offset: offset applied during the blur pass.
  9490. * Only useful if useKernelBlur = false
  9491. */
  9492. /**
  9493. * Sets the blur box offset: offset applied during the blur pass.
  9494. * Only useful if useKernelBlur = false
  9495. */
  9496. blurBoxOffset: number;
  9497. private _blurScale;
  9498. /**
  9499. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9500. * 2 means half of the size.
  9501. */
  9502. /**
  9503. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9504. * 2 means half of the size.
  9505. */
  9506. blurScale: number;
  9507. private _blurKernel;
  9508. /**
  9509. * Gets the blur kernel: kernel size of the blur pass.
  9510. * Only useful if useKernelBlur = true
  9511. */
  9512. /**
  9513. * Sets the blur kernel: kernel size of the blur pass.
  9514. * Only useful if useKernelBlur = true
  9515. */
  9516. blurKernel: number;
  9517. private _useKernelBlur;
  9518. /**
  9519. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9520. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9521. */
  9522. /**
  9523. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9524. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9525. */
  9526. useKernelBlur: boolean;
  9527. private _depthScale;
  9528. /**
  9529. * Gets the depth scale used in ESM mode.
  9530. */
  9531. /**
  9532. * Sets the depth scale used in ESM mode.
  9533. * This can override the scale stored on the light.
  9534. */
  9535. depthScale: number;
  9536. private _filter;
  9537. /**
  9538. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9539. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9540. */
  9541. /**
  9542. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9543. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9544. */
  9545. filter: number;
  9546. /**
  9547. * Gets if the current filter is set to Poisson Sampling.
  9548. */
  9549. /**
  9550. * Sets the current filter to Poisson Sampling.
  9551. */
  9552. usePoissonSampling: boolean;
  9553. /**
  9554. * Gets if the current filter is set to ESM.
  9555. */
  9556. /**
  9557. * Sets the current filter is to ESM.
  9558. */
  9559. useExponentialShadowMap: boolean;
  9560. /**
  9561. * Gets if the current filter is set to filtered ESM.
  9562. */
  9563. /**
  9564. * Gets if the current filter is set to filtered ESM.
  9565. */
  9566. useBlurExponentialShadowMap: boolean;
  9567. /**
  9568. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9569. * exponential to prevent steep falloff artifacts).
  9570. */
  9571. /**
  9572. * Sets the current filter to "close ESM" (using the inverse of the
  9573. * exponential to prevent steep falloff artifacts).
  9574. */
  9575. useCloseExponentialShadowMap: boolean;
  9576. /**
  9577. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9578. * exponential to prevent steep falloff artifacts).
  9579. */
  9580. /**
  9581. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9582. * exponential to prevent steep falloff artifacts).
  9583. */
  9584. useBlurCloseExponentialShadowMap: boolean;
  9585. /**
  9586. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9587. */
  9588. /**
  9589. * Sets the current filter to "PCF" (percentage closer filtering).
  9590. */
  9591. usePercentageCloserFiltering: boolean;
  9592. private _filteringQuality;
  9593. /**
  9594. * Gets the PCF or PCSS Quality.
  9595. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9596. */
  9597. /**
  9598. * Sets the PCF or PCSS Quality.
  9599. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9600. */
  9601. filteringQuality: number;
  9602. /**
  9603. * Gets if the current filter is set to "PCSS" (contact hardening).
  9604. */
  9605. /**
  9606. * Sets the current filter to "PCSS" (contact hardening).
  9607. */
  9608. useContactHardeningShadow: boolean;
  9609. private _contactHardeningLightSizeUVRatio;
  9610. /**
  9611. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9612. * Using a ratio helps keeping shape stability independently of the map size.
  9613. *
  9614. * It does not account for the light projection as it was having too much
  9615. * instability during the light setup or during light position changes.
  9616. *
  9617. * Only valid if useContactHardeningShadow is true.
  9618. */
  9619. /**
  9620. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9621. * Using a ratio helps keeping shape stability independently of the map size.
  9622. *
  9623. * It does not account for the light projection as it was having too much
  9624. * instability during the light setup or during light position changes.
  9625. *
  9626. * Only valid if useContactHardeningShadow is true.
  9627. */
  9628. contactHardeningLightSizeUVRatio: number;
  9629. private _darkness;
  9630. /** Gets or sets the actual darkness of a shadow */
  9631. darkness: number;
  9632. /**
  9633. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9634. * 0 means strongest and 1 would means no shadow.
  9635. * @returns the darkness.
  9636. */
  9637. getDarkness(): number;
  9638. /**
  9639. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9640. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9641. * @returns the shadow generator allowing fluent coding.
  9642. */
  9643. setDarkness(darkness: number): ShadowGenerator;
  9644. private _transparencyShadow;
  9645. /** Gets or sets the ability to have transparent shadow */
  9646. transparencyShadow: boolean;
  9647. /**
  9648. * Sets the ability to have transparent shadow (boolean).
  9649. * @param transparent True if transparent else False
  9650. * @returns the shadow generator allowing fluent coding
  9651. */
  9652. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9653. private _shadowMap;
  9654. private _shadowMap2;
  9655. /**
  9656. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9657. * @returns The render target texture if present otherwise, null
  9658. */
  9659. getShadowMap(): Nullable<RenderTargetTexture>;
  9660. /**
  9661. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9662. * @returns The render target texture if the shadow map is present otherwise, null
  9663. */
  9664. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9665. /**
  9666. * Gets the class name of that object
  9667. * @returns "ShadowGenerator"
  9668. */
  9669. getClassName(): string;
  9670. /**
  9671. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9672. * @param mesh Mesh to add
  9673. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9674. * @returns the Shadow Generator itself
  9675. */
  9676. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9677. /**
  9678. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9679. * @param mesh Mesh to remove
  9680. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9681. * @returns the Shadow Generator itself
  9682. */
  9683. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9684. /**
  9685. * Controls the extent to which the shadows fade out at the edge of the frustum
  9686. * Used only by directionals and spots
  9687. */
  9688. frustumEdgeFalloff: number;
  9689. private _light;
  9690. /**
  9691. * Returns the associated light object.
  9692. * @returns the light generating the shadow
  9693. */
  9694. getLight(): IShadowLight;
  9695. /**
  9696. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9697. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9698. * It might on the other hand introduce peter panning.
  9699. */
  9700. forceBackFacesOnly: boolean;
  9701. private _scene;
  9702. private _lightDirection;
  9703. private _effect;
  9704. private _viewMatrix;
  9705. private _projectionMatrix;
  9706. private _transformMatrix;
  9707. private _cachedPosition;
  9708. private _cachedDirection;
  9709. private _cachedDefines;
  9710. private _currentRenderID;
  9711. private _boxBlurPostprocess;
  9712. private _kernelBlurXPostprocess;
  9713. private _kernelBlurYPostprocess;
  9714. private _blurPostProcesses;
  9715. private _mapSize;
  9716. private _currentFaceIndex;
  9717. private _currentFaceIndexCache;
  9718. private _textureType;
  9719. private _defaultTextureMatrix;
  9720. /** @hidden */
  9721. static _SceneComponentInitialization: (scene: Scene) => void;
  9722. /**
  9723. * Creates a ShadowGenerator object.
  9724. * A ShadowGenerator is the required tool to use the shadows.
  9725. * Each light casting shadows needs to use its own ShadowGenerator.
  9726. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9727. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9728. * @param light The light object generating the shadows.
  9729. * @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.
  9730. */
  9731. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9732. private _initializeGenerator;
  9733. private _initializeShadowMap;
  9734. private _initializeBlurRTTAndPostProcesses;
  9735. private _renderForShadowMap;
  9736. private _renderSubMeshForShadowMap;
  9737. private _applyFilterValues;
  9738. /**
  9739. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9740. * @param onCompiled Callback triggered at the and of the effects compilation
  9741. * @param options Sets of optional options forcing the compilation with different modes
  9742. */
  9743. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9744. useInstances: boolean;
  9745. }>): void;
  9746. /**
  9747. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9748. * @param options Sets of optional options forcing the compilation with different modes
  9749. * @returns A promise that resolves when the compilation completes
  9750. */
  9751. forceCompilationAsync(options?: Partial<{
  9752. useInstances: boolean;
  9753. }>): Promise<void>;
  9754. /**
  9755. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9756. * @param subMesh The submesh we want to render in the shadow map
  9757. * @param useInstances Defines wether will draw in the map using instances
  9758. * @returns true if ready otherwise, false
  9759. */
  9760. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9761. /**
  9762. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9763. * @param defines Defines of the material we want to update
  9764. * @param lightIndex Index of the light in the enabled light list of the material
  9765. */
  9766. prepareDefines(defines: any, lightIndex: number): void;
  9767. /**
  9768. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9769. * defined in the generator but impacting the effect).
  9770. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9771. * @param effect The effect we are binfing the information for
  9772. */
  9773. bindShadowLight(lightIndex: string, effect: Effect): void;
  9774. /**
  9775. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9776. * (eq to shadow prjection matrix * light transform matrix)
  9777. * @returns The transform matrix used to create the shadow map
  9778. */
  9779. getTransformMatrix(): Matrix;
  9780. /**
  9781. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9782. * Cube and 2D textures for instance.
  9783. */
  9784. recreateShadowMap(): void;
  9785. private _disposeBlurPostProcesses;
  9786. private _disposeRTTandPostProcesses;
  9787. /**
  9788. * Disposes the ShadowGenerator.
  9789. * Returns nothing.
  9790. */
  9791. dispose(): void;
  9792. /**
  9793. * Serializes the shadow generator setup to a json object.
  9794. * @returns The serialized JSON object
  9795. */
  9796. serialize(): any;
  9797. /**
  9798. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9799. * @param parsedShadowGenerator The JSON object to parse
  9800. * @param scene The scene to create the shadow map for
  9801. * @returns The parsed shadow generator
  9802. */
  9803. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9804. }
  9805. }
  9806. declare module "babylonjs/Lights/light" {
  9807. import { Nullable } from "babylonjs/types";
  9808. import { Scene } from "babylonjs/scene";
  9809. import { Vector3 } from "babylonjs/Maths/math.vector";
  9810. import { Color3 } from "babylonjs/Maths/math.color";
  9811. import { Node } from "babylonjs/node";
  9812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9813. import { Effect } from "babylonjs/Materials/effect";
  9814. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9815. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9816. /**
  9817. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9818. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9819. * 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.
  9820. */
  9821. export abstract class Light extends Node {
  9822. /**
  9823. * Falloff Default: light is falling off following the material specification:
  9824. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9825. */
  9826. static readonly FALLOFF_DEFAULT: number;
  9827. /**
  9828. * Falloff Physical: light is falling off following the inverse squared distance law.
  9829. */
  9830. static readonly FALLOFF_PHYSICAL: number;
  9831. /**
  9832. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9833. * to enhance interoperability with other engines.
  9834. */
  9835. static readonly FALLOFF_GLTF: number;
  9836. /**
  9837. * Falloff Standard: light is falling off like in the standard material
  9838. * to enhance interoperability with other materials.
  9839. */
  9840. static readonly FALLOFF_STANDARD: number;
  9841. /**
  9842. * If every light affecting the material is in this lightmapMode,
  9843. * material.lightmapTexture adds or multiplies
  9844. * (depends on material.useLightmapAsShadowmap)
  9845. * after every other light calculations.
  9846. */
  9847. static readonly LIGHTMAP_DEFAULT: number;
  9848. /**
  9849. * material.lightmapTexture as only diffuse lighting from this light
  9850. * adds only specular lighting from this light
  9851. * adds dynamic shadows
  9852. */
  9853. static readonly LIGHTMAP_SPECULAR: number;
  9854. /**
  9855. * material.lightmapTexture as only lighting
  9856. * no light calculation from this light
  9857. * only adds dynamic shadows from this light
  9858. */
  9859. static readonly LIGHTMAP_SHADOWSONLY: number;
  9860. /**
  9861. * Each light type uses the default quantity according to its type:
  9862. * point/spot lights use luminous intensity
  9863. * directional lights use illuminance
  9864. */
  9865. static readonly INTENSITYMODE_AUTOMATIC: number;
  9866. /**
  9867. * lumen (lm)
  9868. */
  9869. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9870. /**
  9871. * candela (lm/sr)
  9872. */
  9873. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9874. /**
  9875. * lux (lm/m^2)
  9876. */
  9877. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9878. /**
  9879. * nit (cd/m^2)
  9880. */
  9881. static readonly INTENSITYMODE_LUMINANCE: number;
  9882. /**
  9883. * Light type const id of the point light.
  9884. */
  9885. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9886. /**
  9887. * Light type const id of the directional light.
  9888. */
  9889. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9890. /**
  9891. * Light type const id of the spot light.
  9892. */
  9893. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9894. /**
  9895. * Light type const id of the hemispheric light.
  9896. */
  9897. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9898. /**
  9899. * Diffuse gives the basic color to an object.
  9900. */
  9901. diffuse: Color3;
  9902. /**
  9903. * Specular produces a highlight color on an object.
  9904. * Note: This is note affecting PBR materials.
  9905. */
  9906. specular: Color3;
  9907. /**
  9908. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9909. * falling off base on range or angle.
  9910. * This can be set to any values in Light.FALLOFF_x.
  9911. *
  9912. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9913. * other types of materials.
  9914. */
  9915. falloffType: number;
  9916. /**
  9917. * Strength of the light.
  9918. * Note: By default it is define in the framework own unit.
  9919. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9920. */
  9921. intensity: number;
  9922. private _range;
  9923. protected _inverseSquaredRange: number;
  9924. /**
  9925. * Defines how far from the source the light is impacting in scene units.
  9926. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9927. */
  9928. /**
  9929. * Defines how far from the source the light is impacting in scene units.
  9930. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9931. */
  9932. range: number;
  9933. /**
  9934. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9935. * of light.
  9936. */
  9937. private _photometricScale;
  9938. private _intensityMode;
  9939. /**
  9940. * Gets the photometric scale used to interpret the intensity.
  9941. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9942. */
  9943. /**
  9944. * Sets the photometric scale used to interpret the intensity.
  9945. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9946. */
  9947. intensityMode: number;
  9948. private _radius;
  9949. /**
  9950. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9951. */
  9952. /**
  9953. * sets the light radius used by PBR Materials to simulate soft area lights.
  9954. */
  9955. radius: number;
  9956. private _renderPriority;
  9957. /**
  9958. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9959. * exceeding the number allowed of the materials.
  9960. */
  9961. renderPriority: number;
  9962. private _shadowEnabled;
  9963. /**
  9964. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9965. * the current shadow generator.
  9966. */
  9967. /**
  9968. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9969. * the current shadow generator.
  9970. */
  9971. shadowEnabled: boolean;
  9972. private _includedOnlyMeshes;
  9973. /**
  9974. * Gets the only meshes impacted by this light.
  9975. */
  9976. /**
  9977. * Sets the only meshes impacted by this light.
  9978. */
  9979. includedOnlyMeshes: AbstractMesh[];
  9980. private _excludedMeshes;
  9981. /**
  9982. * Gets the meshes not impacted by this light.
  9983. */
  9984. /**
  9985. * Sets the meshes not impacted by this light.
  9986. */
  9987. excludedMeshes: AbstractMesh[];
  9988. private _excludeWithLayerMask;
  9989. /**
  9990. * Gets the layer id use to find what meshes are not impacted by the light.
  9991. * Inactive if 0
  9992. */
  9993. /**
  9994. * Sets the layer id use to find what meshes are not impacted by the light.
  9995. * Inactive if 0
  9996. */
  9997. excludeWithLayerMask: number;
  9998. private _includeOnlyWithLayerMask;
  9999. /**
  10000. * Gets the layer id use to find what meshes are impacted by the light.
  10001. * Inactive if 0
  10002. */
  10003. /**
  10004. * Sets the layer id use to find what meshes are impacted by the light.
  10005. * Inactive if 0
  10006. */
  10007. includeOnlyWithLayerMask: number;
  10008. private _lightmapMode;
  10009. /**
  10010. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10011. */
  10012. /**
  10013. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10014. */
  10015. lightmapMode: number;
  10016. /**
  10017. * Shadow generator associted to the light.
  10018. * @hidden Internal use only.
  10019. */
  10020. _shadowGenerator: Nullable<IShadowGenerator>;
  10021. /**
  10022. * @hidden Internal use only.
  10023. */
  10024. _excludedMeshesIds: string[];
  10025. /**
  10026. * @hidden Internal use only.
  10027. */
  10028. _includedOnlyMeshesIds: string[];
  10029. /**
  10030. * The current light unifom buffer.
  10031. * @hidden Internal use only.
  10032. */
  10033. _uniformBuffer: UniformBuffer;
  10034. /**
  10035. * Creates a Light object in the scene.
  10036. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10037. * @param name The firendly name of the light
  10038. * @param scene The scene the light belongs too
  10039. */
  10040. constructor(name: string, scene: Scene);
  10041. protected abstract _buildUniformLayout(): void;
  10042. /**
  10043. * Sets the passed Effect "effect" with the Light information.
  10044. * @param effect The effect to update
  10045. * @param lightIndex The index of the light in the effect to update
  10046. * @returns The light
  10047. */
  10048. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10049. /**
  10050. * Sets the passed Effect "effect" with the Light information.
  10051. * @param effect The effect to update
  10052. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10053. * @returns The light
  10054. */
  10055. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10056. /**
  10057. * Returns the string "Light".
  10058. * @returns the class name
  10059. */
  10060. getClassName(): string;
  10061. /** @hidden */
  10062. readonly _isLight: boolean;
  10063. /**
  10064. * Converts the light information to a readable string for debug purpose.
  10065. * @param fullDetails Supports for multiple levels of logging within scene loading
  10066. * @returns the human readable light info
  10067. */
  10068. toString(fullDetails?: boolean): string;
  10069. /** @hidden */
  10070. protected _syncParentEnabledState(): void;
  10071. /**
  10072. * Set the enabled state of this node.
  10073. * @param value - the new enabled state
  10074. */
  10075. setEnabled(value: boolean): void;
  10076. /**
  10077. * Returns the Light associated shadow generator if any.
  10078. * @return the associated shadow generator.
  10079. */
  10080. getShadowGenerator(): Nullable<IShadowGenerator>;
  10081. /**
  10082. * Returns a Vector3, the absolute light position in the World.
  10083. * @returns the world space position of the light
  10084. */
  10085. getAbsolutePosition(): Vector3;
  10086. /**
  10087. * Specifies if the light will affect the passed mesh.
  10088. * @param mesh The mesh to test against the light
  10089. * @return true the mesh is affected otherwise, false.
  10090. */
  10091. canAffectMesh(mesh: AbstractMesh): boolean;
  10092. /**
  10093. * Sort function to order lights for rendering.
  10094. * @param a First Light object to compare to second.
  10095. * @param b Second Light object to compare first.
  10096. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10097. */
  10098. static CompareLightsPriority(a: Light, b: Light): number;
  10099. /**
  10100. * Releases resources associated with this node.
  10101. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10102. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10103. */
  10104. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10105. /**
  10106. * Returns the light type ID (integer).
  10107. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10108. */
  10109. getTypeID(): number;
  10110. /**
  10111. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10112. * @returns the scaled intensity in intensity mode unit
  10113. */
  10114. getScaledIntensity(): number;
  10115. /**
  10116. * Returns a new Light object, named "name", from the current one.
  10117. * @param name The name of the cloned light
  10118. * @returns the new created light
  10119. */
  10120. clone(name: string): Nullable<Light>;
  10121. /**
  10122. * Serializes the current light into a Serialization object.
  10123. * @returns the serialized object.
  10124. */
  10125. serialize(): any;
  10126. /**
  10127. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10128. * This new light is named "name" and added to the passed scene.
  10129. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10130. * @param name The friendly name of the light
  10131. * @param scene The scene the new light will belong to
  10132. * @returns the constructor function
  10133. */
  10134. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10135. /**
  10136. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10137. * @param parsedLight The JSON representation of the light
  10138. * @param scene The scene to create the parsed light in
  10139. * @returns the created light after parsing
  10140. */
  10141. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10142. private _hookArrayForExcluded;
  10143. private _hookArrayForIncludedOnly;
  10144. private _resyncMeshes;
  10145. /**
  10146. * Forces the meshes to update their light related information in their rendering used effects
  10147. * @hidden Internal Use Only
  10148. */
  10149. _markMeshesAsLightDirty(): void;
  10150. /**
  10151. * Recomputes the cached photometric scale if needed.
  10152. */
  10153. private _computePhotometricScale;
  10154. /**
  10155. * Returns the Photometric Scale according to the light type and intensity mode.
  10156. */
  10157. private _getPhotometricScale;
  10158. /**
  10159. * Reorder the light in the scene according to their defined priority.
  10160. * @hidden Internal Use Only
  10161. */
  10162. _reorderLightsInScene(): void;
  10163. /**
  10164. * Prepares the list of defines specific to the light type.
  10165. * @param defines the list of defines
  10166. * @param lightIndex defines the index of the light for the effect
  10167. */
  10168. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10169. }
  10170. }
  10171. declare module "babylonjs/Actions/action" {
  10172. import { Observable } from "babylonjs/Misc/observable";
  10173. import { Condition } from "babylonjs/Actions/condition";
  10174. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10175. import { ActionManager } from "babylonjs/Actions/actionManager";
  10176. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10177. /**
  10178. * Interface used to define Action
  10179. */
  10180. export interface IAction {
  10181. /**
  10182. * Trigger for the action
  10183. */
  10184. trigger: number;
  10185. /** Options of the trigger */
  10186. triggerOptions: any;
  10187. /**
  10188. * Gets the trigger parameters
  10189. * @returns the trigger parameters
  10190. */
  10191. getTriggerParameter(): any;
  10192. /**
  10193. * Internal only - executes current action event
  10194. * @hidden
  10195. */
  10196. _executeCurrent(evt?: ActionEvent): void;
  10197. /**
  10198. * Serialize placeholder for child classes
  10199. * @param parent of child
  10200. * @returns the serialized object
  10201. */
  10202. serialize(parent: any): any;
  10203. /**
  10204. * Internal only
  10205. * @hidden
  10206. */
  10207. _prepare(): void;
  10208. /**
  10209. * Internal only - manager for action
  10210. * @hidden
  10211. */
  10212. _actionManager: AbstractActionManager;
  10213. /**
  10214. * Adds action to chain of actions, may be a DoNothingAction
  10215. * @param action defines the next action to execute
  10216. * @returns The action passed in
  10217. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10218. */
  10219. then(action: IAction): IAction;
  10220. }
  10221. /**
  10222. * The action to be carried out following a trigger
  10223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10224. */
  10225. export class Action implements IAction {
  10226. /** the trigger, with or without parameters, for the action */
  10227. triggerOptions: any;
  10228. /**
  10229. * Trigger for the action
  10230. */
  10231. trigger: number;
  10232. /**
  10233. * Internal only - manager for action
  10234. * @hidden
  10235. */
  10236. _actionManager: ActionManager;
  10237. private _nextActiveAction;
  10238. private _child;
  10239. private _condition?;
  10240. private _triggerParameter;
  10241. /**
  10242. * An event triggered prior to action being executed.
  10243. */
  10244. onBeforeExecuteObservable: Observable<Action>;
  10245. /**
  10246. * Creates a new Action
  10247. * @param triggerOptions the trigger, with or without parameters, for the action
  10248. * @param condition an optional determinant of action
  10249. */
  10250. constructor(
  10251. /** the trigger, with or without parameters, for the action */
  10252. triggerOptions: any, condition?: Condition);
  10253. /**
  10254. * Internal only
  10255. * @hidden
  10256. */
  10257. _prepare(): void;
  10258. /**
  10259. * Gets the trigger parameters
  10260. * @returns the trigger parameters
  10261. */
  10262. getTriggerParameter(): any;
  10263. /**
  10264. * Internal only - executes current action event
  10265. * @hidden
  10266. */
  10267. _executeCurrent(evt?: ActionEvent): void;
  10268. /**
  10269. * Execute placeholder for child classes
  10270. * @param evt optional action event
  10271. */
  10272. execute(evt?: ActionEvent): void;
  10273. /**
  10274. * Skips to next active action
  10275. */
  10276. skipToNextActiveAction(): void;
  10277. /**
  10278. * Adds action to chain of actions, may be a DoNothingAction
  10279. * @param action defines the next action to execute
  10280. * @returns The action passed in
  10281. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10282. */
  10283. then(action: Action): Action;
  10284. /**
  10285. * Internal only
  10286. * @hidden
  10287. */
  10288. _getProperty(propertyPath: string): string;
  10289. /**
  10290. * Internal only
  10291. * @hidden
  10292. */
  10293. _getEffectiveTarget(target: any, propertyPath: string): any;
  10294. /**
  10295. * Serialize placeholder for child classes
  10296. * @param parent of child
  10297. * @returns the serialized object
  10298. */
  10299. serialize(parent: any): any;
  10300. /**
  10301. * Internal only called by serialize
  10302. * @hidden
  10303. */
  10304. protected _serialize(serializedAction: any, parent?: any): any;
  10305. /**
  10306. * Internal only
  10307. * @hidden
  10308. */
  10309. static _SerializeValueAsString: (value: any) => string;
  10310. /**
  10311. * Internal only
  10312. * @hidden
  10313. */
  10314. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10315. name: string;
  10316. targetType: string;
  10317. value: string;
  10318. };
  10319. }
  10320. }
  10321. declare module "babylonjs/Actions/condition" {
  10322. import { ActionManager } from "babylonjs/Actions/actionManager";
  10323. /**
  10324. * A Condition applied to an Action
  10325. */
  10326. export class Condition {
  10327. /**
  10328. * Internal only - manager for action
  10329. * @hidden
  10330. */
  10331. _actionManager: ActionManager;
  10332. /**
  10333. * Internal only
  10334. * @hidden
  10335. */
  10336. _evaluationId: number;
  10337. /**
  10338. * Internal only
  10339. * @hidden
  10340. */
  10341. _currentResult: boolean;
  10342. /**
  10343. * Creates a new Condition
  10344. * @param actionManager the manager of the action the condition is applied to
  10345. */
  10346. constructor(actionManager: ActionManager);
  10347. /**
  10348. * Check if the current condition is valid
  10349. * @returns a boolean
  10350. */
  10351. isValid(): boolean;
  10352. /**
  10353. * Internal only
  10354. * @hidden
  10355. */
  10356. _getProperty(propertyPath: string): string;
  10357. /**
  10358. * Internal only
  10359. * @hidden
  10360. */
  10361. _getEffectiveTarget(target: any, propertyPath: string): any;
  10362. /**
  10363. * Serialize placeholder for child classes
  10364. * @returns the serialized object
  10365. */
  10366. serialize(): any;
  10367. /**
  10368. * Internal only
  10369. * @hidden
  10370. */
  10371. protected _serialize(serializedCondition: any): any;
  10372. }
  10373. /**
  10374. * Defines specific conditional operators as extensions of Condition
  10375. */
  10376. export class ValueCondition extends Condition {
  10377. /** path to specify the property of the target the conditional operator uses */
  10378. propertyPath: string;
  10379. /** the value compared by the conditional operator against the current value of the property */
  10380. value: any;
  10381. /** the conditional operator, default ValueCondition.IsEqual */
  10382. operator: number;
  10383. /**
  10384. * Internal only
  10385. * @hidden
  10386. */
  10387. private static _IsEqual;
  10388. /**
  10389. * Internal only
  10390. * @hidden
  10391. */
  10392. private static _IsDifferent;
  10393. /**
  10394. * Internal only
  10395. * @hidden
  10396. */
  10397. private static _IsGreater;
  10398. /**
  10399. * Internal only
  10400. * @hidden
  10401. */
  10402. private static _IsLesser;
  10403. /**
  10404. * returns the number for IsEqual
  10405. */
  10406. static readonly IsEqual: number;
  10407. /**
  10408. * Returns the number for IsDifferent
  10409. */
  10410. static readonly IsDifferent: number;
  10411. /**
  10412. * Returns the number for IsGreater
  10413. */
  10414. static readonly IsGreater: number;
  10415. /**
  10416. * Returns the number for IsLesser
  10417. */
  10418. static readonly IsLesser: number;
  10419. /**
  10420. * Internal only The action manager for the condition
  10421. * @hidden
  10422. */
  10423. _actionManager: ActionManager;
  10424. /**
  10425. * Internal only
  10426. * @hidden
  10427. */
  10428. private _target;
  10429. /**
  10430. * Internal only
  10431. * @hidden
  10432. */
  10433. private _effectiveTarget;
  10434. /**
  10435. * Internal only
  10436. * @hidden
  10437. */
  10438. private _property;
  10439. /**
  10440. * Creates a new ValueCondition
  10441. * @param actionManager manager for the action the condition applies to
  10442. * @param target for the action
  10443. * @param propertyPath path to specify the property of the target the conditional operator uses
  10444. * @param value the value compared by the conditional operator against the current value of the property
  10445. * @param operator the conditional operator, default ValueCondition.IsEqual
  10446. */
  10447. constructor(actionManager: ActionManager, target: any,
  10448. /** path to specify the property of the target the conditional operator uses */
  10449. propertyPath: string,
  10450. /** the value compared by the conditional operator against the current value of the property */
  10451. value: any,
  10452. /** the conditional operator, default ValueCondition.IsEqual */
  10453. operator?: number);
  10454. /**
  10455. * Compares the given value with the property value for the specified conditional operator
  10456. * @returns the result of the comparison
  10457. */
  10458. isValid(): boolean;
  10459. /**
  10460. * Serialize the ValueCondition into a JSON compatible object
  10461. * @returns serialization object
  10462. */
  10463. serialize(): any;
  10464. /**
  10465. * Gets the name of the conditional operator for the ValueCondition
  10466. * @param operator the conditional operator
  10467. * @returns the name
  10468. */
  10469. static GetOperatorName(operator: number): string;
  10470. }
  10471. /**
  10472. * Defines a predicate condition as an extension of Condition
  10473. */
  10474. export class PredicateCondition extends Condition {
  10475. /** defines the predicate function used to validate the condition */
  10476. predicate: () => boolean;
  10477. /**
  10478. * Internal only - manager for action
  10479. * @hidden
  10480. */
  10481. _actionManager: ActionManager;
  10482. /**
  10483. * Creates a new PredicateCondition
  10484. * @param actionManager manager for the action the condition applies to
  10485. * @param predicate defines the predicate function used to validate the condition
  10486. */
  10487. constructor(actionManager: ActionManager,
  10488. /** defines the predicate function used to validate the condition */
  10489. predicate: () => boolean);
  10490. /**
  10491. * @returns the validity of the predicate condition
  10492. */
  10493. isValid(): boolean;
  10494. }
  10495. /**
  10496. * Defines a state condition as an extension of Condition
  10497. */
  10498. export class StateCondition extends Condition {
  10499. /** Value to compare with target state */
  10500. value: string;
  10501. /**
  10502. * Internal only - manager for action
  10503. * @hidden
  10504. */
  10505. _actionManager: ActionManager;
  10506. /**
  10507. * Internal only
  10508. * @hidden
  10509. */
  10510. private _target;
  10511. /**
  10512. * Creates a new StateCondition
  10513. * @param actionManager manager for the action the condition applies to
  10514. * @param target of the condition
  10515. * @param value to compare with target state
  10516. */
  10517. constructor(actionManager: ActionManager, target: any,
  10518. /** Value to compare with target state */
  10519. value: string);
  10520. /**
  10521. * Gets a boolean indicating if the current condition is met
  10522. * @returns the validity of the state
  10523. */
  10524. isValid(): boolean;
  10525. /**
  10526. * Serialize the StateCondition into a JSON compatible object
  10527. * @returns serialization object
  10528. */
  10529. serialize(): any;
  10530. }
  10531. }
  10532. declare module "babylonjs/Actions/directActions" {
  10533. import { Action } from "babylonjs/Actions/action";
  10534. import { Condition } from "babylonjs/Actions/condition";
  10535. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10536. /**
  10537. * This defines an action responsible to toggle a boolean once triggered.
  10538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10539. */
  10540. export class SwitchBooleanAction extends Action {
  10541. /**
  10542. * The path to the boolean property in the target object
  10543. */
  10544. propertyPath: string;
  10545. private _target;
  10546. private _effectiveTarget;
  10547. private _property;
  10548. /**
  10549. * Instantiate the action
  10550. * @param triggerOptions defines the trigger options
  10551. * @param target defines the object containing the boolean
  10552. * @param propertyPath defines the path to the boolean property in the target object
  10553. * @param condition defines the trigger related conditions
  10554. */
  10555. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10556. /** @hidden */
  10557. _prepare(): void;
  10558. /**
  10559. * Execute the action toggle the boolean value.
  10560. */
  10561. execute(): void;
  10562. /**
  10563. * Serializes the actions and its related information.
  10564. * @param parent defines the object to serialize in
  10565. * @returns the serialized object
  10566. */
  10567. serialize(parent: any): any;
  10568. }
  10569. /**
  10570. * This defines an action responsible to set a the state field of the target
  10571. * to a desired value once triggered.
  10572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10573. */
  10574. export class SetStateAction extends Action {
  10575. /**
  10576. * The value to store in the state field.
  10577. */
  10578. value: string;
  10579. private _target;
  10580. /**
  10581. * Instantiate the action
  10582. * @param triggerOptions defines the trigger options
  10583. * @param target defines the object containing the state property
  10584. * @param value defines the value to store in the state field
  10585. * @param condition defines the trigger related conditions
  10586. */
  10587. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10588. /**
  10589. * Execute the action and store the value on the target state property.
  10590. */
  10591. execute(): void;
  10592. /**
  10593. * Serializes the actions and its related information.
  10594. * @param parent defines the object to serialize in
  10595. * @returns the serialized object
  10596. */
  10597. serialize(parent: any): any;
  10598. }
  10599. /**
  10600. * This defines an action responsible to set a property of the target
  10601. * to a desired value once triggered.
  10602. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10603. */
  10604. export class SetValueAction extends Action {
  10605. /**
  10606. * The path of the property to set in the target.
  10607. */
  10608. propertyPath: string;
  10609. /**
  10610. * The value to set in the property
  10611. */
  10612. value: any;
  10613. private _target;
  10614. private _effectiveTarget;
  10615. private _property;
  10616. /**
  10617. * Instantiate the action
  10618. * @param triggerOptions defines the trigger options
  10619. * @param target defines the object containing the property
  10620. * @param propertyPath defines the path of the property to set in the target
  10621. * @param value defines the value to set in the property
  10622. * @param condition defines the trigger related conditions
  10623. */
  10624. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10625. /** @hidden */
  10626. _prepare(): void;
  10627. /**
  10628. * Execute the action and set the targetted property to the desired value.
  10629. */
  10630. execute(): void;
  10631. /**
  10632. * Serializes the actions and its related information.
  10633. * @param parent defines the object to serialize in
  10634. * @returns the serialized object
  10635. */
  10636. serialize(parent: any): any;
  10637. }
  10638. /**
  10639. * This defines an action responsible to increment the target value
  10640. * to a desired value once triggered.
  10641. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10642. */
  10643. export class IncrementValueAction extends Action {
  10644. /**
  10645. * The path of the property to increment in the target.
  10646. */
  10647. propertyPath: string;
  10648. /**
  10649. * The value we should increment the property by.
  10650. */
  10651. value: any;
  10652. private _target;
  10653. private _effectiveTarget;
  10654. private _property;
  10655. /**
  10656. * Instantiate the action
  10657. * @param triggerOptions defines the trigger options
  10658. * @param target defines the object containing the property
  10659. * @param propertyPath defines the path of the property to increment in the target
  10660. * @param value defines the value value we should increment the property by
  10661. * @param condition defines the trigger related conditions
  10662. */
  10663. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10664. /** @hidden */
  10665. _prepare(): void;
  10666. /**
  10667. * Execute the action and increment the target of the value amount.
  10668. */
  10669. execute(): void;
  10670. /**
  10671. * Serializes the actions and its related information.
  10672. * @param parent defines the object to serialize in
  10673. * @returns the serialized object
  10674. */
  10675. serialize(parent: any): any;
  10676. }
  10677. /**
  10678. * This defines an action responsible to start an animation once triggered.
  10679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10680. */
  10681. export class PlayAnimationAction extends Action {
  10682. /**
  10683. * Where the animation should start (animation frame)
  10684. */
  10685. from: number;
  10686. /**
  10687. * Where the animation should stop (animation frame)
  10688. */
  10689. to: number;
  10690. /**
  10691. * Define if the animation should loop or stop after the first play.
  10692. */
  10693. loop?: boolean;
  10694. private _target;
  10695. /**
  10696. * Instantiate the action
  10697. * @param triggerOptions defines the trigger options
  10698. * @param target defines the target animation or animation name
  10699. * @param from defines from where the animation should start (animation frame)
  10700. * @param end defines where the animation should stop (animation frame)
  10701. * @param loop defines if the animation should loop or stop after the first play
  10702. * @param condition defines the trigger related conditions
  10703. */
  10704. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10705. /** @hidden */
  10706. _prepare(): void;
  10707. /**
  10708. * Execute the action and play the animation.
  10709. */
  10710. execute(): void;
  10711. /**
  10712. * Serializes the actions and its related information.
  10713. * @param parent defines the object to serialize in
  10714. * @returns the serialized object
  10715. */
  10716. serialize(parent: any): any;
  10717. }
  10718. /**
  10719. * This defines an action responsible to stop an animation once triggered.
  10720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10721. */
  10722. export class StopAnimationAction extends Action {
  10723. private _target;
  10724. /**
  10725. * Instantiate the action
  10726. * @param triggerOptions defines the trigger options
  10727. * @param target defines the target animation or animation name
  10728. * @param condition defines the trigger related conditions
  10729. */
  10730. constructor(triggerOptions: any, target: any, condition?: Condition);
  10731. /** @hidden */
  10732. _prepare(): void;
  10733. /**
  10734. * Execute the action and stop the animation.
  10735. */
  10736. execute(): void;
  10737. /**
  10738. * Serializes the actions and its related information.
  10739. * @param parent defines the object to serialize in
  10740. * @returns the serialized object
  10741. */
  10742. serialize(parent: any): any;
  10743. }
  10744. /**
  10745. * This defines an action responsible that does nothing once triggered.
  10746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10747. */
  10748. export class DoNothingAction extends Action {
  10749. /**
  10750. * Instantiate the action
  10751. * @param triggerOptions defines the trigger options
  10752. * @param condition defines the trigger related conditions
  10753. */
  10754. constructor(triggerOptions?: any, condition?: Condition);
  10755. /**
  10756. * Execute the action and do nothing.
  10757. */
  10758. execute(): void;
  10759. /**
  10760. * Serializes the actions and its related information.
  10761. * @param parent defines the object to serialize in
  10762. * @returns the serialized object
  10763. */
  10764. serialize(parent: any): any;
  10765. }
  10766. /**
  10767. * This defines an action responsible to trigger several actions once triggered.
  10768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10769. */
  10770. export class CombineAction extends Action {
  10771. /**
  10772. * The list of aggregated animations to run.
  10773. */
  10774. children: Action[];
  10775. /**
  10776. * Instantiate the action
  10777. * @param triggerOptions defines the trigger options
  10778. * @param children defines the list of aggregated animations to run
  10779. * @param condition defines the trigger related conditions
  10780. */
  10781. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10782. /** @hidden */
  10783. _prepare(): void;
  10784. /**
  10785. * Execute the action and executes all the aggregated actions.
  10786. */
  10787. execute(evt: ActionEvent): void;
  10788. /**
  10789. * Serializes the actions and its related information.
  10790. * @param parent defines the object to serialize in
  10791. * @returns the serialized object
  10792. */
  10793. serialize(parent: any): any;
  10794. }
  10795. /**
  10796. * This defines an action responsible to run code (external event) once triggered.
  10797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10798. */
  10799. export class ExecuteCodeAction extends Action {
  10800. /**
  10801. * The callback function to run.
  10802. */
  10803. func: (evt: ActionEvent) => void;
  10804. /**
  10805. * Instantiate the action
  10806. * @param triggerOptions defines the trigger options
  10807. * @param func defines the callback function to run
  10808. * @param condition defines the trigger related conditions
  10809. */
  10810. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10811. /**
  10812. * Execute the action and run the attached code.
  10813. */
  10814. execute(evt: ActionEvent): void;
  10815. }
  10816. /**
  10817. * This defines an action responsible to set the parent property of the target once triggered.
  10818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10819. */
  10820. export class SetParentAction extends Action {
  10821. private _parent;
  10822. private _target;
  10823. /**
  10824. * Instantiate the action
  10825. * @param triggerOptions defines the trigger options
  10826. * @param target defines the target containing the parent property
  10827. * @param parent defines from where the animation should start (animation frame)
  10828. * @param condition defines the trigger related conditions
  10829. */
  10830. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10831. /** @hidden */
  10832. _prepare(): void;
  10833. /**
  10834. * Execute the action and set the parent property.
  10835. */
  10836. execute(): void;
  10837. /**
  10838. * Serializes the actions and its related information.
  10839. * @param parent defines the object to serialize in
  10840. * @returns the serialized object
  10841. */
  10842. serialize(parent: any): any;
  10843. }
  10844. }
  10845. declare module "babylonjs/Actions/actionManager" {
  10846. import { Nullable } from "babylonjs/types";
  10847. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10848. import { Scene } from "babylonjs/scene";
  10849. import { IAction } from "babylonjs/Actions/action";
  10850. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10851. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10852. /**
  10853. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10854. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10856. */
  10857. export class ActionManager extends AbstractActionManager {
  10858. /**
  10859. * Nothing
  10860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10861. */
  10862. static readonly NothingTrigger: number;
  10863. /**
  10864. * On pick
  10865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10866. */
  10867. static readonly OnPickTrigger: number;
  10868. /**
  10869. * On left pick
  10870. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10871. */
  10872. static readonly OnLeftPickTrigger: number;
  10873. /**
  10874. * On right pick
  10875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10876. */
  10877. static readonly OnRightPickTrigger: number;
  10878. /**
  10879. * On center pick
  10880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10881. */
  10882. static readonly OnCenterPickTrigger: number;
  10883. /**
  10884. * On pick down
  10885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10886. */
  10887. static readonly OnPickDownTrigger: number;
  10888. /**
  10889. * On double pick
  10890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10891. */
  10892. static readonly OnDoublePickTrigger: number;
  10893. /**
  10894. * On pick up
  10895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10896. */
  10897. static readonly OnPickUpTrigger: number;
  10898. /**
  10899. * On pick out.
  10900. * This trigger will only be raised if you also declared a OnPickDown
  10901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10902. */
  10903. static readonly OnPickOutTrigger: number;
  10904. /**
  10905. * On long press
  10906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10907. */
  10908. static readonly OnLongPressTrigger: number;
  10909. /**
  10910. * On pointer over
  10911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10912. */
  10913. static readonly OnPointerOverTrigger: number;
  10914. /**
  10915. * On pointer out
  10916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10917. */
  10918. static readonly OnPointerOutTrigger: number;
  10919. /**
  10920. * On every frame
  10921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10922. */
  10923. static readonly OnEveryFrameTrigger: number;
  10924. /**
  10925. * On intersection enter
  10926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10927. */
  10928. static readonly OnIntersectionEnterTrigger: number;
  10929. /**
  10930. * On intersection exit
  10931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10932. */
  10933. static readonly OnIntersectionExitTrigger: number;
  10934. /**
  10935. * On key down
  10936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10937. */
  10938. static readonly OnKeyDownTrigger: number;
  10939. /**
  10940. * On key up
  10941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10942. */
  10943. static readonly OnKeyUpTrigger: number;
  10944. private _scene;
  10945. /**
  10946. * Creates a new action manager
  10947. * @param scene defines the hosting scene
  10948. */
  10949. constructor(scene: Scene);
  10950. /**
  10951. * Releases all associated resources
  10952. */
  10953. dispose(): void;
  10954. /**
  10955. * Gets hosting scene
  10956. * @returns the hosting scene
  10957. */
  10958. getScene(): Scene;
  10959. /**
  10960. * Does this action manager handles actions of any of the given triggers
  10961. * @param triggers defines the triggers to be tested
  10962. * @return a boolean indicating whether one (or more) of the triggers is handled
  10963. */
  10964. hasSpecificTriggers(triggers: number[]): boolean;
  10965. /**
  10966. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10967. * speed.
  10968. * @param triggerA defines the trigger to be tested
  10969. * @param triggerB defines the trigger to be tested
  10970. * @return a boolean indicating whether one (or more) of the triggers is handled
  10971. */
  10972. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10973. /**
  10974. * Does this action manager handles actions of a given trigger
  10975. * @param trigger defines the trigger to be tested
  10976. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10977. * @return whether the trigger is handled
  10978. */
  10979. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10980. /**
  10981. * Does this action manager has pointer triggers
  10982. */
  10983. readonly hasPointerTriggers: boolean;
  10984. /**
  10985. * Does this action manager has pick triggers
  10986. */
  10987. readonly hasPickTriggers: boolean;
  10988. /**
  10989. * Registers an action to this action manager
  10990. * @param action defines the action to be registered
  10991. * @return the action amended (prepared) after registration
  10992. */
  10993. registerAction(action: IAction): Nullable<IAction>;
  10994. /**
  10995. * Unregisters an action to this action manager
  10996. * @param action defines the action to be unregistered
  10997. * @return a boolean indicating whether the action has been unregistered
  10998. */
  10999. unregisterAction(action: IAction): Boolean;
  11000. /**
  11001. * Process a specific trigger
  11002. * @param trigger defines the trigger to process
  11003. * @param evt defines the event details to be processed
  11004. */
  11005. processTrigger(trigger: number, evt?: IActionEvent): void;
  11006. /** @hidden */
  11007. _getEffectiveTarget(target: any, propertyPath: string): any;
  11008. /** @hidden */
  11009. _getProperty(propertyPath: string): string;
  11010. /**
  11011. * Serialize this manager to a JSON object
  11012. * @param name defines the property name to store this manager
  11013. * @returns a JSON representation of this manager
  11014. */
  11015. serialize(name: string): any;
  11016. /**
  11017. * Creates a new ActionManager from a JSON data
  11018. * @param parsedActions defines the JSON data to read from
  11019. * @param object defines the hosting mesh
  11020. * @param scene defines the hosting scene
  11021. */
  11022. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11023. /**
  11024. * Get a trigger name by index
  11025. * @param trigger defines the trigger index
  11026. * @returns a trigger name
  11027. */
  11028. static GetTriggerName(trigger: number): string;
  11029. }
  11030. }
  11031. declare module "babylonjs/Culling/ray" {
  11032. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11033. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11035. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11036. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11037. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11038. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11039. import { Plane } from "babylonjs/Maths/math.plane";
  11040. /**
  11041. * Class representing a ray with position and direction
  11042. */
  11043. export class Ray {
  11044. /** origin point */
  11045. origin: Vector3;
  11046. /** direction */
  11047. direction: Vector3;
  11048. /** length of the ray */
  11049. length: number;
  11050. private static readonly TmpVector3;
  11051. private _tmpRay;
  11052. /**
  11053. * Creates a new ray
  11054. * @param origin origin point
  11055. * @param direction direction
  11056. * @param length length of the ray
  11057. */
  11058. constructor(
  11059. /** origin point */
  11060. origin: Vector3,
  11061. /** direction */
  11062. direction: Vector3,
  11063. /** length of the ray */
  11064. length?: number);
  11065. /**
  11066. * Checks if the ray intersects a box
  11067. * @param minimum bound of the box
  11068. * @param maximum bound of the box
  11069. * @param intersectionTreshold extra extend to be added to the box in all direction
  11070. * @returns if the box was hit
  11071. */
  11072. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11073. /**
  11074. * Checks if the ray intersects a box
  11075. * @param box the bounding box to check
  11076. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11077. * @returns if the box was hit
  11078. */
  11079. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11080. /**
  11081. * If the ray hits a sphere
  11082. * @param sphere the bounding sphere to check
  11083. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11084. * @returns true if it hits the sphere
  11085. */
  11086. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11087. /**
  11088. * If the ray hits a triange
  11089. * @param vertex0 triangle vertex
  11090. * @param vertex1 triangle vertex
  11091. * @param vertex2 triangle vertex
  11092. * @returns intersection information if hit
  11093. */
  11094. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11095. /**
  11096. * Checks if ray intersects a plane
  11097. * @param plane the plane to check
  11098. * @returns the distance away it was hit
  11099. */
  11100. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11101. /**
  11102. * Calculate the intercept of a ray on a given axis
  11103. * @param axis to check 'x' | 'y' | 'z'
  11104. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11105. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11106. */
  11107. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11108. /**
  11109. * Checks if ray intersects a mesh
  11110. * @param mesh the mesh to check
  11111. * @param fastCheck if only the bounding box should checked
  11112. * @returns picking info of the intersecton
  11113. */
  11114. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11115. /**
  11116. * Checks if ray intersects a mesh
  11117. * @param meshes the meshes to check
  11118. * @param fastCheck if only the bounding box should checked
  11119. * @param results array to store result in
  11120. * @returns Array of picking infos
  11121. */
  11122. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11123. private _comparePickingInfo;
  11124. private static smallnum;
  11125. private static rayl;
  11126. /**
  11127. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11128. * @param sega the first point of the segment to test the intersection against
  11129. * @param segb the second point of the segment to test the intersection against
  11130. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11131. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11132. */
  11133. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11134. /**
  11135. * Update the ray from viewport position
  11136. * @param x position
  11137. * @param y y position
  11138. * @param viewportWidth viewport width
  11139. * @param viewportHeight viewport height
  11140. * @param world world matrix
  11141. * @param view view matrix
  11142. * @param projection projection matrix
  11143. * @returns this ray updated
  11144. */
  11145. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11146. /**
  11147. * Creates a ray with origin and direction of 0,0,0
  11148. * @returns the new ray
  11149. */
  11150. static Zero(): Ray;
  11151. /**
  11152. * Creates a new ray from screen space and viewport
  11153. * @param x position
  11154. * @param y y position
  11155. * @param viewportWidth viewport width
  11156. * @param viewportHeight viewport height
  11157. * @param world world matrix
  11158. * @param view view matrix
  11159. * @param projection projection matrix
  11160. * @returns new ray
  11161. */
  11162. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11163. /**
  11164. * 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
  11165. * transformed to the given world matrix.
  11166. * @param origin The origin point
  11167. * @param end The end point
  11168. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11169. * @returns the new ray
  11170. */
  11171. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11172. /**
  11173. * Transforms a ray by a matrix
  11174. * @param ray ray to transform
  11175. * @param matrix matrix to apply
  11176. * @returns the resulting new ray
  11177. */
  11178. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11179. /**
  11180. * Transforms a ray by a matrix
  11181. * @param ray ray to transform
  11182. * @param matrix matrix to apply
  11183. * @param result ray to store result in
  11184. */
  11185. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11186. /**
  11187. * Unproject a ray from screen space to object space
  11188. * @param sourceX defines the screen space x coordinate to use
  11189. * @param sourceY defines the screen space y coordinate to use
  11190. * @param viewportWidth defines the current width of the viewport
  11191. * @param viewportHeight defines the current height of the viewport
  11192. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11193. * @param view defines the view matrix to use
  11194. * @param projection defines the projection matrix to use
  11195. */
  11196. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11197. }
  11198. /**
  11199. * Type used to define predicate used to select faces when a mesh intersection is detected
  11200. */
  11201. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11202. module "babylonjs/scene" {
  11203. interface Scene {
  11204. /** @hidden */
  11205. _tempPickingRay: Nullable<Ray>;
  11206. /** @hidden */
  11207. _cachedRayForTransform: Ray;
  11208. /** @hidden */
  11209. _pickWithRayInverseMatrix: Matrix;
  11210. /** @hidden */
  11211. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11212. /** @hidden */
  11213. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11214. }
  11215. }
  11216. }
  11217. declare module "babylonjs/sceneComponent" {
  11218. import { Scene } from "babylonjs/scene";
  11219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11220. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11221. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11222. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11223. import { Nullable } from "babylonjs/types";
  11224. import { Camera } from "babylonjs/Cameras/camera";
  11225. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11226. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11227. import { AbstractScene } from "babylonjs/abstractScene";
  11228. /**
  11229. * Groups all the scene component constants in one place to ease maintenance.
  11230. * @hidden
  11231. */
  11232. export class SceneComponentConstants {
  11233. static readonly NAME_EFFECTLAYER: string;
  11234. static readonly NAME_LAYER: string;
  11235. static readonly NAME_LENSFLARESYSTEM: string;
  11236. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11237. static readonly NAME_PARTICLESYSTEM: string;
  11238. static readonly NAME_GAMEPAD: string;
  11239. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11240. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11241. static readonly NAME_DEPTHRENDERER: string;
  11242. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11243. static readonly NAME_SPRITE: string;
  11244. static readonly NAME_OUTLINERENDERER: string;
  11245. static readonly NAME_PROCEDURALTEXTURE: string;
  11246. static readonly NAME_SHADOWGENERATOR: string;
  11247. static readonly NAME_OCTREE: string;
  11248. static readonly NAME_PHYSICSENGINE: string;
  11249. static readonly NAME_AUDIO: string;
  11250. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11251. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11252. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11253. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11254. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11255. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11256. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11257. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11258. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11259. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11260. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11261. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11262. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11263. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11264. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11265. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11266. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11267. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11268. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11269. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11270. static readonly STEP_AFTERRENDER_AUDIO: number;
  11271. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11272. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11273. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11274. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11275. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11276. static readonly STEP_POINTERMOVE_SPRITE: number;
  11277. static readonly STEP_POINTERDOWN_SPRITE: number;
  11278. static readonly STEP_POINTERUP_SPRITE: number;
  11279. }
  11280. /**
  11281. * This represents a scene component.
  11282. *
  11283. * This is used to decouple the dependency the scene is having on the different workloads like
  11284. * layers, post processes...
  11285. */
  11286. export interface ISceneComponent {
  11287. /**
  11288. * The name of the component. Each component must have a unique name.
  11289. */
  11290. name: string;
  11291. /**
  11292. * The scene the component belongs to.
  11293. */
  11294. scene: Scene;
  11295. /**
  11296. * Register the component to one instance of a scene.
  11297. */
  11298. register(): void;
  11299. /**
  11300. * Rebuilds the elements related to this component in case of
  11301. * context lost for instance.
  11302. */
  11303. rebuild(): void;
  11304. /**
  11305. * Disposes the component and the associated ressources.
  11306. */
  11307. dispose(): void;
  11308. }
  11309. /**
  11310. * This represents a SERIALIZABLE scene component.
  11311. *
  11312. * This extends Scene Component to add Serialization methods on top.
  11313. */
  11314. export interface ISceneSerializableComponent extends ISceneComponent {
  11315. /**
  11316. * Adds all the elements from the container to the scene
  11317. * @param container the container holding the elements
  11318. */
  11319. addFromContainer(container: AbstractScene): void;
  11320. /**
  11321. * Removes all the elements in the container from the scene
  11322. * @param container contains the elements to remove
  11323. * @param dispose if the removed element should be disposed (default: false)
  11324. */
  11325. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11326. /**
  11327. * Serializes the component data to the specified json object
  11328. * @param serializationObject The object to serialize to
  11329. */
  11330. serialize(serializationObject: any): void;
  11331. }
  11332. /**
  11333. * Strong typing of a Mesh related stage step action
  11334. */
  11335. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11336. /**
  11337. * Strong typing of a Evaluate Sub Mesh related stage step action
  11338. */
  11339. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11340. /**
  11341. * Strong typing of a Active Mesh related stage step action
  11342. */
  11343. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11344. /**
  11345. * Strong typing of a Camera related stage step action
  11346. */
  11347. export type CameraStageAction = (camera: Camera) => void;
  11348. /**
  11349. * Strong typing of a Camera Frame buffer related stage step action
  11350. */
  11351. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11352. /**
  11353. * Strong typing of a Render Target related stage step action
  11354. */
  11355. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11356. /**
  11357. * Strong typing of a RenderingGroup related stage step action
  11358. */
  11359. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11360. /**
  11361. * Strong typing of a Mesh Render related stage step action
  11362. */
  11363. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11364. /**
  11365. * Strong typing of a simple stage step action
  11366. */
  11367. export type SimpleStageAction = () => void;
  11368. /**
  11369. * Strong typing of a render target action.
  11370. */
  11371. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11372. /**
  11373. * Strong typing of a pointer move action.
  11374. */
  11375. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11376. /**
  11377. * Strong typing of a pointer up/down action.
  11378. */
  11379. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11380. /**
  11381. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11382. * @hidden
  11383. */
  11384. export class Stage<T extends Function> extends Array<{
  11385. index: number;
  11386. component: ISceneComponent;
  11387. action: T;
  11388. }> {
  11389. /**
  11390. * Hide ctor from the rest of the world.
  11391. * @param items The items to add.
  11392. */
  11393. private constructor();
  11394. /**
  11395. * Creates a new Stage.
  11396. * @returns A new instance of a Stage
  11397. */
  11398. static Create<T extends Function>(): Stage<T>;
  11399. /**
  11400. * Registers a step in an ordered way in the targeted stage.
  11401. * @param index Defines the position to register the step in
  11402. * @param component Defines the component attached to the step
  11403. * @param action Defines the action to launch during the step
  11404. */
  11405. registerStep(index: number, component: ISceneComponent, action: T): void;
  11406. /**
  11407. * Clears all the steps from the stage.
  11408. */
  11409. clear(): void;
  11410. }
  11411. }
  11412. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11413. import { Nullable } from "babylonjs/types";
  11414. import { Observable } from "babylonjs/Misc/observable";
  11415. import { Scene } from "babylonjs/scene";
  11416. import { Sprite } from "babylonjs/Sprites/sprite";
  11417. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11418. import { Ray } from "babylonjs/Culling/ray";
  11419. import { Camera } from "babylonjs/Cameras/camera";
  11420. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11421. import { ISceneComponent } from "babylonjs/sceneComponent";
  11422. module "babylonjs/scene" {
  11423. interface Scene {
  11424. /** @hidden */
  11425. _pointerOverSprite: Nullable<Sprite>;
  11426. /** @hidden */
  11427. _pickedDownSprite: Nullable<Sprite>;
  11428. /** @hidden */
  11429. _tempSpritePickingRay: Nullable<Ray>;
  11430. /**
  11431. * All of the sprite managers added to this scene
  11432. * @see http://doc.babylonjs.com/babylon101/sprites
  11433. */
  11434. spriteManagers: Array<ISpriteManager>;
  11435. /**
  11436. * An event triggered when sprites rendering is about to start
  11437. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11438. */
  11439. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11440. /**
  11441. * An event triggered when sprites rendering is done
  11442. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11443. */
  11444. onAfterSpritesRenderingObservable: Observable<Scene>;
  11445. /** @hidden */
  11446. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11447. /** Launch a ray to try to pick a sprite in the scene
  11448. * @param x position on screen
  11449. * @param y position on screen
  11450. * @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
  11451. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11452. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11453. * @returns a PickingInfo
  11454. */
  11455. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11456. /** Use the given ray to pick a sprite in the scene
  11457. * @param ray The ray (in world space) to use to pick meshes
  11458. * @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
  11459. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11460. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11461. * @returns a PickingInfo
  11462. */
  11463. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11464. /** @hidden */
  11465. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11466. /** Launch a ray to try to pick sprites in the scene
  11467. * @param x position on screen
  11468. * @param y position on screen
  11469. * @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
  11470. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11471. * @returns a PickingInfo array
  11472. */
  11473. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11474. /** Use the given ray to pick sprites in the scene
  11475. * @param ray The ray (in world space) to use to pick meshes
  11476. * @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
  11477. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11478. * @returns a PickingInfo array
  11479. */
  11480. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11481. /**
  11482. * Force the sprite under the pointer
  11483. * @param sprite defines the sprite to use
  11484. */
  11485. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11486. /**
  11487. * Gets the sprite under the pointer
  11488. * @returns a Sprite or null if no sprite is under the pointer
  11489. */
  11490. getPointerOverSprite(): Nullable<Sprite>;
  11491. }
  11492. }
  11493. /**
  11494. * Defines the sprite scene component responsible to manage sprites
  11495. * in a given scene.
  11496. */
  11497. export class SpriteSceneComponent implements ISceneComponent {
  11498. /**
  11499. * The component name helpfull to identify the component in the list of scene components.
  11500. */
  11501. readonly name: string;
  11502. /**
  11503. * The scene the component belongs to.
  11504. */
  11505. scene: Scene;
  11506. /** @hidden */
  11507. private _spritePredicate;
  11508. /**
  11509. * Creates a new instance of the component for the given scene
  11510. * @param scene Defines the scene to register the component in
  11511. */
  11512. constructor(scene: Scene);
  11513. /**
  11514. * Registers the component in a given scene
  11515. */
  11516. register(): void;
  11517. /**
  11518. * Rebuilds the elements related to this component in case of
  11519. * context lost for instance.
  11520. */
  11521. rebuild(): void;
  11522. /**
  11523. * Disposes the component and the associated ressources.
  11524. */
  11525. dispose(): void;
  11526. private _pickSpriteButKeepRay;
  11527. private _pointerMove;
  11528. private _pointerDown;
  11529. private _pointerUp;
  11530. }
  11531. }
  11532. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11533. /** @hidden */
  11534. export var fogFragmentDeclaration: {
  11535. name: string;
  11536. shader: string;
  11537. };
  11538. }
  11539. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11540. /** @hidden */
  11541. export var fogFragment: {
  11542. name: string;
  11543. shader: string;
  11544. };
  11545. }
  11546. declare module "babylonjs/Shaders/sprites.fragment" {
  11547. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11548. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11549. /** @hidden */
  11550. export var spritesPixelShader: {
  11551. name: string;
  11552. shader: string;
  11553. };
  11554. }
  11555. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11556. /** @hidden */
  11557. export var fogVertexDeclaration: {
  11558. name: string;
  11559. shader: string;
  11560. };
  11561. }
  11562. declare module "babylonjs/Shaders/sprites.vertex" {
  11563. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11564. /** @hidden */
  11565. export var spritesVertexShader: {
  11566. name: string;
  11567. shader: string;
  11568. };
  11569. }
  11570. declare module "babylonjs/Sprites/spriteManager" {
  11571. import { IDisposable, Scene } from "babylonjs/scene";
  11572. import { Nullable } from "babylonjs/types";
  11573. import { Observable } from "babylonjs/Misc/observable";
  11574. import { Sprite } from "babylonjs/Sprites/sprite";
  11575. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11576. import { Camera } from "babylonjs/Cameras/camera";
  11577. import { Texture } from "babylonjs/Materials/Textures/texture";
  11578. import "babylonjs/Shaders/sprites.fragment";
  11579. import "babylonjs/Shaders/sprites.vertex";
  11580. import { Ray } from "babylonjs/Culling/ray";
  11581. /**
  11582. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11583. */
  11584. export interface ISpriteManager extends IDisposable {
  11585. /**
  11586. * Restricts the camera to viewing objects with the same layerMask.
  11587. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11588. */
  11589. layerMask: number;
  11590. /**
  11591. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11592. */
  11593. isPickable: boolean;
  11594. /**
  11595. * Specifies the rendering group id for this mesh (0 by default)
  11596. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11597. */
  11598. renderingGroupId: number;
  11599. /**
  11600. * Defines the list of sprites managed by the manager.
  11601. */
  11602. sprites: Array<Sprite>;
  11603. /**
  11604. * Tests the intersection of a sprite with a specific ray.
  11605. * @param ray The ray we are sending to test the collision
  11606. * @param camera The camera space we are sending rays in
  11607. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11608. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11609. * @returns picking info or null.
  11610. */
  11611. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11612. /**
  11613. * Intersects the sprites with a ray
  11614. * @param ray defines the ray to intersect with
  11615. * @param camera defines the current active camera
  11616. * @param predicate defines a predicate used to select candidate sprites
  11617. * @returns null if no hit or a PickingInfo array
  11618. */
  11619. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11620. /**
  11621. * Renders the list of sprites on screen.
  11622. */
  11623. render(): void;
  11624. }
  11625. /**
  11626. * Class used to manage multiple sprites on the same spritesheet
  11627. * @see http://doc.babylonjs.com/babylon101/sprites
  11628. */
  11629. export class SpriteManager implements ISpriteManager {
  11630. /** defines the manager's name */
  11631. name: string;
  11632. /** Gets the list of sprites */
  11633. sprites: Sprite[];
  11634. /** Gets or sets the rendering group id (0 by default) */
  11635. renderingGroupId: number;
  11636. /** Gets or sets camera layer mask */
  11637. layerMask: number;
  11638. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11639. fogEnabled: boolean;
  11640. /** Gets or sets a boolean indicating if the sprites are pickable */
  11641. isPickable: boolean;
  11642. /** Defines the default width of a cell in the spritesheet */
  11643. cellWidth: number;
  11644. /** Defines the default height of a cell in the spritesheet */
  11645. cellHeight: number;
  11646. /** Associative array from JSON sprite data file */
  11647. private _cellData;
  11648. /** Array of sprite names from JSON sprite data file */
  11649. private _spriteMap;
  11650. /** True when packed cell data from JSON file is ready*/
  11651. private _packedAndReady;
  11652. /**
  11653. * An event triggered when the manager is disposed.
  11654. */
  11655. onDisposeObservable: Observable<SpriteManager>;
  11656. private _onDisposeObserver;
  11657. /**
  11658. * Callback called when the manager is disposed
  11659. */
  11660. onDispose: () => void;
  11661. private _capacity;
  11662. private _fromPacked;
  11663. private _spriteTexture;
  11664. private _epsilon;
  11665. private _scene;
  11666. private _vertexData;
  11667. private _buffer;
  11668. private _vertexBuffers;
  11669. private _indexBuffer;
  11670. private _effectBase;
  11671. private _effectFog;
  11672. /**
  11673. * Gets or sets the spritesheet texture
  11674. */
  11675. texture: Texture;
  11676. /**
  11677. * Creates a new sprite manager
  11678. * @param name defines the manager's name
  11679. * @param imgUrl defines the sprite sheet url
  11680. * @param capacity defines the maximum allowed number of sprites
  11681. * @param cellSize defines the size of a sprite cell
  11682. * @param scene defines the hosting scene
  11683. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11684. * @param samplingMode defines the smapling mode to use with spritesheet
  11685. * @param fromPacked set to false; do not alter
  11686. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11687. */
  11688. constructor(
  11689. /** defines the manager's name */
  11690. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11691. private _makePacked;
  11692. private _appendSpriteVertex;
  11693. /**
  11694. * Intersects the sprites with a ray
  11695. * @param ray defines the ray to intersect with
  11696. * @param camera defines the current active camera
  11697. * @param predicate defines a predicate used to select candidate sprites
  11698. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11699. * @returns null if no hit or a PickingInfo
  11700. */
  11701. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11702. /**
  11703. * Intersects the sprites with a ray
  11704. * @param ray defines the ray to intersect with
  11705. * @param camera defines the current active camera
  11706. * @param predicate defines a predicate used to select candidate sprites
  11707. * @returns null if no hit or a PickingInfo array
  11708. */
  11709. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11710. /**
  11711. * Render all child sprites
  11712. */
  11713. render(): void;
  11714. /**
  11715. * Release associated resources
  11716. */
  11717. dispose(): void;
  11718. }
  11719. }
  11720. declare module "babylonjs/Sprites/sprite" {
  11721. import { Vector3 } from "babylonjs/Maths/math.vector";
  11722. import { Nullable } from "babylonjs/types";
  11723. import { ActionManager } from "babylonjs/Actions/actionManager";
  11724. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11725. import { Color4 } from "babylonjs/Maths/math.color";
  11726. /**
  11727. * Class used to represent a sprite
  11728. * @see http://doc.babylonjs.com/babylon101/sprites
  11729. */
  11730. export class Sprite {
  11731. /** defines the name */
  11732. name: string;
  11733. /** Gets or sets the current world position */
  11734. position: Vector3;
  11735. /** Gets or sets the main color */
  11736. color: Color4;
  11737. /** Gets or sets the width */
  11738. width: number;
  11739. /** Gets or sets the height */
  11740. height: number;
  11741. /** Gets or sets rotation angle */
  11742. angle: number;
  11743. /** Gets or sets the cell index in the sprite sheet */
  11744. cellIndex: number;
  11745. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11746. cellRef: string;
  11747. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11748. invertU: number;
  11749. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11750. invertV: number;
  11751. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11752. disposeWhenFinishedAnimating: boolean;
  11753. /** Gets the list of attached animations */
  11754. animations: Animation[];
  11755. /** Gets or sets a boolean indicating if the sprite can be picked */
  11756. isPickable: boolean;
  11757. /**
  11758. * Gets or sets the associated action manager
  11759. */
  11760. actionManager: Nullable<ActionManager>;
  11761. private _animationStarted;
  11762. private _loopAnimation;
  11763. private _fromIndex;
  11764. private _toIndex;
  11765. private _delay;
  11766. private _direction;
  11767. private _manager;
  11768. private _time;
  11769. private _onAnimationEnd;
  11770. /**
  11771. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11772. */
  11773. isVisible: boolean;
  11774. /**
  11775. * Gets or sets the sprite size
  11776. */
  11777. size: number;
  11778. /**
  11779. * Creates a new Sprite
  11780. * @param name defines the name
  11781. * @param manager defines the manager
  11782. */
  11783. constructor(
  11784. /** defines the name */
  11785. name: string, manager: ISpriteManager);
  11786. /**
  11787. * Starts an animation
  11788. * @param from defines the initial key
  11789. * @param to defines the end key
  11790. * @param loop defines if the animation must loop
  11791. * @param delay defines the start delay (in ms)
  11792. * @param onAnimationEnd defines a callback to call when animation ends
  11793. */
  11794. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11795. /** Stops current animation (if any) */
  11796. stopAnimation(): void;
  11797. /** @hidden */
  11798. _animate(deltaTime: number): void;
  11799. /** Release associated resources */
  11800. dispose(): void;
  11801. }
  11802. }
  11803. declare module "babylonjs/Collisions/pickingInfo" {
  11804. import { Nullable } from "babylonjs/types";
  11805. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11807. import { Sprite } from "babylonjs/Sprites/sprite";
  11808. import { Ray } from "babylonjs/Culling/ray";
  11809. /**
  11810. * Information about the result of picking within a scene
  11811. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11812. */
  11813. export class PickingInfo {
  11814. /** @hidden */
  11815. _pickingUnavailable: boolean;
  11816. /**
  11817. * If the pick collided with an object
  11818. */
  11819. hit: boolean;
  11820. /**
  11821. * Distance away where the pick collided
  11822. */
  11823. distance: number;
  11824. /**
  11825. * The location of pick collision
  11826. */
  11827. pickedPoint: Nullable<Vector3>;
  11828. /**
  11829. * The mesh corresponding the the pick collision
  11830. */
  11831. pickedMesh: Nullable<AbstractMesh>;
  11832. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11833. bu: number;
  11834. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11835. bv: number;
  11836. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11837. faceId: number;
  11838. /** Id of the the submesh that was picked */
  11839. subMeshId: number;
  11840. /** If a sprite was picked, this will be the sprite the pick collided with */
  11841. pickedSprite: Nullable<Sprite>;
  11842. /**
  11843. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11844. */
  11845. originMesh: Nullable<AbstractMesh>;
  11846. /**
  11847. * The ray that was used to perform the picking.
  11848. */
  11849. ray: Nullable<Ray>;
  11850. /**
  11851. * Gets the normal correspodning to the face the pick collided with
  11852. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11853. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11854. * @returns The normal correspodning to the face the pick collided with
  11855. */
  11856. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11857. /**
  11858. * Gets the texture coordinates of where the pick occured
  11859. * @returns the vector containing the coordnates of the texture
  11860. */
  11861. getTextureCoordinates(): Nullable<Vector2>;
  11862. }
  11863. }
  11864. declare module "babylonjs/Events/pointerEvents" {
  11865. import { Nullable } from "babylonjs/types";
  11866. import { Vector2 } from "babylonjs/Maths/math.vector";
  11867. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11868. import { Ray } from "babylonjs/Culling/ray";
  11869. /**
  11870. * Gather the list of pointer event types as constants.
  11871. */
  11872. export class PointerEventTypes {
  11873. /**
  11874. * 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.
  11875. */
  11876. static readonly POINTERDOWN: number;
  11877. /**
  11878. * The pointerup event is fired when a pointer is no longer active.
  11879. */
  11880. static readonly POINTERUP: number;
  11881. /**
  11882. * The pointermove event is fired when a pointer changes coordinates.
  11883. */
  11884. static readonly POINTERMOVE: number;
  11885. /**
  11886. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11887. */
  11888. static readonly POINTERWHEEL: number;
  11889. /**
  11890. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11891. */
  11892. static readonly POINTERPICK: number;
  11893. /**
  11894. * The pointertap event is fired when a the object has been touched and released without drag.
  11895. */
  11896. static readonly POINTERTAP: number;
  11897. /**
  11898. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11899. */
  11900. static readonly POINTERDOUBLETAP: number;
  11901. }
  11902. /**
  11903. * Base class of pointer info types.
  11904. */
  11905. export class PointerInfoBase {
  11906. /**
  11907. * Defines the type of event (PointerEventTypes)
  11908. */
  11909. type: number;
  11910. /**
  11911. * Defines the related dom event
  11912. */
  11913. event: PointerEvent | MouseWheelEvent;
  11914. /**
  11915. * Instantiates the base class of pointers info.
  11916. * @param type Defines the type of event (PointerEventTypes)
  11917. * @param event Defines the related dom event
  11918. */
  11919. constructor(
  11920. /**
  11921. * Defines the type of event (PointerEventTypes)
  11922. */
  11923. type: number,
  11924. /**
  11925. * Defines the related dom event
  11926. */
  11927. event: PointerEvent | MouseWheelEvent);
  11928. }
  11929. /**
  11930. * This class is used to store pointer related info for the onPrePointerObservable event.
  11931. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11932. */
  11933. export class PointerInfoPre extends PointerInfoBase {
  11934. /**
  11935. * Ray from a pointer if availible (eg. 6dof controller)
  11936. */
  11937. ray: Nullable<Ray>;
  11938. /**
  11939. * Defines the local position of the pointer on the canvas.
  11940. */
  11941. localPosition: Vector2;
  11942. /**
  11943. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11944. */
  11945. skipOnPointerObservable: boolean;
  11946. /**
  11947. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11948. * @param type Defines the type of event (PointerEventTypes)
  11949. * @param event Defines the related dom event
  11950. * @param localX Defines the local x coordinates of the pointer when the event occured
  11951. * @param localY Defines the local y coordinates of the pointer when the event occured
  11952. */
  11953. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11954. }
  11955. /**
  11956. * This type contains all the data related to a pointer event in Babylon.js.
  11957. * 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.
  11958. */
  11959. export class PointerInfo extends PointerInfoBase {
  11960. /**
  11961. * Defines the picking info associated to the info (if any)\
  11962. */
  11963. pickInfo: Nullable<PickingInfo>;
  11964. /**
  11965. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11966. * @param type Defines the type of event (PointerEventTypes)
  11967. * @param event Defines the related dom event
  11968. * @param pickInfo Defines the picking info associated to the info (if any)\
  11969. */
  11970. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11971. /**
  11972. * Defines the picking info associated to the info (if any)\
  11973. */
  11974. pickInfo: Nullable<PickingInfo>);
  11975. }
  11976. /**
  11977. * Data relating to a touch event on the screen.
  11978. */
  11979. export interface PointerTouch {
  11980. /**
  11981. * X coordinate of touch.
  11982. */
  11983. x: number;
  11984. /**
  11985. * Y coordinate of touch.
  11986. */
  11987. y: number;
  11988. /**
  11989. * Id of touch. Unique for each finger.
  11990. */
  11991. pointerId: number;
  11992. /**
  11993. * Event type passed from DOM.
  11994. */
  11995. type: any;
  11996. }
  11997. }
  11998. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11999. import { Observable } from "babylonjs/Misc/observable";
  12000. import { Nullable } from "babylonjs/types";
  12001. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12002. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12003. /**
  12004. * Manage the mouse inputs to control the movement of a free camera.
  12005. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12006. */
  12007. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12008. /**
  12009. * Define if touch is enabled in the mouse input
  12010. */
  12011. touchEnabled: boolean;
  12012. /**
  12013. * Defines the camera the input is attached to.
  12014. */
  12015. camera: FreeCamera;
  12016. /**
  12017. * Defines the buttons associated with the input to handle camera move.
  12018. */
  12019. buttons: number[];
  12020. /**
  12021. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12022. */
  12023. angularSensibility: number;
  12024. private _pointerInput;
  12025. private _onMouseMove;
  12026. private _observer;
  12027. private previousPosition;
  12028. /**
  12029. * Observable for when a pointer move event occurs containing the move offset
  12030. */
  12031. onPointerMovedObservable: Observable<{
  12032. offsetX: number;
  12033. offsetY: number;
  12034. }>;
  12035. /**
  12036. * @hidden
  12037. * If the camera should be rotated automatically based on pointer movement
  12038. */
  12039. _allowCameraRotation: boolean;
  12040. /**
  12041. * Manage the mouse inputs to control the movement of a free camera.
  12042. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12043. * @param touchEnabled Defines if touch is enabled or not
  12044. */
  12045. constructor(
  12046. /**
  12047. * Define if touch is enabled in the mouse input
  12048. */
  12049. touchEnabled?: boolean);
  12050. /**
  12051. * Attach the input controls to a specific dom element to get the input from.
  12052. * @param element Defines the element the controls should be listened from
  12053. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12054. */
  12055. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12056. /**
  12057. * Called on JS contextmenu event.
  12058. * Override this method to provide functionality.
  12059. */
  12060. protected onContextMenu(evt: PointerEvent): void;
  12061. /**
  12062. * Detach the current controls from the specified dom element.
  12063. * @param element Defines the element to stop listening the inputs from
  12064. */
  12065. detachControl(element: Nullable<HTMLElement>): void;
  12066. /**
  12067. * Gets the class name of the current intput.
  12068. * @returns the class name
  12069. */
  12070. getClassName(): string;
  12071. /**
  12072. * Get the friendly name associated with the input class.
  12073. * @returns the input friendly name
  12074. */
  12075. getSimpleName(): string;
  12076. }
  12077. }
  12078. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12079. import { Nullable } from "babylonjs/types";
  12080. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12081. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12082. /**
  12083. * Manage the touch inputs to control the movement of a free camera.
  12084. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12085. */
  12086. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12087. /**
  12088. * Defines the camera the input is attached to.
  12089. */
  12090. camera: FreeCamera;
  12091. /**
  12092. * Defines the touch sensibility for rotation.
  12093. * The higher the faster.
  12094. */
  12095. touchAngularSensibility: number;
  12096. /**
  12097. * Defines the touch sensibility for move.
  12098. * The higher the faster.
  12099. */
  12100. touchMoveSensibility: number;
  12101. private _offsetX;
  12102. private _offsetY;
  12103. private _pointerPressed;
  12104. private _pointerInput;
  12105. private _observer;
  12106. private _onLostFocus;
  12107. /**
  12108. * Attach the input controls to a specific dom element to get the input from.
  12109. * @param element Defines the element the controls should be listened from
  12110. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12111. */
  12112. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12113. /**
  12114. * Detach the current controls from the specified dom element.
  12115. * @param element Defines the element to stop listening the inputs from
  12116. */
  12117. detachControl(element: Nullable<HTMLElement>): void;
  12118. /**
  12119. * Update the current camera state depending on the inputs that have been used this frame.
  12120. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12121. */
  12122. checkInputs(): void;
  12123. /**
  12124. * Gets the class name of the current intput.
  12125. * @returns the class name
  12126. */
  12127. getClassName(): string;
  12128. /**
  12129. * Get the friendly name associated with the input class.
  12130. * @returns the input friendly name
  12131. */
  12132. getSimpleName(): string;
  12133. }
  12134. }
  12135. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12136. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12137. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12138. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12139. import { Nullable } from "babylonjs/types";
  12140. /**
  12141. * Default Inputs manager for the FreeCamera.
  12142. * It groups all the default supported inputs for ease of use.
  12143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12144. */
  12145. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12146. /**
  12147. * @hidden
  12148. */
  12149. _mouseInput: Nullable<FreeCameraMouseInput>;
  12150. /**
  12151. * Instantiates a new FreeCameraInputsManager.
  12152. * @param camera Defines the camera the inputs belong to
  12153. */
  12154. constructor(camera: FreeCamera);
  12155. /**
  12156. * Add keyboard input support to the input manager.
  12157. * @returns the current input manager
  12158. */
  12159. addKeyboard(): FreeCameraInputsManager;
  12160. /**
  12161. * Add mouse input support to the input manager.
  12162. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12163. * @returns the current input manager
  12164. */
  12165. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12166. /**
  12167. * Removes the mouse input support from the manager
  12168. * @returns the current input manager
  12169. */
  12170. removeMouse(): FreeCameraInputsManager;
  12171. /**
  12172. * Add touch input support to the input manager.
  12173. * @returns the current input manager
  12174. */
  12175. addTouch(): FreeCameraInputsManager;
  12176. /**
  12177. * Remove all attached input methods from a camera
  12178. */
  12179. clear(): void;
  12180. }
  12181. }
  12182. declare module "babylonjs/Cameras/freeCamera" {
  12183. import { Vector3 } from "babylonjs/Maths/math.vector";
  12184. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12185. import { Scene } from "babylonjs/scene";
  12186. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12187. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12188. /**
  12189. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12190. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12191. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12192. */
  12193. export class FreeCamera extends TargetCamera {
  12194. /**
  12195. * Define the collision ellipsoid of the camera.
  12196. * This is helpful to simulate a camera body like the player body around the camera
  12197. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12198. */
  12199. ellipsoid: Vector3;
  12200. /**
  12201. * Define an offset for the position of the ellipsoid around the camera.
  12202. * This can be helpful to determine the center of the body near the gravity center of the body
  12203. * instead of its head.
  12204. */
  12205. ellipsoidOffset: Vector3;
  12206. /**
  12207. * Enable or disable collisions of the camera with the rest of the scene objects.
  12208. */
  12209. checkCollisions: boolean;
  12210. /**
  12211. * Enable or disable gravity on the camera.
  12212. */
  12213. applyGravity: boolean;
  12214. /**
  12215. * Define the input manager associated to the camera.
  12216. */
  12217. inputs: FreeCameraInputsManager;
  12218. /**
  12219. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12220. * Higher values reduce sensitivity.
  12221. */
  12222. /**
  12223. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12224. * Higher values reduce sensitivity.
  12225. */
  12226. angularSensibility: number;
  12227. /**
  12228. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12229. */
  12230. keysUp: number[];
  12231. /**
  12232. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12233. */
  12234. keysDown: number[];
  12235. /**
  12236. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12237. */
  12238. keysLeft: number[];
  12239. /**
  12240. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12241. */
  12242. keysRight: number[];
  12243. /**
  12244. * Event raised when the camera collide with a mesh in the scene.
  12245. */
  12246. onCollide: (collidedMesh: AbstractMesh) => void;
  12247. private _collider;
  12248. private _needMoveForGravity;
  12249. private _oldPosition;
  12250. private _diffPosition;
  12251. private _newPosition;
  12252. /** @hidden */
  12253. _localDirection: Vector3;
  12254. /** @hidden */
  12255. _transformedDirection: Vector3;
  12256. /**
  12257. * Instantiates a Free Camera.
  12258. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12259. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12260. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12261. * @param name Define the name of the camera in the scene
  12262. * @param position Define the start position of the camera in the scene
  12263. * @param scene Define the scene the camera belongs to
  12264. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12265. */
  12266. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12267. /**
  12268. * Attached controls to the current camera.
  12269. * @param element Defines the element the controls should be listened from
  12270. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12271. */
  12272. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12273. /**
  12274. * Detach the current controls from the camera.
  12275. * The camera will stop reacting to inputs.
  12276. * @param element Defines the element to stop listening the inputs from
  12277. */
  12278. detachControl(element: HTMLElement): void;
  12279. private _collisionMask;
  12280. /**
  12281. * Define a collision mask to limit the list of object the camera can collide with
  12282. */
  12283. collisionMask: number;
  12284. /** @hidden */
  12285. _collideWithWorld(displacement: Vector3): void;
  12286. private _onCollisionPositionChange;
  12287. /** @hidden */
  12288. _checkInputs(): void;
  12289. /** @hidden */
  12290. _decideIfNeedsToMove(): boolean;
  12291. /** @hidden */
  12292. _updatePosition(): void;
  12293. /**
  12294. * Destroy the camera and release the current resources hold by it.
  12295. */
  12296. dispose(): void;
  12297. /**
  12298. * Gets the current object class name.
  12299. * @return the class name
  12300. */
  12301. getClassName(): string;
  12302. }
  12303. }
  12304. declare module "babylonjs/Gamepads/gamepad" {
  12305. import { Observable } from "babylonjs/Misc/observable";
  12306. /**
  12307. * Represents a gamepad control stick position
  12308. */
  12309. export class StickValues {
  12310. /**
  12311. * The x component of the control stick
  12312. */
  12313. x: number;
  12314. /**
  12315. * The y component of the control stick
  12316. */
  12317. y: number;
  12318. /**
  12319. * Initializes the gamepad x and y control stick values
  12320. * @param x The x component of the gamepad control stick value
  12321. * @param y The y component of the gamepad control stick value
  12322. */
  12323. constructor(
  12324. /**
  12325. * The x component of the control stick
  12326. */
  12327. x: number,
  12328. /**
  12329. * The y component of the control stick
  12330. */
  12331. y: number);
  12332. }
  12333. /**
  12334. * An interface which manages callbacks for gamepad button changes
  12335. */
  12336. export interface GamepadButtonChanges {
  12337. /**
  12338. * Called when a gamepad has been changed
  12339. */
  12340. changed: boolean;
  12341. /**
  12342. * Called when a gamepad press event has been triggered
  12343. */
  12344. pressChanged: boolean;
  12345. /**
  12346. * Called when a touch event has been triggered
  12347. */
  12348. touchChanged: boolean;
  12349. /**
  12350. * Called when a value has changed
  12351. */
  12352. valueChanged: boolean;
  12353. }
  12354. /**
  12355. * Represents a gamepad
  12356. */
  12357. export class Gamepad {
  12358. /**
  12359. * The id of the gamepad
  12360. */
  12361. id: string;
  12362. /**
  12363. * The index of the gamepad
  12364. */
  12365. index: number;
  12366. /**
  12367. * The browser gamepad
  12368. */
  12369. browserGamepad: any;
  12370. /**
  12371. * Specifies what type of gamepad this represents
  12372. */
  12373. type: number;
  12374. private _leftStick;
  12375. private _rightStick;
  12376. /** @hidden */
  12377. _isConnected: boolean;
  12378. private _leftStickAxisX;
  12379. private _leftStickAxisY;
  12380. private _rightStickAxisX;
  12381. private _rightStickAxisY;
  12382. /**
  12383. * Triggered when the left control stick has been changed
  12384. */
  12385. private _onleftstickchanged;
  12386. /**
  12387. * Triggered when the right control stick has been changed
  12388. */
  12389. private _onrightstickchanged;
  12390. /**
  12391. * Represents a gamepad controller
  12392. */
  12393. static GAMEPAD: number;
  12394. /**
  12395. * Represents a generic controller
  12396. */
  12397. static GENERIC: number;
  12398. /**
  12399. * Represents an XBox controller
  12400. */
  12401. static XBOX: number;
  12402. /**
  12403. * Represents a pose-enabled controller
  12404. */
  12405. static POSE_ENABLED: number;
  12406. /**
  12407. * Represents an Dual Shock controller
  12408. */
  12409. static DUALSHOCK: number;
  12410. /**
  12411. * Specifies whether the left control stick should be Y-inverted
  12412. */
  12413. protected _invertLeftStickY: boolean;
  12414. /**
  12415. * Specifies if the gamepad has been connected
  12416. */
  12417. readonly isConnected: boolean;
  12418. /**
  12419. * Initializes the gamepad
  12420. * @param id The id of the gamepad
  12421. * @param index The index of the gamepad
  12422. * @param browserGamepad The browser gamepad
  12423. * @param leftStickX The x component of the left joystick
  12424. * @param leftStickY The y component of the left joystick
  12425. * @param rightStickX The x component of the right joystick
  12426. * @param rightStickY The y component of the right joystick
  12427. */
  12428. constructor(
  12429. /**
  12430. * The id of the gamepad
  12431. */
  12432. id: string,
  12433. /**
  12434. * The index of the gamepad
  12435. */
  12436. index: number,
  12437. /**
  12438. * The browser gamepad
  12439. */
  12440. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12441. /**
  12442. * Callback triggered when the left joystick has changed
  12443. * @param callback
  12444. */
  12445. onleftstickchanged(callback: (values: StickValues) => void): void;
  12446. /**
  12447. * Callback triggered when the right joystick has changed
  12448. * @param callback
  12449. */
  12450. onrightstickchanged(callback: (values: StickValues) => void): void;
  12451. /**
  12452. * Gets the left joystick
  12453. */
  12454. /**
  12455. * Sets the left joystick values
  12456. */
  12457. leftStick: StickValues;
  12458. /**
  12459. * Gets the right joystick
  12460. */
  12461. /**
  12462. * Sets the right joystick value
  12463. */
  12464. rightStick: StickValues;
  12465. /**
  12466. * Updates the gamepad joystick positions
  12467. */
  12468. update(): void;
  12469. /**
  12470. * Disposes the gamepad
  12471. */
  12472. dispose(): void;
  12473. }
  12474. /**
  12475. * Represents a generic gamepad
  12476. */
  12477. export class GenericPad extends Gamepad {
  12478. private _buttons;
  12479. private _onbuttondown;
  12480. private _onbuttonup;
  12481. /**
  12482. * Observable triggered when a button has been pressed
  12483. */
  12484. onButtonDownObservable: Observable<number>;
  12485. /**
  12486. * Observable triggered when a button has been released
  12487. */
  12488. onButtonUpObservable: Observable<number>;
  12489. /**
  12490. * Callback triggered when a button has been pressed
  12491. * @param callback Called when a button has been pressed
  12492. */
  12493. onbuttondown(callback: (buttonPressed: number) => void): void;
  12494. /**
  12495. * Callback triggered when a button has been released
  12496. * @param callback Called when a button has been released
  12497. */
  12498. onbuttonup(callback: (buttonReleased: number) => void): void;
  12499. /**
  12500. * Initializes the generic gamepad
  12501. * @param id The id of the generic gamepad
  12502. * @param index The index of the generic gamepad
  12503. * @param browserGamepad The browser gamepad
  12504. */
  12505. constructor(id: string, index: number, browserGamepad: any);
  12506. private _setButtonValue;
  12507. /**
  12508. * Updates the generic gamepad
  12509. */
  12510. update(): void;
  12511. /**
  12512. * Disposes the generic gamepad
  12513. */
  12514. dispose(): void;
  12515. }
  12516. }
  12517. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12518. import { Nullable } from "babylonjs/types";
  12519. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12520. import { Scene } from "babylonjs/scene";
  12521. module "babylonjs/Engines/engine" {
  12522. interface Engine {
  12523. /**
  12524. * Creates a raw texture
  12525. * @param data defines the data to store in the texture
  12526. * @param width defines the width of the texture
  12527. * @param height defines the height of the texture
  12528. * @param format defines the format of the data
  12529. * @param generateMipMaps defines if the engine should generate the mip levels
  12530. * @param invertY defines if data must be stored with Y axis inverted
  12531. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12532. * @param compression defines the compression used (null by default)
  12533. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12534. * @returns the raw texture inside an InternalTexture
  12535. */
  12536. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12537. /**
  12538. * Update a raw texture
  12539. * @param texture defines the texture to update
  12540. * @param data defines the data to store in the texture
  12541. * @param format defines the format of the data
  12542. * @param invertY defines if data must be stored with Y axis inverted
  12543. */
  12544. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12545. /**
  12546. * Update a raw texture
  12547. * @param texture defines the texture to update
  12548. * @param data defines the data to store in the texture
  12549. * @param format defines the format of the data
  12550. * @param invertY defines if data must be stored with Y axis inverted
  12551. * @param compression defines the compression used (null by default)
  12552. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12553. */
  12554. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12555. /**
  12556. * Creates a new raw cube texture
  12557. * @param data defines the array of data to use to create each face
  12558. * @param size defines the size of the textures
  12559. * @param format defines the format of the data
  12560. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12561. * @param generateMipMaps defines if the engine should generate the mip levels
  12562. * @param invertY defines if data must be stored with Y axis inverted
  12563. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12564. * @param compression defines the compression used (null by default)
  12565. * @returns the cube texture as an InternalTexture
  12566. */
  12567. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12568. /**
  12569. * Update a raw cube texture
  12570. * @param texture defines the texture to udpdate
  12571. * @param data defines the data to store
  12572. * @param format defines the data format
  12573. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12574. * @param invertY defines if data must be stored with Y axis inverted
  12575. */
  12576. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12577. /**
  12578. * Update a raw cube texture
  12579. * @param texture defines the texture to udpdate
  12580. * @param data defines the data to store
  12581. * @param format defines the data format
  12582. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12583. * @param invertY defines if data must be stored with Y axis inverted
  12584. * @param compression defines the compression used (null by default)
  12585. */
  12586. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12587. /**
  12588. * Update a raw cube texture
  12589. * @param texture defines the texture to udpdate
  12590. * @param data defines the data to store
  12591. * @param format defines the data format
  12592. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12593. * @param invertY defines if data must be stored with Y axis inverted
  12594. * @param compression defines the compression used (null by default)
  12595. * @param level defines which level of the texture to update
  12596. */
  12597. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12598. /**
  12599. * Creates a new raw cube texture from a specified url
  12600. * @param url defines the url where the data is located
  12601. * @param scene defines the current scene
  12602. * @param size defines the size of the textures
  12603. * @param format defines the format of the data
  12604. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12605. * @param noMipmap defines if the engine should avoid generating the mip levels
  12606. * @param callback defines a callback used to extract texture data from loaded data
  12607. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12608. * @param onLoad defines a callback called when texture is loaded
  12609. * @param onError defines a callback called if there is an error
  12610. * @returns the cube texture as an InternalTexture
  12611. */
  12612. createRawCubeTextureFromUrl(url: string, scene: 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;
  12613. /**
  12614. * Creates a new raw cube texture from a specified url
  12615. * @param url defines the url where the data is located
  12616. * @param scene defines the current scene
  12617. * @param size defines the size of the textures
  12618. * @param format defines the format of the data
  12619. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12620. * @param noMipmap defines if the engine should avoid generating the mip levels
  12621. * @param callback defines a callback used to extract texture data from loaded data
  12622. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12623. * @param onLoad defines a callback called when texture is loaded
  12624. * @param onError defines a callback called if there is an error
  12625. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12626. * @param invertY defines if data must be stored with Y axis inverted
  12627. * @returns the cube texture as an InternalTexture
  12628. */
  12629. createRawCubeTextureFromUrl(url: string, scene: 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;
  12630. /**
  12631. * Creates a new raw 3D texture
  12632. * @param data defines the data used to create the texture
  12633. * @param width defines the width of the texture
  12634. * @param height defines the height of the texture
  12635. * @param depth defines the depth of the texture
  12636. * @param format defines the format of the texture
  12637. * @param generateMipMaps defines if the engine must generate mip levels
  12638. * @param invertY defines if data must be stored with Y axis inverted
  12639. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12640. * @param compression defines the compressed used (can be null)
  12641. * @param textureType defines the compressed used (can be null)
  12642. * @returns a new raw 3D texture (stored in an InternalTexture)
  12643. */
  12644. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12645. /**
  12646. * Update a raw 3D texture
  12647. * @param texture defines the texture to update
  12648. * @param data defines the data to store
  12649. * @param format defines the data format
  12650. * @param invertY defines if data must be stored with Y axis inverted
  12651. */
  12652. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12653. /**
  12654. * Update a raw 3D texture
  12655. * @param texture defines the texture to update
  12656. * @param data defines the data to store
  12657. * @param format defines the data format
  12658. * @param invertY defines if data must be stored with Y axis inverted
  12659. * @param compression defines the used compression (can be null)
  12660. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12661. */
  12662. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12663. }
  12664. }
  12665. }
  12666. declare module "babylonjs/Materials/Textures/rawTexture" {
  12667. import { Scene } from "babylonjs/scene";
  12668. import { Texture } from "babylonjs/Materials/Textures/texture";
  12669. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12670. /**
  12671. * Raw texture can help creating a texture directly from an array of data.
  12672. * This can be super useful if you either get the data from an uncompressed source or
  12673. * if you wish to create your texture pixel by pixel.
  12674. */
  12675. export class RawTexture extends Texture {
  12676. /**
  12677. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12678. */
  12679. format: number;
  12680. private _engine;
  12681. /**
  12682. * Instantiates a new RawTexture.
  12683. * Raw texture can help creating a texture directly from an array of data.
  12684. * This can be super useful if you either get the data from an uncompressed source or
  12685. * if you wish to create your texture pixel by pixel.
  12686. * @param data define the array of data to use to create the texture
  12687. * @param width define the width of the texture
  12688. * @param height define the height of the texture
  12689. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12690. * @param scene define the scene the texture belongs to
  12691. * @param generateMipMaps define whether mip maps should be generated or not
  12692. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12693. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12694. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12695. */
  12696. constructor(data: ArrayBufferView, width: number, height: number,
  12697. /**
  12698. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12699. */
  12700. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12701. /**
  12702. * Updates the texture underlying data.
  12703. * @param data Define the new data of the texture
  12704. */
  12705. update(data: ArrayBufferView): void;
  12706. /**
  12707. * Creates a luminance texture from some data.
  12708. * @param data Define the texture data
  12709. * @param width Define the width of the texture
  12710. * @param height Define the height of the texture
  12711. * @param scene Define the scene the texture belongs to
  12712. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12713. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12714. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12715. * @returns the luminance texture
  12716. */
  12717. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12718. /**
  12719. * Creates a luminance alpha texture from some data.
  12720. * @param data Define the texture data
  12721. * @param width Define the width of the texture
  12722. * @param height Define the height of the texture
  12723. * @param scene Define the scene the texture belongs to
  12724. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12725. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12726. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12727. * @returns the luminance alpha texture
  12728. */
  12729. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12730. /**
  12731. * Creates an alpha texture from some data.
  12732. * @param data Define the texture data
  12733. * @param width Define the width of the texture
  12734. * @param height Define the height of the texture
  12735. * @param scene Define the scene the texture belongs to
  12736. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12737. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12738. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12739. * @returns the alpha texture
  12740. */
  12741. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12742. /**
  12743. * Creates a RGB texture from some data.
  12744. * @param data Define the texture data
  12745. * @param width Define the width of the texture
  12746. * @param height Define the height of the texture
  12747. * @param scene Define the scene the texture belongs to
  12748. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12749. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12750. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12751. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12752. * @returns the RGB alpha texture
  12753. */
  12754. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12755. /**
  12756. * Creates a RGBA texture from some data.
  12757. * @param data Define the texture data
  12758. * @param width Define the width of the texture
  12759. * @param height Define the height of the texture
  12760. * @param scene Define the scene the texture belongs to
  12761. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12762. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12763. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12764. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12765. * @returns the RGBA texture
  12766. */
  12767. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12768. /**
  12769. * Creates a R texture from some data.
  12770. * @param data Define the texture data
  12771. * @param width Define the width of the texture
  12772. * @param height Define the height of the texture
  12773. * @param scene Define the scene the texture belongs to
  12774. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12775. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12776. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12777. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12778. * @returns the R texture
  12779. */
  12780. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12781. }
  12782. }
  12783. declare module "babylonjs/Maths/math.size" {
  12784. /**
  12785. * Interface for the size containing width and height
  12786. */
  12787. export interface ISize {
  12788. /**
  12789. * Width
  12790. */
  12791. width: number;
  12792. /**
  12793. * Heighht
  12794. */
  12795. height: number;
  12796. }
  12797. /**
  12798. * Size containing widht and height
  12799. */
  12800. export class Size implements ISize {
  12801. /**
  12802. * Width
  12803. */
  12804. width: number;
  12805. /**
  12806. * Height
  12807. */
  12808. height: number;
  12809. /**
  12810. * Creates a Size object from the given width and height (floats).
  12811. * @param width width of the new size
  12812. * @param height height of the new size
  12813. */
  12814. constructor(width: number, height: number);
  12815. /**
  12816. * Returns a string with the Size width and height
  12817. * @returns a string with the Size width and height
  12818. */
  12819. toString(): string;
  12820. /**
  12821. * "Size"
  12822. * @returns the string "Size"
  12823. */
  12824. getClassName(): string;
  12825. /**
  12826. * Returns the Size hash code.
  12827. * @returns a hash code for a unique width and height
  12828. */
  12829. getHashCode(): number;
  12830. /**
  12831. * Updates the current size from the given one.
  12832. * @param src the given size
  12833. */
  12834. copyFrom(src: Size): void;
  12835. /**
  12836. * Updates in place the current Size from the given floats.
  12837. * @param width width of the new size
  12838. * @param height height of the new size
  12839. * @returns the updated Size.
  12840. */
  12841. copyFromFloats(width: number, height: number): Size;
  12842. /**
  12843. * Updates in place the current Size from the given floats.
  12844. * @param width width to set
  12845. * @param height height to set
  12846. * @returns the updated Size.
  12847. */
  12848. set(width: number, height: number): Size;
  12849. /**
  12850. * Multiplies the width and height by numbers
  12851. * @param w factor to multiple the width by
  12852. * @param h factor to multiple the height by
  12853. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12854. */
  12855. multiplyByFloats(w: number, h: number): Size;
  12856. /**
  12857. * Clones the size
  12858. * @returns a new Size copied from the given one.
  12859. */
  12860. clone(): Size;
  12861. /**
  12862. * True if the current Size and the given one width and height are strictly equal.
  12863. * @param other the other size to compare against
  12864. * @returns True if the current Size and the given one width and height are strictly equal.
  12865. */
  12866. equals(other: Size): boolean;
  12867. /**
  12868. * The surface of the Size : width * height (float).
  12869. */
  12870. readonly surface: number;
  12871. /**
  12872. * Create a new size of zero
  12873. * @returns a new Size set to (0.0, 0.0)
  12874. */
  12875. static Zero(): Size;
  12876. /**
  12877. * Sums the width and height of two sizes
  12878. * @param otherSize size to add to this size
  12879. * @returns a new Size set as the addition result of the current Size and the given one.
  12880. */
  12881. add(otherSize: Size): Size;
  12882. /**
  12883. * Subtracts the width and height of two
  12884. * @param otherSize size to subtract to this size
  12885. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12886. */
  12887. subtract(otherSize: Size): Size;
  12888. /**
  12889. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12890. * @param start starting size to lerp between
  12891. * @param end end size to lerp between
  12892. * @param amount amount to lerp between the start and end values
  12893. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12894. */
  12895. static Lerp(start: Size, end: Size, amount: number): Size;
  12896. }
  12897. }
  12898. declare module "babylonjs/Animations/runtimeAnimation" {
  12899. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12900. import { Animatable } from "babylonjs/Animations/animatable";
  12901. import { Scene } from "babylonjs/scene";
  12902. /**
  12903. * Defines a runtime animation
  12904. */
  12905. export class RuntimeAnimation {
  12906. private _events;
  12907. /**
  12908. * The current frame of the runtime animation
  12909. */
  12910. private _currentFrame;
  12911. /**
  12912. * The animation used by the runtime animation
  12913. */
  12914. private _animation;
  12915. /**
  12916. * The target of the runtime animation
  12917. */
  12918. private _target;
  12919. /**
  12920. * The initiating animatable
  12921. */
  12922. private _host;
  12923. /**
  12924. * The original value of the runtime animation
  12925. */
  12926. private _originalValue;
  12927. /**
  12928. * The original blend value of the runtime animation
  12929. */
  12930. private _originalBlendValue;
  12931. /**
  12932. * The offsets cache of the runtime animation
  12933. */
  12934. private _offsetsCache;
  12935. /**
  12936. * The high limits cache of the runtime animation
  12937. */
  12938. private _highLimitsCache;
  12939. /**
  12940. * Specifies if the runtime animation has been stopped
  12941. */
  12942. private _stopped;
  12943. /**
  12944. * The blending factor of the runtime animation
  12945. */
  12946. private _blendingFactor;
  12947. /**
  12948. * The BabylonJS scene
  12949. */
  12950. private _scene;
  12951. /**
  12952. * The current value of the runtime animation
  12953. */
  12954. private _currentValue;
  12955. /** @hidden */
  12956. _animationState: _IAnimationState;
  12957. /**
  12958. * The active target of the runtime animation
  12959. */
  12960. private _activeTargets;
  12961. private _currentActiveTarget;
  12962. private _directTarget;
  12963. /**
  12964. * The target path of the runtime animation
  12965. */
  12966. private _targetPath;
  12967. /**
  12968. * The weight of the runtime animation
  12969. */
  12970. private _weight;
  12971. /**
  12972. * The ratio offset of the runtime animation
  12973. */
  12974. private _ratioOffset;
  12975. /**
  12976. * The previous delay of the runtime animation
  12977. */
  12978. private _previousDelay;
  12979. /**
  12980. * The previous ratio of the runtime animation
  12981. */
  12982. private _previousRatio;
  12983. private _enableBlending;
  12984. private _keys;
  12985. private _minFrame;
  12986. private _maxFrame;
  12987. private _minValue;
  12988. private _maxValue;
  12989. private _targetIsArray;
  12990. /**
  12991. * Gets the current frame of the runtime animation
  12992. */
  12993. readonly currentFrame: number;
  12994. /**
  12995. * Gets the weight of the runtime animation
  12996. */
  12997. readonly weight: number;
  12998. /**
  12999. * Gets the current value of the runtime animation
  13000. */
  13001. readonly currentValue: any;
  13002. /**
  13003. * Gets the target path of the runtime animation
  13004. */
  13005. readonly targetPath: string;
  13006. /**
  13007. * Gets the actual target of the runtime animation
  13008. */
  13009. readonly target: any;
  13010. /** @hidden */
  13011. _onLoop: () => void;
  13012. /**
  13013. * Create a new RuntimeAnimation object
  13014. * @param target defines the target of the animation
  13015. * @param animation defines the source animation object
  13016. * @param scene defines the hosting scene
  13017. * @param host defines the initiating Animatable
  13018. */
  13019. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13020. private _preparePath;
  13021. /**
  13022. * Gets the animation from the runtime animation
  13023. */
  13024. readonly animation: Animation;
  13025. /**
  13026. * Resets the runtime animation to the beginning
  13027. * @param restoreOriginal defines whether to restore the target property to the original value
  13028. */
  13029. reset(restoreOriginal?: boolean): void;
  13030. /**
  13031. * Specifies if the runtime animation is stopped
  13032. * @returns Boolean specifying if the runtime animation is stopped
  13033. */
  13034. isStopped(): boolean;
  13035. /**
  13036. * Disposes of the runtime animation
  13037. */
  13038. dispose(): void;
  13039. /**
  13040. * Apply the interpolated value to the target
  13041. * @param currentValue defines the value computed by the animation
  13042. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13043. */
  13044. setValue(currentValue: any, weight: number): void;
  13045. private _getOriginalValues;
  13046. private _setValue;
  13047. /**
  13048. * Gets the loop pmode of the runtime animation
  13049. * @returns Loop Mode
  13050. */
  13051. private _getCorrectLoopMode;
  13052. /**
  13053. * Move the current animation to a given frame
  13054. * @param frame defines the frame to move to
  13055. */
  13056. goToFrame(frame: number): void;
  13057. /**
  13058. * @hidden Internal use only
  13059. */
  13060. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13061. /**
  13062. * Execute the current animation
  13063. * @param delay defines the delay to add to the current frame
  13064. * @param from defines the lower bound of the animation range
  13065. * @param to defines the upper bound of the animation range
  13066. * @param loop defines if the current animation must loop
  13067. * @param speedRatio defines the current speed ratio
  13068. * @param weight defines the weight of the animation (default is -1 so no weight)
  13069. * @param onLoop optional callback called when animation loops
  13070. * @returns a boolean indicating if the animation is running
  13071. */
  13072. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13073. }
  13074. }
  13075. declare module "babylonjs/Animations/animatable" {
  13076. import { Animation } from "babylonjs/Animations/animation";
  13077. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13078. import { Nullable } from "babylonjs/types";
  13079. import { Observable } from "babylonjs/Misc/observable";
  13080. import { Scene } from "babylonjs/scene";
  13081. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13082. import { Node } from "babylonjs/node";
  13083. /**
  13084. * Class used to store an actual running animation
  13085. */
  13086. export class Animatable {
  13087. /** defines the target object */
  13088. target: any;
  13089. /** defines the starting frame number (default is 0) */
  13090. fromFrame: number;
  13091. /** defines the ending frame number (default is 100) */
  13092. toFrame: number;
  13093. /** defines if the animation must loop (default is false) */
  13094. loopAnimation: boolean;
  13095. /** defines a callback to call when animation ends if it is not looping */
  13096. onAnimationEnd?: (() => void) | null | undefined;
  13097. /** defines a callback to call when animation loops */
  13098. onAnimationLoop?: (() => void) | null | undefined;
  13099. private _localDelayOffset;
  13100. private _pausedDelay;
  13101. private _runtimeAnimations;
  13102. private _paused;
  13103. private _scene;
  13104. private _speedRatio;
  13105. private _weight;
  13106. private _syncRoot;
  13107. /**
  13108. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13109. * This will only apply for non looping animation (default is true)
  13110. */
  13111. disposeOnEnd: boolean;
  13112. /**
  13113. * Gets a boolean indicating if the animation has started
  13114. */
  13115. animationStarted: boolean;
  13116. /**
  13117. * Observer raised when the animation ends
  13118. */
  13119. onAnimationEndObservable: Observable<Animatable>;
  13120. /**
  13121. * Observer raised when the animation loops
  13122. */
  13123. onAnimationLoopObservable: Observable<Animatable>;
  13124. /**
  13125. * Gets the root Animatable used to synchronize and normalize animations
  13126. */
  13127. readonly syncRoot: Nullable<Animatable>;
  13128. /**
  13129. * Gets the current frame of the first RuntimeAnimation
  13130. * Used to synchronize Animatables
  13131. */
  13132. readonly masterFrame: number;
  13133. /**
  13134. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13135. */
  13136. weight: number;
  13137. /**
  13138. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13139. */
  13140. speedRatio: number;
  13141. /**
  13142. * Creates a new Animatable
  13143. * @param scene defines the hosting scene
  13144. * @param target defines the target object
  13145. * @param fromFrame defines the starting frame number (default is 0)
  13146. * @param toFrame defines the ending frame number (default is 100)
  13147. * @param loopAnimation defines if the animation must loop (default is false)
  13148. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13149. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13150. * @param animations defines a group of animation to add to the new Animatable
  13151. * @param onAnimationLoop defines a callback to call when animation loops
  13152. */
  13153. constructor(scene: Scene,
  13154. /** defines the target object */
  13155. target: any,
  13156. /** defines the starting frame number (default is 0) */
  13157. fromFrame?: number,
  13158. /** defines the ending frame number (default is 100) */
  13159. toFrame?: number,
  13160. /** defines if the animation must loop (default is false) */
  13161. loopAnimation?: boolean, speedRatio?: number,
  13162. /** defines a callback to call when animation ends if it is not looping */
  13163. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13164. /** defines a callback to call when animation loops */
  13165. onAnimationLoop?: (() => void) | null | undefined);
  13166. /**
  13167. * Synchronize and normalize current Animatable with a source Animatable
  13168. * This is useful when using animation weights and when animations are not of the same length
  13169. * @param root defines the root Animatable to synchronize with
  13170. * @returns the current Animatable
  13171. */
  13172. syncWith(root: Animatable): Animatable;
  13173. /**
  13174. * Gets the list of runtime animations
  13175. * @returns an array of RuntimeAnimation
  13176. */
  13177. getAnimations(): RuntimeAnimation[];
  13178. /**
  13179. * Adds more animations to the current animatable
  13180. * @param target defines the target of the animations
  13181. * @param animations defines the new animations to add
  13182. */
  13183. appendAnimations(target: any, animations: Animation[]): void;
  13184. /**
  13185. * Gets the source animation for a specific property
  13186. * @param property defines the propertyu to look for
  13187. * @returns null or the source animation for the given property
  13188. */
  13189. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13190. /**
  13191. * Gets the runtime animation for a specific property
  13192. * @param property defines the propertyu to look for
  13193. * @returns null or the runtime animation for the given property
  13194. */
  13195. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13196. /**
  13197. * Resets the animatable to its original state
  13198. */
  13199. reset(): void;
  13200. /**
  13201. * Allows the animatable to blend with current running animations
  13202. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13203. * @param blendingSpeed defines the blending speed to use
  13204. */
  13205. enableBlending(blendingSpeed: number): void;
  13206. /**
  13207. * Disable animation blending
  13208. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13209. */
  13210. disableBlending(): void;
  13211. /**
  13212. * Jump directly to a given frame
  13213. * @param frame defines the frame to jump to
  13214. */
  13215. goToFrame(frame: number): void;
  13216. /**
  13217. * Pause the animation
  13218. */
  13219. pause(): void;
  13220. /**
  13221. * Restart the animation
  13222. */
  13223. restart(): void;
  13224. private _raiseOnAnimationEnd;
  13225. /**
  13226. * Stop and delete the current animation
  13227. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13228. * @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)
  13229. */
  13230. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13231. /**
  13232. * Wait asynchronously for the animation to end
  13233. * @returns a promise which will be fullfilled when the animation ends
  13234. */
  13235. waitAsync(): Promise<Animatable>;
  13236. /** @hidden */
  13237. _animate(delay: number): boolean;
  13238. }
  13239. module "babylonjs/scene" {
  13240. interface Scene {
  13241. /** @hidden */
  13242. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13243. /** @hidden */
  13244. _processLateAnimationBindingsForMatrices(holder: {
  13245. totalWeight: number;
  13246. animations: RuntimeAnimation[];
  13247. originalValue: Matrix;
  13248. }): any;
  13249. /** @hidden */
  13250. _processLateAnimationBindingsForQuaternions(holder: {
  13251. totalWeight: number;
  13252. animations: RuntimeAnimation[];
  13253. originalValue: Quaternion;
  13254. }, refQuaternion: Quaternion): Quaternion;
  13255. /** @hidden */
  13256. _processLateAnimationBindings(): void;
  13257. /**
  13258. * Will start the animation sequence of a given target
  13259. * @param target defines the target
  13260. * @param from defines from which frame should animation start
  13261. * @param to defines until which frame should animation run.
  13262. * @param weight defines the weight to apply to the animation (1.0 by default)
  13263. * @param loop defines if the animation loops
  13264. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13265. * @param onAnimationEnd defines the function to be executed when the animation ends
  13266. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13267. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13268. * @param onAnimationLoop defines the callback to call when an animation loops
  13269. * @returns the animatable object created for this animation
  13270. */
  13271. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13272. /**
  13273. * Will start the animation sequence of a given target
  13274. * @param target defines the target
  13275. * @param from defines from which frame should animation start
  13276. * @param to defines until which frame should animation run.
  13277. * @param loop defines if the animation loops
  13278. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13279. * @param onAnimationEnd defines the function to be executed when the animation ends
  13280. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13281. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13282. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13283. * @param onAnimationLoop defines the callback to call when an animation loops
  13284. * @returns the animatable object created for this animation
  13285. */
  13286. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13287. /**
  13288. * Will start the animation sequence of a given target and its hierarchy
  13289. * @param target defines the target
  13290. * @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.
  13291. * @param from defines from which frame should animation start
  13292. * @param to defines until which frame should animation run.
  13293. * @param loop defines if the animation loops
  13294. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13295. * @param onAnimationEnd defines the function to be executed when the animation ends
  13296. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13297. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13298. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13299. * @param onAnimationLoop defines the callback to call when an animation loops
  13300. * @returns the list of created animatables
  13301. */
  13302. 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): Animatable[];
  13303. /**
  13304. * Begin a new animation on a given node
  13305. * @param target defines the target where the animation will take place
  13306. * @param animations defines the list of animations to start
  13307. * @param from defines the initial value
  13308. * @param to defines the final value
  13309. * @param loop defines if you want animation to loop (off by default)
  13310. * @param speedRatio defines the speed ratio to apply to all animations
  13311. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13312. * @param onAnimationLoop defines the callback to call when an animation loops
  13313. * @returns the list of created animatables
  13314. */
  13315. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13316. /**
  13317. * Begin a new animation on a given node and its hierarchy
  13318. * @param target defines the root node where the animation will take place
  13319. * @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.
  13320. * @param animations defines the list of animations to start
  13321. * @param from defines the initial value
  13322. * @param to defines the final value
  13323. * @param loop defines if you want animation to loop (off by default)
  13324. * @param speedRatio defines the speed ratio to apply to all animations
  13325. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13326. * @param onAnimationLoop defines the callback to call when an animation loops
  13327. * @returns the list of animatables created for all nodes
  13328. */
  13329. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13330. /**
  13331. * Gets the animatable associated with a specific target
  13332. * @param target defines the target of the animatable
  13333. * @returns the required animatable if found
  13334. */
  13335. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13336. /**
  13337. * Gets all animatables associated with a given target
  13338. * @param target defines the target to look animatables for
  13339. * @returns an array of Animatables
  13340. */
  13341. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13342. /**
  13343. * Stops and removes all animations that have been applied to the scene
  13344. */
  13345. stopAllAnimations(): void;
  13346. }
  13347. }
  13348. module "babylonjs/Bones/bone" {
  13349. interface Bone {
  13350. /**
  13351. * Copy an animation range from another bone
  13352. * @param source defines the source bone
  13353. * @param rangeName defines the range name to copy
  13354. * @param frameOffset defines the frame offset
  13355. * @param rescaleAsRequired defines if rescaling must be applied if required
  13356. * @param skelDimensionsRatio defines the scaling ratio
  13357. * @returns true if operation was successful
  13358. */
  13359. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13360. }
  13361. }
  13362. }
  13363. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13364. /**
  13365. * Class used to override all child animations of a given target
  13366. */
  13367. export class AnimationPropertiesOverride {
  13368. /**
  13369. * Gets or sets a value indicating if animation blending must be used
  13370. */
  13371. enableBlending: boolean;
  13372. /**
  13373. * Gets or sets the blending speed to use when enableBlending is true
  13374. */
  13375. blendingSpeed: number;
  13376. /**
  13377. * Gets or sets the default loop mode to use
  13378. */
  13379. loopMode: number;
  13380. }
  13381. }
  13382. declare module "babylonjs/Bones/skeleton" {
  13383. import { Bone } from "babylonjs/Bones/bone";
  13384. import { Observable } from "babylonjs/Misc/observable";
  13385. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13386. import { Scene } from "babylonjs/scene";
  13387. import { Nullable } from "babylonjs/types";
  13388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13389. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13390. import { Animatable } from "babylonjs/Animations/animatable";
  13391. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13392. import { Animation } from "babylonjs/Animations/animation";
  13393. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13394. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13395. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13396. /**
  13397. * Class used to handle skinning animations
  13398. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13399. */
  13400. export class Skeleton implements IAnimatable {
  13401. /** defines the skeleton name */
  13402. name: string;
  13403. /** defines the skeleton Id */
  13404. id: string;
  13405. /**
  13406. * Defines the list of child bones
  13407. */
  13408. bones: Bone[];
  13409. /**
  13410. * Defines an estimate of the dimension of the skeleton at rest
  13411. */
  13412. dimensionsAtRest: Vector3;
  13413. /**
  13414. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13415. */
  13416. needInitialSkinMatrix: boolean;
  13417. /**
  13418. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13419. */
  13420. overrideMesh: Nullable<AbstractMesh>;
  13421. /**
  13422. * Gets the list of animations attached to this skeleton
  13423. */
  13424. animations: Array<Animation>;
  13425. private _scene;
  13426. private _isDirty;
  13427. private _transformMatrices;
  13428. private _transformMatrixTexture;
  13429. private _meshesWithPoseMatrix;
  13430. private _animatables;
  13431. private _identity;
  13432. private _synchronizedWithMesh;
  13433. private _ranges;
  13434. private _lastAbsoluteTransformsUpdateId;
  13435. private _canUseTextureForBones;
  13436. private _uniqueId;
  13437. /** @hidden */
  13438. _numBonesWithLinkedTransformNode: number;
  13439. /** @hidden */
  13440. _hasWaitingData: Nullable<boolean>;
  13441. /**
  13442. * Specifies if the skeleton should be serialized
  13443. */
  13444. doNotSerialize: boolean;
  13445. private _useTextureToStoreBoneMatrices;
  13446. /**
  13447. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13448. * Please note that this option is not available if the hardware does not support it
  13449. */
  13450. useTextureToStoreBoneMatrices: boolean;
  13451. private _animationPropertiesOverride;
  13452. /**
  13453. * Gets or sets the animation properties override
  13454. */
  13455. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13456. /**
  13457. * List of inspectable custom properties (used by the Inspector)
  13458. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13459. */
  13460. inspectableCustomProperties: IInspectable[];
  13461. /**
  13462. * An observable triggered before computing the skeleton's matrices
  13463. */
  13464. onBeforeComputeObservable: Observable<Skeleton>;
  13465. /**
  13466. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13467. */
  13468. readonly isUsingTextureForMatrices: boolean;
  13469. /**
  13470. * Gets the unique ID of this skeleton
  13471. */
  13472. readonly uniqueId: number;
  13473. /**
  13474. * Creates a new skeleton
  13475. * @param name defines the skeleton name
  13476. * @param id defines the skeleton Id
  13477. * @param scene defines the hosting scene
  13478. */
  13479. constructor(
  13480. /** defines the skeleton name */
  13481. name: string,
  13482. /** defines the skeleton Id */
  13483. id: string, scene: Scene);
  13484. /**
  13485. * Gets the current object class name.
  13486. * @return the class name
  13487. */
  13488. getClassName(): string;
  13489. /**
  13490. * Returns an array containing the root bones
  13491. * @returns an array containing the root bones
  13492. */
  13493. getChildren(): Array<Bone>;
  13494. /**
  13495. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13496. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13497. * @returns a Float32Array containing matrices data
  13498. */
  13499. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13500. /**
  13501. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13502. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13503. * @returns a raw texture containing the data
  13504. */
  13505. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13506. /**
  13507. * Gets the current hosting scene
  13508. * @returns a scene object
  13509. */
  13510. getScene(): Scene;
  13511. /**
  13512. * Gets a string representing the current skeleton data
  13513. * @param fullDetails defines a boolean indicating if we want a verbose version
  13514. * @returns a string representing the current skeleton data
  13515. */
  13516. toString(fullDetails?: boolean): string;
  13517. /**
  13518. * Get bone's index searching by name
  13519. * @param name defines bone's name to search for
  13520. * @return the indice of the bone. Returns -1 if not found
  13521. */
  13522. getBoneIndexByName(name: string): number;
  13523. /**
  13524. * Creater a new animation range
  13525. * @param name defines the name of the range
  13526. * @param from defines the start key
  13527. * @param to defines the end key
  13528. */
  13529. createAnimationRange(name: string, from: number, to: number): void;
  13530. /**
  13531. * Delete a specific animation range
  13532. * @param name defines the name of the range
  13533. * @param deleteFrames defines if frames must be removed as well
  13534. */
  13535. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13536. /**
  13537. * Gets a specific animation range
  13538. * @param name defines the name of the range to look for
  13539. * @returns the requested animation range or null if not found
  13540. */
  13541. getAnimationRange(name: string): Nullable<AnimationRange>;
  13542. /**
  13543. * Gets the list of all animation ranges defined on this skeleton
  13544. * @returns an array
  13545. */
  13546. getAnimationRanges(): Nullable<AnimationRange>[];
  13547. /**
  13548. * Copy animation range from a source skeleton.
  13549. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13550. * @param source defines the source skeleton
  13551. * @param name defines the name of the range to copy
  13552. * @param rescaleAsRequired defines if rescaling must be applied if required
  13553. * @returns true if operation was successful
  13554. */
  13555. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13556. /**
  13557. * Forces the skeleton to go to rest pose
  13558. */
  13559. returnToRest(): void;
  13560. private _getHighestAnimationFrame;
  13561. /**
  13562. * Begin a specific animation range
  13563. * @param name defines the name of the range to start
  13564. * @param loop defines if looping must be turned on (false by default)
  13565. * @param speedRatio defines the speed ratio to apply (1 by default)
  13566. * @param onAnimationEnd defines a callback which will be called when animation will end
  13567. * @returns a new animatable
  13568. */
  13569. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13570. /** @hidden */
  13571. _markAsDirty(): void;
  13572. /** @hidden */
  13573. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13574. /** @hidden */
  13575. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13576. private _computeTransformMatrices;
  13577. /**
  13578. * Build all resources required to render a skeleton
  13579. */
  13580. prepare(): void;
  13581. /**
  13582. * Gets the list of animatables currently running for this skeleton
  13583. * @returns an array of animatables
  13584. */
  13585. getAnimatables(): IAnimatable[];
  13586. /**
  13587. * Clone the current skeleton
  13588. * @param name defines the name of the new skeleton
  13589. * @param id defines the id of the new skeleton
  13590. * @returns the new skeleton
  13591. */
  13592. clone(name: string, id: string): Skeleton;
  13593. /**
  13594. * Enable animation blending for this skeleton
  13595. * @param blendingSpeed defines the blending speed to apply
  13596. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13597. */
  13598. enableBlending(blendingSpeed?: number): void;
  13599. /**
  13600. * Releases all resources associated with the current skeleton
  13601. */
  13602. dispose(): void;
  13603. /**
  13604. * Serialize the skeleton in a JSON object
  13605. * @returns a JSON object
  13606. */
  13607. serialize(): any;
  13608. /**
  13609. * Creates a new skeleton from serialized data
  13610. * @param parsedSkeleton defines the serialized data
  13611. * @param scene defines the hosting scene
  13612. * @returns a new skeleton
  13613. */
  13614. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13615. /**
  13616. * Compute all node absolute transforms
  13617. * @param forceUpdate defines if computation must be done even if cache is up to date
  13618. */
  13619. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13620. /**
  13621. * Gets the root pose matrix
  13622. * @returns a matrix
  13623. */
  13624. getPoseMatrix(): Nullable<Matrix>;
  13625. /**
  13626. * Sorts bones per internal index
  13627. */
  13628. sortBones(): void;
  13629. private _sortBones;
  13630. }
  13631. }
  13632. declare module "babylonjs/Bones/bone" {
  13633. import { Skeleton } from "babylonjs/Bones/skeleton";
  13634. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13635. import { Nullable } from "babylonjs/types";
  13636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13637. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13638. import { Node } from "babylonjs/node";
  13639. import { Space } from "babylonjs/Maths/math.axis";
  13640. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13641. /**
  13642. * Class used to store bone information
  13643. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13644. */
  13645. export class Bone extends Node {
  13646. /**
  13647. * defines the bone name
  13648. */
  13649. name: string;
  13650. private static _tmpVecs;
  13651. private static _tmpQuat;
  13652. private static _tmpMats;
  13653. /**
  13654. * Gets the list of child bones
  13655. */
  13656. children: Bone[];
  13657. /** Gets the animations associated with this bone */
  13658. animations: import("babylonjs/Animations/animation").Animation[];
  13659. /**
  13660. * Gets or sets bone length
  13661. */
  13662. length: number;
  13663. /**
  13664. * @hidden Internal only
  13665. * Set this value to map this bone to a different index in the transform matrices
  13666. * Set this value to -1 to exclude the bone from the transform matrices
  13667. */
  13668. _index: Nullable<number>;
  13669. private _skeleton;
  13670. private _localMatrix;
  13671. private _restPose;
  13672. private _baseMatrix;
  13673. private _absoluteTransform;
  13674. private _invertedAbsoluteTransform;
  13675. private _parent;
  13676. private _scalingDeterminant;
  13677. private _worldTransform;
  13678. private _localScaling;
  13679. private _localRotation;
  13680. private _localPosition;
  13681. private _needToDecompose;
  13682. private _needToCompose;
  13683. /** @hidden */
  13684. _linkedTransformNode: Nullable<TransformNode>;
  13685. /** @hidden */
  13686. _waitingTransformNodeId: Nullable<string>;
  13687. /** @hidden */
  13688. /** @hidden */
  13689. _matrix: Matrix;
  13690. /**
  13691. * Create a new bone
  13692. * @param name defines the bone name
  13693. * @param skeleton defines the parent skeleton
  13694. * @param parentBone defines the parent (can be null if the bone is the root)
  13695. * @param localMatrix defines the local matrix
  13696. * @param restPose defines the rest pose matrix
  13697. * @param baseMatrix defines the base matrix
  13698. * @param index defines index of the bone in the hiearchy
  13699. */
  13700. constructor(
  13701. /**
  13702. * defines the bone name
  13703. */
  13704. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13705. /**
  13706. * Gets the current object class name.
  13707. * @return the class name
  13708. */
  13709. getClassName(): string;
  13710. /**
  13711. * Gets the parent skeleton
  13712. * @returns a skeleton
  13713. */
  13714. getSkeleton(): Skeleton;
  13715. /**
  13716. * Gets parent bone
  13717. * @returns a bone or null if the bone is the root of the bone hierarchy
  13718. */
  13719. getParent(): Nullable<Bone>;
  13720. /**
  13721. * Returns an array containing the root bones
  13722. * @returns an array containing the root bones
  13723. */
  13724. getChildren(): Array<Bone>;
  13725. /**
  13726. * Sets the parent bone
  13727. * @param parent defines the parent (can be null if the bone is the root)
  13728. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13729. */
  13730. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13731. /**
  13732. * Gets the local matrix
  13733. * @returns a matrix
  13734. */
  13735. getLocalMatrix(): Matrix;
  13736. /**
  13737. * Gets the base matrix (initial matrix which remains unchanged)
  13738. * @returns a matrix
  13739. */
  13740. getBaseMatrix(): Matrix;
  13741. /**
  13742. * Gets the rest pose matrix
  13743. * @returns a matrix
  13744. */
  13745. getRestPose(): Matrix;
  13746. /**
  13747. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13748. */
  13749. getWorldMatrix(): Matrix;
  13750. /**
  13751. * Sets the local matrix to rest pose matrix
  13752. */
  13753. returnToRest(): void;
  13754. /**
  13755. * Gets the inverse of the absolute transform matrix.
  13756. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13757. * @returns a matrix
  13758. */
  13759. getInvertedAbsoluteTransform(): Matrix;
  13760. /**
  13761. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13762. * @returns a matrix
  13763. */
  13764. getAbsoluteTransform(): Matrix;
  13765. /**
  13766. * Links with the given transform node.
  13767. * The local matrix of this bone is copied from the transform node every frame.
  13768. * @param transformNode defines the transform node to link to
  13769. */
  13770. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13771. /**
  13772. * Gets the node used to drive the bone's transformation
  13773. * @returns a transform node or null
  13774. */
  13775. getTransformNode(): Nullable<TransformNode>;
  13776. /** Gets or sets current position (in local space) */
  13777. position: Vector3;
  13778. /** Gets or sets current rotation (in local space) */
  13779. rotation: Vector3;
  13780. /** Gets or sets current rotation quaternion (in local space) */
  13781. rotationQuaternion: Quaternion;
  13782. /** Gets or sets current scaling (in local space) */
  13783. scaling: Vector3;
  13784. /**
  13785. * Gets the animation properties override
  13786. */
  13787. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13788. private _decompose;
  13789. private _compose;
  13790. /**
  13791. * Update the base and local matrices
  13792. * @param matrix defines the new base or local matrix
  13793. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13794. * @param updateLocalMatrix defines if the local matrix should be updated
  13795. */
  13796. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13797. /** @hidden */
  13798. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13799. /**
  13800. * Flag the bone as dirty (Forcing it to update everything)
  13801. */
  13802. markAsDirty(): void;
  13803. /** @hidden */
  13804. _markAsDirtyAndCompose(): void;
  13805. private _markAsDirtyAndDecompose;
  13806. /**
  13807. * Translate the bone in local or world space
  13808. * @param vec The amount to translate the bone
  13809. * @param space The space that the translation is in
  13810. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13811. */
  13812. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13813. /**
  13814. * Set the postion of the bone in local or world space
  13815. * @param position The position to set the bone
  13816. * @param space The space that the position is in
  13817. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13818. */
  13819. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13820. /**
  13821. * Set the absolute position of the bone (world space)
  13822. * @param position The position to set the bone
  13823. * @param mesh The mesh that this bone is attached to
  13824. */
  13825. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13826. /**
  13827. * Scale the bone on the x, y and z axes (in local space)
  13828. * @param x The amount to scale the bone on the x axis
  13829. * @param y The amount to scale the bone on the y axis
  13830. * @param z The amount to scale the bone on the z axis
  13831. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13832. */
  13833. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13834. /**
  13835. * Set the bone scaling in local space
  13836. * @param scale defines the scaling vector
  13837. */
  13838. setScale(scale: Vector3): void;
  13839. /**
  13840. * Gets the current scaling in local space
  13841. * @returns the current scaling vector
  13842. */
  13843. getScale(): Vector3;
  13844. /**
  13845. * Gets the current scaling in local space and stores it in a target vector
  13846. * @param result defines the target vector
  13847. */
  13848. getScaleToRef(result: Vector3): void;
  13849. /**
  13850. * Set the yaw, pitch, and roll of the bone in local or world space
  13851. * @param yaw The rotation of the bone on the y axis
  13852. * @param pitch The rotation of the bone on the x axis
  13853. * @param roll The rotation of the bone on the z axis
  13854. * @param space The space that the axes of rotation are in
  13855. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13856. */
  13857. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13858. /**
  13859. * Add a rotation to the bone on an axis in local or world space
  13860. * @param axis The axis to rotate the bone on
  13861. * @param amount The amount to rotate the bone
  13862. * @param space The space that the axis is in
  13863. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13864. */
  13865. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13866. /**
  13867. * Set the rotation of the bone to a particular axis angle in local or world space
  13868. * @param axis The axis to rotate the bone on
  13869. * @param angle The angle that the bone should be rotated to
  13870. * @param space The space that the axis is in
  13871. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13872. */
  13873. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13874. /**
  13875. * Set the euler rotation of the bone in local of world space
  13876. * @param rotation The euler rotation that the bone should be set to
  13877. * @param space The space that the rotation is in
  13878. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13879. */
  13880. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13881. /**
  13882. * Set the quaternion rotation of the bone in local of world space
  13883. * @param quat The quaternion rotation that the bone should be set to
  13884. * @param space The space that the rotation is in
  13885. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13886. */
  13887. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13888. /**
  13889. * Set the rotation matrix of the bone in local of world space
  13890. * @param rotMat The rotation matrix that the bone should be set to
  13891. * @param space The space that the rotation is in
  13892. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13893. */
  13894. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13895. private _rotateWithMatrix;
  13896. private _getNegativeRotationToRef;
  13897. /**
  13898. * Get the position of the bone in local or world space
  13899. * @param space The space that the returned position is in
  13900. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13901. * @returns The position of the bone
  13902. */
  13903. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13904. /**
  13905. * Copy the position of the bone to a vector3 in local or world space
  13906. * @param space The space that the returned position is in
  13907. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13908. * @param result The vector3 to copy the position to
  13909. */
  13910. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13911. /**
  13912. * Get the absolute position of the bone (world space)
  13913. * @param mesh The mesh that this bone is attached to
  13914. * @returns The absolute position of the bone
  13915. */
  13916. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13917. /**
  13918. * Copy the absolute position of the bone (world space) to the result param
  13919. * @param mesh The mesh that this bone is attached to
  13920. * @param result The vector3 to copy the absolute position to
  13921. */
  13922. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13923. /**
  13924. * Compute the absolute transforms of this bone and its children
  13925. */
  13926. computeAbsoluteTransforms(): void;
  13927. /**
  13928. * Get the world direction from an axis that is in the local space of the bone
  13929. * @param localAxis The local direction that is used to compute the world direction
  13930. * @param mesh The mesh that this bone is attached to
  13931. * @returns The world direction
  13932. */
  13933. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13934. /**
  13935. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13936. * @param localAxis The local direction that is used to compute the world direction
  13937. * @param mesh The mesh that this bone is attached to
  13938. * @param result The vector3 that the world direction will be copied to
  13939. */
  13940. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13941. /**
  13942. * Get the euler rotation of the bone in local or world space
  13943. * @param space The space that the rotation should be in
  13944. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13945. * @returns The euler rotation
  13946. */
  13947. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13948. /**
  13949. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13950. * @param space The space that the rotation should be in
  13951. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13952. * @param result The vector3 that the rotation should be copied to
  13953. */
  13954. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13955. /**
  13956. * Get the quaternion rotation of the bone in either local or world space
  13957. * @param space The space that the rotation should be in
  13958. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13959. * @returns The quaternion rotation
  13960. */
  13961. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13962. /**
  13963. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13964. * @param space The space that the rotation should be in
  13965. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13966. * @param result The quaternion that the rotation should be copied to
  13967. */
  13968. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13969. /**
  13970. * Get the rotation matrix of the bone in local or world space
  13971. * @param space The space that the rotation should be in
  13972. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13973. * @returns The rotation matrix
  13974. */
  13975. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13976. /**
  13977. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13978. * @param space The space that the rotation should be in
  13979. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13980. * @param result The quaternion that the rotation should be copied to
  13981. */
  13982. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13983. /**
  13984. * Get the world position of a point that is in the local space of the bone
  13985. * @param position The local position
  13986. * @param mesh The mesh that this bone is attached to
  13987. * @returns The world position
  13988. */
  13989. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13990. /**
  13991. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13992. * @param position The local position
  13993. * @param mesh The mesh that this bone is attached to
  13994. * @param result The vector3 that the world position should be copied to
  13995. */
  13996. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13997. /**
  13998. * Get the local position of a point that is in world space
  13999. * @param position The world position
  14000. * @param mesh The mesh that this bone is attached to
  14001. * @returns The local position
  14002. */
  14003. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14004. /**
  14005. * Get the local position of a point that is in world space and copy it to the result param
  14006. * @param position The world position
  14007. * @param mesh The mesh that this bone is attached to
  14008. * @param result The vector3 that the local position should be copied to
  14009. */
  14010. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14011. }
  14012. }
  14013. declare module "babylonjs/Meshes/transformNode" {
  14014. import { DeepImmutable } from "babylonjs/types";
  14015. import { Observable } from "babylonjs/Misc/observable";
  14016. import { Nullable } from "babylonjs/types";
  14017. import { Camera } from "babylonjs/Cameras/camera";
  14018. import { Scene } from "babylonjs/scene";
  14019. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14020. import { Node } from "babylonjs/node";
  14021. import { Bone } from "babylonjs/Bones/bone";
  14022. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14023. import { Space } from "babylonjs/Maths/math.axis";
  14024. /**
  14025. * 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.
  14026. * @see https://doc.babylonjs.com/how_to/transformnode
  14027. */
  14028. export class TransformNode extends Node {
  14029. /**
  14030. * Object will not rotate to face the camera
  14031. */
  14032. static BILLBOARDMODE_NONE: number;
  14033. /**
  14034. * Object will rotate to face the camera but only on the x axis
  14035. */
  14036. static BILLBOARDMODE_X: number;
  14037. /**
  14038. * Object will rotate to face the camera but only on the y axis
  14039. */
  14040. static BILLBOARDMODE_Y: number;
  14041. /**
  14042. * Object will rotate to face the camera but only on the z axis
  14043. */
  14044. static BILLBOARDMODE_Z: number;
  14045. /**
  14046. * Object will rotate to face the camera
  14047. */
  14048. static BILLBOARDMODE_ALL: number;
  14049. /**
  14050. * Object will rotate to face the camera's position instead of orientation
  14051. */
  14052. static BILLBOARDMODE_USE_POSITION: number;
  14053. private _forward;
  14054. private _forwardInverted;
  14055. private _up;
  14056. private _right;
  14057. private _rightInverted;
  14058. private _position;
  14059. private _rotation;
  14060. private _rotationQuaternion;
  14061. protected _scaling: Vector3;
  14062. protected _isDirty: boolean;
  14063. private _transformToBoneReferal;
  14064. private _isAbsoluteSynced;
  14065. private _billboardMode;
  14066. /**
  14067. * Gets or sets the billboard mode. Default is 0.
  14068. *
  14069. * | Value | Type | Description |
  14070. * | --- | --- | --- |
  14071. * | 0 | BILLBOARDMODE_NONE | |
  14072. * | 1 | BILLBOARDMODE_X | |
  14073. * | 2 | BILLBOARDMODE_Y | |
  14074. * | 4 | BILLBOARDMODE_Z | |
  14075. * | 7 | BILLBOARDMODE_ALL | |
  14076. *
  14077. */
  14078. billboardMode: number;
  14079. private _preserveParentRotationForBillboard;
  14080. /**
  14081. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14082. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14083. */
  14084. preserveParentRotationForBillboard: boolean;
  14085. /**
  14086. * 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
  14087. */
  14088. scalingDeterminant: number;
  14089. private _infiniteDistance;
  14090. /**
  14091. * Gets or sets the distance of the object to max, often used by skybox
  14092. */
  14093. infiniteDistance: boolean;
  14094. /**
  14095. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14096. * By default the system will update normals to compensate
  14097. */
  14098. ignoreNonUniformScaling: boolean;
  14099. /**
  14100. * 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
  14101. */
  14102. reIntegrateRotationIntoRotationQuaternion: boolean;
  14103. /** @hidden */
  14104. _poseMatrix: Nullable<Matrix>;
  14105. /** @hidden */
  14106. _localMatrix: Matrix;
  14107. private _usePivotMatrix;
  14108. private _absolutePosition;
  14109. private _absoluteScaling;
  14110. private _absoluteRotationQuaternion;
  14111. private _pivotMatrix;
  14112. private _pivotMatrixInverse;
  14113. protected _postMultiplyPivotMatrix: boolean;
  14114. protected _isWorldMatrixFrozen: boolean;
  14115. /** @hidden */
  14116. _indexInSceneTransformNodesArray: number;
  14117. /**
  14118. * An event triggered after the world matrix is updated
  14119. */
  14120. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14121. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14122. /**
  14123. * Gets a string identifying the name of the class
  14124. * @returns "TransformNode" string
  14125. */
  14126. getClassName(): string;
  14127. /**
  14128. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14129. */
  14130. position: Vector3;
  14131. /**
  14132. * 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)).
  14133. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14134. */
  14135. rotation: Vector3;
  14136. /**
  14137. * 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)).
  14138. */
  14139. scaling: Vector3;
  14140. /**
  14141. * 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).
  14142. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14143. */
  14144. rotationQuaternion: Nullable<Quaternion>;
  14145. /**
  14146. * The forward direction of that transform in world space.
  14147. */
  14148. readonly forward: Vector3;
  14149. /**
  14150. * The up direction of that transform in world space.
  14151. */
  14152. readonly up: Vector3;
  14153. /**
  14154. * The right direction of that transform in world space.
  14155. */
  14156. readonly right: Vector3;
  14157. /**
  14158. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14159. * @param matrix the matrix to copy the pose from
  14160. * @returns this TransformNode.
  14161. */
  14162. updatePoseMatrix(matrix: Matrix): TransformNode;
  14163. /**
  14164. * Returns the mesh Pose matrix.
  14165. * @returns the pose matrix
  14166. */
  14167. getPoseMatrix(): Matrix;
  14168. /** @hidden */
  14169. _isSynchronized(): boolean;
  14170. /** @hidden */
  14171. _initCache(): void;
  14172. /**
  14173. * Flag the transform node as dirty (Forcing it to update everything)
  14174. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14175. * @returns this transform node
  14176. */
  14177. markAsDirty(property: string): TransformNode;
  14178. /**
  14179. * Returns the current mesh absolute position.
  14180. * Returns a Vector3.
  14181. */
  14182. readonly absolutePosition: Vector3;
  14183. /**
  14184. * Returns the current mesh absolute scaling.
  14185. * Returns a Vector3.
  14186. */
  14187. readonly absoluteScaling: Vector3;
  14188. /**
  14189. * Returns the current mesh absolute rotation.
  14190. * Returns a Quaternion.
  14191. */
  14192. readonly absoluteRotationQuaternion: Quaternion;
  14193. /**
  14194. * Sets a new matrix to apply before all other transformation
  14195. * @param matrix defines the transform matrix
  14196. * @returns the current TransformNode
  14197. */
  14198. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14199. /**
  14200. * Sets a new pivot matrix to the current node
  14201. * @param matrix defines the new pivot matrix to use
  14202. * @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
  14203. * @returns the current TransformNode
  14204. */
  14205. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14206. /**
  14207. * Returns the mesh pivot matrix.
  14208. * Default : Identity.
  14209. * @returns the matrix
  14210. */
  14211. getPivotMatrix(): Matrix;
  14212. /**
  14213. * Instantiate (when possible) or clone that node with its hierarchy
  14214. * @param newParent defines the new parent to use for the instance (or clone)
  14215. * @returns an instance (or a clone) of the current node with its hiearchy
  14216. */
  14217. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14218. /**
  14219. * Prevents the World matrix to be computed any longer
  14220. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14221. * @returns the TransformNode.
  14222. */
  14223. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14224. /**
  14225. * Allows back the World matrix computation.
  14226. * @returns the TransformNode.
  14227. */
  14228. unfreezeWorldMatrix(): this;
  14229. /**
  14230. * True if the World matrix has been frozen.
  14231. */
  14232. readonly isWorldMatrixFrozen: boolean;
  14233. /**
  14234. * Retuns the mesh absolute position in the World.
  14235. * @returns a Vector3.
  14236. */
  14237. getAbsolutePosition(): Vector3;
  14238. /**
  14239. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14240. * @param absolutePosition the absolute position to set
  14241. * @returns the TransformNode.
  14242. */
  14243. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14244. /**
  14245. * Sets the mesh position in its local space.
  14246. * @param vector3 the position to set in localspace
  14247. * @returns the TransformNode.
  14248. */
  14249. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14250. /**
  14251. * Returns the mesh position in the local space from the current World matrix values.
  14252. * @returns a new Vector3.
  14253. */
  14254. getPositionExpressedInLocalSpace(): Vector3;
  14255. /**
  14256. * Translates the mesh along the passed Vector3 in its local space.
  14257. * @param vector3 the distance to translate in localspace
  14258. * @returns the TransformNode.
  14259. */
  14260. locallyTranslate(vector3: Vector3): TransformNode;
  14261. private static _lookAtVectorCache;
  14262. /**
  14263. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14264. * @param targetPoint the position (must be in same space as current mesh) to look at
  14265. * @param yawCor optional yaw (y-axis) correction in radians
  14266. * @param pitchCor optional pitch (x-axis) correction in radians
  14267. * @param rollCor optional roll (z-axis) correction in radians
  14268. * @param space the choosen space of the target
  14269. * @returns the TransformNode.
  14270. */
  14271. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14272. /**
  14273. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14274. * This Vector3 is expressed in the World space.
  14275. * @param localAxis axis to rotate
  14276. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14277. */
  14278. getDirection(localAxis: Vector3): Vector3;
  14279. /**
  14280. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14281. * localAxis is expressed in the mesh local space.
  14282. * result is computed in the Wordl space from the mesh World matrix.
  14283. * @param localAxis axis to rotate
  14284. * @param result the resulting transformnode
  14285. * @returns this TransformNode.
  14286. */
  14287. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14288. /**
  14289. * Sets this transform node rotation to the given local axis.
  14290. * @param localAxis the axis in local space
  14291. * @param yawCor optional yaw (y-axis) correction in radians
  14292. * @param pitchCor optional pitch (x-axis) correction in radians
  14293. * @param rollCor optional roll (z-axis) correction in radians
  14294. * @returns this TransformNode
  14295. */
  14296. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14297. /**
  14298. * Sets a new pivot point to the current node
  14299. * @param point defines the new pivot point to use
  14300. * @param space defines if the point is in world or local space (local by default)
  14301. * @returns the current TransformNode
  14302. */
  14303. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14304. /**
  14305. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14306. * @returns the pivot point
  14307. */
  14308. getPivotPoint(): Vector3;
  14309. /**
  14310. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14311. * @param result the vector3 to store the result
  14312. * @returns this TransformNode.
  14313. */
  14314. getPivotPointToRef(result: Vector3): TransformNode;
  14315. /**
  14316. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14317. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14318. */
  14319. getAbsolutePivotPoint(): Vector3;
  14320. /**
  14321. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14322. * @param result vector3 to store the result
  14323. * @returns this TransformNode.
  14324. */
  14325. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14326. /**
  14327. * Defines the passed node as the parent of the current node.
  14328. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14329. * @see https://doc.babylonjs.com/how_to/parenting
  14330. * @param node the node ot set as the parent
  14331. * @returns this TransformNode.
  14332. */
  14333. setParent(node: Nullable<Node>): TransformNode;
  14334. private _nonUniformScaling;
  14335. /**
  14336. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14337. */
  14338. readonly nonUniformScaling: boolean;
  14339. /** @hidden */
  14340. _updateNonUniformScalingState(value: boolean): boolean;
  14341. /**
  14342. * Attach the current TransformNode to another TransformNode associated with a bone
  14343. * @param bone Bone affecting the TransformNode
  14344. * @param affectedTransformNode TransformNode associated with the bone
  14345. * @returns this object
  14346. */
  14347. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14348. /**
  14349. * Detach the transform node if its associated with a bone
  14350. * @returns this object
  14351. */
  14352. detachFromBone(): TransformNode;
  14353. private static _rotationAxisCache;
  14354. /**
  14355. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14356. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14357. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14358. * The passed axis is also normalized.
  14359. * @param axis the axis to rotate around
  14360. * @param amount the amount to rotate in radians
  14361. * @param space Space to rotate in (Default: local)
  14362. * @returns the TransformNode.
  14363. */
  14364. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14365. /**
  14366. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14367. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14368. * The passed axis is also normalized. .
  14369. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14370. * @param point the point to rotate around
  14371. * @param axis the axis to rotate around
  14372. * @param amount the amount to rotate in radians
  14373. * @returns the TransformNode
  14374. */
  14375. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14376. /**
  14377. * Translates the mesh along the axis vector for the passed distance in the given space.
  14378. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14379. * @param axis the axis to translate in
  14380. * @param distance the distance to translate
  14381. * @param space Space to rotate in (Default: local)
  14382. * @returns the TransformNode.
  14383. */
  14384. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14385. /**
  14386. * Adds a rotation step to the mesh current rotation.
  14387. * x, y, z are Euler angles expressed in radians.
  14388. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14389. * This means this rotation is made in the mesh local space only.
  14390. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14391. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14392. * ```javascript
  14393. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14394. * ```
  14395. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14396. * 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.
  14397. * @param x Rotation to add
  14398. * @param y Rotation to add
  14399. * @param z Rotation to add
  14400. * @returns the TransformNode.
  14401. */
  14402. addRotation(x: number, y: number, z: number): TransformNode;
  14403. /**
  14404. * @hidden
  14405. */
  14406. protected _getEffectiveParent(): Nullable<Node>;
  14407. /**
  14408. * Computes the world matrix of the node
  14409. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14410. * @returns the world matrix
  14411. */
  14412. computeWorldMatrix(force?: boolean): Matrix;
  14413. protected _afterComputeWorldMatrix(): void;
  14414. /**
  14415. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14416. * @param func callback function to add
  14417. *
  14418. * @returns the TransformNode.
  14419. */
  14420. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14421. /**
  14422. * Removes a registered callback function.
  14423. * @param func callback function to remove
  14424. * @returns the TransformNode.
  14425. */
  14426. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14427. /**
  14428. * Gets the position of the current mesh in camera space
  14429. * @param camera defines the camera to use
  14430. * @returns a position
  14431. */
  14432. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14433. /**
  14434. * Returns the distance from the mesh to the active camera
  14435. * @param camera defines the camera to use
  14436. * @returns the distance
  14437. */
  14438. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14439. /**
  14440. * Clone the current transform node
  14441. * @param name Name of the new clone
  14442. * @param newParent New parent for the clone
  14443. * @param doNotCloneChildren Do not clone children hierarchy
  14444. * @returns the new transform node
  14445. */
  14446. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14447. /**
  14448. * Serializes the objects information.
  14449. * @param currentSerializationObject defines the object to serialize in
  14450. * @returns the serialized object
  14451. */
  14452. serialize(currentSerializationObject?: any): any;
  14453. /**
  14454. * Returns a new TransformNode object parsed from the source provided.
  14455. * @param parsedTransformNode is the source.
  14456. * @param scene the scne the object belongs to
  14457. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14458. * @returns a new TransformNode object parsed from the source provided.
  14459. */
  14460. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14461. /**
  14462. * Get all child-transformNodes of this node
  14463. * @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
  14464. * @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
  14465. * @returns an array of TransformNode
  14466. */
  14467. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14468. /**
  14469. * Releases resources associated with this transform node.
  14470. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14471. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14472. */
  14473. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14474. /**
  14475. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14476. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14477. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14478. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14479. * @returns the current mesh
  14480. */
  14481. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14482. private _syncAbsoluteScalingAndRotation;
  14483. }
  14484. }
  14485. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14486. import { Observable } from "babylonjs/Misc/observable";
  14487. import { Nullable } from "babylonjs/types";
  14488. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14489. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14491. import { Ray } from "babylonjs/Culling/ray";
  14492. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14493. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14494. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14495. /**
  14496. * Defines the types of pose enabled controllers that are supported
  14497. */
  14498. export enum PoseEnabledControllerType {
  14499. /**
  14500. * HTC Vive
  14501. */
  14502. VIVE = 0,
  14503. /**
  14504. * Oculus Rift
  14505. */
  14506. OCULUS = 1,
  14507. /**
  14508. * Windows mixed reality
  14509. */
  14510. WINDOWS = 2,
  14511. /**
  14512. * Samsung gear VR
  14513. */
  14514. GEAR_VR = 3,
  14515. /**
  14516. * Google Daydream
  14517. */
  14518. DAYDREAM = 4,
  14519. /**
  14520. * Generic
  14521. */
  14522. GENERIC = 5
  14523. }
  14524. /**
  14525. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14526. */
  14527. export interface MutableGamepadButton {
  14528. /**
  14529. * Value of the button/trigger
  14530. */
  14531. value: number;
  14532. /**
  14533. * If the button/trigger is currently touched
  14534. */
  14535. touched: boolean;
  14536. /**
  14537. * If the button/trigger is currently pressed
  14538. */
  14539. pressed: boolean;
  14540. }
  14541. /**
  14542. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14543. * @hidden
  14544. */
  14545. export interface ExtendedGamepadButton extends GamepadButton {
  14546. /**
  14547. * If the button/trigger is currently pressed
  14548. */
  14549. readonly pressed: boolean;
  14550. /**
  14551. * If the button/trigger is currently touched
  14552. */
  14553. readonly touched: boolean;
  14554. /**
  14555. * Value of the button/trigger
  14556. */
  14557. readonly value: number;
  14558. }
  14559. /** @hidden */
  14560. export interface _GamePadFactory {
  14561. /**
  14562. * Returns wether or not the current gamepad can be created for this type of controller.
  14563. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14564. * @returns true if it can be created, otherwise false
  14565. */
  14566. canCreate(gamepadInfo: any): boolean;
  14567. /**
  14568. * Creates a new instance of the Gamepad.
  14569. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14570. * @returns the new gamepad instance
  14571. */
  14572. create(gamepadInfo: any): Gamepad;
  14573. }
  14574. /**
  14575. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14576. */
  14577. export class PoseEnabledControllerHelper {
  14578. /** @hidden */
  14579. static _ControllerFactories: _GamePadFactory[];
  14580. /** @hidden */
  14581. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14582. /**
  14583. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14584. * @param vrGamepad the gamepad to initialized
  14585. * @returns a vr controller of the type the gamepad identified as
  14586. */
  14587. static InitiateController(vrGamepad: any): Gamepad;
  14588. }
  14589. /**
  14590. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14591. */
  14592. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14593. /**
  14594. * If the controller is used in a webXR session
  14595. */
  14596. isXR: boolean;
  14597. private _deviceRoomPosition;
  14598. private _deviceRoomRotationQuaternion;
  14599. /**
  14600. * The device position in babylon space
  14601. */
  14602. devicePosition: Vector3;
  14603. /**
  14604. * The device rotation in babylon space
  14605. */
  14606. deviceRotationQuaternion: Quaternion;
  14607. /**
  14608. * The scale factor of the device in babylon space
  14609. */
  14610. deviceScaleFactor: number;
  14611. /**
  14612. * (Likely devicePosition should be used instead) The device position in its room space
  14613. */
  14614. position: Vector3;
  14615. /**
  14616. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14617. */
  14618. rotationQuaternion: Quaternion;
  14619. /**
  14620. * The type of controller (Eg. Windows mixed reality)
  14621. */
  14622. controllerType: PoseEnabledControllerType;
  14623. protected _calculatedPosition: Vector3;
  14624. private _calculatedRotation;
  14625. /**
  14626. * The raw pose from the device
  14627. */
  14628. rawPose: DevicePose;
  14629. private _trackPosition;
  14630. private _maxRotationDistFromHeadset;
  14631. private _draggedRoomRotation;
  14632. /**
  14633. * @hidden
  14634. */
  14635. _disableTrackPosition(fixedPosition: Vector3): void;
  14636. /**
  14637. * Internal, the mesh attached to the controller
  14638. * @hidden
  14639. */
  14640. _mesh: Nullable<AbstractMesh>;
  14641. private _poseControlledCamera;
  14642. private _leftHandSystemQuaternion;
  14643. /**
  14644. * Internal, matrix used to convert room space to babylon space
  14645. * @hidden
  14646. */
  14647. _deviceToWorld: Matrix;
  14648. /**
  14649. * Node to be used when casting a ray from the controller
  14650. * @hidden
  14651. */
  14652. _pointingPoseNode: Nullable<TransformNode>;
  14653. /**
  14654. * Name of the child mesh that can be used to cast a ray from the controller
  14655. */
  14656. static readonly POINTING_POSE: string;
  14657. /**
  14658. * Creates a new PoseEnabledController from a gamepad
  14659. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14660. */
  14661. constructor(browserGamepad: any);
  14662. private _workingMatrix;
  14663. /**
  14664. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14665. */
  14666. update(): void;
  14667. /**
  14668. * Updates only the pose device and mesh without doing any button event checking
  14669. */
  14670. protected _updatePoseAndMesh(): void;
  14671. /**
  14672. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14673. * @param poseData raw pose fromthe device
  14674. */
  14675. updateFromDevice(poseData: DevicePose): void;
  14676. /**
  14677. * @hidden
  14678. */
  14679. _meshAttachedObservable: Observable<AbstractMesh>;
  14680. /**
  14681. * Attaches a mesh to the controller
  14682. * @param mesh the mesh to be attached
  14683. */
  14684. attachToMesh(mesh: AbstractMesh): void;
  14685. /**
  14686. * Attaches the controllers mesh to a camera
  14687. * @param camera the camera the mesh should be attached to
  14688. */
  14689. attachToPoseControlledCamera(camera: TargetCamera): void;
  14690. /**
  14691. * Disposes of the controller
  14692. */
  14693. dispose(): void;
  14694. /**
  14695. * The mesh that is attached to the controller
  14696. */
  14697. readonly mesh: Nullable<AbstractMesh>;
  14698. /**
  14699. * Gets the ray of the controller in the direction the controller is pointing
  14700. * @param length the length the resulting ray should be
  14701. * @returns a ray in the direction the controller is pointing
  14702. */
  14703. getForwardRay(length?: number): Ray;
  14704. }
  14705. }
  14706. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14707. import { Observable } from "babylonjs/Misc/observable";
  14708. import { Scene } from "babylonjs/scene";
  14709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14710. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14711. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14712. /**
  14713. * Defines the WebVRController object that represents controllers tracked in 3D space
  14714. */
  14715. export abstract class WebVRController extends PoseEnabledController {
  14716. /**
  14717. * Internal, the default controller model for the controller
  14718. */
  14719. protected _defaultModel: AbstractMesh;
  14720. /**
  14721. * Fired when the trigger state has changed
  14722. */
  14723. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14724. /**
  14725. * Fired when the main button state has changed
  14726. */
  14727. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14728. /**
  14729. * Fired when the secondary button state has changed
  14730. */
  14731. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14732. /**
  14733. * Fired when the pad state has changed
  14734. */
  14735. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14736. /**
  14737. * Fired when controllers stick values have changed
  14738. */
  14739. onPadValuesChangedObservable: Observable<StickValues>;
  14740. /**
  14741. * Array of button availible on the controller
  14742. */
  14743. protected _buttons: Array<MutableGamepadButton>;
  14744. private _onButtonStateChange;
  14745. /**
  14746. * Fired when a controller button's state has changed
  14747. * @param callback the callback containing the button that was modified
  14748. */
  14749. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14750. /**
  14751. * X and Y axis corresponding to the controllers joystick
  14752. */
  14753. pad: StickValues;
  14754. /**
  14755. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14756. */
  14757. hand: string;
  14758. /**
  14759. * The default controller model for the controller
  14760. */
  14761. readonly defaultModel: AbstractMesh;
  14762. /**
  14763. * Creates a new WebVRController from a gamepad
  14764. * @param vrGamepad the gamepad that the WebVRController should be created from
  14765. */
  14766. constructor(vrGamepad: any);
  14767. /**
  14768. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14769. */
  14770. update(): void;
  14771. /**
  14772. * Function to be called when a button is modified
  14773. */
  14774. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14775. /**
  14776. * Loads a mesh and attaches it to the controller
  14777. * @param scene the scene the mesh should be added to
  14778. * @param meshLoaded callback for when the mesh has been loaded
  14779. */
  14780. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14781. private _setButtonValue;
  14782. private _changes;
  14783. private _checkChanges;
  14784. /**
  14785. * Disposes of th webVRCOntroller
  14786. */
  14787. dispose(): void;
  14788. }
  14789. }
  14790. declare module "babylonjs/Lights/hemisphericLight" {
  14791. import { Nullable } from "babylonjs/types";
  14792. import { Scene } from "babylonjs/scene";
  14793. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14794. import { Color3 } from "babylonjs/Maths/math.color";
  14795. import { Effect } from "babylonjs/Materials/effect";
  14796. import { Light } from "babylonjs/Lights/light";
  14797. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14798. /**
  14799. * The HemisphericLight simulates the ambient environment light,
  14800. * so the passed direction is the light reflection direction, not the incoming direction.
  14801. */
  14802. export class HemisphericLight extends Light {
  14803. /**
  14804. * The groundColor is the light in the opposite direction to the one specified during creation.
  14805. * 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.
  14806. */
  14807. groundColor: Color3;
  14808. /**
  14809. * The light reflection direction, not the incoming direction.
  14810. */
  14811. direction: Vector3;
  14812. /**
  14813. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14814. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14815. * The HemisphericLight can't cast shadows.
  14816. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14817. * @param name The friendly name of the light
  14818. * @param direction The direction of the light reflection
  14819. * @param scene The scene the light belongs to
  14820. */
  14821. constructor(name: string, direction: Vector3, scene: Scene);
  14822. protected _buildUniformLayout(): void;
  14823. /**
  14824. * Returns the string "HemisphericLight".
  14825. * @return The class name
  14826. */
  14827. getClassName(): string;
  14828. /**
  14829. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14830. * Returns the updated direction.
  14831. * @param target The target the direction should point to
  14832. * @return The computed direction
  14833. */
  14834. setDirectionToTarget(target: Vector3): Vector3;
  14835. /**
  14836. * Returns the shadow generator associated to the light.
  14837. * @returns Always null for hemispheric lights because it does not support shadows.
  14838. */
  14839. getShadowGenerator(): Nullable<IShadowGenerator>;
  14840. /**
  14841. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14842. * @param effect The effect to update
  14843. * @param lightIndex The index of the light in the effect to update
  14844. * @returns The hemispheric light
  14845. */
  14846. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14847. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14848. /**
  14849. * Computes the world matrix of the node
  14850. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14851. * @param useWasUpdatedFlag defines a reserved property
  14852. * @returns the world matrix
  14853. */
  14854. computeWorldMatrix(): Matrix;
  14855. /**
  14856. * Returns the integer 3.
  14857. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14858. */
  14859. getTypeID(): number;
  14860. /**
  14861. * Prepares the list of defines specific to the light type.
  14862. * @param defines the list of defines
  14863. * @param lightIndex defines the index of the light for the effect
  14864. */
  14865. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14866. }
  14867. }
  14868. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14869. /** @hidden */
  14870. export var vrMultiviewToSingleviewPixelShader: {
  14871. name: string;
  14872. shader: string;
  14873. };
  14874. }
  14875. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14876. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14877. import { Scene } from "babylonjs/scene";
  14878. /**
  14879. * Renders to multiple views with a single draw call
  14880. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14881. */
  14882. export class MultiviewRenderTarget extends RenderTargetTexture {
  14883. /**
  14884. * Creates a multiview render target
  14885. * @param scene scene used with the render target
  14886. * @param size the size of the render target (used for each view)
  14887. */
  14888. constructor(scene: Scene, size?: number | {
  14889. width: number;
  14890. height: number;
  14891. } | {
  14892. ratio: number;
  14893. });
  14894. /**
  14895. * @hidden
  14896. * @param faceIndex the face index, if its a cube texture
  14897. */
  14898. _bindFrameBuffer(faceIndex?: number): void;
  14899. /**
  14900. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14901. * @returns the view count
  14902. */
  14903. getViewCount(): number;
  14904. }
  14905. }
  14906. declare module "babylonjs/Maths/math.frustum" {
  14907. import { Matrix } from "babylonjs/Maths/math.vector";
  14908. import { DeepImmutable } from "babylonjs/types";
  14909. import { Plane } from "babylonjs/Maths/math.plane";
  14910. /**
  14911. * Represents a camera frustum
  14912. */
  14913. export class Frustum {
  14914. /**
  14915. * Gets the planes representing the frustum
  14916. * @param transform matrix to be applied to the returned planes
  14917. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14918. */
  14919. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14920. /**
  14921. * Gets the near frustum plane transformed by the transform matrix
  14922. * @param transform transformation matrix to be applied to the resulting frustum plane
  14923. * @param frustumPlane the resuling frustum plane
  14924. */
  14925. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14926. /**
  14927. * Gets the far frustum plane transformed by the transform matrix
  14928. * @param transform transformation matrix to be applied to the resulting frustum plane
  14929. * @param frustumPlane the resuling frustum plane
  14930. */
  14931. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14932. /**
  14933. * Gets the left frustum plane transformed by the transform matrix
  14934. * @param transform transformation matrix to be applied to the resulting frustum plane
  14935. * @param frustumPlane the resuling frustum plane
  14936. */
  14937. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14938. /**
  14939. * Gets the right frustum plane transformed by the transform matrix
  14940. * @param transform transformation matrix to be applied to the resulting frustum plane
  14941. * @param frustumPlane the resuling frustum plane
  14942. */
  14943. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14944. /**
  14945. * Gets the top frustum plane transformed by the transform matrix
  14946. * @param transform transformation matrix to be applied to the resulting frustum plane
  14947. * @param frustumPlane the resuling frustum plane
  14948. */
  14949. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14950. /**
  14951. * Gets the bottom frustum plane transformed by the transform matrix
  14952. * @param transform transformation matrix to be applied to the resulting frustum plane
  14953. * @param frustumPlane the resuling frustum plane
  14954. */
  14955. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14956. /**
  14957. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14958. * @param transform transformation matrix to be applied to the resulting frustum planes
  14959. * @param frustumPlanes the resuling frustum planes
  14960. */
  14961. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14962. }
  14963. }
  14964. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14965. import { Camera } from "babylonjs/Cameras/camera";
  14966. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14967. import { Nullable } from "babylonjs/types";
  14968. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14969. import { Matrix } from "babylonjs/Maths/math.vector";
  14970. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14971. module "babylonjs/Engines/engine" {
  14972. interface Engine {
  14973. /**
  14974. * Creates a new multiview render target
  14975. * @param width defines the width of the texture
  14976. * @param height defines the height of the texture
  14977. * @returns the created multiview texture
  14978. */
  14979. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14980. /**
  14981. * Binds a multiview framebuffer to be drawn to
  14982. * @param multiviewTexture texture to bind
  14983. */
  14984. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14985. }
  14986. }
  14987. module "babylonjs/Cameras/camera" {
  14988. interface Camera {
  14989. /**
  14990. * @hidden
  14991. * 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)
  14992. */
  14993. _useMultiviewToSingleView: boolean;
  14994. /**
  14995. * @hidden
  14996. * 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)
  14997. */
  14998. _multiviewTexture: Nullable<RenderTargetTexture>;
  14999. /**
  15000. * @hidden
  15001. * ensures the multiview texture of the camera exists and has the specified width/height
  15002. * @param width height to set on the multiview texture
  15003. * @param height width to set on the multiview texture
  15004. */
  15005. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15006. }
  15007. }
  15008. module "babylonjs/scene" {
  15009. interface Scene {
  15010. /** @hidden */
  15011. _transformMatrixR: Matrix;
  15012. /** @hidden */
  15013. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15014. /** @hidden */
  15015. _createMultiviewUbo(): void;
  15016. /** @hidden */
  15017. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15018. /** @hidden */
  15019. _renderMultiviewToSingleView(camera: Camera): void;
  15020. }
  15021. }
  15022. }
  15023. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15024. import { Camera } from "babylonjs/Cameras/camera";
  15025. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15026. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15027. import "babylonjs/Engines/Extensions/engine.multiview";
  15028. /**
  15029. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15030. * This will not be used for webXR as it supports displaying texture arrays directly
  15031. */
  15032. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15033. /**
  15034. * Initializes a VRMultiviewToSingleview
  15035. * @param name name of the post process
  15036. * @param camera camera to be applied to
  15037. * @param scaleFactor scaling factor to the size of the output texture
  15038. */
  15039. constructor(name: string, camera: Camera, scaleFactor: number);
  15040. }
  15041. }
  15042. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15043. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15044. import { Nullable } from "babylonjs/types";
  15045. import { Size } from "babylonjs/Maths/math.size";
  15046. import { Observable } from "babylonjs/Misc/observable";
  15047. module "babylonjs/Engines/engine" {
  15048. interface Engine {
  15049. /** @hidden */
  15050. _vrDisplay: any;
  15051. /** @hidden */
  15052. _vrSupported: boolean;
  15053. /** @hidden */
  15054. _oldSize: Size;
  15055. /** @hidden */
  15056. _oldHardwareScaleFactor: number;
  15057. /** @hidden */
  15058. _vrExclusivePointerMode: boolean;
  15059. /** @hidden */
  15060. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15061. /** @hidden */
  15062. _onVRDisplayPointerRestricted: () => void;
  15063. /** @hidden */
  15064. _onVRDisplayPointerUnrestricted: () => void;
  15065. /** @hidden */
  15066. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15067. /** @hidden */
  15068. _onVrDisplayDisconnect: Nullable<() => void>;
  15069. /** @hidden */
  15070. _onVrDisplayPresentChange: Nullable<() => void>;
  15071. /**
  15072. * Observable signaled when VR display mode changes
  15073. */
  15074. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15075. /**
  15076. * Observable signaled when VR request present is complete
  15077. */
  15078. onVRRequestPresentComplete: Observable<boolean>;
  15079. /**
  15080. * Observable signaled when VR request present starts
  15081. */
  15082. onVRRequestPresentStart: Observable<Engine>;
  15083. /**
  15084. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15085. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15086. */
  15087. isInVRExclusivePointerMode: boolean;
  15088. /**
  15089. * Gets a boolean indicating if a webVR device was detected
  15090. * @returns true if a webVR device was detected
  15091. */
  15092. isVRDevicePresent(): boolean;
  15093. /**
  15094. * Gets the current webVR device
  15095. * @returns the current webVR device (or null)
  15096. */
  15097. getVRDevice(): any;
  15098. /**
  15099. * Initializes a webVR display and starts listening to display change events
  15100. * The onVRDisplayChangedObservable will be notified upon these changes
  15101. * @returns A promise containing a VRDisplay and if vr is supported
  15102. */
  15103. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15104. /** @hidden */
  15105. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15106. /**
  15107. * Call this function to switch to webVR mode
  15108. * Will do nothing if webVR is not supported or if there is no webVR device
  15109. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15110. */
  15111. enableVR(): void;
  15112. /** @hidden */
  15113. _onVRFullScreenTriggered(): void;
  15114. }
  15115. }
  15116. }
  15117. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15118. import { Nullable } from "babylonjs/types";
  15119. import { Observable } from "babylonjs/Misc/observable";
  15120. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15121. import { Scene } from "babylonjs/scene";
  15122. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15123. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15124. import { Node } from "babylonjs/node";
  15125. import { Ray } from "babylonjs/Culling/ray";
  15126. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15127. import "babylonjs/Engines/Extensions/engine.webVR";
  15128. /**
  15129. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15130. * IMPORTANT!! The data is right-hand data.
  15131. * @export
  15132. * @interface DevicePose
  15133. */
  15134. export interface DevicePose {
  15135. /**
  15136. * The position of the device, values in array are [x,y,z].
  15137. */
  15138. readonly position: Nullable<Float32Array>;
  15139. /**
  15140. * The linearVelocity of the device, values in array are [x,y,z].
  15141. */
  15142. readonly linearVelocity: Nullable<Float32Array>;
  15143. /**
  15144. * The linearAcceleration of the device, values in array are [x,y,z].
  15145. */
  15146. readonly linearAcceleration: Nullable<Float32Array>;
  15147. /**
  15148. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15149. */
  15150. readonly orientation: Nullable<Float32Array>;
  15151. /**
  15152. * The angularVelocity of the device, values in array are [x,y,z].
  15153. */
  15154. readonly angularVelocity: Nullable<Float32Array>;
  15155. /**
  15156. * The angularAcceleration of the device, values in array are [x,y,z].
  15157. */
  15158. readonly angularAcceleration: Nullable<Float32Array>;
  15159. }
  15160. /**
  15161. * Interface representing a pose controlled object in Babylon.
  15162. * A pose controlled object has both regular pose values as well as pose values
  15163. * from an external device such as a VR head mounted display
  15164. */
  15165. export interface PoseControlled {
  15166. /**
  15167. * The position of the object in babylon space.
  15168. */
  15169. position: Vector3;
  15170. /**
  15171. * The rotation quaternion of the object in babylon space.
  15172. */
  15173. rotationQuaternion: Quaternion;
  15174. /**
  15175. * The position of the device in babylon space.
  15176. */
  15177. devicePosition?: Vector3;
  15178. /**
  15179. * The rotation quaternion of the device in babylon space.
  15180. */
  15181. deviceRotationQuaternion: Quaternion;
  15182. /**
  15183. * The raw pose coming from the device.
  15184. */
  15185. rawPose: Nullable<DevicePose>;
  15186. /**
  15187. * The scale of the device to be used when translating from device space to babylon space.
  15188. */
  15189. deviceScaleFactor: number;
  15190. /**
  15191. * Updates the poseControlled values based on the input device pose.
  15192. * @param poseData the pose data to update the object with
  15193. */
  15194. updateFromDevice(poseData: DevicePose): void;
  15195. }
  15196. /**
  15197. * Set of options to customize the webVRCamera
  15198. */
  15199. export interface WebVROptions {
  15200. /**
  15201. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15202. */
  15203. trackPosition?: boolean;
  15204. /**
  15205. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15206. */
  15207. positionScale?: number;
  15208. /**
  15209. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15210. */
  15211. displayName?: string;
  15212. /**
  15213. * Should the native controller meshes be initialized. (default: true)
  15214. */
  15215. controllerMeshes?: boolean;
  15216. /**
  15217. * Creating a default HemiLight only on controllers. (default: true)
  15218. */
  15219. defaultLightingOnControllers?: boolean;
  15220. /**
  15221. * If you don't want to use the default VR button of the helper. (default: false)
  15222. */
  15223. useCustomVRButton?: boolean;
  15224. /**
  15225. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15226. */
  15227. customVRButton?: HTMLButtonElement;
  15228. /**
  15229. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15230. */
  15231. rayLength?: number;
  15232. /**
  15233. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15234. */
  15235. defaultHeight?: number;
  15236. /**
  15237. * If multiview should be used if availible (default: false)
  15238. */
  15239. useMultiview?: boolean;
  15240. }
  15241. /**
  15242. * This represents a WebVR camera.
  15243. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15244. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15245. */
  15246. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15247. private webVROptions;
  15248. /**
  15249. * @hidden
  15250. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15251. */
  15252. _vrDevice: any;
  15253. /**
  15254. * The rawPose of the vrDevice.
  15255. */
  15256. rawPose: Nullable<DevicePose>;
  15257. private _onVREnabled;
  15258. private _specsVersion;
  15259. private _attached;
  15260. private _frameData;
  15261. protected _descendants: Array<Node>;
  15262. private _deviceRoomPosition;
  15263. /** @hidden */
  15264. _deviceRoomRotationQuaternion: Quaternion;
  15265. private _standingMatrix;
  15266. /**
  15267. * Represents device position in babylon space.
  15268. */
  15269. devicePosition: Vector3;
  15270. /**
  15271. * Represents device rotation in babylon space.
  15272. */
  15273. deviceRotationQuaternion: Quaternion;
  15274. /**
  15275. * The scale of the device to be used when translating from device space to babylon space.
  15276. */
  15277. deviceScaleFactor: number;
  15278. private _deviceToWorld;
  15279. private _worldToDevice;
  15280. /**
  15281. * References to the webVR controllers for the vrDevice.
  15282. */
  15283. controllers: Array<WebVRController>;
  15284. /**
  15285. * Emits an event when a controller is attached.
  15286. */
  15287. onControllersAttachedObservable: Observable<WebVRController[]>;
  15288. /**
  15289. * Emits an event when a controller's mesh has been loaded;
  15290. */
  15291. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15292. /**
  15293. * Emits an event when the HMD's pose has been updated.
  15294. */
  15295. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15296. private _poseSet;
  15297. /**
  15298. * If the rig cameras be used as parent instead of this camera.
  15299. */
  15300. rigParenting: boolean;
  15301. private _lightOnControllers;
  15302. private _defaultHeight?;
  15303. /**
  15304. * Instantiates a WebVRFreeCamera.
  15305. * @param name The name of the WebVRFreeCamera
  15306. * @param position The starting anchor position for the camera
  15307. * @param scene The scene the camera belongs to
  15308. * @param webVROptions a set of customizable options for the webVRCamera
  15309. */
  15310. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15311. /**
  15312. * Gets the device distance from the ground in meters.
  15313. * @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.
  15314. */
  15315. deviceDistanceToRoomGround(): number;
  15316. /**
  15317. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15318. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15319. */
  15320. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15321. /**
  15322. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15323. * @returns A promise with a boolean set to if the standing matrix is supported.
  15324. */
  15325. useStandingMatrixAsync(): Promise<boolean>;
  15326. /**
  15327. * Disposes the camera
  15328. */
  15329. dispose(): void;
  15330. /**
  15331. * Gets a vrController by name.
  15332. * @param name The name of the controller to retreive
  15333. * @returns the controller matching the name specified or null if not found
  15334. */
  15335. getControllerByName(name: string): Nullable<WebVRController>;
  15336. private _leftController;
  15337. /**
  15338. * The controller corresponding to the users left hand.
  15339. */
  15340. readonly leftController: Nullable<WebVRController>;
  15341. private _rightController;
  15342. /**
  15343. * The controller corresponding to the users right hand.
  15344. */
  15345. readonly rightController: Nullable<WebVRController>;
  15346. /**
  15347. * Casts a ray forward from the vrCamera's gaze.
  15348. * @param length Length of the ray (default: 100)
  15349. * @returns the ray corresponding to the gaze
  15350. */
  15351. getForwardRay(length?: number): Ray;
  15352. /**
  15353. * @hidden
  15354. * Updates the camera based on device's frame data
  15355. */
  15356. _checkInputs(): void;
  15357. /**
  15358. * Updates the poseControlled values based on the input device pose.
  15359. * @param poseData Pose coming from the device
  15360. */
  15361. updateFromDevice(poseData: DevicePose): void;
  15362. private _htmlElementAttached;
  15363. private _detachIfAttached;
  15364. /**
  15365. * WebVR's attach control will start broadcasting frames to the device.
  15366. * Note that in certain browsers (chrome for example) this function must be called
  15367. * within a user-interaction callback. Example:
  15368. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15369. *
  15370. * @param element html element to attach the vrDevice to
  15371. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15372. */
  15373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15374. /**
  15375. * Detaches the camera from the html element and disables VR
  15376. *
  15377. * @param element html element to detach from
  15378. */
  15379. detachControl(element: HTMLElement): void;
  15380. /**
  15381. * @returns the name of this class
  15382. */
  15383. getClassName(): string;
  15384. /**
  15385. * Calls resetPose on the vrDisplay
  15386. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15387. */
  15388. resetToCurrentRotation(): void;
  15389. /**
  15390. * @hidden
  15391. * Updates the rig cameras (left and right eye)
  15392. */
  15393. _updateRigCameras(): void;
  15394. private _workingVector;
  15395. private _oneVector;
  15396. private _workingMatrix;
  15397. private updateCacheCalled;
  15398. private _correctPositionIfNotTrackPosition;
  15399. /**
  15400. * @hidden
  15401. * Updates the cached values of the camera
  15402. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15403. */
  15404. _updateCache(ignoreParentClass?: boolean): void;
  15405. /**
  15406. * @hidden
  15407. * Get current device position in babylon world
  15408. */
  15409. _computeDevicePosition(): void;
  15410. /**
  15411. * Updates the current device position and rotation in the babylon world
  15412. */
  15413. update(): void;
  15414. /**
  15415. * @hidden
  15416. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15417. * @returns an identity matrix
  15418. */
  15419. _getViewMatrix(): Matrix;
  15420. private _tmpMatrix;
  15421. /**
  15422. * This function is called by the two RIG cameras.
  15423. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15424. * @hidden
  15425. */
  15426. _getWebVRViewMatrix(): Matrix;
  15427. /** @hidden */
  15428. _getWebVRProjectionMatrix(): Matrix;
  15429. private _onGamepadConnectedObserver;
  15430. private _onGamepadDisconnectedObserver;
  15431. private _updateCacheWhenTrackingDisabledObserver;
  15432. /**
  15433. * Initializes the controllers and their meshes
  15434. */
  15435. initControllers(): void;
  15436. }
  15437. }
  15438. declare module "babylonjs/PostProcesses/postProcess" {
  15439. import { Nullable } from "babylonjs/types";
  15440. import { SmartArray } from "babylonjs/Misc/smartArray";
  15441. import { Observable } from "babylonjs/Misc/observable";
  15442. import { Vector2 } from "babylonjs/Maths/math.vector";
  15443. import { Camera } from "babylonjs/Cameras/camera";
  15444. import { Effect } from "babylonjs/Materials/effect";
  15445. import "babylonjs/Shaders/postprocess.vertex";
  15446. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15447. import { Engine } from "babylonjs/Engines/engine";
  15448. import { Color4 } from "babylonjs/Maths/math.color";
  15449. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15450. /**
  15451. * Size options for a post process
  15452. */
  15453. export type PostProcessOptions = {
  15454. width: number;
  15455. height: number;
  15456. };
  15457. /**
  15458. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15459. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15460. */
  15461. export class PostProcess {
  15462. /** Name of the PostProcess. */
  15463. name: string;
  15464. /**
  15465. * Gets or sets the unique id of the post process
  15466. */
  15467. uniqueId: number;
  15468. /**
  15469. * Width of the texture to apply the post process on
  15470. */
  15471. width: number;
  15472. /**
  15473. * Height of the texture to apply the post process on
  15474. */
  15475. height: number;
  15476. /**
  15477. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15478. * @hidden
  15479. */
  15480. _outputTexture: Nullable<InternalTexture>;
  15481. /**
  15482. * Sampling mode used by the shader
  15483. * See https://doc.babylonjs.com/classes/3.1/texture
  15484. */
  15485. renderTargetSamplingMode: number;
  15486. /**
  15487. * Clear color to use when screen clearing
  15488. */
  15489. clearColor: Color4;
  15490. /**
  15491. * If the buffer needs to be cleared before applying the post process. (default: true)
  15492. * Should be set to false if shader will overwrite all previous pixels.
  15493. */
  15494. autoClear: boolean;
  15495. /**
  15496. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15497. */
  15498. alphaMode: number;
  15499. /**
  15500. * Sets the setAlphaBlendConstants of the babylon engine
  15501. */
  15502. alphaConstants: Color4;
  15503. /**
  15504. * Animations to be used for the post processing
  15505. */
  15506. animations: import("babylonjs/Animations/animation").Animation[];
  15507. /**
  15508. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15509. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15510. */
  15511. enablePixelPerfectMode: boolean;
  15512. /**
  15513. * Force the postprocess to be applied without taking in account viewport
  15514. */
  15515. forceFullscreenViewport: boolean;
  15516. /**
  15517. * List of inspectable custom properties (used by the Inspector)
  15518. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15519. */
  15520. inspectableCustomProperties: IInspectable[];
  15521. /**
  15522. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15523. *
  15524. * | Value | Type | Description |
  15525. * | ----- | ----------------------------------- | ----------- |
  15526. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15527. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15528. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15529. *
  15530. */
  15531. scaleMode: number;
  15532. /**
  15533. * Force textures to be a power of two (default: false)
  15534. */
  15535. alwaysForcePOT: boolean;
  15536. private _samples;
  15537. /**
  15538. * Number of sample textures (default: 1)
  15539. */
  15540. samples: number;
  15541. /**
  15542. * Modify the scale of the post process to be the same as the viewport (default: false)
  15543. */
  15544. adaptScaleToCurrentViewport: boolean;
  15545. private _camera;
  15546. private _scene;
  15547. private _engine;
  15548. private _options;
  15549. private _reusable;
  15550. private _textureType;
  15551. /**
  15552. * Smart array of input and output textures for the post process.
  15553. * @hidden
  15554. */
  15555. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15556. /**
  15557. * The index in _textures that corresponds to the output texture.
  15558. * @hidden
  15559. */
  15560. _currentRenderTextureInd: number;
  15561. private _effect;
  15562. private _samplers;
  15563. private _fragmentUrl;
  15564. private _vertexUrl;
  15565. private _parameters;
  15566. private _scaleRatio;
  15567. protected _indexParameters: any;
  15568. private _shareOutputWithPostProcess;
  15569. private _texelSize;
  15570. private _forcedOutputTexture;
  15571. /**
  15572. * Returns the fragment url or shader name used in the post process.
  15573. * @returns the fragment url or name in the shader store.
  15574. */
  15575. getEffectName(): string;
  15576. /**
  15577. * An event triggered when the postprocess is activated.
  15578. */
  15579. onActivateObservable: Observable<Camera>;
  15580. private _onActivateObserver;
  15581. /**
  15582. * A function that is added to the onActivateObservable
  15583. */
  15584. onActivate: Nullable<(camera: Camera) => void>;
  15585. /**
  15586. * An event triggered when the postprocess changes its size.
  15587. */
  15588. onSizeChangedObservable: Observable<PostProcess>;
  15589. private _onSizeChangedObserver;
  15590. /**
  15591. * A function that is added to the onSizeChangedObservable
  15592. */
  15593. onSizeChanged: (postProcess: PostProcess) => void;
  15594. /**
  15595. * An event triggered when the postprocess applies its effect.
  15596. */
  15597. onApplyObservable: Observable<Effect>;
  15598. private _onApplyObserver;
  15599. /**
  15600. * A function that is added to the onApplyObservable
  15601. */
  15602. onApply: (effect: Effect) => void;
  15603. /**
  15604. * An event triggered before rendering the postprocess
  15605. */
  15606. onBeforeRenderObservable: Observable<Effect>;
  15607. private _onBeforeRenderObserver;
  15608. /**
  15609. * A function that is added to the onBeforeRenderObservable
  15610. */
  15611. onBeforeRender: (effect: Effect) => void;
  15612. /**
  15613. * An event triggered after rendering the postprocess
  15614. */
  15615. onAfterRenderObservable: Observable<Effect>;
  15616. private _onAfterRenderObserver;
  15617. /**
  15618. * A function that is added to the onAfterRenderObservable
  15619. */
  15620. onAfterRender: (efect: Effect) => void;
  15621. /**
  15622. * 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
  15623. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15624. */
  15625. inputTexture: InternalTexture;
  15626. /**
  15627. * Gets the camera which post process is applied to.
  15628. * @returns The camera the post process is applied to.
  15629. */
  15630. getCamera(): Camera;
  15631. /**
  15632. * Gets the texel size of the postprocess.
  15633. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15634. */
  15635. readonly texelSize: Vector2;
  15636. /**
  15637. * Creates a new instance PostProcess
  15638. * @param name The name of the PostProcess.
  15639. * @param fragmentUrl The url of the fragment shader to be used.
  15640. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15641. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15642. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15643. * @param camera The camera to apply the render pass to.
  15644. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15645. * @param engine The engine which the post process will be applied. (default: current engine)
  15646. * @param reusable If the post process can be reused on the same frame. (default: false)
  15647. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15648. * @param textureType Type of textures used when performing the post process. (default: 0)
  15649. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15650. * @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
  15651. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15652. */
  15653. constructor(
  15654. /** Name of the PostProcess. */
  15655. 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);
  15656. /**
  15657. * Gets a string idenfifying the name of the class
  15658. * @returns "PostProcess" string
  15659. */
  15660. getClassName(): string;
  15661. /**
  15662. * Gets the engine which this post process belongs to.
  15663. * @returns The engine the post process was enabled with.
  15664. */
  15665. getEngine(): Engine;
  15666. /**
  15667. * The effect that is created when initializing the post process.
  15668. * @returns The created effect corresponding the the postprocess.
  15669. */
  15670. getEffect(): Effect;
  15671. /**
  15672. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15673. * @param postProcess The post process to share the output with.
  15674. * @returns This post process.
  15675. */
  15676. shareOutputWith(postProcess: PostProcess): PostProcess;
  15677. /**
  15678. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15679. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15680. */
  15681. useOwnOutput(): void;
  15682. /**
  15683. * Updates the effect with the current post process compile time values and recompiles the shader.
  15684. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15685. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15686. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15687. * @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
  15688. * @param onCompiled Called when the shader has been compiled.
  15689. * @param onError Called if there is an error when compiling a shader.
  15690. */
  15691. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15692. /**
  15693. * The post process is reusable if it can be used multiple times within one frame.
  15694. * @returns If the post process is reusable
  15695. */
  15696. isReusable(): boolean;
  15697. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15698. markTextureDirty(): void;
  15699. /**
  15700. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15701. * 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.
  15702. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15703. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15704. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15705. * @returns The target texture that was bound to be written to.
  15706. */
  15707. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15708. /**
  15709. * If the post process is supported.
  15710. */
  15711. readonly isSupported: boolean;
  15712. /**
  15713. * The aspect ratio of the output texture.
  15714. */
  15715. readonly aspectRatio: number;
  15716. /**
  15717. * Get a value indicating if the post-process is ready to be used
  15718. * @returns true if the post-process is ready (shader is compiled)
  15719. */
  15720. isReady(): boolean;
  15721. /**
  15722. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15723. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15724. */
  15725. apply(): Nullable<Effect>;
  15726. private _disposeTextures;
  15727. /**
  15728. * Disposes the post process.
  15729. * @param camera The camera to dispose the post process on.
  15730. */
  15731. dispose(camera?: Camera): void;
  15732. }
  15733. }
  15734. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15735. /** @hidden */
  15736. export var kernelBlurVaryingDeclaration: {
  15737. name: string;
  15738. shader: string;
  15739. };
  15740. }
  15741. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15742. /** @hidden */
  15743. export var kernelBlurFragment: {
  15744. name: string;
  15745. shader: string;
  15746. };
  15747. }
  15748. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15749. /** @hidden */
  15750. export var kernelBlurFragment2: {
  15751. name: string;
  15752. shader: string;
  15753. };
  15754. }
  15755. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15756. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15757. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15758. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15759. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15760. /** @hidden */
  15761. export var kernelBlurPixelShader: {
  15762. name: string;
  15763. shader: string;
  15764. };
  15765. }
  15766. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15767. /** @hidden */
  15768. export var kernelBlurVertex: {
  15769. name: string;
  15770. shader: string;
  15771. };
  15772. }
  15773. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15774. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15775. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15776. /** @hidden */
  15777. export var kernelBlurVertexShader: {
  15778. name: string;
  15779. shader: string;
  15780. };
  15781. }
  15782. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15783. import { Vector2 } from "babylonjs/Maths/math.vector";
  15784. import { Nullable } from "babylonjs/types";
  15785. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15786. import { Camera } from "babylonjs/Cameras/camera";
  15787. import { Effect } from "babylonjs/Materials/effect";
  15788. import { Engine } from "babylonjs/Engines/engine";
  15789. import "babylonjs/Shaders/kernelBlur.fragment";
  15790. import "babylonjs/Shaders/kernelBlur.vertex";
  15791. /**
  15792. * The Blur Post Process which blurs an image based on a kernel and direction.
  15793. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15794. */
  15795. export class BlurPostProcess extends PostProcess {
  15796. /** The direction in which to blur the image. */
  15797. direction: Vector2;
  15798. private blockCompilation;
  15799. protected _kernel: number;
  15800. protected _idealKernel: number;
  15801. protected _packedFloat: boolean;
  15802. private _staticDefines;
  15803. /**
  15804. * Sets the length in pixels of the blur sample region
  15805. */
  15806. /**
  15807. * Gets the length in pixels of the blur sample region
  15808. */
  15809. kernel: number;
  15810. /**
  15811. * Sets wether or not the blur needs to unpack/repack floats
  15812. */
  15813. /**
  15814. * Gets wether or not the blur is unpacking/repacking floats
  15815. */
  15816. packedFloat: boolean;
  15817. /**
  15818. * Creates a new instance BlurPostProcess
  15819. * @param name The name of the effect.
  15820. * @param direction The direction in which to blur the image.
  15821. * @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.
  15822. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15823. * @param camera The camera to apply the render pass to.
  15824. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15825. * @param engine The engine which the post process will be applied. (default: current engine)
  15826. * @param reusable If the post process can be reused on the same frame. (default: false)
  15827. * @param textureType Type of textures used when performing the post process. (default: 0)
  15828. * @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)
  15829. */
  15830. constructor(name: string,
  15831. /** The direction in which to blur the image. */
  15832. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15833. /**
  15834. * Updates the effect with the current post process compile time values and recompiles the shader.
  15835. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15836. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15837. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15838. * @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
  15839. * @param onCompiled Called when the shader has been compiled.
  15840. * @param onError Called if there is an error when compiling a shader.
  15841. */
  15842. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15843. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15844. /**
  15845. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15846. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15847. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15848. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15849. * The gaps between physical kernels are compensated for in the weighting of the samples
  15850. * @param idealKernel Ideal blur kernel.
  15851. * @return Nearest best kernel.
  15852. */
  15853. protected _nearestBestKernel(idealKernel: number): number;
  15854. /**
  15855. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15856. * @param x The point on the Gaussian distribution to sample.
  15857. * @return the value of the Gaussian function at x.
  15858. */
  15859. protected _gaussianWeight(x: number): number;
  15860. /**
  15861. * Generates a string that can be used as a floating point number in GLSL.
  15862. * @param x Value to print.
  15863. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15864. * @return GLSL float string.
  15865. */
  15866. protected _glslFloat(x: number, decimalFigures?: number): string;
  15867. }
  15868. }
  15869. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15870. import { Scene } from "babylonjs/scene";
  15871. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15872. import { Plane } from "babylonjs/Maths/math.plane";
  15873. /**
  15874. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15875. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15876. * You can then easily use it as a reflectionTexture on a flat surface.
  15877. * In case the surface is not a plane, please consider relying on reflection probes.
  15878. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15879. */
  15880. export class MirrorTexture extends RenderTargetTexture {
  15881. private scene;
  15882. /**
  15883. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15884. * 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.
  15885. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15886. */
  15887. mirrorPlane: Plane;
  15888. /**
  15889. * Define the blur ratio used to blur the reflection if needed.
  15890. */
  15891. blurRatio: number;
  15892. /**
  15893. * Define the adaptive blur kernel used to blur the reflection if needed.
  15894. * This will autocompute the closest best match for the `blurKernel`
  15895. */
  15896. adaptiveBlurKernel: number;
  15897. /**
  15898. * Define the blur kernel used to blur the reflection if needed.
  15899. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15900. */
  15901. blurKernel: number;
  15902. /**
  15903. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15904. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15905. */
  15906. blurKernelX: number;
  15907. /**
  15908. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15909. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15910. */
  15911. blurKernelY: number;
  15912. private _autoComputeBlurKernel;
  15913. protected _onRatioRescale(): void;
  15914. private _updateGammaSpace;
  15915. private _imageProcessingConfigChangeObserver;
  15916. private _transformMatrix;
  15917. private _mirrorMatrix;
  15918. private _savedViewMatrix;
  15919. private _blurX;
  15920. private _blurY;
  15921. private _adaptiveBlurKernel;
  15922. private _blurKernelX;
  15923. private _blurKernelY;
  15924. private _blurRatio;
  15925. /**
  15926. * Instantiates a Mirror Texture.
  15927. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15928. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15929. * You can then easily use it as a reflectionTexture on a flat surface.
  15930. * In case the surface is not a plane, please consider relying on reflection probes.
  15931. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15932. * @param name
  15933. * @param size
  15934. * @param scene
  15935. * @param generateMipMaps
  15936. * @param type
  15937. * @param samplingMode
  15938. * @param generateDepthBuffer
  15939. */
  15940. constructor(name: string, size: number | {
  15941. width: number;
  15942. height: number;
  15943. } | {
  15944. ratio: number;
  15945. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15946. private _preparePostProcesses;
  15947. /**
  15948. * Clone the mirror texture.
  15949. * @returns the cloned texture
  15950. */
  15951. clone(): MirrorTexture;
  15952. /**
  15953. * Serialize the texture to a JSON representation you could use in Parse later on
  15954. * @returns the serialized JSON representation
  15955. */
  15956. serialize(): any;
  15957. /**
  15958. * Dispose the texture and release its associated resources.
  15959. */
  15960. dispose(): void;
  15961. }
  15962. }
  15963. declare module "babylonjs/Materials/Textures/texture" {
  15964. import { Observable } from "babylonjs/Misc/observable";
  15965. import { Nullable } from "babylonjs/types";
  15966. import { Scene } from "babylonjs/scene";
  15967. import { Matrix } from "babylonjs/Maths/math.vector";
  15968. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15969. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15970. import { Engine } from "babylonjs/Engines/engine";
  15971. /**
  15972. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15973. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15974. */
  15975. export class Texture extends BaseTexture {
  15976. /**
  15977. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15978. */
  15979. static SerializeBuffers: boolean;
  15980. /** @hidden */
  15981. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15982. /** @hidden */
  15983. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15984. /** @hidden */
  15985. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15986. /** nearest is mag = nearest and min = nearest and mip = linear */
  15987. static readonly NEAREST_SAMPLINGMODE: number;
  15988. /** nearest is mag = nearest and min = nearest and mip = linear */
  15989. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15990. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15991. static readonly BILINEAR_SAMPLINGMODE: number;
  15992. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15993. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15994. /** Trilinear is mag = linear and min = linear and mip = linear */
  15995. static readonly TRILINEAR_SAMPLINGMODE: number;
  15996. /** Trilinear is mag = linear and min = linear and mip = linear */
  15997. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15998. /** mag = nearest and min = nearest and mip = nearest */
  15999. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16000. /** mag = nearest and min = linear and mip = nearest */
  16001. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16002. /** mag = nearest and min = linear and mip = linear */
  16003. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16004. /** mag = nearest and min = linear and mip = none */
  16005. static readonly NEAREST_LINEAR: number;
  16006. /** mag = nearest and min = nearest and mip = none */
  16007. static readonly NEAREST_NEAREST: number;
  16008. /** mag = linear and min = nearest and mip = nearest */
  16009. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16010. /** mag = linear and min = nearest and mip = linear */
  16011. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16012. /** mag = linear and min = linear and mip = none */
  16013. static readonly LINEAR_LINEAR: number;
  16014. /** mag = linear and min = nearest and mip = none */
  16015. static readonly LINEAR_NEAREST: number;
  16016. /** Explicit coordinates mode */
  16017. static readonly EXPLICIT_MODE: number;
  16018. /** Spherical coordinates mode */
  16019. static readonly SPHERICAL_MODE: number;
  16020. /** Planar coordinates mode */
  16021. static readonly PLANAR_MODE: number;
  16022. /** Cubic coordinates mode */
  16023. static readonly CUBIC_MODE: number;
  16024. /** Projection coordinates mode */
  16025. static readonly PROJECTION_MODE: number;
  16026. /** Inverse Cubic coordinates mode */
  16027. static readonly SKYBOX_MODE: number;
  16028. /** Inverse Cubic coordinates mode */
  16029. static readonly INVCUBIC_MODE: number;
  16030. /** Equirectangular coordinates mode */
  16031. static readonly EQUIRECTANGULAR_MODE: number;
  16032. /** Equirectangular Fixed coordinates mode */
  16033. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16034. /** Equirectangular Fixed Mirrored coordinates mode */
  16035. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16036. /** Texture is not repeating outside of 0..1 UVs */
  16037. static readonly CLAMP_ADDRESSMODE: number;
  16038. /** Texture is repeating outside of 0..1 UVs */
  16039. static readonly WRAP_ADDRESSMODE: number;
  16040. /** Texture is repeating and mirrored */
  16041. static readonly MIRROR_ADDRESSMODE: number;
  16042. /**
  16043. * 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
  16044. */
  16045. static UseSerializedUrlIfAny: boolean;
  16046. /**
  16047. * Define the url of the texture.
  16048. */
  16049. url: Nullable<string>;
  16050. /**
  16051. * Define an offset on the texture to offset the u coordinates of the UVs
  16052. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16053. */
  16054. uOffset: number;
  16055. /**
  16056. * Define an offset on the texture to offset the v coordinates of the UVs
  16057. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16058. */
  16059. vOffset: number;
  16060. /**
  16061. * Define an offset on the texture to scale the u coordinates of the UVs
  16062. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16063. */
  16064. uScale: number;
  16065. /**
  16066. * Define an offset on the texture to scale the v coordinates of the UVs
  16067. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16068. */
  16069. vScale: number;
  16070. /**
  16071. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16072. * @see http://doc.babylonjs.com/how_to/more_materials
  16073. */
  16074. uAng: number;
  16075. /**
  16076. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16077. * @see http://doc.babylonjs.com/how_to/more_materials
  16078. */
  16079. vAng: number;
  16080. /**
  16081. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16082. * @see http://doc.babylonjs.com/how_to/more_materials
  16083. */
  16084. wAng: number;
  16085. /**
  16086. * Defines the center of rotation (U)
  16087. */
  16088. uRotationCenter: number;
  16089. /**
  16090. * Defines the center of rotation (V)
  16091. */
  16092. vRotationCenter: number;
  16093. /**
  16094. * Defines the center of rotation (W)
  16095. */
  16096. wRotationCenter: number;
  16097. /**
  16098. * Are mip maps generated for this texture or not.
  16099. */
  16100. readonly noMipmap: boolean;
  16101. /**
  16102. * List of inspectable custom properties (used by the Inspector)
  16103. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16104. */
  16105. inspectableCustomProperties: Nullable<IInspectable[]>;
  16106. private _noMipmap;
  16107. /** @hidden */
  16108. _invertY: boolean;
  16109. private _rowGenerationMatrix;
  16110. private _cachedTextureMatrix;
  16111. private _projectionModeMatrix;
  16112. private _t0;
  16113. private _t1;
  16114. private _t2;
  16115. private _cachedUOffset;
  16116. private _cachedVOffset;
  16117. private _cachedUScale;
  16118. private _cachedVScale;
  16119. private _cachedUAng;
  16120. private _cachedVAng;
  16121. private _cachedWAng;
  16122. private _cachedProjectionMatrixId;
  16123. private _cachedCoordinatesMode;
  16124. /** @hidden */
  16125. protected _initialSamplingMode: number;
  16126. /** @hidden */
  16127. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16128. private _deleteBuffer;
  16129. protected _format: Nullable<number>;
  16130. private _delayedOnLoad;
  16131. private _delayedOnError;
  16132. /**
  16133. * Observable triggered once the texture has been loaded.
  16134. */
  16135. onLoadObservable: Observable<Texture>;
  16136. protected _isBlocking: boolean;
  16137. /**
  16138. * Is the texture preventing material to render while loading.
  16139. * If false, a default texture will be used instead of the loading one during the preparation step.
  16140. */
  16141. isBlocking: boolean;
  16142. /**
  16143. * Get the current sampling mode associated with the texture.
  16144. */
  16145. readonly samplingMode: number;
  16146. /**
  16147. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16148. */
  16149. readonly invertY: boolean;
  16150. /**
  16151. * Instantiates a new texture.
  16152. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16153. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16154. * @param url define the url of the picture to load as a texture
  16155. * @param scene define the scene or engine the texture will belong to
  16156. * @param noMipmap define if the texture will require mip maps or not
  16157. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16158. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16159. * @param onLoad define a callback triggered when the texture has been loaded
  16160. * @param onError define a callback triggered when an error occurred during the loading session
  16161. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16162. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16163. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16164. */
  16165. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16166. /**
  16167. * Update the url (and optional buffer) of this texture if url was null during construction.
  16168. * @param url the url of the texture
  16169. * @param buffer the buffer of the texture (defaults to null)
  16170. * @param onLoad callback called when the texture is loaded (defaults to null)
  16171. */
  16172. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16173. /**
  16174. * Finish the loading sequence of a texture flagged as delayed load.
  16175. * @hidden
  16176. */
  16177. delayLoad(): void;
  16178. private _prepareRowForTextureGeneration;
  16179. /**
  16180. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16181. * @returns the transform matrix of the texture.
  16182. */
  16183. getTextureMatrix(): Matrix;
  16184. /**
  16185. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16186. * @returns The reflection texture transform
  16187. */
  16188. getReflectionTextureMatrix(): Matrix;
  16189. /**
  16190. * Clones the texture.
  16191. * @returns the cloned texture
  16192. */
  16193. clone(): Texture;
  16194. /**
  16195. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16196. * @returns The JSON representation of the texture
  16197. */
  16198. serialize(): any;
  16199. /**
  16200. * Get the current class name of the texture useful for serialization or dynamic coding.
  16201. * @returns "Texture"
  16202. */
  16203. getClassName(): string;
  16204. /**
  16205. * Dispose the texture and release its associated resources.
  16206. */
  16207. dispose(): void;
  16208. /**
  16209. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16210. * @param parsedTexture Define the JSON representation of the texture
  16211. * @param scene Define the scene the parsed texture should be instantiated in
  16212. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16213. * @returns The parsed texture if successful
  16214. */
  16215. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16216. /**
  16217. * Creates a texture from its base 64 representation.
  16218. * @param data Define the base64 payload without the data: prefix
  16219. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16220. * @param scene Define the scene the texture should belong to
  16221. * @param noMipmap Forces the texture to not create mip map information if true
  16222. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16223. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16224. * @param onLoad define a callback triggered when the texture has been loaded
  16225. * @param onError define a callback triggered when an error occurred during the loading session
  16226. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16227. * @returns the created texture
  16228. */
  16229. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16230. /**
  16231. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16232. * @param data Define the base64 payload without the data: prefix
  16233. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16234. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16235. * @param scene Define the scene the texture should belong to
  16236. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16237. * @param noMipmap Forces the texture to not create mip map information if true
  16238. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16239. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16240. * @param onLoad define a callback triggered when the texture has been loaded
  16241. * @param onError define a callback triggered when an error occurred during the loading session
  16242. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16243. * @returns the created texture
  16244. */
  16245. 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;
  16246. }
  16247. }
  16248. declare module "babylonjs/PostProcesses/postProcessManager" {
  16249. import { Nullable } from "babylonjs/types";
  16250. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16251. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16252. import { Scene } from "babylonjs/scene";
  16253. /**
  16254. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16255. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16256. */
  16257. export class PostProcessManager {
  16258. private _scene;
  16259. private _indexBuffer;
  16260. private _vertexBuffers;
  16261. /**
  16262. * Creates a new instance PostProcess
  16263. * @param scene The scene that the post process is associated with.
  16264. */
  16265. constructor(scene: Scene);
  16266. private _prepareBuffers;
  16267. private _buildIndexBuffer;
  16268. /**
  16269. * Rebuilds the vertex buffers of the manager.
  16270. * @hidden
  16271. */
  16272. _rebuild(): void;
  16273. /**
  16274. * Prepares a frame to be run through a post process.
  16275. * @param sourceTexture The input texture to the post procesess. (default: null)
  16276. * @param postProcesses An array of post processes to be run. (default: null)
  16277. * @returns True if the post processes were able to be run.
  16278. * @hidden
  16279. */
  16280. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16281. /**
  16282. * Manually render a set of post processes to a texture.
  16283. * @param postProcesses An array of post processes to be run.
  16284. * @param targetTexture The target texture to render to.
  16285. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16286. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16287. * @param lodLevel defines which lod of the texture to render to
  16288. */
  16289. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16290. /**
  16291. * Finalize the result of the output of the postprocesses.
  16292. * @param doNotPresent If true the result will not be displayed to the screen.
  16293. * @param targetTexture The target texture to render to.
  16294. * @param faceIndex The index of the face to bind the target texture to.
  16295. * @param postProcesses The array of post processes to render.
  16296. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16297. * @hidden
  16298. */
  16299. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16300. /**
  16301. * Disposes of the post process manager.
  16302. */
  16303. dispose(): void;
  16304. }
  16305. }
  16306. declare module "babylonjs/Misc/gradients" {
  16307. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16308. /** Interface used by value gradients (color, factor, ...) */
  16309. export interface IValueGradient {
  16310. /**
  16311. * Gets or sets the gradient value (between 0 and 1)
  16312. */
  16313. gradient: number;
  16314. }
  16315. /** Class used to store color4 gradient */
  16316. export class ColorGradient implements IValueGradient {
  16317. /**
  16318. * Gets or sets the gradient value (between 0 and 1)
  16319. */
  16320. gradient: number;
  16321. /**
  16322. * Gets or sets first associated color
  16323. */
  16324. color1: Color4;
  16325. /**
  16326. * Gets or sets second associated color
  16327. */
  16328. color2?: Color4;
  16329. /**
  16330. * Will get a color picked randomly between color1 and color2.
  16331. * If color2 is undefined then color1 will be used
  16332. * @param result defines the target Color4 to store the result in
  16333. */
  16334. getColorToRef(result: Color4): void;
  16335. }
  16336. /** Class used to store color 3 gradient */
  16337. export class Color3Gradient implements IValueGradient {
  16338. /**
  16339. * Gets or sets the gradient value (between 0 and 1)
  16340. */
  16341. gradient: number;
  16342. /**
  16343. * Gets or sets the associated color
  16344. */
  16345. color: Color3;
  16346. }
  16347. /** Class used to store factor gradient */
  16348. export class FactorGradient implements IValueGradient {
  16349. /**
  16350. * Gets or sets the gradient value (between 0 and 1)
  16351. */
  16352. gradient: number;
  16353. /**
  16354. * Gets or sets first associated factor
  16355. */
  16356. factor1: number;
  16357. /**
  16358. * Gets or sets second associated factor
  16359. */
  16360. factor2?: number;
  16361. /**
  16362. * Will get a number picked randomly between factor1 and factor2.
  16363. * If factor2 is undefined then factor1 will be used
  16364. * @returns the picked number
  16365. */
  16366. getFactor(): number;
  16367. }
  16368. /**
  16369. * Helper used to simplify some generic gradient tasks
  16370. */
  16371. export class GradientHelper {
  16372. /**
  16373. * Gets the current gradient from an array of IValueGradient
  16374. * @param ratio defines the current ratio to get
  16375. * @param gradients defines the array of IValueGradient
  16376. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16377. */
  16378. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16379. }
  16380. }
  16381. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16382. import { Scene } from "babylonjs/scene";
  16383. import { Texture } from "babylonjs/Materials/Textures/texture";
  16384. /**
  16385. * A class extending Texture allowing drawing on a texture
  16386. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16387. */
  16388. export class DynamicTexture extends Texture {
  16389. private _generateMipMaps;
  16390. private _canvas;
  16391. private _context;
  16392. private _engine;
  16393. /**
  16394. * Creates a DynamicTexture
  16395. * @param name defines the name of the texture
  16396. * @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
  16397. * @param scene defines the scene where you want the texture
  16398. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16399. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16400. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16401. */
  16402. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16403. /**
  16404. * Get the current class name of the texture useful for serialization or dynamic coding.
  16405. * @returns "DynamicTexture"
  16406. */
  16407. getClassName(): string;
  16408. /**
  16409. * Gets the current state of canRescale
  16410. */
  16411. readonly canRescale: boolean;
  16412. private _recreate;
  16413. /**
  16414. * Scales the texture
  16415. * @param ratio the scale factor to apply to both width and height
  16416. */
  16417. scale(ratio: number): void;
  16418. /**
  16419. * Resizes the texture
  16420. * @param width the new width
  16421. * @param height the new height
  16422. */
  16423. scaleTo(width: number, height: number): void;
  16424. /**
  16425. * Gets the context of the canvas used by the texture
  16426. * @returns the canvas context of the dynamic texture
  16427. */
  16428. getContext(): CanvasRenderingContext2D;
  16429. /**
  16430. * Clears the texture
  16431. */
  16432. clear(): void;
  16433. /**
  16434. * Updates the texture
  16435. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16436. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16437. */
  16438. update(invertY?: boolean, premulAlpha?: boolean): void;
  16439. /**
  16440. * Draws text onto the texture
  16441. * @param text defines the text to be drawn
  16442. * @param x defines the placement of the text from the left
  16443. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16444. * @param font defines the font to be used with font-style, font-size, font-name
  16445. * @param color defines the color used for the text
  16446. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16447. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16448. * @param update defines whether texture is immediately update (default is true)
  16449. */
  16450. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16451. /**
  16452. * Clones the texture
  16453. * @returns the clone of the texture.
  16454. */
  16455. clone(): DynamicTexture;
  16456. /**
  16457. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16458. * @returns a serialized dynamic texture object
  16459. */
  16460. serialize(): any;
  16461. /** @hidden */
  16462. _rebuild(): void;
  16463. }
  16464. }
  16465. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16466. import { Scene } from "babylonjs/scene";
  16467. import { ISceneComponent } from "babylonjs/sceneComponent";
  16468. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16469. module "babylonjs/abstractScene" {
  16470. interface AbstractScene {
  16471. /**
  16472. * The list of procedural textures added to the scene
  16473. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16474. */
  16475. proceduralTextures: Array<ProceduralTexture>;
  16476. }
  16477. }
  16478. /**
  16479. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16480. * in a given scene.
  16481. */
  16482. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16483. /**
  16484. * The component name helpfull to identify the component in the list of scene components.
  16485. */
  16486. readonly name: string;
  16487. /**
  16488. * The scene the component belongs to.
  16489. */
  16490. scene: Scene;
  16491. /**
  16492. * Creates a new instance of the component for the given scene
  16493. * @param scene Defines the scene to register the component in
  16494. */
  16495. constructor(scene: Scene);
  16496. /**
  16497. * Registers the component in a given scene
  16498. */
  16499. register(): void;
  16500. /**
  16501. * Rebuilds the elements related to this component in case of
  16502. * context lost for instance.
  16503. */
  16504. rebuild(): void;
  16505. /**
  16506. * Disposes the component and the associated ressources.
  16507. */
  16508. dispose(): void;
  16509. private _beforeClear;
  16510. }
  16511. }
  16512. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16513. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16514. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16515. module "babylonjs/Engines/engine" {
  16516. interface Engine {
  16517. /**
  16518. * Creates a new render target cube texture
  16519. * @param size defines the size of the texture
  16520. * @param options defines the options used to create the texture
  16521. * @returns a new render target cube texture stored in an InternalTexture
  16522. */
  16523. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16524. }
  16525. }
  16526. }
  16527. declare module "babylonjs/Shaders/procedural.vertex" {
  16528. /** @hidden */
  16529. export var proceduralVertexShader: {
  16530. name: string;
  16531. shader: string;
  16532. };
  16533. }
  16534. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16535. import { Observable } from "babylonjs/Misc/observable";
  16536. import { Nullable } from "babylonjs/types";
  16537. import { Scene } from "babylonjs/scene";
  16538. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16539. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16540. import { Effect } from "babylonjs/Materials/effect";
  16541. import { Texture } from "babylonjs/Materials/Textures/texture";
  16542. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16543. import "babylonjs/Shaders/procedural.vertex";
  16544. /**
  16545. * 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.
  16546. * This is the base class of any Procedural texture and contains most of the shareable code.
  16547. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16548. */
  16549. export class ProceduralTexture extends Texture {
  16550. isCube: boolean;
  16551. /**
  16552. * Define if the texture is enabled or not (disabled texture will not render)
  16553. */
  16554. isEnabled: boolean;
  16555. /**
  16556. * Define if the texture must be cleared before rendering (default is true)
  16557. */
  16558. autoClear: boolean;
  16559. /**
  16560. * Callback called when the texture is generated
  16561. */
  16562. onGenerated: () => void;
  16563. /**
  16564. * Event raised when the texture is generated
  16565. */
  16566. onGeneratedObservable: Observable<ProceduralTexture>;
  16567. /** @hidden */
  16568. _generateMipMaps: boolean;
  16569. /** @hidden **/
  16570. _effect: Effect;
  16571. /** @hidden */
  16572. _textures: {
  16573. [key: string]: Texture;
  16574. };
  16575. private _size;
  16576. private _currentRefreshId;
  16577. private _refreshRate;
  16578. private _vertexBuffers;
  16579. private _indexBuffer;
  16580. private _uniforms;
  16581. private _samplers;
  16582. private _fragment;
  16583. private _floats;
  16584. private _ints;
  16585. private _floatsArrays;
  16586. private _colors3;
  16587. private _colors4;
  16588. private _vectors2;
  16589. private _vectors3;
  16590. private _matrices;
  16591. private _fallbackTexture;
  16592. private _fallbackTextureUsed;
  16593. private _engine;
  16594. private _cachedDefines;
  16595. private _contentUpdateId;
  16596. private _contentData;
  16597. /**
  16598. * Instantiates a new procedural texture.
  16599. * 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.
  16600. * This is the base class of any Procedural texture and contains most of the shareable code.
  16601. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16602. * @param name Define the name of the texture
  16603. * @param size Define the size of the texture to create
  16604. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16605. * @param scene Define the scene the texture belongs to
  16606. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16607. * @param generateMipMaps Define if the texture should creates mip maps or not
  16608. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16609. */
  16610. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16611. /**
  16612. * The effect that is created when initializing the post process.
  16613. * @returns The created effect corresponding the the postprocess.
  16614. */
  16615. getEffect(): Effect;
  16616. /**
  16617. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16618. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16619. */
  16620. getContent(): Nullable<ArrayBufferView>;
  16621. private _createIndexBuffer;
  16622. /** @hidden */
  16623. _rebuild(): void;
  16624. /**
  16625. * Resets the texture in order to recreate its associated resources.
  16626. * This can be called in case of context loss
  16627. */
  16628. reset(): void;
  16629. protected _getDefines(): string;
  16630. /**
  16631. * Is the texture ready to be used ? (rendered at least once)
  16632. * @returns true if ready, otherwise, false.
  16633. */
  16634. isReady(): boolean;
  16635. /**
  16636. * Resets the refresh counter of the texture and start bak from scratch.
  16637. * Could be useful to regenerate the texture if it is setup to render only once.
  16638. */
  16639. resetRefreshCounter(): void;
  16640. /**
  16641. * Set the fragment shader to use in order to render the texture.
  16642. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16643. */
  16644. setFragment(fragment: any): void;
  16645. /**
  16646. * Define the refresh rate of the texture or the rendering frequency.
  16647. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16648. */
  16649. refreshRate: number;
  16650. /** @hidden */
  16651. _shouldRender(): boolean;
  16652. /**
  16653. * Get the size the texture is rendering at.
  16654. * @returns the size (texture is always squared)
  16655. */
  16656. getRenderSize(): number;
  16657. /**
  16658. * Resize the texture to new value.
  16659. * @param size Define the new size the texture should have
  16660. * @param generateMipMaps Define whether the new texture should create mip maps
  16661. */
  16662. resize(size: number, generateMipMaps: boolean): void;
  16663. private _checkUniform;
  16664. /**
  16665. * Set a texture in the shader program used to render.
  16666. * @param name Define the name of the uniform samplers as defined in the shader
  16667. * @param texture Define the texture to bind to this sampler
  16668. * @return the texture itself allowing "fluent" like uniform updates
  16669. */
  16670. setTexture(name: string, texture: Texture): ProceduralTexture;
  16671. /**
  16672. * Set a float in the shader.
  16673. * @param name Define the name of the uniform as defined in the shader
  16674. * @param value Define the value to give to the uniform
  16675. * @return the texture itself allowing "fluent" like uniform updates
  16676. */
  16677. setFloat(name: string, value: number): ProceduralTexture;
  16678. /**
  16679. * Set a int in the shader.
  16680. * @param name Define the name of the uniform as defined in the shader
  16681. * @param value Define the value to give to the uniform
  16682. * @return the texture itself allowing "fluent" like uniform updates
  16683. */
  16684. setInt(name: string, value: number): ProceduralTexture;
  16685. /**
  16686. * Set an array of floats in the shader.
  16687. * @param name Define the name of the uniform as defined in the shader
  16688. * @param value Define the value to give to the uniform
  16689. * @return the texture itself allowing "fluent" like uniform updates
  16690. */
  16691. setFloats(name: string, value: number[]): ProceduralTexture;
  16692. /**
  16693. * Set a vec3 in the shader from a Color3.
  16694. * @param name Define the name of the uniform as defined in the shader
  16695. * @param value Define the value to give to the uniform
  16696. * @return the texture itself allowing "fluent" like uniform updates
  16697. */
  16698. setColor3(name: string, value: Color3): ProceduralTexture;
  16699. /**
  16700. * Set a vec4 in the shader from a Color4.
  16701. * @param name Define the name of the uniform as defined in the shader
  16702. * @param value Define the value to give to the uniform
  16703. * @return the texture itself allowing "fluent" like uniform updates
  16704. */
  16705. setColor4(name: string, value: Color4): ProceduralTexture;
  16706. /**
  16707. * Set a vec2 in the shader from a Vector2.
  16708. * @param name Define the name of the uniform as defined in the shader
  16709. * @param value Define the value to give to the uniform
  16710. * @return the texture itself allowing "fluent" like uniform updates
  16711. */
  16712. setVector2(name: string, value: Vector2): ProceduralTexture;
  16713. /**
  16714. * Set a vec3 in the shader from a Vector3.
  16715. * @param name Define the name of the uniform as defined in the shader
  16716. * @param value Define the value to give to the uniform
  16717. * @return the texture itself allowing "fluent" like uniform updates
  16718. */
  16719. setVector3(name: string, value: Vector3): ProceduralTexture;
  16720. /**
  16721. * Set a mat4 in the shader from a MAtrix.
  16722. * @param name Define the name of the uniform as defined in the shader
  16723. * @param value Define the value to give to the uniform
  16724. * @return the texture itself allowing "fluent" like uniform updates
  16725. */
  16726. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16727. /**
  16728. * Render the texture to its associated render target.
  16729. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16730. */
  16731. render(useCameraPostProcess?: boolean): void;
  16732. /**
  16733. * Clone the texture.
  16734. * @returns the cloned texture
  16735. */
  16736. clone(): ProceduralTexture;
  16737. /**
  16738. * Dispose the texture and release its asoociated resources.
  16739. */
  16740. dispose(): void;
  16741. }
  16742. }
  16743. declare module "babylonjs/Particles/baseParticleSystem" {
  16744. import { Nullable } from "babylonjs/types";
  16745. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16747. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16748. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16749. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16750. import { Scene } from "babylonjs/scene";
  16751. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16752. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16753. import { Texture } from "babylonjs/Materials/Textures/texture";
  16754. import { Color4 } from "babylonjs/Maths/math.color";
  16755. import { Animation } from "babylonjs/Animations/animation";
  16756. /**
  16757. * This represents the base class for particle system in Babylon.
  16758. * 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.
  16759. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16760. * @example https://doc.babylonjs.com/babylon101/particles
  16761. */
  16762. export class BaseParticleSystem {
  16763. /**
  16764. * Source color is added to the destination color without alpha affecting the result
  16765. */
  16766. static BLENDMODE_ONEONE: number;
  16767. /**
  16768. * Blend current color and particle color using particle’s alpha
  16769. */
  16770. static BLENDMODE_STANDARD: number;
  16771. /**
  16772. * Add current color and particle color multiplied by particle’s alpha
  16773. */
  16774. static BLENDMODE_ADD: number;
  16775. /**
  16776. * Multiply current color with particle color
  16777. */
  16778. static BLENDMODE_MULTIPLY: number;
  16779. /**
  16780. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16781. */
  16782. static BLENDMODE_MULTIPLYADD: number;
  16783. /**
  16784. * List of animations used by the particle system.
  16785. */
  16786. animations: Animation[];
  16787. /**
  16788. * The id of the Particle system.
  16789. */
  16790. id: string;
  16791. /**
  16792. * The friendly name of the Particle system.
  16793. */
  16794. name: string;
  16795. /**
  16796. * The rendering group used by the Particle system to chose when to render.
  16797. */
  16798. renderingGroupId: number;
  16799. /**
  16800. * The emitter represents the Mesh or position we are attaching the particle system to.
  16801. */
  16802. emitter: Nullable<AbstractMesh | Vector3>;
  16803. /**
  16804. * The maximum number of particles to emit per frame
  16805. */
  16806. emitRate: number;
  16807. /**
  16808. * If you want to launch only a few particles at once, that can be done, as well.
  16809. */
  16810. manualEmitCount: number;
  16811. /**
  16812. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16813. */
  16814. updateSpeed: number;
  16815. /**
  16816. * The amount of time the particle system is running (depends of the overall update speed).
  16817. */
  16818. targetStopDuration: number;
  16819. /**
  16820. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16821. */
  16822. disposeOnStop: boolean;
  16823. /**
  16824. * Minimum power of emitting particles.
  16825. */
  16826. minEmitPower: number;
  16827. /**
  16828. * Maximum power of emitting particles.
  16829. */
  16830. maxEmitPower: number;
  16831. /**
  16832. * Minimum life time of emitting particles.
  16833. */
  16834. minLifeTime: number;
  16835. /**
  16836. * Maximum life time of emitting particles.
  16837. */
  16838. maxLifeTime: number;
  16839. /**
  16840. * Minimum Size of emitting particles.
  16841. */
  16842. minSize: number;
  16843. /**
  16844. * Maximum Size of emitting particles.
  16845. */
  16846. maxSize: number;
  16847. /**
  16848. * Minimum scale of emitting particles on X axis.
  16849. */
  16850. minScaleX: number;
  16851. /**
  16852. * Maximum scale of emitting particles on X axis.
  16853. */
  16854. maxScaleX: number;
  16855. /**
  16856. * Minimum scale of emitting particles on Y axis.
  16857. */
  16858. minScaleY: number;
  16859. /**
  16860. * Maximum scale of emitting particles on Y axis.
  16861. */
  16862. maxScaleY: number;
  16863. /**
  16864. * Gets or sets the minimal initial rotation in radians.
  16865. */
  16866. minInitialRotation: number;
  16867. /**
  16868. * Gets or sets the maximal initial rotation in radians.
  16869. */
  16870. maxInitialRotation: number;
  16871. /**
  16872. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16873. */
  16874. minAngularSpeed: number;
  16875. /**
  16876. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16877. */
  16878. maxAngularSpeed: number;
  16879. /**
  16880. * The texture used to render each particle. (this can be a spritesheet)
  16881. */
  16882. particleTexture: Nullable<Texture>;
  16883. /**
  16884. * The layer mask we are rendering the particles through.
  16885. */
  16886. layerMask: number;
  16887. /**
  16888. * This can help using your own shader to render the particle system.
  16889. * The according effect will be created
  16890. */
  16891. customShader: any;
  16892. /**
  16893. * By default particle system starts as soon as they are created. This prevents the
  16894. * automatic start to happen and let you decide when to start emitting particles.
  16895. */
  16896. preventAutoStart: boolean;
  16897. private _noiseTexture;
  16898. /**
  16899. * Gets or sets a texture used to add random noise to particle positions
  16900. */
  16901. noiseTexture: Nullable<ProceduralTexture>;
  16902. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16903. noiseStrength: Vector3;
  16904. /**
  16905. * Callback triggered when the particle animation is ending.
  16906. */
  16907. onAnimationEnd: Nullable<() => void>;
  16908. /**
  16909. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16910. */
  16911. blendMode: number;
  16912. /**
  16913. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16914. * to override the particles.
  16915. */
  16916. forceDepthWrite: boolean;
  16917. /** 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 */
  16918. preWarmCycles: number;
  16919. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16920. preWarmStepOffset: number;
  16921. /**
  16922. * 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)
  16923. */
  16924. spriteCellChangeSpeed: number;
  16925. /**
  16926. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16927. */
  16928. startSpriteCellID: number;
  16929. /**
  16930. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16931. */
  16932. endSpriteCellID: number;
  16933. /**
  16934. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16935. */
  16936. spriteCellWidth: number;
  16937. /**
  16938. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16939. */
  16940. spriteCellHeight: number;
  16941. /**
  16942. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16943. */
  16944. spriteRandomStartCell: boolean;
  16945. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16946. translationPivot: Vector2;
  16947. /** @hidden */
  16948. protected _isAnimationSheetEnabled: boolean;
  16949. /**
  16950. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16951. */
  16952. beginAnimationOnStart: boolean;
  16953. /**
  16954. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16955. */
  16956. beginAnimationFrom: number;
  16957. /**
  16958. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16959. */
  16960. beginAnimationTo: number;
  16961. /**
  16962. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16963. */
  16964. beginAnimationLoop: boolean;
  16965. /**
  16966. * Gets or sets a world offset applied to all particles
  16967. */
  16968. worldOffset: Vector3;
  16969. /**
  16970. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16971. */
  16972. isAnimationSheetEnabled: boolean;
  16973. /**
  16974. * Get hosting scene
  16975. * @returns the scene
  16976. */
  16977. getScene(): Scene;
  16978. /**
  16979. * You can use gravity if you want to give an orientation to your particles.
  16980. */
  16981. gravity: Vector3;
  16982. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16983. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16984. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16985. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16986. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16987. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16988. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16989. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16990. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16991. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16992. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16993. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16994. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16995. /**
  16996. * Defines the delay in milliseconds before starting the system (0 by default)
  16997. */
  16998. startDelay: number;
  16999. /**
  17000. * Gets the current list of drag gradients.
  17001. * You must use addDragGradient and removeDragGradient to udpate this list
  17002. * @returns the list of drag gradients
  17003. */
  17004. getDragGradients(): Nullable<Array<FactorGradient>>;
  17005. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17006. limitVelocityDamping: number;
  17007. /**
  17008. * Gets the current list of limit velocity gradients.
  17009. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17010. * @returns the list of limit velocity gradients
  17011. */
  17012. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17013. /**
  17014. * Gets the current list of color gradients.
  17015. * You must use addColorGradient and removeColorGradient to udpate this list
  17016. * @returns the list of color gradients
  17017. */
  17018. getColorGradients(): Nullable<Array<ColorGradient>>;
  17019. /**
  17020. * Gets the current list of size gradients.
  17021. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17022. * @returns the list of size gradients
  17023. */
  17024. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17025. /**
  17026. * Gets the current list of color remap gradients.
  17027. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17028. * @returns the list of color remap gradients
  17029. */
  17030. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17031. /**
  17032. * Gets the current list of alpha remap gradients.
  17033. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17034. * @returns the list of alpha remap gradients
  17035. */
  17036. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17037. /**
  17038. * Gets the current list of life time gradients.
  17039. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17040. * @returns the list of life time gradients
  17041. */
  17042. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17043. /**
  17044. * Gets the current list of angular speed gradients.
  17045. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17046. * @returns the list of angular speed gradients
  17047. */
  17048. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17049. /**
  17050. * Gets the current list of velocity gradients.
  17051. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17052. * @returns the list of velocity gradients
  17053. */
  17054. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17055. /**
  17056. * Gets the current list of start size gradients.
  17057. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17058. * @returns the list of start size gradients
  17059. */
  17060. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17061. /**
  17062. * Gets the current list of emit rate gradients.
  17063. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17064. * @returns the list of emit rate gradients
  17065. */
  17066. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17067. /**
  17068. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17069. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17070. */
  17071. direction1: Vector3;
  17072. /**
  17073. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17074. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17075. */
  17076. direction2: Vector3;
  17077. /**
  17078. * 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.
  17079. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17080. */
  17081. minEmitBox: Vector3;
  17082. /**
  17083. * 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.
  17084. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17085. */
  17086. maxEmitBox: Vector3;
  17087. /**
  17088. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17089. */
  17090. color1: Color4;
  17091. /**
  17092. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17093. */
  17094. color2: Color4;
  17095. /**
  17096. * Color the particle will have at the end of its lifetime
  17097. */
  17098. colorDead: Color4;
  17099. /**
  17100. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17101. */
  17102. textureMask: Color4;
  17103. /**
  17104. * The particle emitter type defines the emitter used by the particle system.
  17105. * It can be for example box, sphere, or cone...
  17106. */
  17107. particleEmitterType: IParticleEmitterType;
  17108. /** @hidden */
  17109. _isSubEmitter: boolean;
  17110. /**
  17111. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17112. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17113. */
  17114. billboardMode: number;
  17115. protected _isBillboardBased: boolean;
  17116. /**
  17117. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17118. */
  17119. isBillboardBased: boolean;
  17120. /**
  17121. * The scene the particle system belongs to.
  17122. */
  17123. protected _scene: Scene;
  17124. /**
  17125. * Local cache of defines for image processing.
  17126. */
  17127. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17128. /**
  17129. * Default configuration related to image processing available in the standard Material.
  17130. */
  17131. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17132. /**
  17133. * Gets the image processing configuration used either in this material.
  17134. */
  17135. /**
  17136. * Sets the Default image processing configuration used either in the this material.
  17137. *
  17138. * If sets to null, the scene one is in use.
  17139. */
  17140. imageProcessingConfiguration: ImageProcessingConfiguration;
  17141. /**
  17142. * Attaches a new image processing configuration to the Standard Material.
  17143. * @param configuration
  17144. */
  17145. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17146. /** @hidden */
  17147. protected _reset(): void;
  17148. /** @hidden */
  17149. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17150. /**
  17151. * Instantiates a particle system.
  17152. * 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.
  17153. * @param name The name of the particle system
  17154. */
  17155. constructor(name: string);
  17156. /**
  17157. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17158. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17159. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17160. * @returns the emitter
  17161. */
  17162. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17163. /**
  17164. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17165. * @param radius The radius of the hemisphere to emit from
  17166. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17167. * @returns the emitter
  17168. */
  17169. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17170. /**
  17171. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17172. * @param radius The radius of the sphere to emit from
  17173. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17174. * @returns the emitter
  17175. */
  17176. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17177. /**
  17178. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17179. * @param radius The radius of the sphere to emit from
  17180. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17181. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17182. * @returns the emitter
  17183. */
  17184. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17185. /**
  17186. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17187. * @param radius The radius of the emission cylinder
  17188. * @param height The height of the emission cylinder
  17189. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17190. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17191. * @returns the emitter
  17192. */
  17193. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17194. /**
  17195. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17196. * @param radius The radius of the cylinder to emit from
  17197. * @param height The height of the emission cylinder
  17198. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17199. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17200. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17201. * @returns the emitter
  17202. */
  17203. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17204. /**
  17205. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17206. * @param radius The radius of the cone to emit from
  17207. * @param angle The base angle of the cone
  17208. * @returns the emitter
  17209. */
  17210. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17211. /**
  17212. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17213. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17214. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17215. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17216. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17217. * @returns the emitter
  17218. */
  17219. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17220. }
  17221. }
  17222. declare module "babylonjs/Particles/subEmitter" {
  17223. import { Scene } from "babylonjs/scene";
  17224. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17225. /**
  17226. * Type of sub emitter
  17227. */
  17228. export enum SubEmitterType {
  17229. /**
  17230. * Attached to the particle over it's lifetime
  17231. */
  17232. ATTACHED = 0,
  17233. /**
  17234. * Created when the particle dies
  17235. */
  17236. END = 1
  17237. }
  17238. /**
  17239. * Sub emitter class used to emit particles from an existing particle
  17240. */
  17241. export class SubEmitter {
  17242. /**
  17243. * the particle system to be used by the sub emitter
  17244. */
  17245. particleSystem: ParticleSystem;
  17246. /**
  17247. * Type of the submitter (Default: END)
  17248. */
  17249. type: SubEmitterType;
  17250. /**
  17251. * 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)
  17252. * Note: This only is supported when using an emitter of type Mesh
  17253. */
  17254. inheritDirection: boolean;
  17255. /**
  17256. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17257. */
  17258. inheritedVelocityAmount: number;
  17259. /**
  17260. * Creates a sub emitter
  17261. * @param particleSystem the particle system to be used by the sub emitter
  17262. */
  17263. constructor(
  17264. /**
  17265. * the particle system to be used by the sub emitter
  17266. */
  17267. particleSystem: ParticleSystem);
  17268. /**
  17269. * Clones the sub emitter
  17270. * @returns the cloned sub emitter
  17271. */
  17272. clone(): SubEmitter;
  17273. /**
  17274. * Serialize current object to a JSON object
  17275. * @returns the serialized object
  17276. */
  17277. serialize(): any;
  17278. /** @hidden */
  17279. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17280. /**
  17281. * Creates a new SubEmitter from a serialized JSON version
  17282. * @param serializationObject defines the JSON object to read from
  17283. * @param scene defines the hosting scene
  17284. * @param rootUrl defines the rootUrl for data loading
  17285. * @returns a new SubEmitter
  17286. */
  17287. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17288. /** Release associated resources */
  17289. dispose(): void;
  17290. }
  17291. }
  17292. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17293. /** @hidden */
  17294. export var clipPlaneFragmentDeclaration: {
  17295. name: string;
  17296. shader: string;
  17297. };
  17298. }
  17299. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17300. /** @hidden */
  17301. export var imageProcessingDeclaration: {
  17302. name: string;
  17303. shader: string;
  17304. };
  17305. }
  17306. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17307. /** @hidden */
  17308. export var imageProcessingFunctions: {
  17309. name: string;
  17310. shader: string;
  17311. };
  17312. }
  17313. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17314. /** @hidden */
  17315. export var clipPlaneFragment: {
  17316. name: string;
  17317. shader: string;
  17318. };
  17319. }
  17320. declare module "babylonjs/Shaders/particles.fragment" {
  17321. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17322. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17323. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17324. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17325. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17326. /** @hidden */
  17327. export var particlesPixelShader: {
  17328. name: string;
  17329. shader: string;
  17330. };
  17331. }
  17332. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17333. /** @hidden */
  17334. export var clipPlaneVertexDeclaration: {
  17335. name: string;
  17336. shader: string;
  17337. };
  17338. }
  17339. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17340. /** @hidden */
  17341. export var clipPlaneVertex: {
  17342. name: string;
  17343. shader: string;
  17344. };
  17345. }
  17346. declare module "babylonjs/Shaders/particles.vertex" {
  17347. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17348. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17349. /** @hidden */
  17350. export var particlesVertexShader: {
  17351. name: string;
  17352. shader: string;
  17353. };
  17354. }
  17355. declare module "babylonjs/Particles/particleSystem" {
  17356. import { Nullable } from "babylonjs/types";
  17357. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17358. import { Observable } from "babylonjs/Misc/observable";
  17359. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17360. import { Effect } from "babylonjs/Materials/effect";
  17361. import { Scene, IDisposable } from "babylonjs/scene";
  17362. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17363. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17364. import { Particle } from "babylonjs/Particles/particle";
  17365. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17366. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17367. import "babylonjs/Shaders/particles.fragment";
  17368. import "babylonjs/Shaders/particles.vertex";
  17369. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17370. /**
  17371. * This represents a particle system in Babylon.
  17372. * 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.
  17373. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17374. * @example https://doc.babylonjs.com/babylon101/particles
  17375. */
  17376. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17377. /**
  17378. * Billboard mode will only apply to Y axis
  17379. */
  17380. static readonly BILLBOARDMODE_Y: number;
  17381. /**
  17382. * Billboard mode will apply to all axes
  17383. */
  17384. static readonly BILLBOARDMODE_ALL: number;
  17385. /**
  17386. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17387. */
  17388. static readonly BILLBOARDMODE_STRETCHED: number;
  17389. /**
  17390. * This function can be defined to provide custom update for active particles.
  17391. * This function will be called instead of regular update (age, position, color, etc.).
  17392. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17393. */
  17394. updateFunction: (particles: Particle[]) => void;
  17395. private _emitterWorldMatrix;
  17396. /**
  17397. * This function can be defined to specify initial direction for every new particle.
  17398. * It by default use the emitterType defined function
  17399. */
  17400. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17401. /**
  17402. * This function can be defined to specify initial position for every new particle.
  17403. * It by default use the emitterType defined function
  17404. */
  17405. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17406. /**
  17407. * @hidden
  17408. */
  17409. _inheritedVelocityOffset: Vector3;
  17410. /**
  17411. * An event triggered when the system is disposed
  17412. */
  17413. onDisposeObservable: Observable<ParticleSystem>;
  17414. private _onDisposeObserver;
  17415. /**
  17416. * Sets a callback that will be triggered when the system is disposed
  17417. */
  17418. onDispose: () => void;
  17419. private _particles;
  17420. private _epsilon;
  17421. private _capacity;
  17422. private _stockParticles;
  17423. private _newPartsExcess;
  17424. private _vertexData;
  17425. private _vertexBuffer;
  17426. private _vertexBuffers;
  17427. private _spriteBuffer;
  17428. private _indexBuffer;
  17429. private _effect;
  17430. private _customEffect;
  17431. private _cachedDefines;
  17432. private _scaledColorStep;
  17433. private _colorDiff;
  17434. private _scaledDirection;
  17435. private _scaledGravity;
  17436. private _currentRenderId;
  17437. private _alive;
  17438. private _useInstancing;
  17439. private _started;
  17440. private _stopped;
  17441. private _actualFrame;
  17442. private _scaledUpdateSpeed;
  17443. private _vertexBufferSize;
  17444. /** @hidden */
  17445. _currentEmitRateGradient: Nullable<FactorGradient>;
  17446. /** @hidden */
  17447. _currentEmitRate1: number;
  17448. /** @hidden */
  17449. _currentEmitRate2: number;
  17450. /** @hidden */
  17451. _currentStartSizeGradient: Nullable<FactorGradient>;
  17452. /** @hidden */
  17453. _currentStartSize1: number;
  17454. /** @hidden */
  17455. _currentStartSize2: number;
  17456. private readonly _rawTextureWidth;
  17457. private _rampGradientsTexture;
  17458. private _useRampGradients;
  17459. /** Gets or sets a boolean indicating that ramp gradients must be used
  17460. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17461. */
  17462. useRampGradients: boolean;
  17463. /**
  17464. * 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.
  17465. * 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: [])
  17466. */
  17467. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17468. private _subEmitters;
  17469. /**
  17470. * @hidden
  17471. * If the particle systems emitter should be disposed when the particle system is disposed
  17472. */
  17473. _disposeEmitterOnDispose: boolean;
  17474. /**
  17475. * The current active Sub-systems, this property is used by the root particle system only.
  17476. */
  17477. activeSubSystems: Array<ParticleSystem>;
  17478. private _rootParticleSystem;
  17479. /**
  17480. * Gets the current list of active particles
  17481. */
  17482. readonly particles: Particle[];
  17483. /**
  17484. * Returns the string "ParticleSystem"
  17485. * @returns a string containing the class name
  17486. */
  17487. getClassName(): string;
  17488. /**
  17489. * Instantiates a particle system.
  17490. * 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.
  17491. * @param name The name of the particle system
  17492. * @param capacity The max number of particles alive at the same time
  17493. * @param scene The scene the particle system belongs to
  17494. * @param customEffect a custom effect used to change the way particles are rendered by default
  17495. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17496. * @param epsilon Offset used to render the particles
  17497. */
  17498. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17499. private _addFactorGradient;
  17500. private _removeFactorGradient;
  17501. /**
  17502. * Adds a new life time gradient
  17503. * @param gradient defines the gradient to use (between 0 and 1)
  17504. * @param factor defines the life time factor to affect to the specified gradient
  17505. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17506. * @returns the current particle system
  17507. */
  17508. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17509. /**
  17510. * Remove a specific life time gradient
  17511. * @param gradient defines the gradient to remove
  17512. * @returns the current particle system
  17513. */
  17514. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17515. /**
  17516. * Adds a new size gradient
  17517. * @param gradient defines the gradient to use (between 0 and 1)
  17518. * @param factor defines the size factor to affect to the specified gradient
  17519. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17520. * @returns the current particle system
  17521. */
  17522. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17523. /**
  17524. * Remove a specific size gradient
  17525. * @param gradient defines the gradient to remove
  17526. * @returns the current particle system
  17527. */
  17528. removeSizeGradient(gradient: number): IParticleSystem;
  17529. /**
  17530. * Adds a new color remap gradient
  17531. * @param gradient defines the gradient to use (between 0 and 1)
  17532. * @param min defines the color remap minimal range
  17533. * @param max defines the color remap maximal range
  17534. * @returns the current particle system
  17535. */
  17536. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17537. /**
  17538. * Remove a specific color remap gradient
  17539. * @param gradient defines the gradient to remove
  17540. * @returns the current particle system
  17541. */
  17542. removeColorRemapGradient(gradient: number): IParticleSystem;
  17543. /**
  17544. * Adds a new alpha remap gradient
  17545. * @param gradient defines the gradient to use (between 0 and 1)
  17546. * @param min defines the alpha remap minimal range
  17547. * @param max defines the alpha remap maximal range
  17548. * @returns the current particle system
  17549. */
  17550. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17551. /**
  17552. * Remove a specific alpha remap gradient
  17553. * @param gradient defines the gradient to remove
  17554. * @returns the current particle system
  17555. */
  17556. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17557. /**
  17558. * Adds a new angular speed gradient
  17559. * @param gradient defines the gradient to use (between 0 and 1)
  17560. * @param factor defines the angular speed to affect to the specified gradient
  17561. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17562. * @returns the current particle system
  17563. */
  17564. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17565. /**
  17566. * Remove a specific angular speed gradient
  17567. * @param gradient defines the gradient to remove
  17568. * @returns the current particle system
  17569. */
  17570. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17571. /**
  17572. * Adds a new velocity gradient
  17573. * @param gradient defines the gradient to use (between 0 and 1)
  17574. * @param factor defines the velocity to affect to the specified gradient
  17575. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17576. * @returns the current particle system
  17577. */
  17578. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17579. /**
  17580. * Remove a specific velocity gradient
  17581. * @param gradient defines the gradient to remove
  17582. * @returns the current particle system
  17583. */
  17584. removeVelocityGradient(gradient: number): IParticleSystem;
  17585. /**
  17586. * Adds a new limit velocity gradient
  17587. * @param gradient defines the gradient to use (between 0 and 1)
  17588. * @param factor defines the limit velocity value to affect to the specified gradient
  17589. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17590. * @returns the current particle system
  17591. */
  17592. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17593. /**
  17594. * Remove a specific limit velocity gradient
  17595. * @param gradient defines the gradient to remove
  17596. * @returns the current particle system
  17597. */
  17598. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17599. /**
  17600. * Adds a new drag gradient
  17601. * @param gradient defines the gradient to use (between 0 and 1)
  17602. * @param factor defines the drag value to affect to the specified gradient
  17603. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17604. * @returns the current particle system
  17605. */
  17606. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17607. /**
  17608. * Remove a specific drag gradient
  17609. * @param gradient defines the gradient to remove
  17610. * @returns the current particle system
  17611. */
  17612. removeDragGradient(gradient: number): IParticleSystem;
  17613. /**
  17614. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17615. * @param gradient defines the gradient to use (between 0 and 1)
  17616. * @param factor defines the emit rate value to affect to the specified gradient
  17617. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17618. * @returns the current particle system
  17619. */
  17620. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17621. /**
  17622. * Remove a specific emit rate gradient
  17623. * @param gradient defines the gradient to remove
  17624. * @returns the current particle system
  17625. */
  17626. removeEmitRateGradient(gradient: number): IParticleSystem;
  17627. /**
  17628. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17629. * @param gradient defines the gradient to use (between 0 and 1)
  17630. * @param factor defines the start size value to affect to the specified gradient
  17631. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17632. * @returns the current particle system
  17633. */
  17634. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17635. /**
  17636. * Remove a specific start size gradient
  17637. * @param gradient defines the gradient to remove
  17638. * @returns the current particle system
  17639. */
  17640. removeStartSizeGradient(gradient: number): IParticleSystem;
  17641. private _createRampGradientTexture;
  17642. /**
  17643. * Gets the current list of ramp gradients.
  17644. * You must use addRampGradient and removeRampGradient to udpate this list
  17645. * @returns the list of ramp gradients
  17646. */
  17647. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17648. /**
  17649. * Adds a new ramp gradient used to remap particle colors
  17650. * @param gradient defines the gradient to use (between 0 and 1)
  17651. * @param color defines the color to affect to the specified gradient
  17652. * @returns the current particle system
  17653. */
  17654. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17655. /**
  17656. * Remove a specific ramp gradient
  17657. * @param gradient defines the gradient to remove
  17658. * @returns the current particle system
  17659. */
  17660. removeRampGradient(gradient: number): ParticleSystem;
  17661. /**
  17662. * Adds a new color gradient
  17663. * @param gradient defines the gradient to use (between 0 and 1)
  17664. * @param color1 defines the color to affect to the specified gradient
  17665. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17666. * @returns this particle system
  17667. */
  17668. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17669. /**
  17670. * Remove a specific color gradient
  17671. * @param gradient defines the gradient to remove
  17672. * @returns this particle system
  17673. */
  17674. removeColorGradient(gradient: number): IParticleSystem;
  17675. private _fetchR;
  17676. protected _reset(): void;
  17677. private _resetEffect;
  17678. private _createVertexBuffers;
  17679. private _createIndexBuffer;
  17680. /**
  17681. * Gets the maximum number of particles active at the same time.
  17682. * @returns The max number of active particles.
  17683. */
  17684. getCapacity(): number;
  17685. /**
  17686. * Gets whether there are still active particles in the system.
  17687. * @returns True if it is alive, otherwise false.
  17688. */
  17689. isAlive(): boolean;
  17690. /**
  17691. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17692. * @returns True if it has been started, otherwise false.
  17693. */
  17694. isStarted(): boolean;
  17695. private _prepareSubEmitterInternalArray;
  17696. /**
  17697. * Starts the particle system and begins to emit
  17698. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17699. */
  17700. start(delay?: number): void;
  17701. /**
  17702. * Stops the particle system.
  17703. * @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.
  17704. */
  17705. stop(stopSubEmitters?: boolean): void;
  17706. /**
  17707. * Remove all active particles
  17708. */
  17709. reset(): void;
  17710. /**
  17711. * @hidden (for internal use only)
  17712. */
  17713. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17714. /**
  17715. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17716. * Its lifetime will start back at 0.
  17717. */
  17718. recycleParticle: (particle: Particle) => void;
  17719. private _stopSubEmitters;
  17720. private _createParticle;
  17721. private _removeFromRoot;
  17722. private _emitFromParticle;
  17723. private _update;
  17724. /** @hidden */
  17725. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17726. /** @hidden */
  17727. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17728. /** @hidden */
  17729. private _getEffect;
  17730. /**
  17731. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17732. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17733. */
  17734. animate(preWarmOnly?: boolean): void;
  17735. private _appendParticleVertices;
  17736. /**
  17737. * Rebuilds the particle system.
  17738. */
  17739. rebuild(): void;
  17740. /**
  17741. * Is this system ready to be used/rendered
  17742. * @return true if the system is ready
  17743. */
  17744. isReady(): boolean;
  17745. private _render;
  17746. /**
  17747. * Renders the particle system in its current state.
  17748. * @returns the current number of particles
  17749. */
  17750. render(): number;
  17751. /**
  17752. * Disposes the particle system and free the associated resources
  17753. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17754. */
  17755. dispose(disposeTexture?: boolean): void;
  17756. /**
  17757. * Clones the particle system.
  17758. * @param name The name of the cloned object
  17759. * @param newEmitter The new emitter to use
  17760. * @returns the cloned particle system
  17761. */
  17762. clone(name: string, newEmitter: any): ParticleSystem;
  17763. /**
  17764. * Serializes the particle system to a JSON object.
  17765. * @returns the JSON object
  17766. */
  17767. serialize(): any;
  17768. /** @hidden */
  17769. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17770. /** @hidden */
  17771. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17772. /**
  17773. * Parses a JSON object to create a particle system.
  17774. * @param parsedParticleSystem The JSON object to parse
  17775. * @param scene The scene to create the particle system in
  17776. * @param rootUrl The root url to use to load external dependencies like texture
  17777. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17778. * @returns the Parsed particle system
  17779. */
  17780. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17781. }
  17782. }
  17783. declare module "babylonjs/Particles/particle" {
  17784. import { Nullable } from "babylonjs/types";
  17785. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17786. import { Color4 } from "babylonjs/Maths/math.color";
  17787. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17788. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17789. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17790. /**
  17791. * A particle represents one of the element emitted by a particle system.
  17792. * This is mainly define by its coordinates, direction, velocity and age.
  17793. */
  17794. export class Particle {
  17795. /**
  17796. * The particle system the particle belongs to.
  17797. */
  17798. particleSystem: ParticleSystem;
  17799. private static _Count;
  17800. /**
  17801. * Unique ID of the particle
  17802. */
  17803. id: number;
  17804. /**
  17805. * The world position of the particle in the scene.
  17806. */
  17807. position: Vector3;
  17808. /**
  17809. * The world direction of the particle in the scene.
  17810. */
  17811. direction: Vector3;
  17812. /**
  17813. * The color of the particle.
  17814. */
  17815. color: Color4;
  17816. /**
  17817. * The color change of the particle per step.
  17818. */
  17819. colorStep: Color4;
  17820. /**
  17821. * Defines how long will the life of the particle be.
  17822. */
  17823. lifeTime: number;
  17824. /**
  17825. * The current age of the particle.
  17826. */
  17827. age: number;
  17828. /**
  17829. * The current size of the particle.
  17830. */
  17831. size: number;
  17832. /**
  17833. * The current scale of the particle.
  17834. */
  17835. scale: Vector2;
  17836. /**
  17837. * The current angle of the particle.
  17838. */
  17839. angle: number;
  17840. /**
  17841. * Defines how fast is the angle changing.
  17842. */
  17843. angularSpeed: number;
  17844. /**
  17845. * Defines the cell index used by the particle to be rendered from a sprite.
  17846. */
  17847. cellIndex: number;
  17848. /**
  17849. * The information required to support color remapping
  17850. */
  17851. remapData: Vector4;
  17852. /** @hidden */
  17853. _randomCellOffset?: number;
  17854. /** @hidden */
  17855. _initialDirection: Nullable<Vector3>;
  17856. /** @hidden */
  17857. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17858. /** @hidden */
  17859. _initialStartSpriteCellID: number;
  17860. /** @hidden */
  17861. _initialEndSpriteCellID: number;
  17862. /** @hidden */
  17863. _currentColorGradient: Nullable<ColorGradient>;
  17864. /** @hidden */
  17865. _currentColor1: Color4;
  17866. /** @hidden */
  17867. _currentColor2: Color4;
  17868. /** @hidden */
  17869. _currentSizeGradient: Nullable<FactorGradient>;
  17870. /** @hidden */
  17871. _currentSize1: number;
  17872. /** @hidden */
  17873. _currentSize2: number;
  17874. /** @hidden */
  17875. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17876. /** @hidden */
  17877. _currentAngularSpeed1: number;
  17878. /** @hidden */
  17879. _currentAngularSpeed2: number;
  17880. /** @hidden */
  17881. _currentVelocityGradient: Nullable<FactorGradient>;
  17882. /** @hidden */
  17883. _currentVelocity1: number;
  17884. /** @hidden */
  17885. _currentVelocity2: number;
  17886. /** @hidden */
  17887. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17888. /** @hidden */
  17889. _currentLimitVelocity1: number;
  17890. /** @hidden */
  17891. _currentLimitVelocity2: number;
  17892. /** @hidden */
  17893. _currentDragGradient: Nullable<FactorGradient>;
  17894. /** @hidden */
  17895. _currentDrag1: number;
  17896. /** @hidden */
  17897. _currentDrag2: number;
  17898. /** @hidden */
  17899. _randomNoiseCoordinates1: Vector3;
  17900. /** @hidden */
  17901. _randomNoiseCoordinates2: Vector3;
  17902. /**
  17903. * Creates a new instance Particle
  17904. * @param particleSystem the particle system the particle belongs to
  17905. */
  17906. constructor(
  17907. /**
  17908. * The particle system the particle belongs to.
  17909. */
  17910. particleSystem: ParticleSystem);
  17911. private updateCellInfoFromSystem;
  17912. /**
  17913. * Defines how the sprite cell index is updated for the particle
  17914. */
  17915. updateCellIndex(): void;
  17916. /** @hidden */
  17917. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17918. /** @hidden */
  17919. _inheritParticleInfoToSubEmitters(): void;
  17920. /** @hidden */
  17921. _reset(): void;
  17922. /**
  17923. * Copy the properties of particle to another one.
  17924. * @param other the particle to copy the information to.
  17925. */
  17926. copyTo(other: Particle): void;
  17927. }
  17928. }
  17929. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17930. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17931. import { Effect } from "babylonjs/Materials/effect";
  17932. import { Particle } from "babylonjs/Particles/particle";
  17933. /**
  17934. * Particle emitter represents a volume emitting particles.
  17935. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17936. */
  17937. export interface IParticleEmitterType {
  17938. /**
  17939. * Called by the particle System when the direction is computed for the created particle.
  17940. * @param worldMatrix is the world matrix of the particle system
  17941. * @param directionToUpdate is the direction vector to update with the result
  17942. * @param particle is the particle we are computed the direction for
  17943. */
  17944. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17945. /**
  17946. * Called by the particle System when the position is computed for the created particle.
  17947. * @param worldMatrix is the world matrix of the particle system
  17948. * @param positionToUpdate is the position vector to update with the result
  17949. * @param particle is the particle we are computed the position for
  17950. */
  17951. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17952. /**
  17953. * Clones the current emitter and returns a copy of it
  17954. * @returns the new emitter
  17955. */
  17956. clone(): IParticleEmitterType;
  17957. /**
  17958. * Called by the GPUParticleSystem to setup the update shader
  17959. * @param effect defines the update shader
  17960. */
  17961. applyToShader(effect: Effect): void;
  17962. /**
  17963. * Returns a string to use to update the GPU particles update shader
  17964. * @returns the effect defines string
  17965. */
  17966. getEffectDefines(): string;
  17967. /**
  17968. * Returns a string representing the class name
  17969. * @returns a string containing the class name
  17970. */
  17971. getClassName(): string;
  17972. /**
  17973. * Serializes the particle system to a JSON object.
  17974. * @returns the JSON object
  17975. */
  17976. serialize(): any;
  17977. /**
  17978. * Parse properties from a JSON object
  17979. * @param serializationObject defines the JSON object
  17980. */
  17981. parse(serializationObject: any): void;
  17982. }
  17983. }
  17984. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17985. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17986. import { Effect } from "babylonjs/Materials/effect";
  17987. import { Particle } from "babylonjs/Particles/particle";
  17988. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17989. /**
  17990. * Particle emitter emitting particles from the inside of a box.
  17991. * It emits the particles randomly between 2 given directions.
  17992. */
  17993. export class BoxParticleEmitter implements IParticleEmitterType {
  17994. /**
  17995. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17996. */
  17997. direction1: Vector3;
  17998. /**
  17999. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18000. */
  18001. direction2: Vector3;
  18002. /**
  18003. * 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.
  18004. */
  18005. minEmitBox: Vector3;
  18006. /**
  18007. * 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.
  18008. */
  18009. maxEmitBox: Vector3;
  18010. /**
  18011. * Creates a new instance BoxParticleEmitter
  18012. */
  18013. constructor();
  18014. /**
  18015. * Called by the particle System when the direction is computed for the created particle.
  18016. * @param worldMatrix is the world matrix of the particle system
  18017. * @param directionToUpdate is the direction vector to update with the result
  18018. * @param particle is the particle we are computed the direction for
  18019. */
  18020. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18021. /**
  18022. * Called by the particle System when the position is computed for the created particle.
  18023. * @param worldMatrix is the world matrix of the particle system
  18024. * @param positionToUpdate is the position vector to update with the result
  18025. * @param particle is the particle we are computed the position for
  18026. */
  18027. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18028. /**
  18029. * Clones the current emitter and returns a copy of it
  18030. * @returns the new emitter
  18031. */
  18032. clone(): BoxParticleEmitter;
  18033. /**
  18034. * Called by the GPUParticleSystem to setup the update shader
  18035. * @param effect defines the update shader
  18036. */
  18037. applyToShader(effect: Effect): void;
  18038. /**
  18039. * Returns a string to use to update the GPU particles update shader
  18040. * @returns a string containng the defines string
  18041. */
  18042. getEffectDefines(): string;
  18043. /**
  18044. * Returns the string "BoxParticleEmitter"
  18045. * @returns a string containing the class name
  18046. */
  18047. getClassName(): string;
  18048. /**
  18049. * Serializes the particle system to a JSON object.
  18050. * @returns the JSON object
  18051. */
  18052. serialize(): any;
  18053. /**
  18054. * Parse properties from a JSON object
  18055. * @param serializationObject defines the JSON object
  18056. */
  18057. parse(serializationObject: any): void;
  18058. }
  18059. }
  18060. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18061. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18062. import { Effect } from "babylonjs/Materials/effect";
  18063. import { Particle } from "babylonjs/Particles/particle";
  18064. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18065. /**
  18066. * Particle emitter emitting particles from the inside of a cone.
  18067. * It emits the particles alongside the cone volume from the base to the particle.
  18068. * The emission direction might be randomized.
  18069. */
  18070. export class ConeParticleEmitter implements IParticleEmitterType {
  18071. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18072. directionRandomizer: number;
  18073. private _radius;
  18074. private _angle;
  18075. private _height;
  18076. /**
  18077. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18078. */
  18079. radiusRange: number;
  18080. /**
  18081. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18082. */
  18083. heightRange: number;
  18084. /**
  18085. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18086. */
  18087. emitFromSpawnPointOnly: boolean;
  18088. /**
  18089. * Gets or sets the radius of the emission cone
  18090. */
  18091. radius: number;
  18092. /**
  18093. * Gets or sets the angle of the emission cone
  18094. */
  18095. angle: number;
  18096. private _buildHeight;
  18097. /**
  18098. * Creates a new instance ConeParticleEmitter
  18099. * @param radius the radius of the emission cone (1 by default)
  18100. * @param angle the cone base angle (PI by default)
  18101. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18102. */
  18103. constructor(radius?: number, angle?: number,
  18104. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18105. directionRandomizer?: number);
  18106. /**
  18107. * Called by the particle System when the direction is computed for the created particle.
  18108. * @param worldMatrix is the world matrix of the particle system
  18109. * @param directionToUpdate is the direction vector to update with the result
  18110. * @param particle is the particle we are computed the direction for
  18111. */
  18112. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18113. /**
  18114. * Called by the particle System when the position is computed for the created particle.
  18115. * @param worldMatrix is the world matrix of the particle system
  18116. * @param positionToUpdate is the position vector to update with the result
  18117. * @param particle is the particle we are computed the position for
  18118. */
  18119. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18120. /**
  18121. * Clones the current emitter and returns a copy of it
  18122. * @returns the new emitter
  18123. */
  18124. clone(): ConeParticleEmitter;
  18125. /**
  18126. * Called by the GPUParticleSystem to setup the update shader
  18127. * @param effect defines the update shader
  18128. */
  18129. applyToShader(effect: Effect): void;
  18130. /**
  18131. * Returns a string to use to update the GPU particles update shader
  18132. * @returns a string containng the defines string
  18133. */
  18134. getEffectDefines(): string;
  18135. /**
  18136. * Returns the string "ConeParticleEmitter"
  18137. * @returns a string containing the class name
  18138. */
  18139. getClassName(): string;
  18140. /**
  18141. * Serializes the particle system to a JSON object.
  18142. * @returns the JSON object
  18143. */
  18144. serialize(): any;
  18145. /**
  18146. * Parse properties from a JSON object
  18147. * @param serializationObject defines the JSON object
  18148. */
  18149. parse(serializationObject: any): void;
  18150. }
  18151. }
  18152. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18153. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18154. import { Effect } from "babylonjs/Materials/effect";
  18155. import { Particle } from "babylonjs/Particles/particle";
  18156. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18157. /**
  18158. * Particle emitter emitting particles from the inside of a cylinder.
  18159. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18160. */
  18161. export class CylinderParticleEmitter implements IParticleEmitterType {
  18162. /**
  18163. * The radius of the emission cylinder.
  18164. */
  18165. radius: number;
  18166. /**
  18167. * The height of the emission cylinder.
  18168. */
  18169. height: number;
  18170. /**
  18171. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18172. */
  18173. radiusRange: number;
  18174. /**
  18175. * How much to randomize the particle direction [0-1].
  18176. */
  18177. directionRandomizer: number;
  18178. /**
  18179. * Creates a new instance CylinderParticleEmitter
  18180. * @param radius the radius of the emission cylinder (1 by default)
  18181. * @param height the height of the emission cylinder (1 by default)
  18182. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18183. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18184. */
  18185. constructor(
  18186. /**
  18187. * The radius of the emission cylinder.
  18188. */
  18189. radius?: number,
  18190. /**
  18191. * The height of the emission cylinder.
  18192. */
  18193. height?: number,
  18194. /**
  18195. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18196. */
  18197. radiusRange?: number,
  18198. /**
  18199. * How much to randomize the particle direction [0-1].
  18200. */
  18201. directionRandomizer?: number);
  18202. /**
  18203. * Called by the particle System when the direction is computed for the created particle.
  18204. * @param worldMatrix is the world matrix of the particle system
  18205. * @param directionToUpdate is the direction vector to update with the result
  18206. * @param particle is the particle we are computed the direction for
  18207. */
  18208. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18209. /**
  18210. * Called by the particle System when the position is computed for the created particle.
  18211. * @param worldMatrix is the world matrix of the particle system
  18212. * @param positionToUpdate is the position vector to update with the result
  18213. * @param particle is the particle we are computed the position for
  18214. */
  18215. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18216. /**
  18217. * Clones the current emitter and returns a copy of it
  18218. * @returns the new emitter
  18219. */
  18220. clone(): CylinderParticleEmitter;
  18221. /**
  18222. * Called by the GPUParticleSystem to setup the update shader
  18223. * @param effect defines the update shader
  18224. */
  18225. applyToShader(effect: Effect): void;
  18226. /**
  18227. * Returns a string to use to update the GPU particles update shader
  18228. * @returns a string containng the defines string
  18229. */
  18230. getEffectDefines(): string;
  18231. /**
  18232. * Returns the string "CylinderParticleEmitter"
  18233. * @returns a string containing the class name
  18234. */
  18235. getClassName(): string;
  18236. /**
  18237. * Serializes the particle system to a JSON object.
  18238. * @returns the JSON object
  18239. */
  18240. serialize(): any;
  18241. /**
  18242. * Parse properties from a JSON object
  18243. * @param serializationObject defines the JSON object
  18244. */
  18245. parse(serializationObject: any): void;
  18246. }
  18247. /**
  18248. * Particle emitter emitting particles from the inside of a cylinder.
  18249. * It emits the particles randomly between two vectors.
  18250. */
  18251. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18252. /**
  18253. * The min limit of the emission direction.
  18254. */
  18255. direction1: Vector3;
  18256. /**
  18257. * The max limit of the emission direction.
  18258. */
  18259. direction2: Vector3;
  18260. /**
  18261. * Creates a new instance CylinderDirectedParticleEmitter
  18262. * @param radius the radius of the emission cylinder (1 by default)
  18263. * @param height the height of the emission cylinder (1 by default)
  18264. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18265. * @param direction1 the min limit of the emission direction (up vector by default)
  18266. * @param direction2 the max limit of the emission direction (up vector by default)
  18267. */
  18268. constructor(radius?: number, height?: number, radiusRange?: number,
  18269. /**
  18270. * The min limit of the emission direction.
  18271. */
  18272. direction1?: Vector3,
  18273. /**
  18274. * The max limit of the emission direction.
  18275. */
  18276. direction2?: Vector3);
  18277. /**
  18278. * Called by the particle System when the direction is computed for the created particle.
  18279. * @param worldMatrix is the world matrix of the particle system
  18280. * @param directionToUpdate is the direction vector to update with the result
  18281. * @param particle is the particle we are computed the direction for
  18282. */
  18283. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18284. /**
  18285. * Clones the current emitter and returns a copy of it
  18286. * @returns the new emitter
  18287. */
  18288. clone(): CylinderDirectedParticleEmitter;
  18289. /**
  18290. * Called by the GPUParticleSystem to setup the update shader
  18291. * @param effect defines the update shader
  18292. */
  18293. applyToShader(effect: Effect): void;
  18294. /**
  18295. * Returns a string to use to update the GPU particles update shader
  18296. * @returns a string containng the defines string
  18297. */
  18298. getEffectDefines(): string;
  18299. /**
  18300. * Returns the string "CylinderDirectedParticleEmitter"
  18301. * @returns a string containing the class name
  18302. */
  18303. getClassName(): string;
  18304. /**
  18305. * Serializes the particle system to a JSON object.
  18306. * @returns the JSON object
  18307. */
  18308. serialize(): any;
  18309. /**
  18310. * Parse properties from a JSON object
  18311. * @param serializationObject defines the JSON object
  18312. */
  18313. parse(serializationObject: any): void;
  18314. }
  18315. }
  18316. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18317. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18318. import { Effect } from "babylonjs/Materials/effect";
  18319. import { Particle } from "babylonjs/Particles/particle";
  18320. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18321. /**
  18322. * Particle emitter emitting particles from the inside of a hemisphere.
  18323. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18324. */
  18325. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18326. /**
  18327. * The radius of the emission hemisphere.
  18328. */
  18329. radius: number;
  18330. /**
  18331. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18332. */
  18333. radiusRange: number;
  18334. /**
  18335. * How much to randomize the particle direction [0-1].
  18336. */
  18337. directionRandomizer: number;
  18338. /**
  18339. * Creates a new instance HemisphericParticleEmitter
  18340. * @param radius the radius of the emission hemisphere (1 by default)
  18341. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18342. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18343. */
  18344. constructor(
  18345. /**
  18346. * The radius of the emission hemisphere.
  18347. */
  18348. radius?: number,
  18349. /**
  18350. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18351. */
  18352. radiusRange?: number,
  18353. /**
  18354. * How much to randomize the particle direction [0-1].
  18355. */
  18356. directionRandomizer?: number);
  18357. /**
  18358. * Called by the particle System when the direction is computed for the created particle.
  18359. * @param worldMatrix is the world matrix of the particle system
  18360. * @param directionToUpdate is the direction vector to update with the result
  18361. * @param particle is the particle we are computed the direction for
  18362. */
  18363. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18364. /**
  18365. * Called by the particle System when the position is computed for the created particle.
  18366. * @param worldMatrix is the world matrix of the particle system
  18367. * @param positionToUpdate is the position vector to update with the result
  18368. * @param particle is the particle we are computed the position for
  18369. */
  18370. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18371. /**
  18372. * Clones the current emitter and returns a copy of it
  18373. * @returns the new emitter
  18374. */
  18375. clone(): HemisphericParticleEmitter;
  18376. /**
  18377. * Called by the GPUParticleSystem to setup the update shader
  18378. * @param effect defines the update shader
  18379. */
  18380. applyToShader(effect: Effect): void;
  18381. /**
  18382. * Returns a string to use to update the GPU particles update shader
  18383. * @returns a string containng the defines string
  18384. */
  18385. getEffectDefines(): string;
  18386. /**
  18387. * Returns the string "HemisphericParticleEmitter"
  18388. * @returns a string containing the class name
  18389. */
  18390. getClassName(): string;
  18391. /**
  18392. * Serializes the particle system to a JSON object.
  18393. * @returns the JSON object
  18394. */
  18395. serialize(): any;
  18396. /**
  18397. * Parse properties from a JSON object
  18398. * @param serializationObject defines the JSON object
  18399. */
  18400. parse(serializationObject: any): void;
  18401. }
  18402. }
  18403. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18404. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18405. import { Effect } from "babylonjs/Materials/effect";
  18406. import { Particle } from "babylonjs/Particles/particle";
  18407. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18408. /**
  18409. * Particle emitter emitting particles from a point.
  18410. * It emits the particles randomly between 2 given directions.
  18411. */
  18412. export class PointParticleEmitter implements IParticleEmitterType {
  18413. /**
  18414. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18415. */
  18416. direction1: Vector3;
  18417. /**
  18418. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18419. */
  18420. direction2: Vector3;
  18421. /**
  18422. * Creates a new instance PointParticleEmitter
  18423. */
  18424. constructor();
  18425. /**
  18426. * Called by the particle System when the direction is computed for the created particle.
  18427. * @param worldMatrix is the world matrix of the particle system
  18428. * @param directionToUpdate is the direction vector to update with the result
  18429. * @param particle is the particle we are computed the direction for
  18430. */
  18431. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18432. /**
  18433. * Called by the particle System when the position is computed for the created particle.
  18434. * @param worldMatrix is the world matrix of the particle system
  18435. * @param positionToUpdate is the position vector to update with the result
  18436. * @param particle is the particle we are computed the position for
  18437. */
  18438. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18439. /**
  18440. * Clones the current emitter and returns a copy of it
  18441. * @returns the new emitter
  18442. */
  18443. clone(): PointParticleEmitter;
  18444. /**
  18445. * Called by the GPUParticleSystem to setup the update shader
  18446. * @param effect defines the update shader
  18447. */
  18448. applyToShader(effect: Effect): void;
  18449. /**
  18450. * Returns a string to use to update the GPU particles update shader
  18451. * @returns a string containng the defines string
  18452. */
  18453. getEffectDefines(): string;
  18454. /**
  18455. * Returns the string "PointParticleEmitter"
  18456. * @returns a string containing the class name
  18457. */
  18458. getClassName(): string;
  18459. /**
  18460. * Serializes the particle system to a JSON object.
  18461. * @returns the JSON object
  18462. */
  18463. serialize(): any;
  18464. /**
  18465. * Parse properties from a JSON object
  18466. * @param serializationObject defines the JSON object
  18467. */
  18468. parse(serializationObject: any): void;
  18469. }
  18470. }
  18471. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18472. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18473. import { Effect } from "babylonjs/Materials/effect";
  18474. import { Particle } from "babylonjs/Particles/particle";
  18475. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18476. /**
  18477. * Particle emitter emitting particles from the inside of a sphere.
  18478. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18479. */
  18480. export class SphereParticleEmitter implements IParticleEmitterType {
  18481. /**
  18482. * The radius of the emission sphere.
  18483. */
  18484. radius: number;
  18485. /**
  18486. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18487. */
  18488. radiusRange: number;
  18489. /**
  18490. * How much to randomize the particle direction [0-1].
  18491. */
  18492. directionRandomizer: number;
  18493. /**
  18494. * Creates a new instance SphereParticleEmitter
  18495. * @param radius the radius of the emission sphere (1 by default)
  18496. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18497. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18498. */
  18499. constructor(
  18500. /**
  18501. * The radius of the emission sphere.
  18502. */
  18503. radius?: number,
  18504. /**
  18505. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18506. */
  18507. radiusRange?: number,
  18508. /**
  18509. * How much to randomize the particle direction [0-1].
  18510. */
  18511. directionRandomizer?: number);
  18512. /**
  18513. * Called by the particle System when the direction is computed for the created particle.
  18514. * @param worldMatrix is the world matrix of the particle system
  18515. * @param directionToUpdate is the direction vector to update with the result
  18516. * @param particle is the particle we are computed the direction for
  18517. */
  18518. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18519. /**
  18520. * Called by the particle System when the position is computed for the created particle.
  18521. * @param worldMatrix is the world matrix of the particle system
  18522. * @param positionToUpdate is the position vector to update with the result
  18523. * @param particle is the particle we are computed the position for
  18524. */
  18525. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18526. /**
  18527. * Clones the current emitter and returns a copy of it
  18528. * @returns the new emitter
  18529. */
  18530. clone(): SphereParticleEmitter;
  18531. /**
  18532. * Called by the GPUParticleSystem to setup the update shader
  18533. * @param effect defines the update shader
  18534. */
  18535. applyToShader(effect: Effect): void;
  18536. /**
  18537. * Returns a string to use to update the GPU particles update shader
  18538. * @returns a string containng the defines string
  18539. */
  18540. getEffectDefines(): string;
  18541. /**
  18542. * Returns the string "SphereParticleEmitter"
  18543. * @returns a string containing the class name
  18544. */
  18545. getClassName(): string;
  18546. /**
  18547. * Serializes the particle system to a JSON object.
  18548. * @returns the JSON object
  18549. */
  18550. serialize(): any;
  18551. /**
  18552. * Parse properties from a JSON object
  18553. * @param serializationObject defines the JSON object
  18554. */
  18555. parse(serializationObject: any): void;
  18556. }
  18557. /**
  18558. * Particle emitter emitting particles from the inside of a sphere.
  18559. * It emits the particles randomly between two vectors.
  18560. */
  18561. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18562. /**
  18563. * The min limit of the emission direction.
  18564. */
  18565. direction1: Vector3;
  18566. /**
  18567. * The max limit of the emission direction.
  18568. */
  18569. direction2: Vector3;
  18570. /**
  18571. * Creates a new instance SphereDirectedParticleEmitter
  18572. * @param radius the radius of the emission sphere (1 by default)
  18573. * @param direction1 the min limit of the emission direction (up vector by default)
  18574. * @param direction2 the max limit of the emission direction (up vector by default)
  18575. */
  18576. constructor(radius?: number,
  18577. /**
  18578. * The min limit of the emission direction.
  18579. */
  18580. direction1?: Vector3,
  18581. /**
  18582. * The max limit of the emission direction.
  18583. */
  18584. direction2?: Vector3);
  18585. /**
  18586. * Called by the particle System when the direction is computed for the created particle.
  18587. * @param worldMatrix is the world matrix of the particle system
  18588. * @param directionToUpdate is the direction vector to update with the result
  18589. * @param particle is the particle we are computed the direction for
  18590. */
  18591. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18592. /**
  18593. * Clones the current emitter and returns a copy of it
  18594. * @returns the new emitter
  18595. */
  18596. clone(): SphereDirectedParticleEmitter;
  18597. /**
  18598. * Called by the GPUParticleSystem to setup the update shader
  18599. * @param effect defines the update shader
  18600. */
  18601. applyToShader(effect: Effect): void;
  18602. /**
  18603. * Returns a string to use to update the GPU particles update shader
  18604. * @returns a string containng the defines string
  18605. */
  18606. getEffectDefines(): string;
  18607. /**
  18608. * Returns the string "SphereDirectedParticleEmitter"
  18609. * @returns a string containing the class name
  18610. */
  18611. getClassName(): string;
  18612. /**
  18613. * Serializes the particle system to a JSON object.
  18614. * @returns the JSON object
  18615. */
  18616. serialize(): any;
  18617. /**
  18618. * Parse properties from a JSON object
  18619. * @param serializationObject defines the JSON object
  18620. */
  18621. parse(serializationObject: any): void;
  18622. }
  18623. }
  18624. declare module "babylonjs/Particles/EmitterTypes/index" {
  18625. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18626. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18627. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18628. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18629. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18630. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18631. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18632. }
  18633. declare module "babylonjs/Particles/IParticleSystem" {
  18634. import { Nullable } from "babylonjs/types";
  18635. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18636. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18638. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18639. import { Texture } from "babylonjs/Materials/Textures/texture";
  18640. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18641. import { Scene } from "babylonjs/scene";
  18642. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18643. import { Animation } from "babylonjs/Animations/animation";
  18644. /**
  18645. * Interface representing a particle system in Babylon.js.
  18646. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18647. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18648. */
  18649. export interface IParticleSystem {
  18650. /**
  18651. * List of animations used by the particle system.
  18652. */
  18653. animations: Animation[];
  18654. /**
  18655. * The id of the Particle system.
  18656. */
  18657. id: string;
  18658. /**
  18659. * The name of the Particle system.
  18660. */
  18661. name: string;
  18662. /**
  18663. * The emitter represents the Mesh or position we are attaching the particle system to.
  18664. */
  18665. emitter: Nullable<AbstractMesh | Vector3>;
  18666. /**
  18667. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18668. */
  18669. isBillboardBased: boolean;
  18670. /**
  18671. * The rendering group used by the Particle system to chose when to render.
  18672. */
  18673. renderingGroupId: number;
  18674. /**
  18675. * The layer mask we are rendering the particles through.
  18676. */
  18677. layerMask: number;
  18678. /**
  18679. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18680. */
  18681. updateSpeed: number;
  18682. /**
  18683. * The amount of time the particle system is running (depends of the overall update speed).
  18684. */
  18685. targetStopDuration: number;
  18686. /**
  18687. * The texture used to render each particle. (this can be a spritesheet)
  18688. */
  18689. particleTexture: Nullable<Texture>;
  18690. /**
  18691. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18692. */
  18693. blendMode: number;
  18694. /**
  18695. * Minimum life time of emitting particles.
  18696. */
  18697. minLifeTime: number;
  18698. /**
  18699. * Maximum life time of emitting particles.
  18700. */
  18701. maxLifeTime: number;
  18702. /**
  18703. * Minimum Size of emitting particles.
  18704. */
  18705. minSize: number;
  18706. /**
  18707. * Maximum Size of emitting particles.
  18708. */
  18709. maxSize: number;
  18710. /**
  18711. * Minimum scale of emitting particles on X axis.
  18712. */
  18713. minScaleX: number;
  18714. /**
  18715. * Maximum scale of emitting particles on X axis.
  18716. */
  18717. maxScaleX: number;
  18718. /**
  18719. * Minimum scale of emitting particles on Y axis.
  18720. */
  18721. minScaleY: number;
  18722. /**
  18723. * Maximum scale of emitting particles on Y axis.
  18724. */
  18725. maxScaleY: number;
  18726. /**
  18727. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18728. */
  18729. color1: Color4;
  18730. /**
  18731. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18732. */
  18733. color2: Color4;
  18734. /**
  18735. * Color the particle will have at the end of its lifetime.
  18736. */
  18737. colorDead: Color4;
  18738. /**
  18739. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18740. */
  18741. emitRate: number;
  18742. /**
  18743. * You can use gravity if you want to give an orientation to your particles.
  18744. */
  18745. gravity: Vector3;
  18746. /**
  18747. * Minimum power of emitting particles.
  18748. */
  18749. minEmitPower: number;
  18750. /**
  18751. * Maximum power of emitting particles.
  18752. */
  18753. maxEmitPower: number;
  18754. /**
  18755. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18756. */
  18757. minAngularSpeed: number;
  18758. /**
  18759. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18760. */
  18761. maxAngularSpeed: number;
  18762. /**
  18763. * Gets or sets the minimal initial rotation in radians.
  18764. */
  18765. minInitialRotation: number;
  18766. /**
  18767. * Gets or sets the maximal initial rotation in radians.
  18768. */
  18769. maxInitialRotation: number;
  18770. /**
  18771. * The particle emitter type defines the emitter used by the particle system.
  18772. * It can be for example box, sphere, or cone...
  18773. */
  18774. particleEmitterType: Nullable<IParticleEmitterType>;
  18775. /**
  18776. * Defines the delay in milliseconds before starting the system (0 by default)
  18777. */
  18778. startDelay: number;
  18779. /**
  18780. * 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
  18781. */
  18782. preWarmCycles: number;
  18783. /**
  18784. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18785. */
  18786. preWarmStepOffset: number;
  18787. /**
  18788. * 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)
  18789. */
  18790. spriteCellChangeSpeed: number;
  18791. /**
  18792. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18793. */
  18794. startSpriteCellID: number;
  18795. /**
  18796. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18797. */
  18798. endSpriteCellID: number;
  18799. /**
  18800. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18801. */
  18802. spriteCellWidth: number;
  18803. /**
  18804. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18805. */
  18806. spriteCellHeight: number;
  18807. /**
  18808. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18809. */
  18810. spriteRandomStartCell: boolean;
  18811. /**
  18812. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18813. */
  18814. isAnimationSheetEnabled: boolean;
  18815. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18816. translationPivot: Vector2;
  18817. /**
  18818. * Gets or sets a texture used to add random noise to particle positions
  18819. */
  18820. noiseTexture: Nullable<BaseTexture>;
  18821. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18822. noiseStrength: Vector3;
  18823. /**
  18824. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18825. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18826. */
  18827. billboardMode: number;
  18828. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18829. limitVelocityDamping: number;
  18830. /**
  18831. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18832. */
  18833. beginAnimationOnStart: boolean;
  18834. /**
  18835. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18836. */
  18837. beginAnimationFrom: number;
  18838. /**
  18839. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18840. */
  18841. beginAnimationTo: number;
  18842. /**
  18843. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18844. */
  18845. beginAnimationLoop: boolean;
  18846. /**
  18847. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18848. */
  18849. disposeOnStop: boolean;
  18850. /**
  18851. * Gets the maximum number of particles active at the same time.
  18852. * @returns The max number of active particles.
  18853. */
  18854. getCapacity(): number;
  18855. /**
  18856. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18857. * @returns True if it has been started, otherwise false.
  18858. */
  18859. isStarted(): boolean;
  18860. /**
  18861. * Animates the particle system for this frame.
  18862. */
  18863. animate(): void;
  18864. /**
  18865. * Renders the particle system in its current state.
  18866. * @returns the current number of particles
  18867. */
  18868. render(): number;
  18869. /**
  18870. * Dispose the particle system and frees its associated resources.
  18871. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18872. */
  18873. dispose(disposeTexture?: boolean): void;
  18874. /**
  18875. * Clones the particle system.
  18876. * @param name The name of the cloned object
  18877. * @param newEmitter The new emitter to use
  18878. * @returns the cloned particle system
  18879. */
  18880. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18881. /**
  18882. * Serializes the particle system to a JSON object.
  18883. * @returns the JSON object
  18884. */
  18885. serialize(): any;
  18886. /**
  18887. * Rebuild the particle system
  18888. */
  18889. rebuild(): void;
  18890. /**
  18891. * Starts the particle system and begins to emit
  18892. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18893. */
  18894. start(delay?: number): void;
  18895. /**
  18896. * Stops the particle system.
  18897. */
  18898. stop(): void;
  18899. /**
  18900. * Remove all active particles
  18901. */
  18902. reset(): void;
  18903. /**
  18904. * Is this system ready to be used/rendered
  18905. * @return true if the system is ready
  18906. */
  18907. isReady(): boolean;
  18908. /**
  18909. * Adds a new color gradient
  18910. * @param gradient defines the gradient to use (between 0 and 1)
  18911. * @param color1 defines the color to affect to the specified gradient
  18912. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18913. * @returns the current particle system
  18914. */
  18915. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18916. /**
  18917. * Remove a specific color gradient
  18918. * @param gradient defines the gradient to remove
  18919. * @returns the current particle system
  18920. */
  18921. removeColorGradient(gradient: number): IParticleSystem;
  18922. /**
  18923. * Adds a new size gradient
  18924. * @param gradient defines the gradient to use (between 0 and 1)
  18925. * @param factor defines the size factor to affect to the specified gradient
  18926. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18927. * @returns the current particle system
  18928. */
  18929. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18930. /**
  18931. * Remove a specific size gradient
  18932. * @param gradient defines the gradient to remove
  18933. * @returns the current particle system
  18934. */
  18935. removeSizeGradient(gradient: number): IParticleSystem;
  18936. /**
  18937. * Gets the current list of color gradients.
  18938. * You must use addColorGradient and removeColorGradient to udpate this list
  18939. * @returns the list of color gradients
  18940. */
  18941. getColorGradients(): Nullable<Array<ColorGradient>>;
  18942. /**
  18943. * Gets the current list of size gradients.
  18944. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18945. * @returns the list of size gradients
  18946. */
  18947. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18948. /**
  18949. * Gets the current list of angular speed gradients.
  18950. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18951. * @returns the list of angular speed gradients
  18952. */
  18953. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18954. /**
  18955. * Adds a new angular speed gradient
  18956. * @param gradient defines the gradient to use (between 0 and 1)
  18957. * @param factor defines the angular speed to affect to the specified gradient
  18958. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18959. * @returns the current particle system
  18960. */
  18961. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18962. /**
  18963. * Remove a specific angular speed gradient
  18964. * @param gradient defines the gradient to remove
  18965. * @returns the current particle system
  18966. */
  18967. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18968. /**
  18969. * Gets the current list of velocity gradients.
  18970. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18971. * @returns the list of velocity gradients
  18972. */
  18973. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18974. /**
  18975. * Adds a new velocity gradient
  18976. * @param gradient defines the gradient to use (between 0 and 1)
  18977. * @param factor defines the velocity to affect to the specified gradient
  18978. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18979. * @returns the current particle system
  18980. */
  18981. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18982. /**
  18983. * Remove a specific velocity gradient
  18984. * @param gradient defines the gradient to remove
  18985. * @returns the current particle system
  18986. */
  18987. removeVelocityGradient(gradient: number): IParticleSystem;
  18988. /**
  18989. * Gets the current list of limit velocity gradients.
  18990. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18991. * @returns the list of limit velocity gradients
  18992. */
  18993. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18994. /**
  18995. * Adds a new limit velocity gradient
  18996. * @param gradient defines the gradient to use (between 0 and 1)
  18997. * @param factor defines the limit velocity to affect to the specified gradient
  18998. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18999. * @returns the current particle system
  19000. */
  19001. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19002. /**
  19003. * Remove a specific limit velocity gradient
  19004. * @param gradient defines the gradient to remove
  19005. * @returns the current particle system
  19006. */
  19007. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19008. /**
  19009. * Adds a new drag gradient
  19010. * @param gradient defines the gradient to use (between 0 and 1)
  19011. * @param factor defines the drag to affect to the specified gradient
  19012. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19013. * @returns the current particle system
  19014. */
  19015. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19016. /**
  19017. * Remove a specific drag gradient
  19018. * @param gradient defines the gradient to remove
  19019. * @returns the current particle system
  19020. */
  19021. removeDragGradient(gradient: number): IParticleSystem;
  19022. /**
  19023. * Gets the current list of drag gradients.
  19024. * You must use addDragGradient and removeDragGradient to udpate this list
  19025. * @returns the list of drag gradients
  19026. */
  19027. getDragGradients(): Nullable<Array<FactorGradient>>;
  19028. /**
  19029. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19030. * @param gradient defines the gradient to use (between 0 and 1)
  19031. * @param factor defines the emit rate to affect to the specified gradient
  19032. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19033. * @returns the current particle system
  19034. */
  19035. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19036. /**
  19037. * Remove a specific emit rate gradient
  19038. * @param gradient defines the gradient to remove
  19039. * @returns the current particle system
  19040. */
  19041. removeEmitRateGradient(gradient: number): IParticleSystem;
  19042. /**
  19043. * Gets the current list of emit rate gradients.
  19044. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19045. * @returns the list of emit rate gradients
  19046. */
  19047. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19048. /**
  19049. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19050. * @param gradient defines the gradient to use (between 0 and 1)
  19051. * @param factor defines the start size to affect to the specified gradient
  19052. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19053. * @returns the current particle system
  19054. */
  19055. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19056. /**
  19057. * Remove a specific start size gradient
  19058. * @param gradient defines the gradient to remove
  19059. * @returns the current particle system
  19060. */
  19061. removeStartSizeGradient(gradient: number): IParticleSystem;
  19062. /**
  19063. * Gets the current list of start size gradients.
  19064. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19065. * @returns the list of start size gradients
  19066. */
  19067. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19068. /**
  19069. * Adds a new life time gradient
  19070. * @param gradient defines the gradient to use (between 0 and 1)
  19071. * @param factor defines the life time factor to affect to the specified gradient
  19072. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19073. * @returns the current particle system
  19074. */
  19075. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19076. /**
  19077. * Remove a specific life time gradient
  19078. * @param gradient defines the gradient to remove
  19079. * @returns the current particle system
  19080. */
  19081. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19082. /**
  19083. * Gets the current list of life time gradients.
  19084. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19085. * @returns the list of life time gradients
  19086. */
  19087. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19088. /**
  19089. * Gets the current list of color gradients.
  19090. * You must use addColorGradient and removeColorGradient to udpate this list
  19091. * @returns the list of color gradients
  19092. */
  19093. getColorGradients(): Nullable<Array<ColorGradient>>;
  19094. /**
  19095. * Adds a new ramp gradient used to remap particle colors
  19096. * @param gradient defines the gradient to use (between 0 and 1)
  19097. * @param color defines the color to affect to the specified gradient
  19098. * @returns the current particle system
  19099. */
  19100. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19101. /**
  19102. * Gets the current list of ramp gradients.
  19103. * You must use addRampGradient and removeRampGradient to udpate this list
  19104. * @returns the list of ramp gradients
  19105. */
  19106. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19107. /** Gets or sets a boolean indicating that ramp gradients must be used
  19108. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19109. */
  19110. useRampGradients: boolean;
  19111. /**
  19112. * Adds a new color remap gradient
  19113. * @param gradient defines the gradient to use (between 0 and 1)
  19114. * @param min defines the color remap minimal range
  19115. * @param max defines the color remap maximal range
  19116. * @returns the current particle system
  19117. */
  19118. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19119. /**
  19120. * Gets the current list of color remap gradients.
  19121. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19122. * @returns the list of color remap gradients
  19123. */
  19124. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19125. /**
  19126. * Adds a new alpha remap gradient
  19127. * @param gradient defines the gradient to use (between 0 and 1)
  19128. * @param min defines the alpha remap minimal range
  19129. * @param max defines the alpha remap maximal range
  19130. * @returns the current particle system
  19131. */
  19132. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19133. /**
  19134. * Gets the current list of alpha remap gradients.
  19135. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19136. * @returns the list of alpha remap gradients
  19137. */
  19138. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19139. /**
  19140. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19141. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19142. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19143. * @returns the emitter
  19144. */
  19145. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19146. /**
  19147. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19148. * @param radius The radius of the hemisphere to emit from
  19149. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19150. * @returns the emitter
  19151. */
  19152. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19153. /**
  19154. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19155. * @param radius The radius of the sphere to emit from
  19156. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19157. * @returns the emitter
  19158. */
  19159. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19160. /**
  19161. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19162. * @param radius The radius of the sphere to emit from
  19163. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19164. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19165. * @returns the emitter
  19166. */
  19167. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19168. /**
  19169. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19170. * @param radius The radius of the emission cylinder
  19171. * @param height The height of the emission cylinder
  19172. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19173. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19174. * @returns the emitter
  19175. */
  19176. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19177. /**
  19178. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19179. * @param radius The radius of the cylinder to emit from
  19180. * @param height The height of the emission cylinder
  19181. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19182. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19183. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19184. * @returns the emitter
  19185. */
  19186. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19187. /**
  19188. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19189. * @param radius The radius of the cone to emit from
  19190. * @param angle The base angle of the cone
  19191. * @returns the emitter
  19192. */
  19193. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19194. /**
  19195. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19196. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19197. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19198. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19199. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19200. * @returns the emitter
  19201. */
  19202. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19203. /**
  19204. * Get hosting scene
  19205. * @returns the scene
  19206. */
  19207. getScene(): Scene;
  19208. }
  19209. }
  19210. declare module "babylonjs/Meshes/instancedMesh" {
  19211. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19212. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19213. import { Camera } from "babylonjs/Cameras/camera";
  19214. import { Node } from "babylonjs/node";
  19215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19216. import { Mesh } from "babylonjs/Meshes/mesh";
  19217. import { Material } from "babylonjs/Materials/material";
  19218. import { Skeleton } from "babylonjs/Bones/skeleton";
  19219. import { Light } from "babylonjs/Lights/light";
  19220. /**
  19221. * Creates an instance based on a source mesh.
  19222. */
  19223. export class InstancedMesh extends AbstractMesh {
  19224. private _sourceMesh;
  19225. private _currentLOD;
  19226. /** @hidden */
  19227. _indexInSourceMeshInstanceArray: number;
  19228. constructor(name: string, source: Mesh);
  19229. /**
  19230. * Returns the string "InstancedMesh".
  19231. */
  19232. getClassName(): string;
  19233. /** Gets the list of lights affecting that mesh */
  19234. readonly lightSources: Light[];
  19235. _resyncLightSources(): void;
  19236. _resyncLighSource(light: Light): void;
  19237. _removeLightSource(light: Light, dispose: boolean): void;
  19238. /**
  19239. * If the source mesh receives shadows
  19240. */
  19241. readonly receiveShadows: boolean;
  19242. /**
  19243. * The material of the source mesh
  19244. */
  19245. readonly material: Nullable<Material>;
  19246. /**
  19247. * Visibility of the source mesh
  19248. */
  19249. readonly visibility: number;
  19250. /**
  19251. * Skeleton of the source mesh
  19252. */
  19253. readonly skeleton: Nullable<Skeleton>;
  19254. /**
  19255. * Rendering ground id of the source mesh
  19256. */
  19257. renderingGroupId: number;
  19258. /**
  19259. * Returns the total number of vertices (integer).
  19260. */
  19261. getTotalVertices(): number;
  19262. /**
  19263. * Returns a positive integer : the total number of indices in this mesh geometry.
  19264. * @returns the numner of indices or zero if the mesh has no geometry.
  19265. */
  19266. getTotalIndices(): number;
  19267. /**
  19268. * The source mesh of the instance
  19269. */
  19270. readonly sourceMesh: Mesh;
  19271. /**
  19272. * Is this node ready to be used/rendered
  19273. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19274. * @return {boolean} is it ready
  19275. */
  19276. isReady(completeCheck?: boolean): boolean;
  19277. /**
  19278. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19279. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19280. * @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.
  19281. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19282. */
  19283. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19284. /**
  19285. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19286. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19287. * The `data` are either a numeric array either a Float32Array.
  19288. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19289. * 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).
  19290. * Note that a new underlying VertexBuffer object is created each call.
  19291. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19292. *
  19293. * Possible `kind` values :
  19294. * - VertexBuffer.PositionKind
  19295. * - VertexBuffer.UVKind
  19296. * - VertexBuffer.UV2Kind
  19297. * - VertexBuffer.UV3Kind
  19298. * - VertexBuffer.UV4Kind
  19299. * - VertexBuffer.UV5Kind
  19300. * - VertexBuffer.UV6Kind
  19301. * - VertexBuffer.ColorKind
  19302. * - VertexBuffer.MatricesIndicesKind
  19303. * - VertexBuffer.MatricesIndicesExtraKind
  19304. * - VertexBuffer.MatricesWeightsKind
  19305. * - VertexBuffer.MatricesWeightsExtraKind
  19306. *
  19307. * Returns the Mesh.
  19308. */
  19309. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19310. /**
  19311. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19312. * If the mesh has no geometry, it is simply returned as it is.
  19313. * The `data` are either a numeric array either a Float32Array.
  19314. * No new underlying VertexBuffer object is created.
  19315. * 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.
  19316. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19317. *
  19318. * Possible `kind` values :
  19319. * - VertexBuffer.PositionKind
  19320. * - VertexBuffer.UVKind
  19321. * - VertexBuffer.UV2Kind
  19322. * - VertexBuffer.UV3Kind
  19323. * - VertexBuffer.UV4Kind
  19324. * - VertexBuffer.UV5Kind
  19325. * - VertexBuffer.UV6Kind
  19326. * - VertexBuffer.ColorKind
  19327. * - VertexBuffer.MatricesIndicesKind
  19328. * - VertexBuffer.MatricesIndicesExtraKind
  19329. * - VertexBuffer.MatricesWeightsKind
  19330. * - VertexBuffer.MatricesWeightsExtraKind
  19331. *
  19332. * Returns the Mesh.
  19333. */
  19334. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19335. /**
  19336. * Sets the mesh indices.
  19337. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19338. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19339. * This method creates a new index buffer each call.
  19340. * Returns the Mesh.
  19341. */
  19342. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19343. /**
  19344. * Boolean : True if the mesh owns the requested kind of data.
  19345. */
  19346. isVerticesDataPresent(kind: string): boolean;
  19347. /**
  19348. * Returns an array of indices (IndicesArray).
  19349. */
  19350. getIndices(): Nullable<IndicesArray>;
  19351. readonly _positions: Nullable<Vector3[]>;
  19352. /**
  19353. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19354. * This means the mesh underlying bounding box and sphere are recomputed.
  19355. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19356. * @returns the current mesh
  19357. */
  19358. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19359. /** @hidden */
  19360. _preActivate(): InstancedMesh;
  19361. /** @hidden */
  19362. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19363. /** @hidden */
  19364. _postActivate(): void;
  19365. getWorldMatrix(): Matrix;
  19366. readonly isAnInstance: boolean;
  19367. /**
  19368. * Returns the current associated LOD AbstractMesh.
  19369. */
  19370. getLOD(camera: Camera): AbstractMesh;
  19371. /** @hidden */
  19372. _syncSubMeshes(): InstancedMesh;
  19373. /** @hidden */
  19374. _generatePointsArray(): boolean;
  19375. /**
  19376. * Creates a new InstancedMesh from the current mesh.
  19377. * - name (string) : the cloned mesh name
  19378. * - newParent (optional Node) : the optional Node to parent the clone to.
  19379. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19380. *
  19381. * Returns the clone.
  19382. */
  19383. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19384. /**
  19385. * Disposes the InstancedMesh.
  19386. * Returns nothing.
  19387. */
  19388. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19389. }
  19390. }
  19391. declare module "babylonjs/Materials/shaderMaterial" {
  19392. import { Scene } from "babylonjs/scene";
  19393. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19395. import { Mesh } from "babylonjs/Meshes/mesh";
  19396. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19397. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19398. import { Texture } from "babylonjs/Materials/Textures/texture";
  19399. import { Material } from "babylonjs/Materials/material";
  19400. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19401. /**
  19402. * Defines the options associated with the creation of a shader material.
  19403. */
  19404. export interface IShaderMaterialOptions {
  19405. /**
  19406. * Does the material work in alpha blend mode
  19407. */
  19408. needAlphaBlending: boolean;
  19409. /**
  19410. * Does the material work in alpha test mode
  19411. */
  19412. needAlphaTesting: boolean;
  19413. /**
  19414. * The list of attribute names used in the shader
  19415. */
  19416. attributes: string[];
  19417. /**
  19418. * The list of unifrom names used in the shader
  19419. */
  19420. uniforms: string[];
  19421. /**
  19422. * The list of UBO names used in the shader
  19423. */
  19424. uniformBuffers: string[];
  19425. /**
  19426. * The list of sampler names used in the shader
  19427. */
  19428. samplers: string[];
  19429. /**
  19430. * The list of defines used in the shader
  19431. */
  19432. defines: string[];
  19433. }
  19434. /**
  19435. * 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.
  19436. *
  19437. * This returned material effects how the mesh will look based on the code in the shaders.
  19438. *
  19439. * @see http://doc.babylonjs.com/how_to/shader_material
  19440. */
  19441. export class ShaderMaterial extends Material {
  19442. private _shaderPath;
  19443. private _options;
  19444. private _textures;
  19445. private _textureArrays;
  19446. private _floats;
  19447. private _ints;
  19448. private _floatsArrays;
  19449. private _colors3;
  19450. private _colors3Arrays;
  19451. private _colors4;
  19452. private _colors4Arrays;
  19453. private _vectors2;
  19454. private _vectors3;
  19455. private _vectors4;
  19456. private _matrices;
  19457. private _matrices3x3;
  19458. private _matrices2x2;
  19459. private _vectors2Arrays;
  19460. private _vectors3Arrays;
  19461. private _vectors4Arrays;
  19462. private _cachedWorldViewMatrix;
  19463. private _cachedWorldViewProjectionMatrix;
  19464. private _renderId;
  19465. /**
  19466. * Instantiate a new shader material.
  19467. * 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.
  19468. * This returned material effects how the mesh will look based on the code in the shaders.
  19469. * @see http://doc.babylonjs.com/how_to/shader_material
  19470. * @param name Define the name of the material in the scene
  19471. * @param scene Define the scene the material belongs to
  19472. * @param shaderPath Defines the route to the shader code in one of three ways:
  19473. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19474. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19475. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19476. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19477. * @param options Define the options used to create the shader
  19478. */
  19479. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19480. /**
  19481. * Gets the options used to compile the shader.
  19482. * They can be modified to trigger a new compilation
  19483. */
  19484. readonly options: IShaderMaterialOptions;
  19485. /**
  19486. * Gets the current class name of the material e.g. "ShaderMaterial"
  19487. * Mainly use in serialization.
  19488. * @returns the class name
  19489. */
  19490. getClassName(): string;
  19491. /**
  19492. * Specifies if the material will require alpha blending
  19493. * @returns a boolean specifying if alpha blending is needed
  19494. */
  19495. needAlphaBlending(): boolean;
  19496. /**
  19497. * Specifies if this material should be rendered in alpha test mode
  19498. * @returns a boolean specifying if an alpha test is needed.
  19499. */
  19500. needAlphaTesting(): boolean;
  19501. private _checkUniform;
  19502. /**
  19503. * Set a texture in the shader.
  19504. * @param name Define the name of the uniform samplers as defined in the shader
  19505. * @param texture Define the texture to bind to this sampler
  19506. * @return the material itself allowing "fluent" like uniform updates
  19507. */
  19508. setTexture(name: string, texture: Texture): ShaderMaterial;
  19509. /**
  19510. * Set a texture array in the shader.
  19511. * @param name Define the name of the uniform sampler array as defined in the shader
  19512. * @param textures Define the list of textures to bind to this sampler
  19513. * @return the material itself allowing "fluent" like uniform updates
  19514. */
  19515. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19516. /**
  19517. * Set a float in the shader.
  19518. * @param name Define the name of the uniform as defined in the shader
  19519. * @param value Define the value to give to the uniform
  19520. * @return the material itself allowing "fluent" like uniform updates
  19521. */
  19522. setFloat(name: string, value: number): ShaderMaterial;
  19523. /**
  19524. * Set a int in the shader.
  19525. * @param name Define the name of the uniform as defined in the shader
  19526. * @param value Define the value to give to the uniform
  19527. * @return the material itself allowing "fluent" like uniform updates
  19528. */
  19529. setInt(name: string, value: number): ShaderMaterial;
  19530. /**
  19531. * Set an array of floats in the shader.
  19532. * @param name Define the name of the uniform as defined in the shader
  19533. * @param value Define the value to give to the uniform
  19534. * @return the material itself allowing "fluent" like uniform updates
  19535. */
  19536. setFloats(name: string, value: number[]): ShaderMaterial;
  19537. /**
  19538. * Set a vec3 in the shader from a Color3.
  19539. * @param name Define the name of the uniform as defined in the shader
  19540. * @param value Define the value to give to the uniform
  19541. * @return the material itself allowing "fluent" like uniform updates
  19542. */
  19543. setColor3(name: string, value: Color3): ShaderMaterial;
  19544. /**
  19545. * Set a vec3 array in the shader from a Color3 array.
  19546. * @param name Define the name of the uniform as defined in the shader
  19547. * @param value Define the value to give to the uniform
  19548. * @return the material itself allowing "fluent" like uniform updates
  19549. */
  19550. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19551. /**
  19552. * Set a vec4 in the shader from a Color4.
  19553. * @param name Define the name of the uniform as defined in the shader
  19554. * @param value Define the value to give to the uniform
  19555. * @return the material itself allowing "fluent" like uniform updates
  19556. */
  19557. setColor4(name: string, value: Color4): ShaderMaterial;
  19558. /**
  19559. * Set a vec4 array in the shader from a Color4 array.
  19560. * @param name Define the name of the uniform as defined in the shader
  19561. * @param value Define the value to give to the uniform
  19562. * @return the material itself allowing "fluent" like uniform updates
  19563. */
  19564. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19565. /**
  19566. * Set a vec2 in the shader from a Vector2.
  19567. * @param name Define the name of the uniform as defined in the shader
  19568. * @param value Define the value to give to the uniform
  19569. * @return the material itself allowing "fluent" like uniform updates
  19570. */
  19571. setVector2(name: string, value: Vector2): ShaderMaterial;
  19572. /**
  19573. * Set a vec3 in the shader from a Vector3.
  19574. * @param name Define the name of the uniform as defined in the shader
  19575. * @param value Define the value to give to the uniform
  19576. * @return the material itself allowing "fluent" like uniform updates
  19577. */
  19578. setVector3(name: string, value: Vector3): ShaderMaterial;
  19579. /**
  19580. * Set a vec4 in the shader from a Vector4.
  19581. * @param name Define the name of the uniform as defined in the shader
  19582. * @param value Define the value to give to the uniform
  19583. * @return the material itself allowing "fluent" like uniform updates
  19584. */
  19585. setVector4(name: string, value: Vector4): ShaderMaterial;
  19586. /**
  19587. * Set a mat4 in the shader from a Matrix.
  19588. * @param name Define the name of the uniform as defined in the shader
  19589. * @param value Define the value to give to the uniform
  19590. * @return the material itself allowing "fluent" like uniform updates
  19591. */
  19592. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19593. /**
  19594. * Set a mat3 in the shader from a Float32Array.
  19595. * @param name Define the name of the uniform as defined in the shader
  19596. * @param value Define the value to give to the uniform
  19597. * @return the material itself allowing "fluent" like uniform updates
  19598. */
  19599. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19600. /**
  19601. * Set a mat2 in the shader from a Float32Array.
  19602. * @param name Define the name of the uniform as defined in the shader
  19603. * @param value Define the value to give to the uniform
  19604. * @return the material itself allowing "fluent" like uniform updates
  19605. */
  19606. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19607. /**
  19608. * Set a vec2 array in the shader from a number array.
  19609. * @param name Define the name of the uniform as defined in the shader
  19610. * @param value Define the value to give to the uniform
  19611. * @return the material itself allowing "fluent" like uniform updates
  19612. */
  19613. setArray2(name: string, value: number[]): ShaderMaterial;
  19614. /**
  19615. * Set a vec3 array in the shader from a number array.
  19616. * @param name Define the name of the uniform as defined in the shader
  19617. * @param value Define the value to give to the uniform
  19618. * @return the material itself allowing "fluent" like uniform updates
  19619. */
  19620. setArray3(name: string, value: number[]): ShaderMaterial;
  19621. /**
  19622. * Set a vec4 array in the shader from a number array.
  19623. * @param name Define the name of the uniform as defined in the shader
  19624. * @param value Define the value to give to the uniform
  19625. * @return the material itself allowing "fluent" like uniform updates
  19626. */
  19627. setArray4(name: string, value: number[]): ShaderMaterial;
  19628. private _checkCache;
  19629. /**
  19630. * Specifies that the submesh is ready to be used
  19631. * @param mesh defines the mesh to check
  19632. * @param subMesh defines which submesh to check
  19633. * @param useInstances specifies that instances should be used
  19634. * @returns a boolean indicating that the submesh is ready or not
  19635. */
  19636. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19637. /**
  19638. * Checks if the material is ready to render the requested mesh
  19639. * @param mesh Define the mesh to render
  19640. * @param useInstances Define whether or not the material is used with instances
  19641. * @returns true if ready, otherwise false
  19642. */
  19643. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19644. /**
  19645. * Binds the world matrix to the material
  19646. * @param world defines the world transformation matrix
  19647. */
  19648. bindOnlyWorldMatrix(world: Matrix): void;
  19649. /**
  19650. * Binds the material to the mesh
  19651. * @param world defines the world transformation matrix
  19652. * @param mesh defines the mesh to bind the material to
  19653. */
  19654. bind(world: Matrix, mesh?: Mesh): void;
  19655. /**
  19656. * Gets the active textures from the material
  19657. * @returns an array of textures
  19658. */
  19659. getActiveTextures(): BaseTexture[];
  19660. /**
  19661. * Specifies if the material uses a texture
  19662. * @param texture defines the texture to check against the material
  19663. * @returns a boolean specifying if the material uses the texture
  19664. */
  19665. hasTexture(texture: BaseTexture): boolean;
  19666. /**
  19667. * Makes a duplicate of the material, and gives it a new name
  19668. * @param name defines the new name for the duplicated material
  19669. * @returns the cloned material
  19670. */
  19671. clone(name: string): ShaderMaterial;
  19672. /**
  19673. * Disposes the material
  19674. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19675. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19676. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19677. */
  19678. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19679. /**
  19680. * Serializes this material in a JSON representation
  19681. * @returns the serialized material object
  19682. */
  19683. serialize(): any;
  19684. /**
  19685. * Creates a shader material from parsed shader material data
  19686. * @param source defines the JSON represnetation of the material
  19687. * @param scene defines the hosting scene
  19688. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19689. * @returns a new material
  19690. */
  19691. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19692. }
  19693. }
  19694. declare module "babylonjs/Shaders/color.fragment" {
  19695. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19696. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19697. /** @hidden */
  19698. export var colorPixelShader: {
  19699. name: string;
  19700. shader: string;
  19701. };
  19702. }
  19703. declare module "babylonjs/Shaders/color.vertex" {
  19704. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19705. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19706. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19707. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19708. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19709. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19710. /** @hidden */
  19711. export var colorVertexShader: {
  19712. name: string;
  19713. shader: string;
  19714. };
  19715. }
  19716. declare module "babylonjs/Meshes/linesMesh" {
  19717. import { Nullable } from "babylonjs/types";
  19718. import { Scene } from "babylonjs/scene";
  19719. import { Color3 } from "babylonjs/Maths/math.color";
  19720. import { Node } from "babylonjs/node";
  19721. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19722. import { Mesh } from "babylonjs/Meshes/mesh";
  19723. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19724. import { Effect } from "babylonjs/Materials/effect";
  19725. import { Material } from "babylonjs/Materials/material";
  19726. import "babylonjs/Shaders/color.fragment";
  19727. import "babylonjs/Shaders/color.vertex";
  19728. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19729. /**
  19730. * Line mesh
  19731. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19732. */
  19733. export class LinesMesh extends Mesh {
  19734. /**
  19735. * If vertex color should be applied to the mesh
  19736. */
  19737. readonly useVertexColor?: boolean | undefined;
  19738. /**
  19739. * If vertex alpha should be applied to the mesh
  19740. */
  19741. readonly useVertexAlpha?: boolean | undefined;
  19742. /**
  19743. * Color of the line (Default: White)
  19744. */
  19745. color: Color3;
  19746. /**
  19747. * Alpha of the line (Default: 1)
  19748. */
  19749. alpha: number;
  19750. /**
  19751. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19752. * This margin is expressed in world space coordinates, so its value may vary.
  19753. * Default value is 0.1
  19754. */
  19755. intersectionThreshold: number;
  19756. private _colorShader;
  19757. private color4;
  19758. /**
  19759. * Creates a new LinesMesh
  19760. * @param name defines the name
  19761. * @param scene defines the hosting scene
  19762. * @param parent defines the parent mesh if any
  19763. * @param source defines the optional source LinesMesh used to clone data from
  19764. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19765. * When false, achieved by calling a clone(), also passing False.
  19766. * This will make creation of children, recursive.
  19767. * @param useVertexColor defines if this LinesMesh supports vertex color
  19768. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19769. */
  19770. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19771. /**
  19772. * If vertex color should be applied to the mesh
  19773. */
  19774. useVertexColor?: boolean | undefined,
  19775. /**
  19776. * If vertex alpha should be applied to the mesh
  19777. */
  19778. useVertexAlpha?: boolean | undefined);
  19779. private _addClipPlaneDefine;
  19780. private _removeClipPlaneDefine;
  19781. isReady(): boolean;
  19782. /**
  19783. * Returns the string "LineMesh"
  19784. */
  19785. getClassName(): string;
  19786. /**
  19787. * @hidden
  19788. */
  19789. /**
  19790. * @hidden
  19791. */
  19792. material: Material;
  19793. /**
  19794. * @hidden
  19795. */
  19796. readonly checkCollisions: boolean;
  19797. /** @hidden */
  19798. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19799. /** @hidden */
  19800. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19801. /**
  19802. * Disposes of the line mesh
  19803. * @param doNotRecurse If children should be disposed
  19804. */
  19805. dispose(doNotRecurse?: boolean): void;
  19806. /**
  19807. * Returns a new LineMesh object cloned from the current one.
  19808. */
  19809. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19810. /**
  19811. * Creates a new InstancedLinesMesh object from the mesh model.
  19812. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19813. * @param name defines the name of the new instance
  19814. * @returns a new InstancedLinesMesh
  19815. */
  19816. createInstance(name: string): InstancedLinesMesh;
  19817. }
  19818. /**
  19819. * Creates an instance based on a source LinesMesh
  19820. */
  19821. export class InstancedLinesMesh extends InstancedMesh {
  19822. /**
  19823. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19824. * This margin is expressed in world space coordinates, so its value may vary.
  19825. * Initilized with the intersectionThreshold value of the source LinesMesh
  19826. */
  19827. intersectionThreshold: number;
  19828. constructor(name: string, source: LinesMesh);
  19829. /**
  19830. * Returns the string "InstancedLinesMesh".
  19831. */
  19832. getClassName(): string;
  19833. }
  19834. }
  19835. declare module "babylonjs/Shaders/line.fragment" {
  19836. /** @hidden */
  19837. export var linePixelShader: {
  19838. name: string;
  19839. shader: string;
  19840. };
  19841. }
  19842. declare module "babylonjs/Shaders/line.vertex" {
  19843. /** @hidden */
  19844. export var lineVertexShader: {
  19845. name: string;
  19846. shader: string;
  19847. };
  19848. }
  19849. declare module "babylonjs/Rendering/edgesRenderer" {
  19850. import { Nullable } from "babylonjs/types";
  19851. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19853. import { Vector3 } from "babylonjs/Maths/math.vector";
  19854. import { IDisposable } from "babylonjs/scene";
  19855. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19856. import "babylonjs/Shaders/line.fragment";
  19857. import "babylonjs/Shaders/line.vertex";
  19858. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19859. module "babylonjs/Meshes/abstractMesh" {
  19860. interface AbstractMesh {
  19861. /**
  19862. * Gets the edgesRenderer associated with the mesh
  19863. */
  19864. edgesRenderer: Nullable<EdgesRenderer>;
  19865. }
  19866. }
  19867. module "babylonjs/Meshes/linesMesh" {
  19868. interface LinesMesh {
  19869. /**
  19870. * Enables the edge rendering mode on the mesh.
  19871. * This mode makes the mesh edges visible
  19872. * @param epsilon defines the maximal distance between two angles to detect a face
  19873. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19874. * @returns the currentAbstractMesh
  19875. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19876. */
  19877. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19878. }
  19879. }
  19880. module "babylonjs/Meshes/linesMesh" {
  19881. interface InstancedLinesMesh {
  19882. /**
  19883. * Enables the edge rendering mode on the mesh.
  19884. * This mode makes the mesh edges visible
  19885. * @param epsilon defines the maximal distance between two angles to detect a face
  19886. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19887. * @returns the current InstancedLinesMesh
  19888. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19889. */
  19890. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19891. }
  19892. }
  19893. /**
  19894. * Defines the minimum contract an Edges renderer should follow.
  19895. */
  19896. export interface IEdgesRenderer extends IDisposable {
  19897. /**
  19898. * Gets or sets a boolean indicating if the edgesRenderer is active
  19899. */
  19900. isEnabled: boolean;
  19901. /**
  19902. * Renders the edges of the attached mesh,
  19903. */
  19904. render(): void;
  19905. /**
  19906. * Checks wether or not the edges renderer is ready to render.
  19907. * @return true if ready, otherwise false.
  19908. */
  19909. isReady(): boolean;
  19910. }
  19911. /**
  19912. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19913. */
  19914. export class EdgesRenderer implements IEdgesRenderer {
  19915. /**
  19916. * Define the size of the edges with an orthographic camera
  19917. */
  19918. edgesWidthScalerForOrthographic: number;
  19919. /**
  19920. * Define the size of the edges with a perspective camera
  19921. */
  19922. edgesWidthScalerForPerspective: number;
  19923. protected _source: AbstractMesh;
  19924. protected _linesPositions: number[];
  19925. protected _linesNormals: number[];
  19926. protected _linesIndices: number[];
  19927. protected _epsilon: number;
  19928. protected _indicesCount: number;
  19929. protected _lineShader: ShaderMaterial;
  19930. protected _ib: DataBuffer;
  19931. protected _buffers: {
  19932. [key: string]: Nullable<VertexBuffer>;
  19933. };
  19934. protected _checkVerticesInsteadOfIndices: boolean;
  19935. private _meshRebuildObserver;
  19936. private _meshDisposeObserver;
  19937. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19938. isEnabled: boolean;
  19939. /**
  19940. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19941. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19942. * @param source Mesh used to create edges
  19943. * @param epsilon sum of angles in adjacency to check for edge
  19944. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19945. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19946. */
  19947. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19948. protected _prepareRessources(): void;
  19949. /** @hidden */
  19950. _rebuild(): void;
  19951. /**
  19952. * Releases the required resources for the edges renderer
  19953. */
  19954. dispose(): void;
  19955. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19956. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19957. /**
  19958. * Checks if the pair of p0 and p1 is en edge
  19959. * @param faceIndex
  19960. * @param edge
  19961. * @param faceNormals
  19962. * @param p0
  19963. * @param p1
  19964. * @private
  19965. */
  19966. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19967. /**
  19968. * push line into the position, normal and index buffer
  19969. * @protected
  19970. */
  19971. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19972. /**
  19973. * Generates lines edges from adjacencjes
  19974. * @private
  19975. */
  19976. _generateEdgesLines(): void;
  19977. /**
  19978. * Checks wether or not the edges renderer is ready to render.
  19979. * @return true if ready, otherwise false.
  19980. */
  19981. isReady(): boolean;
  19982. /**
  19983. * Renders the edges of the attached mesh,
  19984. */
  19985. render(): void;
  19986. }
  19987. /**
  19988. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19989. */
  19990. export class LineEdgesRenderer extends EdgesRenderer {
  19991. /**
  19992. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19993. * @param source LineMesh used to generate edges
  19994. * @param epsilon not important (specified angle for edge detection)
  19995. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19996. */
  19997. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19998. /**
  19999. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20000. */
  20001. _generateEdgesLines(): void;
  20002. }
  20003. }
  20004. declare module "babylonjs/Rendering/renderingGroup" {
  20005. import { SmartArray } from "babylonjs/Misc/smartArray";
  20006. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20008. import { Nullable } from "babylonjs/types";
  20009. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20010. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20011. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20012. import { Material } from "babylonjs/Materials/material";
  20013. import { Scene } from "babylonjs/scene";
  20014. /**
  20015. * This represents the object necessary to create a rendering group.
  20016. * This is exclusively used and created by the rendering manager.
  20017. * To modify the behavior, you use the available helpers in your scene or meshes.
  20018. * @hidden
  20019. */
  20020. export class RenderingGroup {
  20021. index: number;
  20022. private static _zeroVector;
  20023. private _scene;
  20024. private _opaqueSubMeshes;
  20025. private _transparentSubMeshes;
  20026. private _alphaTestSubMeshes;
  20027. private _depthOnlySubMeshes;
  20028. private _particleSystems;
  20029. private _spriteManagers;
  20030. private _opaqueSortCompareFn;
  20031. private _alphaTestSortCompareFn;
  20032. private _transparentSortCompareFn;
  20033. private _renderOpaque;
  20034. private _renderAlphaTest;
  20035. private _renderTransparent;
  20036. /** @hidden */
  20037. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20038. onBeforeTransparentRendering: () => void;
  20039. /**
  20040. * Set the opaque sort comparison function.
  20041. * If null the sub meshes will be render in the order they were created
  20042. */
  20043. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20044. /**
  20045. * Set the alpha test sort comparison function.
  20046. * If null the sub meshes will be render in the order they were created
  20047. */
  20048. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20049. /**
  20050. * Set the transparent sort comparison function.
  20051. * If null the sub meshes will be render in the order they were created
  20052. */
  20053. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20054. /**
  20055. * Creates a new rendering group.
  20056. * @param index The rendering group index
  20057. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20058. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20059. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20060. */
  20061. 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>);
  20062. /**
  20063. * Render all the sub meshes contained in the group.
  20064. * @param customRenderFunction Used to override the default render behaviour of the group.
  20065. * @returns true if rendered some submeshes.
  20066. */
  20067. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20068. /**
  20069. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20070. * @param subMeshes The submeshes to render
  20071. */
  20072. private renderOpaqueSorted;
  20073. /**
  20074. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20075. * @param subMeshes The submeshes to render
  20076. */
  20077. private renderAlphaTestSorted;
  20078. /**
  20079. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20080. * @param subMeshes The submeshes to render
  20081. */
  20082. private renderTransparentSorted;
  20083. /**
  20084. * Renders the submeshes in a specified order.
  20085. * @param subMeshes The submeshes to sort before render
  20086. * @param sortCompareFn The comparison function use to sort
  20087. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20088. * @param transparent Specifies to activate blending if true
  20089. */
  20090. private static renderSorted;
  20091. /**
  20092. * Renders the submeshes in the order they were dispatched (no sort applied).
  20093. * @param subMeshes The submeshes to render
  20094. */
  20095. private static renderUnsorted;
  20096. /**
  20097. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20098. * are rendered back to front if in the same alpha index.
  20099. *
  20100. * @param a The first submesh
  20101. * @param b The second submesh
  20102. * @returns The result of the comparison
  20103. */
  20104. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20105. /**
  20106. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20107. * are rendered back to front.
  20108. *
  20109. * @param a The first submesh
  20110. * @param b The second submesh
  20111. * @returns The result of the comparison
  20112. */
  20113. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20114. /**
  20115. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20116. * are rendered front to back (prevent overdraw).
  20117. *
  20118. * @param a The first submesh
  20119. * @param b The second submesh
  20120. * @returns The result of the comparison
  20121. */
  20122. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20123. /**
  20124. * Resets the different lists of submeshes to prepare a new frame.
  20125. */
  20126. prepare(): void;
  20127. dispose(): void;
  20128. /**
  20129. * Inserts the submesh in its correct queue depending on its material.
  20130. * @param subMesh The submesh to dispatch
  20131. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20132. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20133. */
  20134. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20135. dispatchSprites(spriteManager: ISpriteManager): void;
  20136. dispatchParticles(particleSystem: IParticleSystem): void;
  20137. private _renderParticles;
  20138. private _renderSprites;
  20139. }
  20140. }
  20141. declare module "babylonjs/Rendering/renderingManager" {
  20142. import { Nullable } from "babylonjs/types";
  20143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20144. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20145. import { SmartArray } from "babylonjs/Misc/smartArray";
  20146. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20147. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20148. import { Material } from "babylonjs/Materials/material";
  20149. import { Scene } from "babylonjs/scene";
  20150. import { Camera } from "babylonjs/Cameras/camera";
  20151. /**
  20152. * Interface describing the different options available in the rendering manager
  20153. * regarding Auto Clear between groups.
  20154. */
  20155. export interface IRenderingManagerAutoClearSetup {
  20156. /**
  20157. * Defines whether or not autoclear is enable.
  20158. */
  20159. autoClear: boolean;
  20160. /**
  20161. * Defines whether or not to autoclear the depth buffer.
  20162. */
  20163. depth: boolean;
  20164. /**
  20165. * Defines whether or not to autoclear the stencil buffer.
  20166. */
  20167. stencil: boolean;
  20168. }
  20169. /**
  20170. * This class is used by the onRenderingGroupObservable
  20171. */
  20172. export class RenderingGroupInfo {
  20173. /**
  20174. * The Scene that being rendered
  20175. */
  20176. scene: Scene;
  20177. /**
  20178. * The camera currently used for the rendering pass
  20179. */
  20180. camera: Nullable<Camera>;
  20181. /**
  20182. * The ID of the renderingGroup being processed
  20183. */
  20184. renderingGroupId: number;
  20185. }
  20186. /**
  20187. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20188. * It is enable to manage the different groups as well as the different necessary sort functions.
  20189. * This should not be used directly aside of the few static configurations
  20190. */
  20191. export class RenderingManager {
  20192. /**
  20193. * The max id used for rendering groups (not included)
  20194. */
  20195. static MAX_RENDERINGGROUPS: number;
  20196. /**
  20197. * The min id used for rendering groups (included)
  20198. */
  20199. static MIN_RENDERINGGROUPS: number;
  20200. /**
  20201. * Used to globally prevent autoclearing scenes.
  20202. */
  20203. static AUTOCLEAR: boolean;
  20204. /**
  20205. * @hidden
  20206. */
  20207. _useSceneAutoClearSetup: boolean;
  20208. private _scene;
  20209. private _renderingGroups;
  20210. private _depthStencilBufferAlreadyCleaned;
  20211. private _autoClearDepthStencil;
  20212. private _customOpaqueSortCompareFn;
  20213. private _customAlphaTestSortCompareFn;
  20214. private _customTransparentSortCompareFn;
  20215. private _renderingGroupInfo;
  20216. /**
  20217. * Instantiates a new rendering group for a particular scene
  20218. * @param scene Defines the scene the groups belongs to
  20219. */
  20220. constructor(scene: Scene);
  20221. private _clearDepthStencilBuffer;
  20222. /**
  20223. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20224. * @hidden
  20225. */
  20226. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20227. /**
  20228. * Resets the different information of the group to prepare a new frame
  20229. * @hidden
  20230. */
  20231. reset(): void;
  20232. /**
  20233. * Dispose and release the group and its associated resources.
  20234. * @hidden
  20235. */
  20236. dispose(): void;
  20237. /**
  20238. * Clear the info related to rendering groups preventing retention points during dispose.
  20239. */
  20240. freeRenderingGroups(): void;
  20241. private _prepareRenderingGroup;
  20242. /**
  20243. * Add a sprite manager to the rendering manager in order to render it this frame.
  20244. * @param spriteManager Define the sprite manager to render
  20245. */
  20246. dispatchSprites(spriteManager: ISpriteManager): void;
  20247. /**
  20248. * Add a particle system to the rendering manager in order to render it this frame.
  20249. * @param particleSystem Define the particle system to render
  20250. */
  20251. dispatchParticles(particleSystem: IParticleSystem): void;
  20252. /**
  20253. * Add a submesh to the manager in order to render it this frame
  20254. * @param subMesh The submesh to dispatch
  20255. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20256. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20257. */
  20258. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20259. /**
  20260. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20261. * This allowed control for front to back rendering or reversly depending of the special needs.
  20262. *
  20263. * @param renderingGroupId The rendering group id corresponding to its index
  20264. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20265. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20266. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20267. */
  20268. 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;
  20269. /**
  20270. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20271. *
  20272. * @param renderingGroupId The rendering group id corresponding to its index
  20273. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20274. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20275. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20276. */
  20277. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20278. /**
  20279. * Gets the current auto clear configuration for one rendering group of the rendering
  20280. * manager.
  20281. * @param index the rendering group index to get the information for
  20282. * @returns The auto clear setup for the requested rendering group
  20283. */
  20284. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20285. }
  20286. }
  20287. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20288. import { Observable } from "babylonjs/Misc/observable";
  20289. import { SmartArray } from "babylonjs/Misc/smartArray";
  20290. import { Nullable } from "babylonjs/types";
  20291. import { Camera } from "babylonjs/Cameras/camera";
  20292. import { Scene } from "babylonjs/scene";
  20293. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20294. import { Color4 } from "babylonjs/Maths/math.color";
  20295. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20297. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20298. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20299. import { Texture } from "babylonjs/Materials/Textures/texture";
  20300. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20301. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20302. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20303. import { Engine } from "babylonjs/Engines/engine";
  20304. /**
  20305. * This Helps creating a texture that will be created from a camera in your scene.
  20306. * It is basically a dynamic texture that could be used to create special effects for instance.
  20307. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20308. */
  20309. export class RenderTargetTexture extends Texture {
  20310. isCube: boolean;
  20311. /**
  20312. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20313. */
  20314. static readonly REFRESHRATE_RENDER_ONCE: number;
  20315. /**
  20316. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20317. */
  20318. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20319. /**
  20320. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20321. * the central point of your effect and can save a lot of performances.
  20322. */
  20323. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20324. /**
  20325. * Use this predicate to dynamically define the list of mesh you want to render.
  20326. * If set, the renderList property will be overwritten.
  20327. */
  20328. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20329. private _renderList;
  20330. /**
  20331. * Use this list to define the list of mesh you want to render.
  20332. */
  20333. renderList: Nullable<Array<AbstractMesh>>;
  20334. private _hookArray;
  20335. /**
  20336. * Define if particles should be rendered in your texture.
  20337. */
  20338. renderParticles: boolean;
  20339. /**
  20340. * Define if sprites should be rendered in your texture.
  20341. */
  20342. renderSprites: boolean;
  20343. /**
  20344. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20345. */
  20346. coordinatesMode: number;
  20347. /**
  20348. * Define the camera used to render the texture.
  20349. */
  20350. activeCamera: Nullable<Camera>;
  20351. /**
  20352. * Override the render function of the texture with your own one.
  20353. */
  20354. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20355. /**
  20356. * Define if camera post processes should be use while rendering the texture.
  20357. */
  20358. useCameraPostProcesses: boolean;
  20359. /**
  20360. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20361. */
  20362. ignoreCameraViewport: boolean;
  20363. private _postProcessManager;
  20364. private _postProcesses;
  20365. private _resizeObserver;
  20366. /**
  20367. * An event triggered when the texture is unbind.
  20368. */
  20369. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20370. /**
  20371. * An event triggered when the texture is unbind.
  20372. */
  20373. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20374. private _onAfterUnbindObserver;
  20375. /**
  20376. * Set a after unbind callback in the texture.
  20377. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20378. */
  20379. onAfterUnbind: () => void;
  20380. /**
  20381. * An event triggered before rendering the texture
  20382. */
  20383. onBeforeRenderObservable: Observable<number>;
  20384. private _onBeforeRenderObserver;
  20385. /**
  20386. * Set a before render callback in the texture.
  20387. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20388. */
  20389. onBeforeRender: (faceIndex: number) => void;
  20390. /**
  20391. * An event triggered after rendering the texture
  20392. */
  20393. onAfterRenderObservable: Observable<number>;
  20394. private _onAfterRenderObserver;
  20395. /**
  20396. * Set a after render callback in the texture.
  20397. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20398. */
  20399. onAfterRender: (faceIndex: number) => void;
  20400. /**
  20401. * An event triggered after the texture clear
  20402. */
  20403. onClearObservable: Observable<Engine>;
  20404. private _onClearObserver;
  20405. /**
  20406. * Set a clear callback in the texture.
  20407. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20408. */
  20409. onClear: (Engine: Engine) => void;
  20410. /**
  20411. * An event triggered when the texture is resized.
  20412. */
  20413. onResizeObservable: Observable<RenderTargetTexture>;
  20414. /**
  20415. * Define the clear color of the Render Target if it should be different from the scene.
  20416. */
  20417. clearColor: Color4;
  20418. protected _size: number | {
  20419. width: number;
  20420. height: number;
  20421. };
  20422. protected _initialSizeParameter: number | {
  20423. width: number;
  20424. height: number;
  20425. } | {
  20426. ratio: number;
  20427. };
  20428. protected _sizeRatio: Nullable<number>;
  20429. /** @hidden */
  20430. _generateMipMaps: boolean;
  20431. protected _renderingManager: RenderingManager;
  20432. /** @hidden */
  20433. _waitingRenderList: string[];
  20434. protected _doNotChangeAspectRatio: boolean;
  20435. protected _currentRefreshId: number;
  20436. protected _refreshRate: number;
  20437. protected _textureMatrix: Matrix;
  20438. protected _samples: number;
  20439. protected _renderTargetOptions: RenderTargetCreationOptions;
  20440. /**
  20441. * Gets render target creation options that were used.
  20442. */
  20443. readonly renderTargetOptions: RenderTargetCreationOptions;
  20444. protected _engine: Engine;
  20445. protected _onRatioRescale(): void;
  20446. /**
  20447. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20448. * It must define where the camera used to render the texture is set
  20449. */
  20450. boundingBoxPosition: Vector3;
  20451. private _boundingBoxSize;
  20452. /**
  20453. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20454. * When defined, the cubemap will switch to local mode
  20455. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20456. * @example https://www.babylonjs-playground.com/#RNASML
  20457. */
  20458. boundingBoxSize: Vector3;
  20459. /**
  20460. * In case the RTT has been created with a depth texture, get the associated
  20461. * depth texture.
  20462. * Otherwise, return null.
  20463. */
  20464. depthStencilTexture: Nullable<InternalTexture>;
  20465. /**
  20466. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20467. * or used a shadow, depth texture...
  20468. * @param name The friendly name of the texture
  20469. * @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)
  20470. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20471. * @param generateMipMaps True if mip maps need to be generated after render.
  20472. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20473. * @param type The type of the buffer in the RTT (int, half float, float...)
  20474. * @param isCube True if a cube texture needs to be created
  20475. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20476. * @param generateDepthBuffer True to generate a depth buffer
  20477. * @param generateStencilBuffer True to generate a stencil buffer
  20478. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20479. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20480. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20481. */
  20482. constructor(name: string, size: number | {
  20483. width: number;
  20484. height: number;
  20485. } | {
  20486. ratio: number;
  20487. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20488. /**
  20489. * Creates a depth stencil texture.
  20490. * This is only available in WebGL 2 or with the depth texture extension available.
  20491. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20492. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20493. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20494. */
  20495. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20496. private _processSizeParameter;
  20497. /**
  20498. * Define the number of samples to use in case of MSAA.
  20499. * It defaults to one meaning no MSAA has been enabled.
  20500. */
  20501. samples: number;
  20502. /**
  20503. * Resets the refresh counter of the texture and start bak from scratch.
  20504. * Could be useful to regenerate the texture if it is setup to render only once.
  20505. */
  20506. resetRefreshCounter(): void;
  20507. /**
  20508. * Define the refresh rate of the texture or the rendering frequency.
  20509. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20510. */
  20511. refreshRate: number;
  20512. /**
  20513. * Adds a post process to the render target rendering passes.
  20514. * @param postProcess define the post process to add
  20515. */
  20516. addPostProcess(postProcess: PostProcess): void;
  20517. /**
  20518. * Clear all the post processes attached to the render target
  20519. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20520. */
  20521. clearPostProcesses(dispose?: boolean): void;
  20522. /**
  20523. * Remove one of the post process from the list of attached post processes to the texture
  20524. * @param postProcess define the post process to remove from the list
  20525. */
  20526. removePostProcess(postProcess: PostProcess): void;
  20527. /** @hidden */
  20528. _shouldRender(): boolean;
  20529. /**
  20530. * Gets the actual render size of the texture.
  20531. * @returns the width of the render size
  20532. */
  20533. getRenderSize(): number;
  20534. /**
  20535. * Gets the actual render width of the texture.
  20536. * @returns the width of the render size
  20537. */
  20538. getRenderWidth(): number;
  20539. /**
  20540. * Gets the actual render height of the texture.
  20541. * @returns the height of the render size
  20542. */
  20543. getRenderHeight(): number;
  20544. /**
  20545. * Get if the texture can be rescaled or not.
  20546. */
  20547. readonly canRescale: boolean;
  20548. /**
  20549. * Resize the texture using a ratio.
  20550. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20551. */
  20552. scale(ratio: number): void;
  20553. /**
  20554. * Get the texture reflection matrix used to rotate/transform the reflection.
  20555. * @returns the reflection matrix
  20556. */
  20557. getReflectionTextureMatrix(): Matrix;
  20558. /**
  20559. * Resize the texture to a new desired size.
  20560. * Be carrefull as it will recreate all the data in the new texture.
  20561. * @param size Define the new size. It can be:
  20562. * - a number for squared texture,
  20563. * - an object containing { width: number, height: number }
  20564. * - or an object containing a ratio { ratio: number }
  20565. */
  20566. resize(size: number | {
  20567. width: number;
  20568. height: number;
  20569. } | {
  20570. ratio: number;
  20571. }): void;
  20572. /**
  20573. * Renders all the objects from the render list into the texture.
  20574. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20575. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20576. */
  20577. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20578. private _bestReflectionRenderTargetDimension;
  20579. /**
  20580. * @hidden
  20581. * @param faceIndex face index to bind to if this is a cubetexture
  20582. */
  20583. _bindFrameBuffer(faceIndex?: number): void;
  20584. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20585. private renderToTarget;
  20586. /**
  20587. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20588. * This allowed control for front to back rendering or reversly depending of the special needs.
  20589. *
  20590. * @param renderingGroupId The rendering group id corresponding to its index
  20591. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20592. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20593. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20594. */
  20595. 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;
  20596. /**
  20597. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20598. *
  20599. * @param renderingGroupId The rendering group id corresponding to its index
  20600. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20601. */
  20602. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20603. /**
  20604. * Clones the texture.
  20605. * @returns the cloned texture
  20606. */
  20607. clone(): RenderTargetTexture;
  20608. /**
  20609. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20610. * @returns The JSON representation of the texture
  20611. */
  20612. serialize(): any;
  20613. /**
  20614. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20615. */
  20616. disposeFramebufferObjects(): void;
  20617. /**
  20618. * Dispose the texture and release its associated resources.
  20619. */
  20620. dispose(): void;
  20621. /** @hidden */
  20622. _rebuild(): void;
  20623. /**
  20624. * Clear the info related to rendering groups preventing retention point in material dispose.
  20625. */
  20626. freeRenderingGroups(): void;
  20627. /**
  20628. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20629. * @returns the view count
  20630. */
  20631. getViewCount(): number;
  20632. }
  20633. }
  20634. declare module "babylonjs/Materials/material" {
  20635. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20636. import { SmartArray } from "babylonjs/Misc/smartArray";
  20637. import { Observable } from "babylonjs/Misc/observable";
  20638. import { Nullable } from "babylonjs/types";
  20639. import { Scene } from "babylonjs/scene";
  20640. import { Matrix } from "babylonjs/Maths/math.vector";
  20641. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20643. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20644. import { Effect } from "babylonjs/Materials/effect";
  20645. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20646. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20647. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20648. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20649. import { Mesh } from "babylonjs/Meshes/mesh";
  20650. import { Animation } from "babylonjs/Animations/animation";
  20651. /**
  20652. * Base class for the main features of a material in Babylon.js
  20653. */
  20654. export class Material implements IAnimatable {
  20655. /**
  20656. * Returns the triangle fill mode
  20657. */
  20658. static readonly TriangleFillMode: number;
  20659. /**
  20660. * Returns the wireframe mode
  20661. */
  20662. static readonly WireFrameFillMode: number;
  20663. /**
  20664. * Returns the point fill mode
  20665. */
  20666. static readonly PointFillMode: number;
  20667. /**
  20668. * Returns the point list draw mode
  20669. */
  20670. static readonly PointListDrawMode: number;
  20671. /**
  20672. * Returns the line list draw mode
  20673. */
  20674. static readonly LineListDrawMode: number;
  20675. /**
  20676. * Returns the line loop draw mode
  20677. */
  20678. static readonly LineLoopDrawMode: number;
  20679. /**
  20680. * Returns the line strip draw mode
  20681. */
  20682. static readonly LineStripDrawMode: number;
  20683. /**
  20684. * Returns the triangle strip draw mode
  20685. */
  20686. static readonly TriangleStripDrawMode: number;
  20687. /**
  20688. * Returns the triangle fan draw mode
  20689. */
  20690. static readonly TriangleFanDrawMode: number;
  20691. /**
  20692. * Stores the clock-wise side orientation
  20693. */
  20694. static readonly ClockWiseSideOrientation: number;
  20695. /**
  20696. * Stores the counter clock-wise side orientation
  20697. */
  20698. static readonly CounterClockWiseSideOrientation: number;
  20699. /**
  20700. * The dirty texture flag value
  20701. */
  20702. static readonly TextureDirtyFlag: number;
  20703. /**
  20704. * The dirty light flag value
  20705. */
  20706. static readonly LightDirtyFlag: number;
  20707. /**
  20708. * The dirty fresnel flag value
  20709. */
  20710. static readonly FresnelDirtyFlag: number;
  20711. /**
  20712. * The dirty attribute flag value
  20713. */
  20714. static readonly AttributesDirtyFlag: number;
  20715. /**
  20716. * The dirty misc flag value
  20717. */
  20718. static readonly MiscDirtyFlag: number;
  20719. /**
  20720. * The all dirty flag value
  20721. */
  20722. static readonly AllDirtyFlag: number;
  20723. /**
  20724. * The ID of the material
  20725. */
  20726. id: string;
  20727. /**
  20728. * Gets or sets the unique id of the material
  20729. */
  20730. uniqueId: number;
  20731. /**
  20732. * The name of the material
  20733. */
  20734. name: string;
  20735. /**
  20736. * Gets or sets user defined metadata
  20737. */
  20738. metadata: any;
  20739. /**
  20740. * For internal use only. Please do not use.
  20741. */
  20742. reservedDataStore: any;
  20743. /**
  20744. * Specifies if the ready state should be checked on each call
  20745. */
  20746. checkReadyOnEveryCall: boolean;
  20747. /**
  20748. * Specifies if the ready state should be checked once
  20749. */
  20750. checkReadyOnlyOnce: boolean;
  20751. /**
  20752. * The state of the material
  20753. */
  20754. state: string;
  20755. /**
  20756. * The alpha value of the material
  20757. */
  20758. protected _alpha: number;
  20759. /**
  20760. * List of inspectable custom properties (used by the Inspector)
  20761. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20762. */
  20763. inspectableCustomProperties: IInspectable[];
  20764. /**
  20765. * Sets the alpha value of the material
  20766. */
  20767. /**
  20768. * Gets the alpha value of the material
  20769. */
  20770. alpha: number;
  20771. /**
  20772. * Specifies if back face culling is enabled
  20773. */
  20774. protected _backFaceCulling: boolean;
  20775. /**
  20776. * Sets the back-face culling state
  20777. */
  20778. /**
  20779. * Gets the back-face culling state
  20780. */
  20781. backFaceCulling: boolean;
  20782. /**
  20783. * Stores the value for side orientation
  20784. */
  20785. sideOrientation: number;
  20786. /**
  20787. * Callback triggered when the material is compiled
  20788. */
  20789. onCompiled: Nullable<(effect: Effect) => void>;
  20790. /**
  20791. * Callback triggered when an error occurs
  20792. */
  20793. onError: Nullable<(effect: Effect, errors: string) => void>;
  20794. /**
  20795. * Callback triggered to get the render target textures
  20796. */
  20797. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20798. /**
  20799. * Gets a boolean indicating that current material needs to register RTT
  20800. */
  20801. readonly hasRenderTargetTextures: boolean;
  20802. /**
  20803. * Specifies if the material should be serialized
  20804. */
  20805. doNotSerialize: boolean;
  20806. /**
  20807. * @hidden
  20808. */
  20809. _storeEffectOnSubMeshes: boolean;
  20810. /**
  20811. * Stores the animations for the material
  20812. */
  20813. animations: Nullable<Array<Animation>>;
  20814. /**
  20815. * An event triggered when the material is disposed
  20816. */
  20817. onDisposeObservable: Observable<Material>;
  20818. /**
  20819. * An observer which watches for dispose events
  20820. */
  20821. private _onDisposeObserver;
  20822. private _onUnBindObservable;
  20823. /**
  20824. * Called during a dispose event
  20825. */
  20826. onDispose: () => void;
  20827. private _onBindObservable;
  20828. /**
  20829. * An event triggered when the material is bound
  20830. */
  20831. readonly onBindObservable: Observable<AbstractMesh>;
  20832. /**
  20833. * An observer which watches for bind events
  20834. */
  20835. private _onBindObserver;
  20836. /**
  20837. * Called during a bind event
  20838. */
  20839. onBind: (Mesh: AbstractMesh) => void;
  20840. /**
  20841. * An event triggered when the material is unbound
  20842. */
  20843. readonly onUnBindObservable: Observable<Material>;
  20844. /**
  20845. * Stores the value of the alpha mode
  20846. */
  20847. private _alphaMode;
  20848. /**
  20849. * Sets the value of the alpha mode.
  20850. *
  20851. * | Value | Type | Description |
  20852. * | --- | --- | --- |
  20853. * | 0 | ALPHA_DISABLE | |
  20854. * | 1 | ALPHA_ADD | |
  20855. * | 2 | ALPHA_COMBINE | |
  20856. * | 3 | ALPHA_SUBTRACT | |
  20857. * | 4 | ALPHA_MULTIPLY | |
  20858. * | 5 | ALPHA_MAXIMIZED | |
  20859. * | 6 | ALPHA_ONEONE | |
  20860. * | 7 | ALPHA_PREMULTIPLIED | |
  20861. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20862. * | 9 | ALPHA_INTERPOLATE | |
  20863. * | 10 | ALPHA_SCREENMODE | |
  20864. *
  20865. */
  20866. /**
  20867. * Gets the value of the alpha mode
  20868. */
  20869. alphaMode: number;
  20870. /**
  20871. * Stores the state of the need depth pre-pass value
  20872. */
  20873. private _needDepthPrePass;
  20874. /**
  20875. * Sets the need depth pre-pass value
  20876. */
  20877. /**
  20878. * Gets the depth pre-pass value
  20879. */
  20880. needDepthPrePass: boolean;
  20881. /**
  20882. * Specifies if depth writing should be disabled
  20883. */
  20884. disableDepthWrite: boolean;
  20885. /**
  20886. * Specifies if depth writing should be forced
  20887. */
  20888. forceDepthWrite: boolean;
  20889. /**
  20890. * Specifies if there should be a separate pass for culling
  20891. */
  20892. separateCullingPass: boolean;
  20893. /**
  20894. * Stores the state specifing if fog should be enabled
  20895. */
  20896. private _fogEnabled;
  20897. /**
  20898. * Sets the state for enabling fog
  20899. */
  20900. /**
  20901. * Gets the value of the fog enabled state
  20902. */
  20903. fogEnabled: boolean;
  20904. /**
  20905. * Stores the size of points
  20906. */
  20907. pointSize: number;
  20908. /**
  20909. * Stores the z offset value
  20910. */
  20911. zOffset: number;
  20912. /**
  20913. * Gets a value specifying if wireframe mode is enabled
  20914. */
  20915. /**
  20916. * Sets the state of wireframe mode
  20917. */
  20918. wireframe: boolean;
  20919. /**
  20920. * Gets the value specifying if point clouds are enabled
  20921. */
  20922. /**
  20923. * Sets the state of point cloud mode
  20924. */
  20925. pointsCloud: boolean;
  20926. /**
  20927. * Gets the material fill mode
  20928. */
  20929. /**
  20930. * Sets the material fill mode
  20931. */
  20932. fillMode: number;
  20933. /**
  20934. * @hidden
  20935. * Stores the effects for the material
  20936. */
  20937. _effect: Nullable<Effect>;
  20938. /**
  20939. * @hidden
  20940. * Specifies if the material was previously ready
  20941. */
  20942. _wasPreviouslyReady: boolean;
  20943. /**
  20944. * Specifies if uniform buffers should be used
  20945. */
  20946. private _useUBO;
  20947. /**
  20948. * Stores a reference to the scene
  20949. */
  20950. private _scene;
  20951. /**
  20952. * Stores the fill mode state
  20953. */
  20954. private _fillMode;
  20955. /**
  20956. * Specifies if the depth write state should be cached
  20957. */
  20958. private _cachedDepthWriteState;
  20959. /**
  20960. * Stores the uniform buffer
  20961. */
  20962. protected _uniformBuffer: UniformBuffer;
  20963. /** @hidden */
  20964. _indexInSceneMaterialArray: number;
  20965. /** @hidden */
  20966. meshMap: Nullable<{
  20967. [id: string]: AbstractMesh | undefined;
  20968. }>;
  20969. /**
  20970. * Creates a material instance
  20971. * @param name defines the name of the material
  20972. * @param scene defines the scene to reference
  20973. * @param doNotAdd specifies if the material should be added to the scene
  20974. */
  20975. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20976. /**
  20977. * Returns a string representation of the current material
  20978. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20979. * @returns a string with material information
  20980. */
  20981. toString(fullDetails?: boolean): string;
  20982. /**
  20983. * Gets the class name of the material
  20984. * @returns a string with the class name of the material
  20985. */
  20986. getClassName(): string;
  20987. /**
  20988. * Specifies if updates for the material been locked
  20989. */
  20990. readonly isFrozen: boolean;
  20991. /**
  20992. * Locks updates for the material
  20993. */
  20994. freeze(): void;
  20995. /**
  20996. * Unlocks updates for the material
  20997. */
  20998. unfreeze(): void;
  20999. /**
  21000. * Specifies if the material is ready to be used
  21001. * @param mesh defines the mesh to check
  21002. * @param useInstances specifies if instances should be used
  21003. * @returns a boolean indicating if the material is ready to be used
  21004. */
  21005. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21006. /**
  21007. * Specifies that the submesh is ready to be used
  21008. * @param mesh defines the mesh to check
  21009. * @param subMesh defines which submesh to check
  21010. * @param useInstances specifies that instances should be used
  21011. * @returns a boolean indicating that the submesh is ready or not
  21012. */
  21013. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21014. /**
  21015. * Returns the material effect
  21016. * @returns the effect associated with the material
  21017. */
  21018. getEffect(): Nullable<Effect>;
  21019. /**
  21020. * Returns the current scene
  21021. * @returns a Scene
  21022. */
  21023. getScene(): Scene;
  21024. /**
  21025. * Specifies if the material will require alpha blending
  21026. * @returns a boolean specifying if alpha blending is needed
  21027. */
  21028. needAlphaBlending(): boolean;
  21029. /**
  21030. * Specifies if the mesh will require alpha blending
  21031. * @param mesh defines the mesh to check
  21032. * @returns a boolean specifying if alpha blending is needed for the mesh
  21033. */
  21034. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21035. /**
  21036. * Specifies if this material should be rendered in alpha test mode
  21037. * @returns a boolean specifying if an alpha test is needed.
  21038. */
  21039. needAlphaTesting(): boolean;
  21040. /**
  21041. * Gets the texture used for the alpha test
  21042. * @returns the texture to use for alpha testing
  21043. */
  21044. getAlphaTestTexture(): Nullable<BaseTexture>;
  21045. /**
  21046. * Marks the material to indicate that it needs to be re-calculated
  21047. */
  21048. markDirty(): void;
  21049. /** @hidden */
  21050. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21051. /**
  21052. * Binds the material to the mesh
  21053. * @param world defines the world transformation matrix
  21054. * @param mesh defines the mesh to bind the material to
  21055. */
  21056. bind(world: Matrix, mesh?: Mesh): void;
  21057. /**
  21058. * Binds the submesh to the material
  21059. * @param world defines the world transformation matrix
  21060. * @param mesh defines the mesh containing the submesh
  21061. * @param subMesh defines the submesh to bind the material to
  21062. */
  21063. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21064. /**
  21065. * Binds the world matrix to the material
  21066. * @param world defines the world transformation matrix
  21067. */
  21068. bindOnlyWorldMatrix(world: Matrix): void;
  21069. /**
  21070. * Binds the scene's uniform buffer to the effect.
  21071. * @param effect defines the effect to bind to the scene uniform buffer
  21072. * @param sceneUbo defines the uniform buffer storing scene data
  21073. */
  21074. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21075. /**
  21076. * Binds the view matrix to the effect
  21077. * @param effect defines the effect to bind the view matrix to
  21078. */
  21079. bindView(effect: Effect): void;
  21080. /**
  21081. * Binds the view projection matrix to the effect
  21082. * @param effect defines the effect to bind the view projection matrix to
  21083. */
  21084. bindViewProjection(effect: Effect): void;
  21085. /**
  21086. * Specifies if material alpha testing should be turned on for the mesh
  21087. * @param mesh defines the mesh to check
  21088. */
  21089. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21090. /**
  21091. * Processes to execute after binding the material to a mesh
  21092. * @param mesh defines the rendered mesh
  21093. */
  21094. protected _afterBind(mesh?: Mesh): void;
  21095. /**
  21096. * Unbinds the material from the mesh
  21097. */
  21098. unbind(): void;
  21099. /**
  21100. * Gets the active textures from the material
  21101. * @returns an array of textures
  21102. */
  21103. getActiveTextures(): BaseTexture[];
  21104. /**
  21105. * Specifies if the material uses a texture
  21106. * @param texture defines the texture to check against the material
  21107. * @returns a boolean specifying if the material uses the texture
  21108. */
  21109. hasTexture(texture: BaseTexture): boolean;
  21110. /**
  21111. * Makes a duplicate of the material, and gives it a new name
  21112. * @param name defines the new name for the duplicated material
  21113. * @returns the cloned material
  21114. */
  21115. clone(name: string): Nullable<Material>;
  21116. /**
  21117. * Gets the meshes bound to the material
  21118. * @returns an array of meshes bound to the material
  21119. */
  21120. getBindedMeshes(): AbstractMesh[];
  21121. /**
  21122. * Force shader compilation
  21123. * @param mesh defines the mesh associated with this material
  21124. * @param onCompiled defines a function to execute once the material is compiled
  21125. * @param options defines the options to configure the compilation
  21126. */
  21127. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21128. clipPlane: boolean;
  21129. }>): void;
  21130. /**
  21131. * Force shader compilation
  21132. * @param mesh defines the mesh that will use this material
  21133. * @param options defines additional options for compiling the shaders
  21134. * @returns a promise that resolves when the compilation completes
  21135. */
  21136. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21137. clipPlane: boolean;
  21138. }>): Promise<void>;
  21139. private static readonly _AllDirtyCallBack;
  21140. private static readonly _ImageProcessingDirtyCallBack;
  21141. private static readonly _TextureDirtyCallBack;
  21142. private static readonly _FresnelDirtyCallBack;
  21143. private static readonly _MiscDirtyCallBack;
  21144. private static readonly _LightsDirtyCallBack;
  21145. private static readonly _AttributeDirtyCallBack;
  21146. private static _FresnelAndMiscDirtyCallBack;
  21147. private static _TextureAndMiscDirtyCallBack;
  21148. private static readonly _DirtyCallbackArray;
  21149. private static readonly _RunDirtyCallBacks;
  21150. /**
  21151. * Marks a define in the material to indicate that it needs to be re-computed
  21152. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21153. */
  21154. markAsDirty(flag: number): void;
  21155. /**
  21156. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21157. * @param func defines a function which checks material defines against the submeshes
  21158. */
  21159. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21160. /**
  21161. * Indicates that we need to re-calculated for all submeshes
  21162. */
  21163. protected _markAllSubMeshesAsAllDirty(): void;
  21164. /**
  21165. * Indicates that image processing needs to be re-calculated for all submeshes
  21166. */
  21167. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21168. /**
  21169. * Indicates that textures need to be re-calculated for all submeshes
  21170. */
  21171. protected _markAllSubMeshesAsTexturesDirty(): void;
  21172. /**
  21173. * Indicates that fresnel needs to be re-calculated for all submeshes
  21174. */
  21175. protected _markAllSubMeshesAsFresnelDirty(): void;
  21176. /**
  21177. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21178. */
  21179. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21180. /**
  21181. * Indicates that lights need to be re-calculated for all submeshes
  21182. */
  21183. protected _markAllSubMeshesAsLightsDirty(): void;
  21184. /**
  21185. * Indicates that attributes need to be re-calculated for all submeshes
  21186. */
  21187. protected _markAllSubMeshesAsAttributesDirty(): void;
  21188. /**
  21189. * Indicates that misc needs to be re-calculated for all submeshes
  21190. */
  21191. protected _markAllSubMeshesAsMiscDirty(): void;
  21192. /**
  21193. * Indicates that textures and misc need to be re-calculated for all submeshes
  21194. */
  21195. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21196. /**
  21197. * Disposes the material
  21198. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21199. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21200. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21201. */
  21202. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21203. /** @hidden */
  21204. private releaseVertexArrayObject;
  21205. /**
  21206. * Serializes this material
  21207. * @returns the serialized material object
  21208. */
  21209. serialize(): any;
  21210. /**
  21211. * Creates a material from parsed material data
  21212. * @param parsedMaterial defines parsed material data
  21213. * @param scene defines the hosting scene
  21214. * @param rootUrl defines the root URL to use to load textures
  21215. * @returns a new material
  21216. */
  21217. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21218. }
  21219. }
  21220. declare module "babylonjs/Materials/multiMaterial" {
  21221. import { Nullable } from "babylonjs/types";
  21222. import { Scene } from "babylonjs/scene";
  21223. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21224. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21225. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21226. import { Material } from "babylonjs/Materials/material";
  21227. /**
  21228. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21229. * separate meshes. This can be use to improve performances.
  21230. * @see http://doc.babylonjs.com/how_to/multi_materials
  21231. */
  21232. export class MultiMaterial extends Material {
  21233. private _subMaterials;
  21234. /**
  21235. * Gets or Sets the list of Materials used within the multi material.
  21236. * They need to be ordered according to the submeshes order in the associated mesh
  21237. */
  21238. subMaterials: Nullable<Material>[];
  21239. /**
  21240. * Function used to align with Node.getChildren()
  21241. * @returns the list of Materials used within the multi material
  21242. */
  21243. getChildren(): Nullable<Material>[];
  21244. /**
  21245. * Instantiates a new Multi Material
  21246. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21247. * separate meshes. This can be use to improve performances.
  21248. * @see http://doc.babylonjs.com/how_to/multi_materials
  21249. * @param name Define the name in the scene
  21250. * @param scene Define the scene the material belongs to
  21251. */
  21252. constructor(name: string, scene: Scene);
  21253. private _hookArray;
  21254. /**
  21255. * Get one of the submaterial by its index in the submaterials array
  21256. * @param index The index to look the sub material at
  21257. * @returns The Material if the index has been defined
  21258. */
  21259. getSubMaterial(index: number): Nullable<Material>;
  21260. /**
  21261. * Get the list of active textures for the whole sub materials list.
  21262. * @returns All the textures that will be used during the rendering
  21263. */
  21264. getActiveTextures(): BaseTexture[];
  21265. /**
  21266. * Gets the current class name of the material e.g. "MultiMaterial"
  21267. * Mainly use in serialization.
  21268. * @returns the class name
  21269. */
  21270. getClassName(): string;
  21271. /**
  21272. * Checks if the material is ready to render the requested sub mesh
  21273. * @param mesh Define the mesh the submesh belongs to
  21274. * @param subMesh Define the sub mesh to look readyness for
  21275. * @param useInstances Define whether or not the material is used with instances
  21276. * @returns true if ready, otherwise false
  21277. */
  21278. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21279. /**
  21280. * Clones the current material and its related sub materials
  21281. * @param name Define the name of the newly cloned material
  21282. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21283. * @returns the cloned material
  21284. */
  21285. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21286. /**
  21287. * Serializes the materials into a JSON representation.
  21288. * @returns the JSON representation
  21289. */
  21290. serialize(): any;
  21291. /**
  21292. * Dispose the material and release its associated resources
  21293. * @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)
  21294. * @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)
  21295. * @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)
  21296. */
  21297. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21298. /**
  21299. * Creates a MultiMaterial from parsed MultiMaterial data.
  21300. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21301. * @param scene defines the hosting scene
  21302. * @returns a new MultiMaterial
  21303. */
  21304. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21305. }
  21306. }
  21307. declare module "babylonjs/Meshes/subMesh" {
  21308. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21309. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21310. import { Engine } from "babylonjs/Engines/engine";
  21311. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21312. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21313. import { Effect } from "babylonjs/Materials/effect";
  21314. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21315. import { Plane } from "babylonjs/Maths/math.plane";
  21316. import { Collider } from "babylonjs/Collisions/collider";
  21317. import { Material } from "babylonjs/Materials/material";
  21318. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21320. import { Mesh } from "babylonjs/Meshes/mesh";
  21321. import { Ray } from "babylonjs/Culling/ray";
  21322. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21323. /**
  21324. * Base class for submeshes
  21325. */
  21326. export class BaseSubMesh {
  21327. /** @hidden */
  21328. _materialDefines: Nullable<MaterialDefines>;
  21329. /** @hidden */
  21330. _materialEffect: Nullable<Effect>;
  21331. /**
  21332. * Gets associated effect
  21333. */
  21334. readonly effect: Nullable<Effect>;
  21335. /**
  21336. * Sets associated effect (effect used to render this submesh)
  21337. * @param effect defines the effect to associate with
  21338. * @param defines defines the set of defines used to compile this effect
  21339. */
  21340. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21341. }
  21342. /**
  21343. * Defines a subdivision inside a mesh
  21344. */
  21345. export class SubMesh extends BaseSubMesh implements ICullable {
  21346. /** the material index to use */
  21347. materialIndex: number;
  21348. /** vertex index start */
  21349. verticesStart: number;
  21350. /** vertices count */
  21351. verticesCount: number;
  21352. /** index start */
  21353. indexStart: number;
  21354. /** indices count */
  21355. indexCount: number;
  21356. /** @hidden */
  21357. _linesIndexCount: number;
  21358. private _mesh;
  21359. private _renderingMesh;
  21360. private _boundingInfo;
  21361. private _linesIndexBuffer;
  21362. /** @hidden */
  21363. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21364. /** @hidden */
  21365. _trianglePlanes: Plane[];
  21366. /** @hidden */
  21367. _lastColliderTransformMatrix: Nullable<Matrix>;
  21368. /** @hidden */
  21369. _renderId: number;
  21370. /** @hidden */
  21371. _alphaIndex: number;
  21372. /** @hidden */
  21373. _distanceToCamera: number;
  21374. /** @hidden */
  21375. _id: number;
  21376. private _currentMaterial;
  21377. /**
  21378. * Add a new submesh to a mesh
  21379. * @param materialIndex defines the material index to use
  21380. * @param verticesStart defines vertex index start
  21381. * @param verticesCount defines vertices count
  21382. * @param indexStart defines index start
  21383. * @param indexCount defines indices count
  21384. * @param mesh defines the parent mesh
  21385. * @param renderingMesh defines an optional rendering mesh
  21386. * @param createBoundingBox defines if bounding box should be created for this submesh
  21387. * @returns the new submesh
  21388. */
  21389. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21390. /**
  21391. * Creates a new submesh
  21392. * @param materialIndex defines the material index to use
  21393. * @param verticesStart defines vertex index start
  21394. * @param verticesCount defines vertices count
  21395. * @param indexStart defines index start
  21396. * @param indexCount defines indices count
  21397. * @param mesh defines the parent mesh
  21398. * @param renderingMesh defines an optional rendering mesh
  21399. * @param createBoundingBox defines if bounding box should be created for this submesh
  21400. */
  21401. constructor(
  21402. /** the material index to use */
  21403. materialIndex: number,
  21404. /** vertex index start */
  21405. verticesStart: number,
  21406. /** vertices count */
  21407. verticesCount: number,
  21408. /** index start */
  21409. indexStart: number,
  21410. /** indices count */
  21411. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21412. /**
  21413. * Returns true if this submesh covers the entire parent mesh
  21414. * @ignorenaming
  21415. */
  21416. readonly IsGlobal: boolean;
  21417. /**
  21418. * Returns the submesh BoudingInfo object
  21419. * @returns current bounding info (or mesh's one if the submesh is global)
  21420. */
  21421. getBoundingInfo(): BoundingInfo;
  21422. /**
  21423. * Sets the submesh BoundingInfo
  21424. * @param boundingInfo defines the new bounding info to use
  21425. * @returns the SubMesh
  21426. */
  21427. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21428. /**
  21429. * Returns the mesh of the current submesh
  21430. * @return the parent mesh
  21431. */
  21432. getMesh(): AbstractMesh;
  21433. /**
  21434. * Returns the rendering mesh of the submesh
  21435. * @returns the rendering mesh (could be different from parent mesh)
  21436. */
  21437. getRenderingMesh(): Mesh;
  21438. /**
  21439. * Returns the submesh material
  21440. * @returns null or the current material
  21441. */
  21442. getMaterial(): Nullable<Material>;
  21443. /**
  21444. * Sets a new updated BoundingInfo object to the submesh
  21445. * @param data defines an optional position array to use to determine the bounding info
  21446. * @returns the SubMesh
  21447. */
  21448. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21449. /** @hidden */
  21450. _checkCollision(collider: Collider): boolean;
  21451. /**
  21452. * Updates the submesh BoundingInfo
  21453. * @param world defines the world matrix to use to update the bounding info
  21454. * @returns the submesh
  21455. */
  21456. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21457. /**
  21458. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21459. * @param frustumPlanes defines the frustum planes
  21460. * @returns true if the submesh is intersecting with the frustum
  21461. */
  21462. isInFrustum(frustumPlanes: Plane[]): boolean;
  21463. /**
  21464. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21465. * @param frustumPlanes defines the frustum planes
  21466. * @returns true if the submesh is inside the frustum
  21467. */
  21468. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21469. /**
  21470. * Renders the submesh
  21471. * @param enableAlphaMode defines if alpha needs to be used
  21472. * @returns the submesh
  21473. */
  21474. render(enableAlphaMode: boolean): SubMesh;
  21475. /**
  21476. * @hidden
  21477. */
  21478. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21479. /**
  21480. * Checks if the submesh intersects with a ray
  21481. * @param ray defines the ray to test
  21482. * @returns true is the passed ray intersects the submesh bounding box
  21483. */
  21484. canIntersects(ray: Ray): boolean;
  21485. /**
  21486. * Intersects current submesh with a ray
  21487. * @param ray defines the ray to test
  21488. * @param positions defines mesh's positions array
  21489. * @param indices defines mesh's indices array
  21490. * @param fastCheck defines if only bounding info should be used
  21491. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21492. * @returns intersection info or null if no intersection
  21493. */
  21494. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21495. /** @hidden */
  21496. private _intersectLines;
  21497. /** @hidden */
  21498. private _intersectUnIndexedLines;
  21499. /** @hidden */
  21500. private _intersectTriangles;
  21501. /** @hidden */
  21502. private _intersectUnIndexedTriangles;
  21503. /** @hidden */
  21504. _rebuild(): void;
  21505. /**
  21506. * Creates a new submesh from the passed mesh
  21507. * @param newMesh defines the new hosting mesh
  21508. * @param newRenderingMesh defines an optional rendering mesh
  21509. * @returns the new submesh
  21510. */
  21511. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21512. /**
  21513. * Release associated resources
  21514. */
  21515. dispose(): void;
  21516. /**
  21517. * Gets the class name
  21518. * @returns the string "SubMesh".
  21519. */
  21520. getClassName(): string;
  21521. /**
  21522. * Creates a new submesh from indices data
  21523. * @param materialIndex the index of the main mesh material
  21524. * @param startIndex the index where to start the copy in the mesh indices array
  21525. * @param indexCount the number of indices to copy then from the startIndex
  21526. * @param mesh the main mesh to create the submesh from
  21527. * @param renderingMesh the optional rendering mesh
  21528. * @returns a new submesh
  21529. */
  21530. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21531. }
  21532. }
  21533. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21534. /**
  21535. * Class used to represent data loading progression
  21536. */
  21537. export class SceneLoaderFlags {
  21538. private static _ForceFullSceneLoadingForIncremental;
  21539. private static _ShowLoadingScreen;
  21540. private static _CleanBoneMatrixWeights;
  21541. private static _loggingLevel;
  21542. /**
  21543. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21544. */
  21545. static ForceFullSceneLoadingForIncremental: boolean;
  21546. /**
  21547. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21548. */
  21549. static ShowLoadingScreen: boolean;
  21550. /**
  21551. * Defines the current logging level (while loading the scene)
  21552. * @ignorenaming
  21553. */
  21554. static loggingLevel: number;
  21555. /**
  21556. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21557. */
  21558. static CleanBoneMatrixWeights: boolean;
  21559. }
  21560. }
  21561. declare module "babylonjs/Meshes/geometry" {
  21562. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21563. import { Scene } from "babylonjs/scene";
  21564. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21565. import { Engine } from "babylonjs/Engines/engine";
  21566. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21567. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21568. import { Effect } from "babylonjs/Materials/effect";
  21569. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21570. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21571. import { Mesh } from "babylonjs/Meshes/mesh";
  21572. /**
  21573. * Class used to store geometry data (vertex buffers + index buffer)
  21574. */
  21575. export class Geometry implements IGetSetVerticesData {
  21576. /**
  21577. * Gets or sets the ID of the geometry
  21578. */
  21579. id: string;
  21580. /**
  21581. * Gets or sets the unique ID of the geometry
  21582. */
  21583. uniqueId: number;
  21584. /**
  21585. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21586. */
  21587. delayLoadState: number;
  21588. /**
  21589. * Gets the file containing the data to load when running in delay load state
  21590. */
  21591. delayLoadingFile: Nullable<string>;
  21592. /**
  21593. * Callback called when the geometry is updated
  21594. */
  21595. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21596. private _scene;
  21597. private _engine;
  21598. private _meshes;
  21599. private _totalVertices;
  21600. /** @hidden */
  21601. _indices: IndicesArray;
  21602. /** @hidden */
  21603. _vertexBuffers: {
  21604. [key: string]: VertexBuffer;
  21605. };
  21606. private _isDisposed;
  21607. private _extend;
  21608. private _boundingBias;
  21609. /** @hidden */
  21610. _delayInfo: Array<string>;
  21611. private _indexBuffer;
  21612. private _indexBufferIsUpdatable;
  21613. /** @hidden */
  21614. _boundingInfo: Nullable<BoundingInfo>;
  21615. /** @hidden */
  21616. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21617. /** @hidden */
  21618. _softwareSkinningFrameId: number;
  21619. private _vertexArrayObjects;
  21620. private _updatable;
  21621. /** @hidden */
  21622. _positions: Nullable<Vector3[]>;
  21623. /**
  21624. * 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
  21625. */
  21626. /**
  21627. * 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
  21628. */
  21629. boundingBias: Vector2;
  21630. /**
  21631. * Static function used to attach a new empty geometry to a mesh
  21632. * @param mesh defines the mesh to attach the geometry to
  21633. * @returns the new Geometry
  21634. */
  21635. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21636. /**
  21637. * Creates a new geometry
  21638. * @param id defines the unique ID
  21639. * @param scene defines the hosting scene
  21640. * @param vertexData defines the VertexData used to get geometry data
  21641. * @param updatable defines if geometry must be updatable (false by default)
  21642. * @param mesh defines the mesh that will be associated with the geometry
  21643. */
  21644. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21645. /**
  21646. * Gets the current extend of the geometry
  21647. */
  21648. readonly extend: {
  21649. minimum: Vector3;
  21650. maximum: Vector3;
  21651. };
  21652. /**
  21653. * Gets the hosting scene
  21654. * @returns the hosting Scene
  21655. */
  21656. getScene(): Scene;
  21657. /**
  21658. * Gets the hosting engine
  21659. * @returns the hosting Engine
  21660. */
  21661. getEngine(): Engine;
  21662. /**
  21663. * Defines if the geometry is ready to use
  21664. * @returns true if the geometry is ready to be used
  21665. */
  21666. isReady(): boolean;
  21667. /**
  21668. * Gets a value indicating that the geometry should not be serialized
  21669. */
  21670. readonly doNotSerialize: boolean;
  21671. /** @hidden */
  21672. _rebuild(): void;
  21673. /**
  21674. * Affects all geometry data in one call
  21675. * @param vertexData defines the geometry data
  21676. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21677. */
  21678. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21679. /**
  21680. * Set specific vertex data
  21681. * @param kind defines the data kind (Position, normal, etc...)
  21682. * @param data defines the vertex data to use
  21683. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21684. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21685. */
  21686. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21687. /**
  21688. * Removes a specific vertex data
  21689. * @param kind defines the data kind (Position, normal, etc...)
  21690. */
  21691. removeVerticesData(kind: string): void;
  21692. /**
  21693. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21694. * @param buffer defines the vertex buffer to use
  21695. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21696. */
  21697. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21698. /**
  21699. * Update a specific vertex buffer
  21700. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21701. * It will do nothing if the buffer is not updatable
  21702. * @param kind defines the data kind (Position, normal, etc...)
  21703. * @param data defines the data to use
  21704. * @param offset defines the offset in the target buffer where to store the data
  21705. * @param useBytes set to true if the offset is in bytes
  21706. */
  21707. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21708. /**
  21709. * Update a specific vertex buffer
  21710. * This function will create a new buffer if the current one is not updatable
  21711. * @param kind defines the data kind (Position, normal, etc...)
  21712. * @param data defines the data to use
  21713. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21714. */
  21715. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21716. private _updateBoundingInfo;
  21717. /** @hidden */
  21718. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21719. /**
  21720. * Gets total number of vertices
  21721. * @returns the total number of vertices
  21722. */
  21723. getTotalVertices(): number;
  21724. /**
  21725. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21726. * @param kind defines the data kind (Position, normal, etc...)
  21727. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21728. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21729. * @returns a float array containing vertex data
  21730. */
  21731. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21732. /**
  21733. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21734. * @param kind defines the data kind (Position, normal, etc...)
  21735. * @returns true if the vertex buffer with the specified kind is updatable
  21736. */
  21737. isVertexBufferUpdatable(kind: string): boolean;
  21738. /**
  21739. * Gets a specific vertex buffer
  21740. * @param kind defines the data kind (Position, normal, etc...)
  21741. * @returns a VertexBuffer
  21742. */
  21743. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21744. /**
  21745. * Returns all vertex buffers
  21746. * @return an object holding all vertex buffers indexed by kind
  21747. */
  21748. getVertexBuffers(): Nullable<{
  21749. [key: string]: VertexBuffer;
  21750. }>;
  21751. /**
  21752. * Gets a boolean indicating if specific vertex buffer is present
  21753. * @param kind defines the data kind (Position, normal, etc...)
  21754. * @returns true if data is present
  21755. */
  21756. isVerticesDataPresent(kind: string): boolean;
  21757. /**
  21758. * Gets a list of all attached data kinds (Position, normal, etc...)
  21759. * @returns a list of string containing all kinds
  21760. */
  21761. getVerticesDataKinds(): string[];
  21762. /**
  21763. * Update index buffer
  21764. * @param indices defines the indices to store in the index buffer
  21765. * @param offset defines the offset in the target buffer where to store the data
  21766. * @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)
  21767. */
  21768. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21769. /**
  21770. * Creates a new index buffer
  21771. * @param indices defines the indices to store in the index buffer
  21772. * @param totalVertices defines the total number of vertices (could be null)
  21773. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21774. */
  21775. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21776. /**
  21777. * Return the total number of indices
  21778. * @returns the total number of indices
  21779. */
  21780. getTotalIndices(): number;
  21781. /**
  21782. * Gets the index buffer array
  21783. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21784. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21785. * @returns the index buffer array
  21786. */
  21787. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21788. /**
  21789. * Gets the index buffer
  21790. * @return the index buffer
  21791. */
  21792. getIndexBuffer(): Nullable<DataBuffer>;
  21793. /** @hidden */
  21794. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21795. /**
  21796. * Release the associated resources for a specific mesh
  21797. * @param mesh defines the source mesh
  21798. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21799. */
  21800. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21801. /**
  21802. * Apply current geometry to a given mesh
  21803. * @param mesh defines the mesh to apply geometry to
  21804. */
  21805. applyToMesh(mesh: Mesh): void;
  21806. private _updateExtend;
  21807. private _applyToMesh;
  21808. private notifyUpdate;
  21809. /**
  21810. * Load the geometry if it was flagged as delay loaded
  21811. * @param scene defines the hosting scene
  21812. * @param onLoaded defines a callback called when the geometry is loaded
  21813. */
  21814. load(scene: Scene, onLoaded?: () => void): void;
  21815. private _queueLoad;
  21816. /**
  21817. * Invert the geometry to move from a right handed system to a left handed one.
  21818. */
  21819. toLeftHanded(): void;
  21820. /** @hidden */
  21821. _resetPointsArrayCache(): void;
  21822. /** @hidden */
  21823. _generatePointsArray(): boolean;
  21824. /**
  21825. * Gets a value indicating if the geometry is disposed
  21826. * @returns true if the geometry was disposed
  21827. */
  21828. isDisposed(): boolean;
  21829. private _disposeVertexArrayObjects;
  21830. /**
  21831. * Free all associated resources
  21832. */
  21833. dispose(): void;
  21834. /**
  21835. * Clone the current geometry into a new geometry
  21836. * @param id defines the unique ID of the new geometry
  21837. * @returns a new geometry object
  21838. */
  21839. copy(id: string): Geometry;
  21840. /**
  21841. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21842. * @return a JSON representation of the current geometry data (without the vertices data)
  21843. */
  21844. serialize(): any;
  21845. private toNumberArray;
  21846. /**
  21847. * Serialize all vertices data into a JSON oject
  21848. * @returns a JSON representation of the current geometry data
  21849. */
  21850. serializeVerticeData(): any;
  21851. /**
  21852. * Extracts a clone of a mesh geometry
  21853. * @param mesh defines the source mesh
  21854. * @param id defines the unique ID of the new geometry object
  21855. * @returns the new geometry object
  21856. */
  21857. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21858. /**
  21859. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21860. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21861. * Be aware Math.random() could cause collisions, but:
  21862. * "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"
  21863. * @returns a string containing a new GUID
  21864. */
  21865. static RandomId(): string;
  21866. /** @hidden */
  21867. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21868. private static _CleanMatricesWeights;
  21869. /**
  21870. * Create a new geometry from persisted data (Using .babylon file format)
  21871. * @param parsedVertexData defines the persisted data
  21872. * @param scene defines the hosting scene
  21873. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21874. * @returns the new geometry object
  21875. */
  21876. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21877. }
  21878. }
  21879. declare module "babylonjs/Meshes/mesh.vertexData" {
  21880. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21881. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21882. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21883. import { Geometry } from "babylonjs/Meshes/geometry";
  21884. import { Mesh } from "babylonjs/Meshes/mesh";
  21885. /**
  21886. * Define an interface for all classes that will get and set the data on vertices
  21887. */
  21888. export interface IGetSetVerticesData {
  21889. /**
  21890. * Gets a boolean indicating if specific vertex data is present
  21891. * @param kind defines the vertex data kind to use
  21892. * @returns true is data kind is present
  21893. */
  21894. isVerticesDataPresent(kind: string): boolean;
  21895. /**
  21896. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21897. * @param kind defines the data kind (Position, normal, etc...)
  21898. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21899. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21900. * @returns a float array containing vertex data
  21901. */
  21902. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21903. /**
  21904. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21905. * @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.
  21906. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21907. * @returns the indices array or an empty array if the mesh has no geometry
  21908. */
  21909. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21910. /**
  21911. * Set specific vertex data
  21912. * @param kind defines the data kind (Position, normal, etc...)
  21913. * @param data defines the vertex data to use
  21914. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21915. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21916. */
  21917. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21918. /**
  21919. * Update a specific associated vertex buffer
  21920. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21921. * - VertexBuffer.PositionKind
  21922. * - VertexBuffer.UVKind
  21923. * - VertexBuffer.UV2Kind
  21924. * - VertexBuffer.UV3Kind
  21925. * - VertexBuffer.UV4Kind
  21926. * - VertexBuffer.UV5Kind
  21927. * - VertexBuffer.UV6Kind
  21928. * - VertexBuffer.ColorKind
  21929. * - VertexBuffer.MatricesIndicesKind
  21930. * - VertexBuffer.MatricesIndicesExtraKind
  21931. * - VertexBuffer.MatricesWeightsKind
  21932. * - VertexBuffer.MatricesWeightsExtraKind
  21933. * @param data defines the data source
  21934. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21935. * @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)
  21936. */
  21937. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21938. /**
  21939. * Creates a new index buffer
  21940. * @param indices defines the indices to store in the index buffer
  21941. * @param totalVertices defines the total number of vertices (could be null)
  21942. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21943. */
  21944. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21945. }
  21946. /**
  21947. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21948. */
  21949. export class VertexData {
  21950. /**
  21951. * Mesh side orientation : usually the external or front surface
  21952. */
  21953. static readonly FRONTSIDE: number;
  21954. /**
  21955. * Mesh side orientation : usually the internal or back surface
  21956. */
  21957. static readonly BACKSIDE: number;
  21958. /**
  21959. * Mesh side orientation : both internal and external or front and back surfaces
  21960. */
  21961. static readonly DOUBLESIDE: number;
  21962. /**
  21963. * Mesh side orientation : by default, `FRONTSIDE`
  21964. */
  21965. static readonly DEFAULTSIDE: number;
  21966. /**
  21967. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21968. */
  21969. positions: Nullable<FloatArray>;
  21970. /**
  21971. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21972. */
  21973. normals: Nullable<FloatArray>;
  21974. /**
  21975. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21976. */
  21977. tangents: Nullable<FloatArray>;
  21978. /**
  21979. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21980. */
  21981. uvs: Nullable<FloatArray>;
  21982. /**
  21983. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21984. */
  21985. uvs2: Nullable<FloatArray>;
  21986. /**
  21987. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21988. */
  21989. uvs3: Nullable<FloatArray>;
  21990. /**
  21991. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21992. */
  21993. uvs4: Nullable<FloatArray>;
  21994. /**
  21995. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21996. */
  21997. uvs5: Nullable<FloatArray>;
  21998. /**
  21999. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22000. */
  22001. uvs6: Nullable<FloatArray>;
  22002. /**
  22003. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22004. */
  22005. colors: Nullable<FloatArray>;
  22006. /**
  22007. * 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).
  22008. */
  22009. matricesIndices: Nullable<FloatArray>;
  22010. /**
  22011. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22012. */
  22013. matricesWeights: Nullable<FloatArray>;
  22014. /**
  22015. * An array extending the number of possible indices
  22016. */
  22017. matricesIndicesExtra: Nullable<FloatArray>;
  22018. /**
  22019. * An array extending the number of possible weights when the number of indices is extended
  22020. */
  22021. matricesWeightsExtra: Nullable<FloatArray>;
  22022. /**
  22023. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22024. */
  22025. indices: Nullable<IndicesArray>;
  22026. /**
  22027. * Uses the passed data array to set the set the values for the specified kind of data
  22028. * @param data a linear array of floating numbers
  22029. * @param kind the type of data that is being set, eg positions, colors etc
  22030. */
  22031. set(data: FloatArray, kind: string): void;
  22032. /**
  22033. * Associates the vertexData to the passed Mesh.
  22034. * Sets it as updatable or not (default `false`)
  22035. * @param mesh the mesh the vertexData is applied to
  22036. * @param updatable when used and having the value true allows new data to update the vertexData
  22037. * @returns the VertexData
  22038. */
  22039. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22040. /**
  22041. * Associates the vertexData to the passed Geometry.
  22042. * Sets it as updatable or not (default `false`)
  22043. * @param geometry the geometry the vertexData is applied to
  22044. * @param updatable when used and having the value true allows new data to update the vertexData
  22045. * @returns VertexData
  22046. */
  22047. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22048. /**
  22049. * Updates the associated mesh
  22050. * @param mesh the mesh to be updated
  22051. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22052. * @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
  22053. * @returns VertexData
  22054. */
  22055. updateMesh(mesh: Mesh): VertexData;
  22056. /**
  22057. * Updates the associated geometry
  22058. * @param geometry the geometry to be updated
  22059. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22060. * @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
  22061. * @returns VertexData.
  22062. */
  22063. updateGeometry(geometry: Geometry): VertexData;
  22064. private _applyTo;
  22065. private _update;
  22066. /**
  22067. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22068. * @param matrix the transforming matrix
  22069. * @returns the VertexData
  22070. */
  22071. transform(matrix: Matrix): VertexData;
  22072. /**
  22073. * Merges the passed VertexData into the current one
  22074. * @param other the VertexData to be merged into the current one
  22075. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22076. * @returns the modified VertexData
  22077. */
  22078. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22079. private _mergeElement;
  22080. private _validate;
  22081. /**
  22082. * Serializes the VertexData
  22083. * @returns a serialized object
  22084. */
  22085. serialize(): any;
  22086. /**
  22087. * Extracts the vertexData from a mesh
  22088. * @param mesh the mesh from which to extract the VertexData
  22089. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22090. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22091. * @returns the object VertexData associated to the passed mesh
  22092. */
  22093. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22094. /**
  22095. * Extracts the vertexData from the geometry
  22096. * @param geometry the geometry from which to extract the VertexData
  22097. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22098. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22099. * @returns the object VertexData associated to the passed mesh
  22100. */
  22101. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22102. private static _ExtractFrom;
  22103. /**
  22104. * Creates the VertexData for a Ribbon
  22105. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22106. * * pathArray array of paths, each of which an array of successive Vector3
  22107. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22108. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22109. * * 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
  22110. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22111. * * 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)
  22112. * * 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)
  22113. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22114. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22115. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22116. * @returns the VertexData of the ribbon
  22117. */
  22118. static CreateRibbon(options: {
  22119. pathArray: Vector3[][];
  22120. closeArray?: boolean;
  22121. closePath?: boolean;
  22122. offset?: number;
  22123. sideOrientation?: number;
  22124. frontUVs?: Vector4;
  22125. backUVs?: Vector4;
  22126. invertUV?: boolean;
  22127. uvs?: Vector2[];
  22128. colors?: Color4[];
  22129. }): VertexData;
  22130. /**
  22131. * Creates the VertexData for a box
  22132. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22133. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22134. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22135. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22136. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22137. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22138. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22139. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22140. * * 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)
  22141. * * 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)
  22142. * @returns the VertexData of the box
  22143. */
  22144. static CreateBox(options: {
  22145. size?: number;
  22146. width?: number;
  22147. height?: number;
  22148. depth?: number;
  22149. faceUV?: Vector4[];
  22150. faceColors?: Color4[];
  22151. sideOrientation?: number;
  22152. frontUVs?: Vector4;
  22153. backUVs?: Vector4;
  22154. }): VertexData;
  22155. /**
  22156. * Creates the VertexData for a tiled box
  22157. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22158. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22159. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22160. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22161. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22162. * @returns the VertexData of the box
  22163. */
  22164. static CreateTiledBox(options: {
  22165. pattern?: number;
  22166. width?: number;
  22167. height?: number;
  22168. depth?: number;
  22169. tileSize?: number;
  22170. tileWidth?: number;
  22171. tileHeight?: number;
  22172. alignHorizontal?: number;
  22173. alignVertical?: number;
  22174. faceUV?: Vector4[];
  22175. faceColors?: Color4[];
  22176. sideOrientation?: number;
  22177. }): VertexData;
  22178. /**
  22179. * Creates the VertexData for a tiled plane
  22180. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22181. * * pattern a limited pattern arrangement depending on the number
  22182. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22183. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22184. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22185. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22186. * * 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)
  22187. * * 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)
  22188. * @returns the VertexData of the tiled plane
  22189. */
  22190. static CreateTiledPlane(options: {
  22191. pattern?: number;
  22192. tileSize?: number;
  22193. tileWidth?: number;
  22194. tileHeight?: number;
  22195. size?: number;
  22196. width?: number;
  22197. height?: number;
  22198. alignHorizontal?: number;
  22199. alignVertical?: number;
  22200. sideOrientation?: number;
  22201. frontUVs?: Vector4;
  22202. backUVs?: Vector4;
  22203. }): VertexData;
  22204. /**
  22205. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22206. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22207. * * segments sets the number of horizontal strips optional, default 32
  22208. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22209. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22210. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22211. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22212. * * 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
  22213. * * 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
  22214. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22215. * * 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)
  22216. * * 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)
  22217. * @returns the VertexData of the ellipsoid
  22218. */
  22219. static CreateSphere(options: {
  22220. segments?: number;
  22221. diameter?: number;
  22222. diameterX?: number;
  22223. diameterY?: number;
  22224. diameterZ?: number;
  22225. arc?: number;
  22226. slice?: number;
  22227. sideOrientation?: number;
  22228. frontUVs?: Vector4;
  22229. backUVs?: Vector4;
  22230. }): VertexData;
  22231. /**
  22232. * Creates the VertexData for a cylinder, cone or prism
  22233. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22234. * * height sets the height (y direction) of the cylinder, optional, default 2
  22235. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22236. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22237. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22238. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22239. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22240. * * 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
  22241. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22242. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22243. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22244. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22245. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22246. * * 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)
  22247. * * 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)
  22248. * @returns the VertexData of the cylinder, cone or prism
  22249. */
  22250. static CreateCylinder(options: {
  22251. height?: number;
  22252. diameterTop?: number;
  22253. diameterBottom?: number;
  22254. diameter?: number;
  22255. tessellation?: number;
  22256. subdivisions?: number;
  22257. arc?: number;
  22258. faceColors?: Color4[];
  22259. faceUV?: Vector4[];
  22260. hasRings?: boolean;
  22261. enclose?: boolean;
  22262. sideOrientation?: number;
  22263. frontUVs?: Vector4;
  22264. backUVs?: Vector4;
  22265. }): VertexData;
  22266. /**
  22267. * Creates the VertexData for a torus
  22268. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22269. * * diameter the diameter of the torus, optional default 1
  22270. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22271. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22272. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22273. * * 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)
  22274. * * 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)
  22275. * @returns the VertexData of the torus
  22276. */
  22277. static CreateTorus(options: {
  22278. diameter?: number;
  22279. thickness?: number;
  22280. tessellation?: number;
  22281. sideOrientation?: number;
  22282. frontUVs?: Vector4;
  22283. backUVs?: Vector4;
  22284. }): VertexData;
  22285. /**
  22286. * Creates the VertexData of the LineSystem
  22287. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22288. * - lines an array of lines, each line being an array of successive Vector3
  22289. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22290. * @returns the VertexData of the LineSystem
  22291. */
  22292. static CreateLineSystem(options: {
  22293. lines: Vector3[][];
  22294. colors?: Nullable<Color4[][]>;
  22295. }): VertexData;
  22296. /**
  22297. * Create the VertexData for a DashedLines
  22298. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22299. * - points an array successive Vector3
  22300. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22301. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22302. * - dashNb the intended total number of dashes, optional, default 200
  22303. * @returns the VertexData for the DashedLines
  22304. */
  22305. static CreateDashedLines(options: {
  22306. points: Vector3[];
  22307. dashSize?: number;
  22308. gapSize?: number;
  22309. dashNb?: number;
  22310. }): VertexData;
  22311. /**
  22312. * Creates the VertexData for a Ground
  22313. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22314. * - width the width (x direction) of the ground, optional, default 1
  22315. * - height the height (z direction) of the ground, optional, default 1
  22316. * - subdivisions the number of subdivisions per side, optional, default 1
  22317. * @returns the VertexData of the Ground
  22318. */
  22319. static CreateGround(options: {
  22320. width?: number;
  22321. height?: number;
  22322. subdivisions?: number;
  22323. subdivisionsX?: number;
  22324. subdivisionsY?: number;
  22325. }): VertexData;
  22326. /**
  22327. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22328. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22329. * * xmin the ground minimum X coordinate, optional, default -1
  22330. * * zmin the ground minimum Z coordinate, optional, default -1
  22331. * * xmax the ground maximum X coordinate, optional, default 1
  22332. * * zmax the ground maximum Z coordinate, optional, default 1
  22333. * * 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}
  22334. * * 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}
  22335. * @returns the VertexData of the TiledGround
  22336. */
  22337. static CreateTiledGround(options: {
  22338. xmin: number;
  22339. zmin: number;
  22340. xmax: number;
  22341. zmax: number;
  22342. subdivisions?: {
  22343. w: number;
  22344. h: number;
  22345. };
  22346. precision?: {
  22347. w: number;
  22348. h: number;
  22349. };
  22350. }): VertexData;
  22351. /**
  22352. * Creates the VertexData of the Ground designed from a heightmap
  22353. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22354. * * width the width (x direction) of the ground
  22355. * * height the height (z direction) of the ground
  22356. * * subdivisions the number of subdivisions per side
  22357. * * minHeight the minimum altitude on the ground, optional, default 0
  22358. * * maxHeight the maximum altitude on the ground, optional default 1
  22359. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22360. * * buffer the array holding the image color data
  22361. * * bufferWidth the width of image
  22362. * * bufferHeight the height of image
  22363. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22364. * @returns the VertexData of the Ground designed from a heightmap
  22365. */
  22366. static CreateGroundFromHeightMap(options: {
  22367. width: number;
  22368. height: number;
  22369. subdivisions: number;
  22370. minHeight: number;
  22371. maxHeight: number;
  22372. colorFilter: Color3;
  22373. buffer: Uint8Array;
  22374. bufferWidth: number;
  22375. bufferHeight: number;
  22376. alphaFilter: number;
  22377. }): VertexData;
  22378. /**
  22379. * Creates the VertexData for a Plane
  22380. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22381. * * size sets the width and height of the plane to the value of size, optional default 1
  22382. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22383. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22384. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22385. * * 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)
  22386. * * 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)
  22387. * @returns the VertexData of the box
  22388. */
  22389. static CreatePlane(options: {
  22390. size?: number;
  22391. width?: number;
  22392. height?: number;
  22393. sideOrientation?: number;
  22394. frontUVs?: Vector4;
  22395. backUVs?: Vector4;
  22396. }): VertexData;
  22397. /**
  22398. * Creates the VertexData of the Disc or regular Polygon
  22399. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22400. * * radius the radius of the disc, optional default 0.5
  22401. * * tessellation the number of polygon sides, optional, default 64
  22402. * * 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
  22403. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22404. * * 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)
  22405. * * 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)
  22406. * @returns the VertexData of the box
  22407. */
  22408. static CreateDisc(options: {
  22409. radius?: number;
  22410. tessellation?: number;
  22411. arc?: number;
  22412. sideOrientation?: number;
  22413. frontUVs?: Vector4;
  22414. backUVs?: Vector4;
  22415. }): VertexData;
  22416. /**
  22417. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22418. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22419. * @param polygon a mesh built from polygonTriangulation.build()
  22420. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22421. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22422. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22423. * @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)
  22424. * @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)
  22425. * @returns the VertexData of the Polygon
  22426. */
  22427. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22428. /**
  22429. * Creates the VertexData of the IcoSphere
  22430. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22431. * * radius the radius of the IcoSphere, optional default 1
  22432. * * radiusX allows stretching in the x direction, optional, default radius
  22433. * * radiusY allows stretching in the y direction, optional, default radius
  22434. * * radiusZ allows stretching in the z direction, optional, default radius
  22435. * * flat when true creates a flat shaded mesh, optional, default true
  22436. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22437. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22438. * * 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)
  22439. * * 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)
  22440. * @returns the VertexData of the IcoSphere
  22441. */
  22442. static CreateIcoSphere(options: {
  22443. radius?: number;
  22444. radiusX?: number;
  22445. radiusY?: number;
  22446. radiusZ?: number;
  22447. flat?: boolean;
  22448. subdivisions?: number;
  22449. sideOrientation?: number;
  22450. frontUVs?: Vector4;
  22451. backUVs?: Vector4;
  22452. }): VertexData;
  22453. /**
  22454. * Creates the VertexData for a Polyhedron
  22455. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22456. * * type provided types are:
  22457. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22458. * * 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)
  22459. * * size the size of the IcoSphere, optional default 1
  22460. * * sizeX allows stretching in the x direction, optional, default size
  22461. * * sizeY allows stretching in the y direction, optional, default size
  22462. * * sizeZ allows stretching in the z direction, optional, default size
  22463. * * 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
  22464. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22465. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22466. * * flat when true creates a flat shaded mesh, optional, default true
  22467. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22468. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22469. * * 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)
  22470. * * 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)
  22471. * @returns the VertexData of the Polyhedron
  22472. */
  22473. static CreatePolyhedron(options: {
  22474. type?: number;
  22475. size?: number;
  22476. sizeX?: number;
  22477. sizeY?: number;
  22478. sizeZ?: number;
  22479. custom?: any;
  22480. faceUV?: Vector4[];
  22481. faceColors?: Color4[];
  22482. flat?: boolean;
  22483. sideOrientation?: number;
  22484. frontUVs?: Vector4;
  22485. backUVs?: Vector4;
  22486. }): VertexData;
  22487. /**
  22488. * Creates the VertexData for a TorusKnot
  22489. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22490. * * radius the radius of the torus knot, optional, default 2
  22491. * * tube the thickness of the tube, optional, default 0.5
  22492. * * radialSegments the number of sides on each tube segments, optional, default 32
  22493. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22494. * * p the number of windings around the z axis, optional, default 2
  22495. * * q the number of windings around the x axis, optional, default 3
  22496. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22497. * * 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)
  22498. * * 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)
  22499. * @returns the VertexData of the Torus Knot
  22500. */
  22501. static CreateTorusKnot(options: {
  22502. radius?: number;
  22503. tube?: number;
  22504. radialSegments?: number;
  22505. tubularSegments?: number;
  22506. p?: number;
  22507. q?: number;
  22508. sideOrientation?: number;
  22509. frontUVs?: Vector4;
  22510. backUVs?: Vector4;
  22511. }): VertexData;
  22512. /**
  22513. * Compute normals for given positions and indices
  22514. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22515. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22516. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22517. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22518. * * facetNormals : optional array of facet normals (vector3)
  22519. * * facetPositions : optional array of facet positions (vector3)
  22520. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22521. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22522. * * bInfo : optional bounding info, required for facetPartitioning computation
  22523. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22524. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22525. * * useRightHandedSystem: optional boolean to for right handed system computation
  22526. * * depthSort : optional boolean to enable the facet depth sort computation
  22527. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22528. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22529. */
  22530. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22531. facetNormals?: any;
  22532. facetPositions?: any;
  22533. facetPartitioning?: any;
  22534. ratio?: number;
  22535. bInfo?: any;
  22536. bbSize?: Vector3;
  22537. subDiv?: any;
  22538. useRightHandedSystem?: boolean;
  22539. depthSort?: boolean;
  22540. distanceTo?: Vector3;
  22541. depthSortedFacets?: any;
  22542. }): void;
  22543. /** @hidden */
  22544. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22545. /**
  22546. * Applies VertexData created from the imported parameters to the geometry
  22547. * @param parsedVertexData the parsed data from an imported file
  22548. * @param geometry the geometry to apply the VertexData to
  22549. */
  22550. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22551. }
  22552. }
  22553. declare module "babylonjs/Morph/morphTarget" {
  22554. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22555. import { Observable } from "babylonjs/Misc/observable";
  22556. import { Nullable, FloatArray } from "babylonjs/types";
  22557. import { Scene } from "babylonjs/scene";
  22558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22559. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22560. /**
  22561. * Defines a target to use with MorphTargetManager
  22562. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22563. */
  22564. export class MorphTarget implements IAnimatable {
  22565. /** defines the name of the target */
  22566. name: string;
  22567. /**
  22568. * Gets or sets the list of animations
  22569. */
  22570. animations: import("babylonjs/Animations/animation").Animation[];
  22571. private _scene;
  22572. private _positions;
  22573. private _normals;
  22574. private _tangents;
  22575. private _uvs;
  22576. private _influence;
  22577. /**
  22578. * Observable raised when the influence changes
  22579. */
  22580. onInfluenceChanged: Observable<boolean>;
  22581. /** @hidden */
  22582. _onDataLayoutChanged: Observable<void>;
  22583. /**
  22584. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22585. */
  22586. influence: number;
  22587. /**
  22588. * Gets or sets the id of the morph Target
  22589. */
  22590. id: string;
  22591. private _animationPropertiesOverride;
  22592. /**
  22593. * Gets or sets the animation properties override
  22594. */
  22595. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22596. /**
  22597. * Creates a new MorphTarget
  22598. * @param name defines the name of the target
  22599. * @param influence defines the influence to use
  22600. * @param scene defines the scene the morphtarget belongs to
  22601. */
  22602. constructor(
  22603. /** defines the name of the target */
  22604. name: string, influence?: number, scene?: Nullable<Scene>);
  22605. /**
  22606. * Gets a boolean defining if the target contains position data
  22607. */
  22608. readonly hasPositions: boolean;
  22609. /**
  22610. * Gets a boolean defining if the target contains normal data
  22611. */
  22612. readonly hasNormals: boolean;
  22613. /**
  22614. * Gets a boolean defining if the target contains tangent data
  22615. */
  22616. readonly hasTangents: boolean;
  22617. /**
  22618. * Gets a boolean defining if the target contains texture coordinates data
  22619. */
  22620. readonly hasUVs: boolean;
  22621. /**
  22622. * Affects position data to this target
  22623. * @param data defines the position data to use
  22624. */
  22625. setPositions(data: Nullable<FloatArray>): void;
  22626. /**
  22627. * Gets the position data stored in this target
  22628. * @returns a FloatArray containing the position data (or null if not present)
  22629. */
  22630. getPositions(): Nullable<FloatArray>;
  22631. /**
  22632. * Affects normal data to this target
  22633. * @param data defines the normal data to use
  22634. */
  22635. setNormals(data: Nullable<FloatArray>): void;
  22636. /**
  22637. * Gets the normal data stored in this target
  22638. * @returns a FloatArray containing the normal data (or null if not present)
  22639. */
  22640. getNormals(): Nullable<FloatArray>;
  22641. /**
  22642. * Affects tangent data to this target
  22643. * @param data defines the tangent data to use
  22644. */
  22645. setTangents(data: Nullable<FloatArray>): void;
  22646. /**
  22647. * Gets the tangent data stored in this target
  22648. * @returns a FloatArray containing the tangent data (or null if not present)
  22649. */
  22650. getTangents(): Nullable<FloatArray>;
  22651. /**
  22652. * Affects texture coordinates data to this target
  22653. * @param data defines the texture coordinates data to use
  22654. */
  22655. setUVs(data: Nullable<FloatArray>): void;
  22656. /**
  22657. * Gets the texture coordinates data stored in this target
  22658. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22659. */
  22660. getUVs(): Nullable<FloatArray>;
  22661. /**
  22662. * Serializes the current target into a Serialization object
  22663. * @returns the serialized object
  22664. */
  22665. serialize(): any;
  22666. /**
  22667. * Returns the string "MorphTarget"
  22668. * @returns "MorphTarget"
  22669. */
  22670. getClassName(): string;
  22671. /**
  22672. * Creates a new target from serialized data
  22673. * @param serializationObject defines the serialized data to use
  22674. * @returns a new MorphTarget
  22675. */
  22676. static Parse(serializationObject: any): MorphTarget;
  22677. /**
  22678. * Creates a MorphTarget from mesh data
  22679. * @param mesh defines the source mesh
  22680. * @param name defines the name to use for the new target
  22681. * @param influence defines the influence to attach to the target
  22682. * @returns a new MorphTarget
  22683. */
  22684. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22685. }
  22686. }
  22687. declare module "babylonjs/Morph/morphTargetManager" {
  22688. import { Nullable } from "babylonjs/types";
  22689. import { Scene } from "babylonjs/scene";
  22690. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22691. /**
  22692. * This class is used to deform meshes using morphing between different targets
  22693. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22694. */
  22695. export class MorphTargetManager {
  22696. private _targets;
  22697. private _targetInfluenceChangedObservers;
  22698. private _targetDataLayoutChangedObservers;
  22699. private _activeTargets;
  22700. private _scene;
  22701. private _influences;
  22702. private _supportsNormals;
  22703. private _supportsTangents;
  22704. private _supportsUVs;
  22705. private _vertexCount;
  22706. private _uniqueId;
  22707. private _tempInfluences;
  22708. /**
  22709. * Gets or sets a boolean indicating if normals must be morphed
  22710. */
  22711. enableNormalMorphing: boolean;
  22712. /**
  22713. * Gets or sets a boolean indicating if tangents must be morphed
  22714. */
  22715. enableTangentMorphing: boolean;
  22716. /**
  22717. * Gets or sets a boolean indicating if UV must be morphed
  22718. */
  22719. enableUVMorphing: boolean;
  22720. /**
  22721. * Creates a new MorphTargetManager
  22722. * @param scene defines the current scene
  22723. */
  22724. constructor(scene?: Nullable<Scene>);
  22725. /**
  22726. * Gets the unique ID of this manager
  22727. */
  22728. readonly uniqueId: number;
  22729. /**
  22730. * Gets the number of vertices handled by this manager
  22731. */
  22732. readonly vertexCount: number;
  22733. /**
  22734. * Gets a boolean indicating if this manager supports morphing of normals
  22735. */
  22736. readonly supportsNormals: boolean;
  22737. /**
  22738. * Gets a boolean indicating if this manager supports morphing of tangents
  22739. */
  22740. readonly supportsTangents: boolean;
  22741. /**
  22742. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22743. */
  22744. readonly supportsUVs: boolean;
  22745. /**
  22746. * Gets the number of targets stored in this manager
  22747. */
  22748. readonly numTargets: number;
  22749. /**
  22750. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22751. */
  22752. readonly numInfluencers: number;
  22753. /**
  22754. * Gets the list of influences (one per target)
  22755. */
  22756. readonly influences: Float32Array;
  22757. /**
  22758. * Gets the active target at specified index. An active target is a target with an influence > 0
  22759. * @param index defines the index to check
  22760. * @returns the requested target
  22761. */
  22762. getActiveTarget(index: number): MorphTarget;
  22763. /**
  22764. * Gets the target at specified index
  22765. * @param index defines the index to check
  22766. * @returns the requested target
  22767. */
  22768. getTarget(index: number): MorphTarget;
  22769. /**
  22770. * Add a new target to this manager
  22771. * @param target defines the target to add
  22772. */
  22773. addTarget(target: MorphTarget): void;
  22774. /**
  22775. * Removes a target from the manager
  22776. * @param target defines the target to remove
  22777. */
  22778. removeTarget(target: MorphTarget): void;
  22779. /**
  22780. * Serializes the current manager into a Serialization object
  22781. * @returns the serialized object
  22782. */
  22783. serialize(): any;
  22784. private _syncActiveTargets;
  22785. /**
  22786. * Syncrhonize the targets with all the meshes using this morph target manager
  22787. */
  22788. synchronize(): void;
  22789. /**
  22790. * Creates a new MorphTargetManager from serialized data
  22791. * @param serializationObject defines the serialized data
  22792. * @param scene defines the hosting scene
  22793. * @returns the new MorphTargetManager
  22794. */
  22795. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22796. }
  22797. }
  22798. declare module "babylonjs/Meshes/meshLODLevel" {
  22799. import { Mesh } from "babylonjs/Meshes/mesh";
  22800. import { Nullable } from "babylonjs/types";
  22801. /**
  22802. * Class used to represent a specific level of detail of a mesh
  22803. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22804. */
  22805. export class MeshLODLevel {
  22806. /** Defines the distance where this level should start being displayed */
  22807. distance: number;
  22808. /** Defines the mesh to use to render this level */
  22809. mesh: Nullable<Mesh>;
  22810. /**
  22811. * Creates a new LOD level
  22812. * @param distance defines the distance where this level should star being displayed
  22813. * @param mesh defines the mesh to use to render this level
  22814. */
  22815. constructor(
  22816. /** Defines the distance where this level should start being displayed */
  22817. distance: number,
  22818. /** Defines the mesh to use to render this level */
  22819. mesh: Nullable<Mesh>);
  22820. }
  22821. }
  22822. declare module "babylonjs/Meshes/groundMesh" {
  22823. import { Scene } from "babylonjs/scene";
  22824. import { Vector3 } from "babylonjs/Maths/math.vector";
  22825. import { Mesh } from "babylonjs/Meshes/mesh";
  22826. /**
  22827. * Mesh representing the gorund
  22828. */
  22829. export class GroundMesh extends Mesh {
  22830. /** If octree should be generated */
  22831. generateOctree: boolean;
  22832. private _heightQuads;
  22833. /** @hidden */
  22834. _subdivisionsX: number;
  22835. /** @hidden */
  22836. _subdivisionsY: number;
  22837. /** @hidden */
  22838. _width: number;
  22839. /** @hidden */
  22840. _height: number;
  22841. /** @hidden */
  22842. _minX: number;
  22843. /** @hidden */
  22844. _maxX: number;
  22845. /** @hidden */
  22846. _minZ: number;
  22847. /** @hidden */
  22848. _maxZ: number;
  22849. constructor(name: string, scene: Scene);
  22850. /**
  22851. * "GroundMesh"
  22852. * @returns "GroundMesh"
  22853. */
  22854. getClassName(): string;
  22855. /**
  22856. * The minimum of x and y subdivisions
  22857. */
  22858. readonly subdivisions: number;
  22859. /**
  22860. * X subdivisions
  22861. */
  22862. readonly subdivisionsX: number;
  22863. /**
  22864. * Y subdivisions
  22865. */
  22866. readonly subdivisionsY: number;
  22867. /**
  22868. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22869. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22870. * @param chunksCount the number of subdivisions for x and y
  22871. * @param octreeBlocksSize (Default: 32)
  22872. */
  22873. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22874. /**
  22875. * Returns a height (y) value in the Worl system :
  22876. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22877. * @param x x coordinate
  22878. * @param z z coordinate
  22879. * @returns the ground y position if (x, z) are outside the ground surface.
  22880. */
  22881. getHeightAtCoordinates(x: number, z: number): number;
  22882. /**
  22883. * Returns a normalized vector (Vector3) orthogonal to the ground
  22884. * at the ground coordinates (x, z) expressed in the World system.
  22885. * @param x x coordinate
  22886. * @param z z coordinate
  22887. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22888. */
  22889. getNormalAtCoordinates(x: number, z: number): Vector3;
  22890. /**
  22891. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22892. * at the ground coordinates (x, z) expressed in the World system.
  22893. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22894. * @param x x coordinate
  22895. * @param z z coordinate
  22896. * @param ref vector to store the result
  22897. * @returns the GroundMesh.
  22898. */
  22899. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22900. /**
  22901. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22902. * if the ground has been updated.
  22903. * This can be used in the render loop.
  22904. * @returns the GroundMesh.
  22905. */
  22906. updateCoordinateHeights(): GroundMesh;
  22907. private _getFacetAt;
  22908. private _initHeightQuads;
  22909. private _computeHeightQuads;
  22910. /**
  22911. * Serializes this ground mesh
  22912. * @param serializationObject object to write serialization to
  22913. */
  22914. serialize(serializationObject: any): void;
  22915. /**
  22916. * Parses a serialized ground mesh
  22917. * @param parsedMesh the serialized mesh
  22918. * @param scene the scene to create the ground mesh in
  22919. * @returns the created ground mesh
  22920. */
  22921. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22922. }
  22923. }
  22924. declare module "babylonjs/Physics/physicsJoint" {
  22925. import { Vector3 } from "babylonjs/Maths/math.vector";
  22926. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22927. /**
  22928. * Interface for Physics-Joint data
  22929. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22930. */
  22931. export interface PhysicsJointData {
  22932. /**
  22933. * The main pivot of the joint
  22934. */
  22935. mainPivot?: Vector3;
  22936. /**
  22937. * The connected pivot of the joint
  22938. */
  22939. connectedPivot?: Vector3;
  22940. /**
  22941. * The main axis of the joint
  22942. */
  22943. mainAxis?: Vector3;
  22944. /**
  22945. * The connected axis of the joint
  22946. */
  22947. connectedAxis?: Vector3;
  22948. /**
  22949. * The collision of the joint
  22950. */
  22951. collision?: boolean;
  22952. /**
  22953. * Native Oimo/Cannon/Energy data
  22954. */
  22955. nativeParams?: any;
  22956. }
  22957. /**
  22958. * This is a holder class for the physics joint created by the physics plugin
  22959. * It holds a set of functions to control the underlying joint
  22960. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22961. */
  22962. export class PhysicsJoint {
  22963. /**
  22964. * The type of the physics joint
  22965. */
  22966. type: number;
  22967. /**
  22968. * The data for the physics joint
  22969. */
  22970. jointData: PhysicsJointData;
  22971. private _physicsJoint;
  22972. protected _physicsPlugin: IPhysicsEnginePlugin;
  22973. /**
  22974. * Initializes the physics joint
  22975. * @param type The type of the physics joint
  22976. * @param jointData The data for the physics joint
  22977. */
  22978. constructor(
  22979. /**
  22980. * The type of the physics joint
  22981. */
  22982. type: number,
  22983. /**
  22984. * The data for the physics joint
  22985. */
  22986. jointData: PhysicsJointData);
  22987. /**
  22988. * Gets the physics joint
  22989. */
  22990. /**
  22991. * Sets the physics joint
  22992. */
  22993. physicsJoint: any;
  22994. /**
  22995. * Sets the physics plugin
  22996. */
  22997. physicsPlugin: IPhysicsEnginePlugin;
  22998. /**
  22999. * Execute a function that is physics-plugin specific.
  23000. * @param {Function} func the function that will be executed.
  23001. * It accepts two parameters: the physics world and the physics joint
  23002. */
  23003. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23004. /**
  23005. * Distance-Joint type
  23006. */
  23007. static DistanceJoint: number;
  23008. /**
  23009. * Hinge-Joint type
  23010. */
  23011. static HingeJoint: number;
  23012. /**
  23013. * Ball-and-Socket joint type
  23014. */
  23015. static BallAndSocketJoint: number;
  23016. /**
  23017. * Wheel-Joint type
  23018. */
  23019. static WheelJoint: number;
  23020. /**
  23021. * Slider-Joint type
  23022. */
  23023. static SliderJoint: number;
  23024. /**
  23025. * Prismatic-Joint type
  23026. */
  23027. static PrismaticJoint: number;
  23028. /**
  23029. * Universal-Joint type
  23030. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23031. */
  23032. static UniversalJoint: number;
  23033. /**
  23034. * Hinge-Joint 2 type
  23035. */
  23036. static Hinge2Joint: number;
  23037. /**
  23038. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23039. */
  23040. static PointToPointJoint: number;
  23041. /**
  23042. * Spring-Joint type
  23043. */
  23044. static SpringJoint: number;
  23045. /**
  23046. * Lock-Joint type
  23047. */
  23048. static LockJoint: number;
  23049. }
  23050. /**
  23051. * A class representing a physics distance joint
  23052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23053. */
  23054. export class DistanceJoint extends PhysicsJoint {
  23055. /**
  23056. *
  23057. * @param jointData The data for the Distance-Joint
  23058. */
  23059. constructor(jointData: DistanceJointData);
  23060. /**
  23061. * Update the predefined distance.
  23062. * @param maxDistance The maximum preferred distance
  23063. * @param minDistance The minimum preferred distance
  23064. */
  23065. updateDistance(maxDistance: number, minDistance?: number): void;
  23066. }
  23067. /**
  23068. * Represents a Motor-Enabled Joint
  23069. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23070. */
  23071. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23072. /**
  23073. * Initializes the Motor-Enabled Joint
  23074. * @param type The type of the joint
  23075. * @param jointData The physica joint data for the joint
  23076. */
  23077. constructor(type: number, jointData: PhysicsJointData);
  23078. /**
  23079. * Set the motor values.
  23080. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23081. * @param force the force to apply
  23082. * @param maxForce max force for this motor.
  23083. */
  23084. setMotor(force?: number, maxForce?: number): void;
  23085. /**
  23086. * Set the motor's limits.
  23087. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23088. * @param upperLimit The upper limit of the motor
  23089. * @param lowerLimit The lower limit of the motor
  23090. */
  23091. setLimit(upperLimit: number, lowerLimit?: number): void;
  23092. }
  23093. /**
  23094. * This class represents a single physics Hinge-Joint
  23095. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23096. */
  23097. export class HingeJoint extends MotorEnabledJoint {
  23098. /**
  23099. * Initializes the Hinge-Joint
  23100. * @param jointData The joint data for the Hinge-Joint
  23101. */
  23102. constructor(jointData: PhysicsJointData);
  23103. /**
  23104. * Set the motor values.
  23105. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23106. * @param {number} force the force to apply
  23107. * @param {number} maxForce max force for this motor.
  23108. */
  23109. setMotor(force?: number, maxForce?: number): void;
  23110. /**
  23111. * Set the motor's limits.
  23112. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23113. * @param upperLimit The upper limit of the motor
  23114. * @param lowerLimit The lower limit of the motor
  23115. */
  23116. setLimit(upperLimit: number, lowerLimit?: number): void;
  23117. }
  23118. /**
  23119. * This class represents a dual hinge physics joint (same as wheel joint)
  23120. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23121. */
  23122. export class Hinge2Joint extends MotorEnabledJoint {
  23123. /**
  23124. * Initializes the Hinge2-Joint
  23125. * @param jointData The joint data for the Hinge2-Joint
  23126. */
  23127. constructor(jointData: PhysicsJointData);
  23128. /**
  23129. * Set the motor values.
  23130. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23131. * @param {number} targetSpeed the speed the motor is to reach
  23132. * @param {number} maxForce max force for this motor.
  23133. * @param {motorIndex} the motor's index, 0 or 1.
  23134. */
  23135. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23136. /**
  23137. * Set the motor limits.
  23138. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23139. * @param {number} upperLimit the upper limit
  23140. * @param {number} lowerLimit lower limit
  23141. * @param {motorIndex} the motor's index, 0 or 1.
  23142. */
  23143. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23144. }
  23145. /**
  23146. * Interface for a motor enabled joint
  23147. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23148. */
  23149. export interface IMotorEnabledJoint {
  23150. /**
  23151. * Physics joint
  23152. */
  23153. physicsJoint: any;
  23154. /**
  23155. * Sets the motor of the motor-enabled joint
  23156. * @param force The force of the motor
  23157. * @param maxForce The maximum force of the motor
  23158. * @param motorIndex The index of the motor
  23159. */
  23160. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23161. /**
  23162. * Sets the limit of the motor
  23163. * @param upperLimit The upper limit of the motor
  23164. * @param lowerLimit The lower limit of the motor
  23165. * @param motorIndex The index of the motor
  23166. */
  23167. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23168. }
  23169. /**
  23170. * Joint data for a Distance-Joint
  23171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23172. */
  23173. export interface DistanceJointData extends PhysicsJointData {
  23174. /**
  23175. * Max distance the 2 joint objects can be apart
  23176. */
  23177. maxDistance: number;
  23178. }
  23179. /**
  23180. * Joint data from a spring joint
  23181. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23182. */
  23183. export interface SpringJointData extends PhysicsJointData {
  23184. /**
  23185. * Length of the spring
  23186. */
  23187. length: number;
  23188. /**
  23189. * Stiffness of the spring
  23190. */
  23191. stiffness: number;
  23192. /**
  23193. * Damping of the spring
  23194. */
  23195. damping: number;
  23196. /** this callback will be called when applying the force to the impostors. */
  23197. forceApplicationCallback: () => void;
  23198. }
  23199. }
  23200. declare module "babylonjs/Physics/physicsRaycastResult" {
  23201. import { Vector3 } from "babylonjs/Maths/math.vector";
  23202. /**
  23203. * Holds the data for the raycast result
  23204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23205. */
  23206. export class PhysicsRaycastResult {
  23207. private _hasHit;
  23208. private _hitDistance;
  23209. private _hitNormalWorld;
  23210. private _hitPointWorld;
  23211. private _rayFromWorld;
  23212. private _rayToWorld;
  23213. /**
  23214. * Gets if there was a hit
  23215. */
  23216. readonly hasHit: boolean;
  23217. /**
  23218. * Gets the distance from the hit
  23219. */
  23220. readonly hitDistance: number;
  23221. /**
  23222. * Gets the hit normal/direction in the world
  23223. */
  23224. readonly hitNormalWorld: Vector3;
  23225. /**
  23226. * Gets the hit point in the world
  23227. */
  23228. readonly hitPointWorld: Vector3;
  23229. /**
  23230. * Gets the ray "start point" of the ray in the world
  23231. */
  23232. readonly rayFromWorld: Vector3;
  23233. /**
  23234. * Gets the ray "end point" of the ray in the world
  23235. */
  23236. readonly rayToWorld: Vector3;
  23237. /**
  23238. * Sets the hit data (normal & point in world space)
  23239. * @param hitNormalWorld defines the normal in world space
  23240. * @param hitPointWorld defines the point in world space
  23241. */
  23242. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23243. /**
  23244. * Sets the distance from the start point to the hit point
  23245. * @param distance
  23246. */
  23247. setHitDistance(distance: number): void;
  23248. /**
  23249. * Calculates the distance manually
  23250. */
  23251. calculateHitDistance(): void;
  23252. /**
  23253. * Resets all the values to default
  23254. * @param from The from point on world space
  23255. * @param to The to point on world space
  23256. */
  23257. reset(from?: Vector3, to?: Vector3): void;
  23258. }
  23259. /**
  23260. * Interface for the size containing width and height
  23261. */
  23262. interface IXYZ {
  23263. /**
  23264. * X
  23265. */
  23266. x: number;
  23267. /**
  23268. * Y
  23269. */
  23270. y: number;
  23271. /**
  23272. * Z
  23273. */
  23274. z: number;
  23275. }
  23276. }
  23277. declare module "babylonjs/Physics/IPhysicsEngine" {
  23278. import { Nullable } from "babylonjs/types";
  23279. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23280. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23281. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23282. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23283. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23284. /**
  23285. * Interface used to describe a physics joint
  23286. */
  23287. export interface PhysicsImpostorJoint {
  23288. /** Defines the main impostor to which the joint is linked */
  23289. mainImpostor: PhysicsImpostor;
  23290. /** Defines the impostor that is connected to the main impostor using this joint */
  23291. connectedImpostor: PhysicsImpostor;
  23292. /** Defines the joint itself */
  23293. joint: PhysicsJoint;
  23294. }
  23295. /** @hidden */
  23296. export interface IPhysicsEnginePlugin {
  23297. world: any;
  23298. name: string;
  23299. setGravity(gravity: Vector3): void;
  23300. setTimeStep(timeStep: number): void;
  23301. getTimeStep(): number;
  23302. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23303. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23304. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23305. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23306. removePhysicsBody(impostor: PhysicsImpostor): void;
  23307. generateJoint(joint: PhysicsImpostorJoint): void;
  23308. removeJoint(joint: PhysicsImpostorJoint): void;
  23309. isSupported(): boolean;
  23310. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23311. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23312. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23313. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23314. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23315. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23316. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23317. getBodyMass(impostor: PhysicsImpostor): number;
  23318. getBodyFriction(impostor: PhysicsImpostor): number;
  23319. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23320. getBodyRestitution(impostor: PhysicsImpostor): number;
  23321. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23322. getBodyPressure?(impostor: PhysicsImpostor): number;
  23323. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23324. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23325. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23326. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23327. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23328. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23329. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23330. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23331. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23332. sleepBody(impostor: PhysicsImpostor): void;
  23333. wakeUpBody(impostor: PhysicsImpostor): void;
  23334. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23335. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23336. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23337. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23338. getRadius(impostor: PhysicsImpostor): number;
  23339. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23340. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23341. dispose(): void;
  23342. }
  23343. /**
  23344. * Interface used to define a physics engine
  23345. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23346. */
  23347. export interface IPhysicsEngine {
  23348. /**
  23349. * Gets the gravity vector used by the simulation
  23350. */
  23351. gravity: Vector3;
  23352. /**
  23353. * Sets the gravity vector used by the simulation
  23354. * @param gravity defines the gravity vector to use
  23355. */
  23356. setGravity(gravity: Vector3): void;
  23357. /**
  23358. * Set the time step of the physics engine.
  23359. * Default is 1/60.
  23360. * To slow it down, enter 1/600 for example.
  23361. * To speed it up, 1/30
  23362. * @param newTimeStep the new timestep to apply to this world.
  23363. */
  23364. setTimeStep(newTimeStep: number): void;
  23365. /**
  23366. * Get the time step of the physics engine.
  23367. * @returns the current time step
  23368. */
  23369. getTimeStep(): number;
  23370. /**
  23371. * Release all resources
  23372. */
  23373. dispose(): void;
  23374. /**
  23375. * Gets the name of the current physics plugin
  23376. * @returns the name of the plugin
  23377. */
  23378. getPhysicsPluginName(): string;
  23379. /**
  23380. * Adding a new impostor for the impostor tracking.
  23381. * This will be done by the impostor itself.
  23382. * @param impostor the impostor to add
  23383. */
  23384. addImpostor(impostor: PhysicsImpostor): void;
  23385. /**
  23386. * Remove an impostor from the engine.
  23387. * This impostor and its mesh will not longer be updated by the physics engine.
  23388. * @param impostor the impostor to remove
  23389. */
  23390. removeImpostor(impostor: PhysicsImpostor): void;
  23391. /**
  23392. * Add a joint to the physics engine
  23393. * @param mainImpostor defines the main impostor to which the joint is added.
  23394. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23395. * @param joint defines the joint that will connect both impostors.
  23396. */
  23397. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23398. /**
  23399. * Removes a joint from the simulation
  23400. * @param mainImpostor defines the impostor used with the joint
  23401. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23402. * @param joint defines the joint to remove
  23403. */
  23404. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23405. /**
  23406. * Gets the current plugin used to run the simulation
  23407. * @returns current plugin
  23408. */
  23409. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23410. /**
  23411. * Gets the list of physic impostors
  23412. * @returns an array of PhysicsImpostor
  23413. */
  23414. getImpostors(): Array<PhysicsImpostor>;
  23415. /**
  23416. * Gets the impostor for a physics enabled object
  23417. * @param object defines the object impersonated by the impostor
  23418. * @returns the PhysicsImpostor or null if not found
  23419. */
  23420. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23421. /**
  23422. * Gets the impostor for a physics body object
  23423. * @param body defines physics body used by the impostor
  23424. * @returns the PhysicsImpostor or null if not found
  23425. */
  23426. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23427. /**
  23428. * Does a raycast in the physics world
  23429. * @param from when should the ray start?
  23430. * @param to when should the ray end?
  23431. * @returns PhysicsRaycastResult
  23432. */
  23433. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23434. /**
  23435. * Called by the scene. No need to call it.
  23436. * @param delta defines the timespam between frames
  23437. */
  23438. _step(delta: number): void;
  23439. }
  23440. }
  23441. declare module "babylonjs/Physics/physicsImpostor" {
  23442. import { Nullable, IndicesArray } from "babylonjs/types";
  23443. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23444. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23445. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23446. import { Scene } from "babylonjs/scene";
  23447. import { Bone } from "babylonjs/Bones/bone";
  23448. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23449. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23450. import { Space } from "babylonjs/Maths/math.axis";
  23451. /**
  23452. * The interface for the physics imposter parameters
  23453. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23454. */
  23455. export interface PhysicsImpostorParameters {
  23456. /**
  23457. * The mass of the physics imposter
  23458. */
  23459. mass: number;
  23460. /**
  23461. * The friction of the physics imposter
  23462. */
  23463. friction?: number;
  23464. /**
  23465. * The coefficient of restitution of the physics imposter
  23466. */
  23467. restitution?: number;
  23468. /**
  23469. * The native options of the physics imposter
  23470. */
  23471. nativeOptions?: any;
  23472. /**
  23473. * Specifies if the parent should be ignored
  23474. */
  23475. ignoreParent?: boolean;
  23476. /**
  23477. * Specifies if bi-directional transformations should be disabled
  23478. */
  23479. disableBidirectionalTransformation?: boolean;
  23480. /**
  23481. * The pressure inside the physics imposter, soft object only
  23482. */
  23483. pressure?: number;
  23484. /**
  23485. * The stiffness the physics imposter, soft object only
  23486. */
  23487. stiffness?: number;
  23488. /**
  23489. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23490. */
  23491. velocityIterations?: number;
  23492. /**
  23493. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23494. */
  23495. positionIterations?: number;
  23496. /**
  23497. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23498. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23499. * Add to fix multiple points
  23500. */
  23501. fixedPoints?: number;
  23502. /**
  23503. * The collision margin around a soft object
  23504. */
  23505. margin?: number;
  23506. /**
  23507. * The collision margin around a soft object
  23508. */
  23509. damping?: number;
  23510. /**
  23511. * The path for a rope based on an extrusion
  23512. */
  23513. path?: any;
  23514. /**
  23515. * The shape of an extrusion used for a rope based on an extrusion
  23516. */
  23517. shape?: any;
  23518. }
  23519. /**
  23520. * Interface for a physics-enabled object
  23521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23522. */
  23523. export interface IPhysicsEnabledObject {
  23524. /**
  23525. * The position of the physics-enabled object
  23526. */
  23527. position: Vector3;
  23528. /**
  23529. * The rotation of the physics-enabled object
  23530. */
  23531. rotationQuaternion: Nullable<Quaternion>;
  23532. /**
  23533. * The scale of the physics-enabled object
  23534. */
  23535. scaling: Vector3;
  23536. /**
  23537. * The rotation of the physics-enabled object
  23538. */
  23539. rotation?: Vector3;
  23540. /**
  23541. * The parent of the physics-enabled object
  23542. */
  23543. parent?: any;
  23544. /**
  23545. * The bounding info of the physics-enabled object
  23546. * @returns The bounding info of the physics-enabled object
  23547. */
  23548. getBoundingInfo(): BoundingInfo;
  23549. /**
  23550. * Computes the world matrix
  23551. * @param force Specifies if the world matrix should be computed by force
  23552. * @returns A world matrix
  23553. */
  23554. computeWorldMatrix(force: boolean): Matrix;
  23555. /**
  23556. * Gets the world matrix
  23557. * @returns A world matrix
  23558. */
  23559. getWorldMatrix?(): Matrix;
  23560. /**
  23561. * Gets the child meshes
  23562. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23563. * @returns An array of abstract meshes
  23564. */
  23565. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23566. /**
  23567. * Gets the vertex data
  23568. * @param kind The type of vertex data
  23569. * @returns A nullable array of numbers, or a float32 array
  23570. */
  23571. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23572. /**
  23573. * Gets the indices from the mesh
  23574. * @returns A nullable array of index arrays
  23575. */
  23576. getIndices?(): Nullable<IndicesArray>;
  23577. /**
  23578. * Gets the scene from the mesh
  23579. * @returns the indices array or null
  23580. */
  23581. getScene?(): Scene;
  23582. /**
  23583. * Gets the absolute position from the mesh
  23584. * @returns the absolute position
  23585. */
  23586. getAbsolutePosition(): Vector3;
  23587. /**
  23588. * Gets the absolute pivot point from the mesh
  23589. * @returns the absolute pivot point
  23590. */
  23591. getAbsolutePivotPoint(): Vector3;
  23592. /**
  23593. * Rotates the mesh
  23594. * @param axis The axis of rotation
  23595. * @param amount The amount of rotation
  23596. * @param space The space of the rotation
  23597. * @returns The rotation transform node
  23598. */
  23599. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23600. /**
  23601. * Translates the mesh
  23602. * @param axis The axis of translation
  23603. * @param distance The distance of translation
  23604. * @param space The space of the translation
  23605. * @returns The transform node
  23606. */
  23607. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23608. /**
  23609. * Sets the absolute position of the mesh
  23610. * @param absolutePosition The absolute position of the mesh
  23611. * @returns The transform node
  23612. */
  23613. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23614. /**
  23615. * Gets the class name of the mesh
  23616. * @returns The class name
  23617. */
  23618. getClassName(): string;
  23619. }
  23620. /**
  23621. * Represents a physics imposter
  23622. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23623. */
  23624. export class PhysicsImpostor {
  23625. /**
  23626. * The physics-enabled object used as the physics imposter
  23627. */
  23628. object: IPhysicsEnabledObject;
  23629. /**
  23630. * The type of the physics imposter
  23631. */
  23632. type: number;
  23633. private _options;
  23634. private _scene?;
  23635. /**
  23636. * The default object size of the imposter
  23637. */
  23638. static DEFAULT_OBJECT_SIZE: Vector3;
  23639. /**
  23640. * The identity quaternion of the imposter
  23641. */
  23642. static IDENTITY_QUATERNION: Quaternion;
  23643. /** @hidden */
  23644. _pluginData: any;
  23645. private _physicsEngine;
  23646. private _physicsBody;
  23647. private _bodyUpdateRequired;
  23648. private _onBeforePhysicsStepCallbacks;
  23649. private _onAfterPhysicsStepCallbacks;
  23650. /** @hidden */
  23651. _onPhysicsCollideCallbacks: Array<{
  23652. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23653. otherImpostors: Array<PhysicsImpostor>;
  23654. }>;
  23655. private _deltaPosition;
  23656. private _deltaRotation;
  23657. private _deltaRotationConjugated;
  23658. /** @hidden */
  23659. _isFromLine: boolean;
  23660. private _parent;
  23661. private _isDisposed;
  23662. private static _tmpVecs;
  23663. private static _tmpQuat;
  23664. /**
  23665. * Specifies if the physics imposter is disposed
  23666. */
  23667. readonly isDisposed: boolean;
  23668. /**
  23669. * Gets the mass of the physics imposter
  23670. */
  23671. mass: number;
  23672. /**
  23673. * Gets the coefficient of friction
  23674. */
  23675. /**
  23676. * Sets the coefficient of friction
  23677. */
  23678. friction: number;
  23679. /**
  23680. * Gets the coefficient of restitution
  23681. */
  23682. /**
  23683. * Sets the coefficient of restitution
  23684. */
  23685. restitution: number;
  23686. /**
  23687. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23688. */
  23689. /**
  23690. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23691. */
  23692. pressure: number;
  23693. /**
  23694. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23695. */
  23696. /**
  23697. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23698. */
  23699. stiffness: number;
  23700. /**
  23701. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23702. */
  23703. /**
  23704. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23705. */
  23706. velocityIterations: number;
  23707. /**
  23708. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23709. */
  23710. /**
  23711. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23712. */
  23713. positionIterations: number;
  23714. /**
  23715. * The unique id of the physics imposter
  23716. * set by the physics engine when adding this impostor to the array
  23717. */
  23718. uniqueId: number;
  23719. /**
  23720. * @hidden
  23721. */
  23722. soft: boolean;
  23723. /**
  23724. * @hidden
  23725. */
  23726. segments: number;
  23727. private _joints;
  23728. /**
  23729. * Initializes the physics imposter
  23730. * @param object The physics-enabled object used as the physics imposter
  23731. * @param type The type of the physics imposter
  23732. * @param _options The options for the physics imposter
  23733. * @param _scene The Babylon scene
  23734. */
  23735. constructor(
  23736. /**
  23737. * The physics-enabled object used as the physics imposter
  23738. */
  23739. object: IPhysicsEnabledObject,
  23740. /**
  23741. * The type of the physics imposter
  23742. */
  23743. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23744. /**
  23745. * This function will completly initialize this impostor.
  23746. * It will create a new body - but only if this mesh has no parent.
  23747. * If it has, this impostor will not be used other than to define the impostor
  23748. * of the child mesh.
  23749. * @hidden
  23750. */
  23751. _init(): void;
  23752. private _getPhysicsParent;
  23753. /**
  23754. * Should a new body be generated.
  23755. * @returns boolean specifying if body initialization is required
  23756. */
  23757. isBodyInitRequired(): boolean;
  23758. /**
  23759. * Sets the updated scaling
  23760. * @param updated Specifies if the scaling is updated
  23761. */
  23762. setScalingUpdated(): void;
  23763. /**
  23764. * Force a regeneration of this or the parent's impostor's body.
  23765. * Use under cautious - This will remove all joints already implemented.
  23766. */
  23767. forceUpdate(): void;
  23768. /**
  23769. * Gets the body that holds this impostor. Either its own, or its parent.
  23770. */
  23771. /**
  23772. * Set the physics body. Used mainly by the physics engine/plugin
  23773. */
  23774. physicsBody: any;
  23775. /**
  23776. * Get the parent of the physics imposter
  23777. * @returns Physics imposter or null
  23778. */
  23779. /**
  23780. * Sets the parent of the physics imposter
  23781. */
  23782. parent: Nullable<PhysicsImpostor>;
  23783. /**
  23784. * Resets the update flags
  23785. */
  23786. resetUpdateFlags(): void;
  23787. /**
  23788. * Gets the object extend size
  23789. * @returns the object extend size
  23790. */
  23791. getObjectExtendSize(): Vector3;
  23792. /**
  23793. * Gets the object center
  23794. * @returns The object center
  23795. */
  23796. getObjectCenter(): Vector3;
  23797. /**
  23798. * Get a specific parametes from the options parameter
  23799. * @param paramName The object parameter name
  23800. * @returns The object parameter
  23801. */
  23802. getParam(paramName: string): any;
  23803. /**
  23804. * Sets a specific parameter in the options given to the physics plugin
  23805. * @param paramName The parameter name
  23806. * @param value The value of the parameter
  23807. */
  23808. setParam(paramName: string, value: number): void;
  23809. /**
  23810. * Specifically change the body's mass option. Won't recreate the physics body object
  23811. * @param mass The mass of the physics imposter
  23812. */
  23813. setMass(mass: number): void;
  23814. /**
  23815. * Gets the linear velocity
  23816. * @returns linear velocity or null
  23817. */
  23818. getLinearVelocity(): Nullable<Vector3>;
  23819. /**
  23820. * Sets the linear velocity
  23821. * @param velocity linear velocity or null
  23822. */
  23823. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23824. /**
  23825. * Gets the angular velocity
  23826. * @returns angular velocity or null
  23827. */
  23828. getAngularVelocity(): Nullable<Vector3>;
  23829. /**
  23830. * Sets the angular velocity
  23831. * @param velocity The velocity or null
  23832. */
  23833. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23834. /**
  23835. * Execute a function with the physics plugin native code
  23836. * Provide a function the will have two variables - the world object and the physics body object
  23837. * @param func The function to execute with the physics plugin native code
  23838. */
  23839. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23840. /**
  23841. * Register a function that will be executed before the physics world is stepping forward
  23842. * @param func The function to execute before the physics world is stepped forward
  23843. */
  23844. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23845. /**
  23846. * Unregister a function that will be executed before the physics world is stepping forward
  23847. * @param func The function to execute before the physics world is stepped forward
  23848. */
  23849. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23850. /**
  23851. * Register a function that will be executed after the physics step
  23852. * @param func The function to execute after physics step
  23853. */
  23854. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23855. /**
  23856. * Unregisters a function that will be executed after the physics step
  23857. * @param func The function to execute after physics step
  23858. */
  23859. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23860. /**
  23861. * register a function that will be executed when this impostor collides against a different body
  23862. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23863. * @param func Callback that is executed on collision
  23864. */
  23865. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23866. /**
  23867. * Unregisters the physics imposter on contact
  23868. * @param collideAgainst The physics object to collide against
  23869. * @param func Callback to execute on collision
  23870. */
  23871. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23872. private _tmpQuat;
  23873. private _tmpQuat2;
  23874. /**
  23875. * Get the parent rotation
  23876. * @returns The parent rotation
  23877. */
  23878. getParentsRotation(): Quaternion;
  23879. /**
  23880. * this function is executed by the physics engine.
  23881. */
  23882. beforeStep: () => void;
  23883. /**
  23884. * this function is executed by the physics engine
  23885. */
  23886. afterStep: () => void;
  23887. /**
  23888. * Legacy collision detection event support
  23889. */
  23890. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23891. /**
  23892. * event and body object due to cannon's event-based architecture.
  23893. */
  23894. onCollide: (e: {
  23895. body: any;
  23896. }) => void;
  23897. /**
  23898. * Apply a force
  23899. * @param force The force to apply
  23900. * @param contactPoint The contact point for the force
  23901. * @returns The physics imposter
  23902. */
  23903. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23904. /**
  23905. * Apply an impulse
  23906. * @param force The impulse force
  23907. * @param contactPoint The contact point for the impulse force
  23908. * @returns The physics imposter
  23909. */
  23910. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23911. /**
  23912. * A help function to create a joint
  23913. * @param otherImpostor A physics imposter used to create a joint
  23914. * @param jointType The type of joint
  23915. * @param jointData The data for the joint
  23916. * @returns The physics imposter
  23917. */
  23918. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23919. /**
  23920. * Add a joint to this impostor with a different impostor
  23921. * @param otherImpostor A physics imposter used to add a joint
  23922. * @param joint The joint to add
  23923. * @returns The physics imposter
  23924. */
  23925. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23926. /**
  23927. * Add an anchor to a cloth impostor
  23928. * @param otherImpostor rigid impostor to anchor to
  23929. * @param width ratio across width from 0 to 1
  23930. * @param height ratio up height from 0 to 1
  23931. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23932. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23933. * @returns impostor the soft imposter
  23934. */
  23935. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23936. /**
  23937. * Add a hook to a rope impostor
  23938. * @param otherImpostor rigid impostor to anchor to
  23939. * @param length ratio across rope from 0 to 1
  23940. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23941. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23942. * @returns impostor the rope imposter
  23943. */
  23944. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23945. /**
  23946. * Will keep this body still, in a sleep mode.
  23947. * @returns the physics imposter
  23948. */
  23949. sleep(): PhysicsImpostor;
  23950. /**
  23951. * Wake the body up.
  23952. * @returns The physics imposter
  23953. */
  23954. wakeUp(): PhysicsImpostor;
  23955. /**
  23956. * Clones the physics imposter
  23957. * @param newObject The physics imposter clones to this physics-enabled object
  23958. * @returns A nullable physics imposter
  23959. */
  23960. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23961. /**
  23962. * Disposes the physics imposter
  23963. */
  23964. dispose(): void;
  23965. /**
  23966. * Sets the delta position
  23967. * @param position The delta position amount
  23968. */
  23969. setDeltaPosition(position: Vector3): void;
  23970. /**
  23971. * Sets the delta rotation
  23972. * @param rotation The delta rotation amount
  23973. */
  23974. setDeltaRotation(rotation: Quaternion): void;
  23975. /**
  23976. * Gets the box size of the physics imposter and stores the result in the input parameter
  23977. * @param result Stores the box size
  23978. * @returns The physics imposter
  23979. */
  23980. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23981. /**
  23982. * Gets the radius of the physics imposter
  23983. * @returns Radius of the physics imposter
  23984. */
  23985. getRadius(): number;
  23986. /**
  23987. * Sync a bone with this impostor
  23988. * @param bone The bone to sync to the impostor.
  23989. * @param boneMesh The mesh that the bone is influencing.
  23990. * @param jointPivot The pivot of the joint / bone in local space.
  23991. * @param distToJoint Optional distance from the impostor to the joint.
  23992. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23993. */
  23994. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23995. /**
  23996. * Sync impostor to a bone
  23997. * @param bone The bone that the impostor will be synced to.
  23998. * @param boneMesh The mesh that the bone is influencing.
  23999. * @param jointPivot The pivot of the joint / bone in local space.
  24000. * @param distToJoint Optional distance from the impostor to the joint.
  24001. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24002. * @param boneAxis Optional vector3 axis the bone is aligned with
  24003. */
  24004. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24005. /**
  24006. * No-Imposter type
  24007. */
  24008. static NoImpostor: number;
  24009. /**
  24010. * Sphere-Imposter type
  24011. */
  24012. static SphereImpostor: number;
  24013. /**
  24014. * Box-Imposter type
  24015. */
  24016. static BoxImpostor: number;
  24017. /**
  24018. * Plane-Imposter type
  24019. */
  24020. static PlaneImpostor: number;
  24021. /**
  24022. * Mesh-imposter type
  24023. */
  24024. static MeshImpostor: number;
  24025. /**
  24026. * Capsule-Impostor type (Ammo.js plugin only)
  24027. */
  24028. static CapsuleImpostor: number;
  24029. /**
  24030. * Cylinder-Imposter type
  24031. */
  24032. static CylinderImpostor: number;
  24033. /**
  24034. * Particle-Imposter type
  24035. */
  24036. static ParticleImpostor: number;
  24037. /**
  24038. * Heightmap-Imposter type
  24039. */
  24040. static HeightmapImpostor: number;
  24041. /**
  24042. * ConvexHull-Impostor type (Ammo.js plugin only)
  24043. */
  24044. static ConvexHullImpostor: number;
  24045. /**
  24046. * Rope-Imposter type
  24047. */
  24048. static RopeImpostor: number;
  24049. /**
  24050. * Cloth-Imposter type
  24051. */
  24052. static ClothImpostor: number;
  24053. /**
  24054. * Softbody-Imposter type
  24055. */
  24056. static SoftbodyImpostor: number;
  24057. }
  24058. }
  24059. declare module "babylonjs/Meshes/mesh" {
  24060. import { Observable } from "babylonjs/Misc/observable";
  24061. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24062. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24063. import { Camera } from "babylonjs/Cameras/camera";
  24064. import { Scene } from "babylonjs/scene";
  24065. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24066. import { Color4 } from "babylonjs/Maths/math.color";
  24067. import { Engine } from "babylonjs/Engines/engine";
  24068. import { Node } from "babylonjs/node";
  24069. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24070. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24071. import { Buffer } from "babylonjs/Meshes/buffer";
  24072. import { Geometry } from "babylonjs/Meshes/geometry";
  24073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24074. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24075. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24076. import { Effect } from "babylonjs/Materials/effect";
  24077. import { Material } from "babylonjs/Materials/material";
  24078. import { Skeleton } from "babylonjs/Bones/skeleton";
  24079. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24080. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24081. import { Path3D } from "babylonjs/Maths/math.path";
  24082. import { Plane } from "babylonjs/Maths/math.plane";
  24083. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24084. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24085. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24086. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24087. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24088. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24089. /**
  24090. * @hidden
  24091. **/
  24092. export class _CreationDataStorage {
  24093. closePath?: boolean;
  24094. closeArray?: boolean;
  24095. idx: number[];
  24096. dashSize: number;
  24097. gapSize: number;
  24098. path3D: Path3D;
  24099. pathArray: Vector3[][];
  24100. arc: number;
  24101. radius: number;
  24102. cap: number;
  24103. tessellation: number;
  24104. }
  24105. /**
  24106. * @hidden
  24107. **/
  24108. class _InstanceDataStorage {
  24109. visibleInstances: any;
  24110. batchCache: _InstancesBatch;
  24111. instancesBufferSize: number;
  24112. instancesBuffer: Nullable<Buffer>;
  24113. instancesData: Float32Array;
  24114. overridenInstanceCount: number;
  24115. isFrozen: boolean;
  24116. previousBatch: Nullable<_InstancesBatch>;
  24117. hardwareInstancedRendering: boolean;
  24118. sideOrientation: number;
  24119. }
  24120. /**
  24121. * @hidden
  24122. **/
  24123. export class _InstancesBatch {
  24124. mustReturn: boolean;
  24125. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24126. renderSelf: boolean[];
  24127. hardwareInstancedRendering: boolean[];
  24128. }
  24129. /**
  24130. * Class used to represent renderable models
  24131. */
  24132. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24133. /**
  24134. * Mesh side orientation : usually the external or front surface
  24135. */
  24136. static readonly FRONTSIDE: number;
  24137. /**
  24138. * Mesh side orientation : usually the internal or back surface
  24139. */
  24140. static readonly BACKSIDE: number;
  24141. /**
  24142. * Mesh side orientation : both internal and external or front and back surfaces
  24143. */
  24144. static readonly DOUBLESIDE: number;
  24145. /**
  24146. * Mesh side orientation : by default, `FRONTSIDE`
  24147. */
  24148. static readonly DEFAULTSIDE: number;
  24149. /**
  24150. * Mesh cap setting : no cap
  24151. */
  24152. static readonly NO_CAP: number;
  24153. /**
  24154. * Mesh cap setting : one cap at the beginning of the mesh
  24155. */
  24156. static readonly CAP_START: number;
  24157. /**
  24158. * Mesh cap setting : one cap at the end of the mesh
  24159. */
  24160. static readonly CAP_END: number;
  24161. /**
  24162. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24163. */
  24164. static readonly CAP_ALL: number;
  24165. /**
  24166. * Mesh pattern setting : no flip or rotate
  24167. */
  24168. static readonly NO_FLIP: number;
  24169. /**
  24170. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24171. */
  24172. static readonly FLIP_TILE: number;
  24173. /**
  24174. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24175. */
  24176. static readonly ROTATE_TILE: number;
  24177. /**
  24178. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24179. */
  24180. static readonly FLIP_ROW: number;
  24181. /**
  24182. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24183. */
  24184. static readonly ROTATE_ROW: number;
  24185. /**
  24186. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24187. */
  24188. static readonly FLIP_N_ROTATE_TILE: number;
  24189. /**
  24190. * Mesh pattern setting : rotate pattern and rotate
  24191. */
  24192. static readonly FLIP_N_ROTATE_ROW: number;
  24193. /**
  24194. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24195. */
  24196. static readonly CENTER: number;
  24197. /**
  24198. * Mesh tile positioning : part tiles on left
  24199. */
  24200. static readonly LEFT: number;
  24201. /**
  24202. * Mesh tile positioning : part tiles on right
  24203. */
  24204. static readonly RIGHT: number;
  24205. /**
  24206. * Mesh tile positioning : part tiles on top
  24207. */
  24208. static readonly TOP: number;
  24209. /**
  24210. * Mesh tile positioning : part tiles on bottom
  24211. */
  24212. static readonly BOTTOM: number;
  24213. /**
  24214. * Gets the default side orientation.
  24215. * @param orientation the orientation to value to attempt to get
  24216. * @returns the default orientation
  24217. * @hidden
  24218. */
  24219. static _GetDefaultSideOrientation(orientation?: number): number;
  24220. private _internalMeshDataInfo;
  24221. /**
  24222. * An event triggered before rendering the mesh
  24223. */
  24224. readonly onBeforeRenderObservable: Observable<Mesh>;
  24225. /**
  24226. * An event triggered before binding the mesh
  24227. */
  24228. readonly onBeforeBindObservable: Observable<Mesh>;
  24229. /**
  24230. * An event triggered after rendering the mesh
  24231. */
  24232. readonly onAfterRenderObservable: Observable<Mesh>;
  24233. /**
  24234. * An event triggered before drawing the mesh
  24235. */
  24236. readonly onBeforeDrawObservable: Observable<Mesh>;
  24237. private _onBeforeDrawObserver;
  24238. /**
  24239. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24240. */
  24241. onBeforeDraw: () => void;
  24242. readonly hasInstances: boolean;
  24243. /**
  24244. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24245. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24246. */
  24247. delayLoadState: number;
  24248. /**
  24249. * Gets the list of instances created from this mesh
  24250. * it is not supposed to be modified manually.
  24251. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24252. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24253. */
  24254. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24255. /**
  24256. * Gets the file containing delay loading data for this mesh
  24257. */
  24258. delayLoadingFile: string;
  24259. /** @hidden */
  24260. _binaryInfo: any;
  24261. /**
  24262. * User defined function used to change how LOD level selection is done
  24263. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24264. */
  24265. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24266. /**
  24267. * Gets or sets the morph target manager
  24268. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24269. */
  24270. morphTargetManager: Nullable<MorphTargetManager>;
  24271. /** @hidden */
  24272. _creationDataStorage: Nullable<_CreationDataStorage>;
  24273. /** @hidden */
  24274. _geometry: Nullable<Geometry>;
  24275. /** @hidden */
  24276. _delayInfo: Array<string>;
  24277. /** @hidden */
  24278. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24279. /** @hidden */
  24280. _instanceDataStorage: _InstanceDataStorage;
  24281. private _effectiveMaterial;
  24282. /** @hidden */
  24283. _shouldGenerateFlatShading: boolean;
  24284. /** @hidden */
  24285. _originalBuilderSideOrientation: number;
  24286. /**
  24287. * Use this property to change the original side orientation defined at construction time
  24288. */
  24289. overrideMaterialSideOrientation: Nullable<number>;
  24290. /**
  24291. * Gets the source mesh (the one used to clone this one from)
  24292. */
  24293. readonly source: Nullable<Mesh>;
  24294. /**
  24295. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24296. */
  24297. isUnIndexed: boolean;
  24298. /**
  24299. * @constructor
  24300. * @param name The value used by scene.getMeshByName() to do a lookup.
  24301. * @param scene The scene to add this mesh to.
  24302. * @param parent The parent of this mesh, if it has one
  24303. * @param source An optional Mesh from which geometry is shared, cloned.
  24304. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24305. * When false, achieved by calling a clone(), also passing False.
  24306. * This will make creation of children, recursive.
  24307. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24308. */
  24309. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24310. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24311. /**
  24312. * Gets the class name
  24313. * @returns the string "Mesh".
  24314. */
  24315. getClassName(): string;
  24316. /** @hidden */
  24317. readonly _isMesh: boolean;
  24318. /**
  24319. * Returns a description of this mesh
  24320. * @param fullDetails define if full details about this mesh must be used
  24321. * @returns a descriptive string representing this mesh
  24322. */
  24323. toString(fullDetails?: boolean): string;
  24324. /** @hidden */
  24325. _unBindEffect(): void;
  24326. /**
  24327. * Gets a boolean indicating if this mesh has LOD
  24328. */
  24329. readonly hasLODLevels: boolean;
  24330. /**
  24331. * Gets the list of MeshLODLevel associated with the current mesh
  24332. * @returns an array of MeshLODLevel
  24333. */
  24334. getLODLevels(): MeshLODLevel[];
  24335. private _sortLODLevels;
  24336. /**
  24337. * Add a mesh as LOD level triggered at the given distance.
  24338. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24339. * @param distance The distance from the center of the object to show this level
  24340. * @param mesh The mesh to be added as LOD level (can be null)
  24341. * @return This mesh (for chaining)
  24342. */
  24343. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24344. /**
  24345. * Returns the LOD level mesh at the passed distance or null if not found.
  24346. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24347. * @param distance The distance from the center of the object to show this level
  24348. * @returns a Mesh or `null`
  24349. */
  24350. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24351. /**
  24352. * Remove a mesh from the LOD array
  24353. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24354. * @param mesh defines the mesh to be removed
  24355. * @return This mesh (for chaining)
  24356. */
  24357. removeLODLevel(mesh: Mesh): Mesh;
  24358. /**
  24359. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24360. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24361. * @param camera defines the camera to use to compute distance
  24362. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24363. * @return This mesh (for chaining)
  24364. */
  24365. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24366. /**
  24367. * Gets the mesh internal Geometry object
  24368. */
  24369. readonly geometry: Nullable<Geometry>;
  24370. /**
  24371. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24372. * @returns the total number of vertices
  24373. */
  24374. getTotalVertices(): number;
  24375. /**
  24376. * Returns the content of an associated vertex buffer
  24377. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24378. * - VertexBuffer.PositionKind
  24379. * - VertexBuffer.UVKind
  24380. * - VertexBuffer.UV2Kind
  24381. * - VertexBuffer.UV3Kind
  24382. * - VertexBuffer.UV4Kind
  24383. * - VertexBuffer.UV5Kind
  24384. * - VertexBuffer.UV6Kind
  24385. * - VertexBuffer.ColorKind
  24386. * - VertexBuffer.MatricesIndicesKind
  24387. * - VertexBuffer.MatricesIndicesExtraKind
  24388. * - VertexBuffer.MatricesWeightsKind
  24389. * - VertexBuffer.MatricesWeightsExtraKind
  24390. * @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
  24391. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24392. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24393. */
  24394. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24395. /**
  24396. * Returns the mesh VertexBuffer object from the requested `kind`
  24397. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24398. * - VertexBuffer.PositionKind
  24399. * - VertexBuffer.NormalKind
  24400. * - VertexBuffer.UVKind
  24401. * - VertexBuffer.UV2Kind
  24402. * - VertexBuffer.UV3Kind
  24403. * - VertexBuffer.UV4Kind
  24404. * - VertexBuffer.UV5Kind
  24405. * - VertexBuffer.UV6Kind
  24406. * - VertexBuffer.ColorKind
  24407. * - VertexBuffer.MatricesIndicesKind
  24408. * - VertexBuffer.MatricesIndicesExtraKind
  24409. * - VertexBuffer.MatricesWeightsKind
  24410. * - VertexBuffer.MatricesWeightsExtraKind
  24411. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24412. */
  24413. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24414. /**
  24415. * Tests if a specific vertex buffer is associated with this mesh
  24416. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24417. * - VertexBuffer.PositionKind
  24418. * - VertexBuffer.NormalKind
  24419. * - VertexBuffer.UVKind
  24420. * - VertexBuffer.UV2Kind
  24421. * - VertexBuffer.UV3Kind
  24422. * - VertexBuffer.UV4Kind
  24423. * - VertexBuffer.UV5Kind
  24424. * - VertexBuffer.UV6Kind
  24425. * - VertexBuffer.ColorKind
  24426. * - VertexBuffer.MatricesIndicesKind
  24427. * - VertexBuffer.MatricesIndicesExtraKind
  24428. * - VertexBuffer.MatricesWeightsKind
  24429. * - VertexBuffer.MatricesWeightsExtraKind
  24430. * @returns a boolean
  24431. */
  24432. isVerticesDataPresent(kind: string): boolean;
  24433. /**
  24434. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24435. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24436. * - VertexBuffer.PositionKind
  24437. * - VertexBuffer.UVKind
  24438. * - VertexBuffer.UV2Kind
  24439. * - VertexBuffer.UV3Kind
  24440. * - VertexBuffer.UV4Kind
  24441. * - VertexBuffer.UV5Kind
  24442. * - VertexBuffer.UV6Kind
  24443. * - VertexBuffer.ColorKind
  24444. * - VertexBuffer.MatricesIndicesKind
  24445. * - VertexBuffer.MatricesIndicesExtraKind
  24446. * - VertexBuffer.MatricesWeightsKind
  24447. * - VertexBuffer.MatricesWeightsExtraKind
  24448. * @returns a boolean
  24449. */
  24450. isVertexBufferUpdatable(kind: string): boolean;
  24451. /**
  24452. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24453. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24454. * - VertexBuffer.PositionKind
  24455. * - VertexBuffer.NormalKind
  24456. * - VertexBuffer.UVKind
  24457. * - VertexBuffer.UV2Kind
  24458. * - VertexBuffer.UV3Kind
  24459. * - VertexBuffer.UV4Kind
  24460. * - VertexBuffer.UV5Kind
  24461. * - VertexBuffer.UV6Kind
  24462. * - VertexBuffer.ColorKind
  24463. * - VertexBuffer.MatricesIndicesKind
  24464. * - VertexBuffer.MatricesIndicesExtraKind
  24465. * - VertexBuffer.MatricesWeightsKind
  24466. * - VertexBuffer.MatricesWeightsExtraKind
  24467. * @returns an array of strings
  24468. */
  24469. getVerticesDataKinds(): string[];
  24470. /**
  24471. * Returns a positive integer : the total number of indices in this mesh geometry.
  24472. * @returns the numner of indices or zero if the mesh has no geometry.
  24473. */
  24474. getTotalIndices(): number;
  24475. /**
  24476. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24477. * @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.
  24478. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24479. * @returns the indices array or an empty array if the mesh has no geometry
  24480. */
  24481. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24482. readonly isBlocked: boolean;
  24483. /**
  24484. * Determine if the current mesh is ready to be rendered
  24485. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24486. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24487. * @returns true if all associated assets are ready (material, textures, shaders)
  24488. */
  24489. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24490. /**
  24491. * 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.
  24492. */
  24493. readonly areNormalsFrozen: boolean;
  24494. /**
  24495. * 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.
  24496. * @returns the current mesh
  24497. */
  24498. freezeNormals(): Mesh;
  24499. /**
  24500. * 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
  24501. * @returns the current mesh
  24502. */
  24503. unfreezeNormals(): Mesh;
  24504. /**
  24505. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24506. */
  24507. overridenInstanceCount: number;
  24508. /** @hidden */
  24509. _preActivate(): Mesh;
  24510. /** @hidden */
  24511. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24512. /** @hidden */
  24513. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24514. /**
  24515. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24516. * This means the mesh underlying bounding box and sphere are recomputed.
  24517. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24518. * @returns the current mesh
  24519. */
  24520. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24521. /** @hidden */
  24522. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24523. /**
  24524. * This function will subdivide the mesh into multiple submeshes
  24525. * @param count defines the expected number of submeshes
  24526. */
  24527. subdivide(count: number): void;
  24528. /**
  24529. * Copy a FloatArray into a specific associated vertex buffer
  24530. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24531. * - VertexBuffer.PositionKind
  24532. * - VertexBuffer.UVKind
  24533. * - VertexBuffer.UV2Kind
  24534. * - VertexBuffer.UV3Kind
  24535. * - VertexBuffer.UV4Kind
  24536. * - VertexBuffer.UV5Kind
  24537. * - VertexBuffer.UV6Kind
  24538. * - VertexBuffer.ColorKind
  24539. * - VertexBuffer.MatricesIndicesKind
  24540. * - VertexBuffer.MatricesIndicesExtraKind
  24541. * - VertexBuffer.MatricesWeightsKind
  24542. * - VertexBuffer.MatricesWeightsExtraKind
  24543. * @param data defines the data source
  24544. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24545. * @param stride defines the data stride size (can be null)
  24546. * @returns the current mesh
  24547. */
  24548. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24549. /**
  24550. * Flags an associated vertex buffer as updatable
  24551. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24552. * - VertexBuffer.PositionKind
  24553. * - VertexBuffer.UVKind
  24554. * - VertexBuffer.UV2Kind
  24555. * - VertexBuffer.UV3Kind
  24556. * - VertexBuffer.UV4Kind
  24557. * - VertexBuffer.UV5Kind
  24558. * - VertexBuffer.UV6Kind
  24559. * - VertexBuffer.ColorKind
  24560. * - VertexBuffer.MatricesIndicesKind
  24561. * - VertexBuffer.MatricesIndicesExtraKind
  24562. * - VertexBuffer.MatricesWeightsKind
  24563. * - VertexBuffer.MatricesWeightsExtraKind
  24564. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24565. */
  24566. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24567. /**
  24568. * Sets the mesh global Vertex Buffer
  24569. * @param buffer defines the buffer to use
  24570. * @returns the current mesh
  24571. */
  24572. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24573. /**
  24574. * Update a specific associated vertex buffer
  24575. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24576. * - VertexBuffer.PositionKind
  24577. * - VertexBuffer.UVKind
  24578. * - VertexBuffer.UV2Kind
  24579. * - VertexBuffer.UV3Kind
  24580. * - VertexBuffer.UV4Kind
  24581. * - VertexBuffer.UV5Kind
  24582. * - VertexBuffer.UV6Kind
  24583. * - VertexBuffer.ColorKind
  24584. * - VertexBuffer.MatricesIndicesKind
  24585. * - VertexBuffer.MatricesIndicesExtraKind
  24586. * - VertexBuffer.MatricesWeightsKind
  24587. * - VertexBuffer.MatricesWeightsExtraKind
  24588. * @param data defines the data source
  24589. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24590. * @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)
  24591. * @returns the current mesh
  24592. */
  24593. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24594. /**
  24595. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24596. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24597. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24598. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24599. * @returns the current mesh
  24600. */
  24601. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24602. /**
  24603. * Creates a un-shared specific occurence of the geometry for the mesh.
  24604. * @returns the current mesh
  24605. */
  24606. makeGeometryUnique(): Mesh;
  24607. /**
  24608. * Set the index buffer of this mesh
  24609. * @param indices defines the source data
  24610. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24611. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24612. * @returns the current mesh
  24613. */
  24614. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24615. /**
  24616. * Update the current index buffer
  24617. * @param indices defines the source data
  24618. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24619. * @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)
  24620. * @returns the current mesh
  24621. */
  24622. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24623. /**
  24624. * Invert the geometry to move from a right handed system to a left handed one.
  24625. * @returns the current mesh
  24626. */
  24627. toLeftHanded(): Mesh;
  24628. /** @hidden */
  24629. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24630. /** @hidden */
  24631. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24632. /**
  24633. * Registers for this mesh a javascript function called just before the rendering process
  24634. * @param func defines the function to call before rendering this mesh
  24635. * @returns the current mesh
  24636. */
  24637. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24638. /**
  24639. * Disposes a previously registered javascript function called before the rendering
  24640. * @param func defines the function to remove
  24641. * @returns the current mesh
  24642. */
  24643. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24644. /**
  24645. * Registers for this mesh a javascript function called just after the rendering is complete
  24646. * @param func defines the function to call after rendering this mesh
  24647. * @returns the current mesh
  24648. */
  24649. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24650. /**
  24651. * Disposes a previously registered javascript function called after the rendering.
  24652. * @param func defines the function to remove
  24653. * @returns the current mesh
  24654. */
  24655. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24656. /** @hidden */
  24657. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24658. /** @hidden */
  24659. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24660. /** @hidden */
  24661. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24662. /** @hidden */
  24663. _rebuild(): void;
  24664. /** @hidden */
  24665. _freeze(): void;
  24666. /** @hidden */
  24667. _unFreeze(): void;
  24668. /**
  24669. * 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
  24670. * @param subMesh defines the subMesh to render
  24671. * @param enableAlphaMode defines if alpha mode can be changed
  24672. * @returns the current mesh
  24673. */
  24674. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24675. private _onBeforeDraw;
  24676. /**
  24677. * Renormalize the mesh and patch it up if there are no weights
  24678. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24679. * However in the case of zero weights then we set just a single influence to 1.
  24680. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24681. */
  24682. cleanMatrixWeights(): void;
  24683. private normalizeSkinFourWeights;
  24684. private normalizeSkinWeightsAndExtra;
  24685. /**
  24686. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24687. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24688. * the user know there was an issue with importing the mesh
  24689. * @returns a validation object with skinned, valid and report string
  24690. */
  24691. validateSkinning(): {
  24692. skinned: boolean;
  24693. valid: boolean;
  24694. report: string;
  24695. };
  24696. /** @hidden */
  24697. _checkDelayState(): Mesh;
  24698. private _queueLoad;
  24699. /**
  24700. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24701. * A mesh is in the frustum if its bounding box intersects the frustum
  24702. * @param frustumPlanes defines the frustum to test
  24703. * @returns true if the mesh is in the frustum planes
  24704. */
  24705. isInFrustum(frustumPlanes: Plane[]): boolean;
  24706. /**
  24707. * Sets the mesh material by the material or multiMaterial `id` property
  24708. * @param id is a string identifying the material or the multiMaterial
  24709. * @returns the current mesh
  24710. */
  24711. setMaterialByID(id: string): Mesh;
  24712. /**
  24713. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24714. * @returns an array of IAnimatable
  24715. */
  24716. getAnimatables(): IAnimatable[];
  24717. /**
  24718. * Modifies the mesh geometry according to the passed transformation matrix.
  24719. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24720. * The mesh normals are modified using the same transformation.
  24721. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24722. * @param transform defines the transform matrix to use
  24723. * @see http://doc.babylonjs.com/resources/baking_transformations
  24724. * @returns the current mesh
  24725. */
  24726. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24727. /**
  24728. * Modifies the mesh geometry according to its own current World Matrix.
  24729. * The mesh World Matrix is then reset.
  24730. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24731. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24732. * @see http://doc.babylonjs.com/resources/baking_transformations
  24733. * @returns the current mesh
  24734. */
  24735. bakeCurrentTransformIntoVertices(): Mesh;
  24736. /** @hidden */
  24737. readonly _positions: Nullable<Vector3[]>;
  24738. /** @hidden */
  24739. _resetPointsArrayCache(): Mesh;
  24740. /** @hidden */
  24741. _generatePointsArray(): boolean;
  24742. /**
  24743. * Returns a new Mesh object generated from the current mesh properties.
  24744. * This method must not get confused with createInstance()
  24745. * @param name is a string, the name given to the new mesh
  24746. * @param newParent can be any Node object (default `null`)
  24747. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24748. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24749. * @returns a new mesh
  24750. */
  24751. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24752. /**
  24753. * Releases resources associated with this mesh.
  24754. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24755. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24756. */
  24757. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24758. /**
  24759. * Modifies the mesh geometry according to a displacement map.
  24760. * 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.
  24761. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24762. * @param url is a string, the URL from the image file is to be downloaded.
  24763. * @param minHeight is the lower limit of the displacement.
  24764. * @param maxHeight is the upper limit of the displacement.
  24765. * @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.
  24766. * @param uvOffset is an optional vector2 used to offset UV.
  24767. * @param uvScale is an optional vector2 used to scale UV.
  24768. * @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.
  24769. * @returns the Mesh.
  24770. */
  24771. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24772. /**
  24773. * Modifies the mesh geometry according to a displacementMap buffer.
  24774. * 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.
  24775. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24776. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24777. * @param heightMapWidth is the width of the buffer image.
  24778. * @param heightMapHeight is the height of the buffer image.
  24779. * @param minHeight is the lower limit of the displacement.
  24780. * @param maxHeight is the upper limit of the displacement.
  24781. * @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.
  24782. * @param uvOffset is an optional vector2 used to offset UV.
  24783. * @param uvScale is an optional vector2 used to scale UV.
  24784. * @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.
  24785. * @returns the Mesh.
  24786. */
  24787. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24788. /**
  24789. * Modify the mesh to get a flat shading rendering.
  24790. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24791. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24792. * @returns current mesh
  24793. */
  24794. convertToFlatShadedMesh(): Mesh;
  24795. /**
  24796. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24797. * In other words, more vertices, no more indices and a single bigger VBO.
  24798. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24799. * @returns current mesh
  24800. */
  24801. convertToUnIndexedMesh(): Mesh;
  24802. /**
  24803. * Inverses facet orientations.
  24804. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24805. * @param flipNormals will also inverts the normals
  24806. * @returns current mesh
  24807. */
  24808. flipFaces(flipNormals?: boolean): Mesh;
  24809. /**
  24810. * Increase the number of facets and hence vertices in a mesh
  24811. * Vertex normals are interpolated from existing vertex normals
  24812. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24813. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24814. */
  24815. increaseVertices(numberPerEdge: number): void;
  24816. /**
  24817. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24818. * This will undo any application of covertToFlatShadedMesh
  24819. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24820. */
  24821. forceSharedVertices(): void;
  24822. /** @hidden */
  24823. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24824. /** @hidden */
  24825. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24826. /**
  24827. * Creates a new InstancedMesh object from the mesh model.
  24828. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24829. * @param name defines the name of the new instance
  24830. * @returns a new InstancedMesh
  24831. */
  24832. createInstance(name: string): InstancedMesh;
  24833. /**
  24834. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24835. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24836. * @returns the current mesh
  24837. */
  24838. synchronizeInstances(): Mesh;
  24839. /**
  24840. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24841. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24842. * This should be used together with the simplification to avoid disappearing triangles.
  24843. * @param successCallback an optional success callback to be called after the optimization finished.
  24844. * @returns the current mesh
  24845. */
  24846. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24847. /**
  24848. * Serialize current mesh
  24849. * @param serializationObject defines the object which will receive the serialization data
  24850. */
  24851. serialize(serializationObject: any): void;
  24852. /** @hidden */
  24853. _syncGeometryWithMorphTargetManager(): void;
  24854. /** @hidden */
  24855. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24856. /**
  24857. * Returns a new Mesh object parsed from the source provided.
  24858. * @param parsedMesh is the source
  24859. * @param scene defines the hosting scene
  24860. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24861. * @returns a new Mesh
  24862. */
  24863. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24864. /**
  24865. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24866. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24867. * @param name defines the name of the mesh to create
  24868. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24869. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24870. * @param closePath creates a seam between the first and the last points of each path of the path array
  24871. * @param offset is taken in account only if the `pathArray` is containing a single path
  24872. * @param scene defines the hosting scene
  24873. * @param updatable defines if the mesh must be flagged as updatable
  24874. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24875. * @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)
  24876. * @returns a new Mesh
  24877. */
  24878. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24879. /**
  24880. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24881. * @param name defines the name of the mesh to create
  24882. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24883. * @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
  24884. * @param scene defines the hosting scene
  24885. * @param updatable defines if the mesh must be flagged as updatable
  24886. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24887. * @returns a new Mesh
  24888. */
  24889. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24890. /**
  24891. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24892. * @param name defines the name of the mesh to create
  24893. * @param size sets the size (float) of each box side (default 1)
  24894. * @param scene defines the hosting scene
  24895. * @param updatable defines if the mesh must be flagged as updatable
  24896. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24897. * @returns a new Mesh
  24898. */
  24899. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24900. /**
  24901. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24902. * @param name defines the name of the mesh to create
  24903. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24904. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24905. * @param scene defines the hosting scene
  24906. * @param updatable defines if the mesh must be flagged as updatable
  24907. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24908. * @returns a new Mesh
  24909. */
  24910. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24911. /**
  24912. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24913. * @param name defines the name of the mesh to create
  24914. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24915. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24916. * @param scene defines the hosting scene
  24917. * @returns a new Mesh
  24918. */
  24919. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24920. /**
  24921. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24922. * @param name defines the name of the mesh to create
  24923. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24924. * @param diameterTop set the top cap diameter (floats, default 1)
  24925. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24926. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24927. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24928. * @param scene defines the hosting scene
  24929. * @param updatable defines if the mesh must be flagged as updatable
  24930. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24931. * @returns a new Mesh
  24932. */
  24933. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24934. /**
  24935. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24936. * @param name defines the name of the mesh to create
  24937. * @param diameter sets the diameter size (float) of the torus (default 1)
  24938. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24939. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24940. * @param scene defines the hosting scene
  24941. * @param updatable defines if the mesh must be flagged as updatable
  24942. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24943. * @returns a new Mesh
  24944. */
  24945. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24946. /**
  24947. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24948. * @param name defines the name of the mesh to create
  24949. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24950. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24951. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24952. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24953. * @param p the number of windings on X axis (positive integers, default 2)
  24954. * @param q the number of windings on Y axis (positive integers, default 3)
  24955. * @param scene defines the hosting scene
  24956. * @param updatable defines if the mesh must be flagged as updatable
  24957. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24958. * @returns a new Mesh
  24959. */
  24960. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24961. /**
  24962. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24963. * @param name defines the name of the mesh to create
  24964. * @param points is an array successive Vector3
  24965. * @param scene defines the hosting scene
  24966. * @param updatable defines if the mesh must be flagged as updatable
  24967. * @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).
  24968. * @returns a new Mesh
  24969. */
  24970. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24971. /**
  24972. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24973. * @param name defines the name of the mesh to create
  24974. * @param points is an array successive Vector3
  24975. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24976. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24977. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24978. * @param scene defines the hosting scene
  24979. * @param updatable defines if the mesh must be flagged as updatable
  24980. * @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)
  24981. * @returns a new Mesh
  24982. */
  24983. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24984. /**
  24985. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24986. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24987. * 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.
  24988. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24989. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24990. * Remember you can only change the shape positions, not their number when updating a polygon.
  24991. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24992. * @param name defines the name of the mesh to create
  24993. * @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
  24994. * @param scene defines the hosting scene
  24995. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24996. * @param updatable defines if the mesh must be flagged as updatable
  24997. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24998. * @param earcutInjection can be used to inject your own earcut reference
  24999. * @returns a new Mesh
  25000. */
  25001. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25002. /**
  25003. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25004. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25005. * @param name defines the name of the mesh to create
  25006. * @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
  25007. * @param depth defines the height of extrusion
  25008. * @param scene defines the hosting scene
  25009. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25010. * @param updatable defines if the mesh must be flagged as updatable
  25011. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25012. * @param earcutInjection can be used to inject your own earcut reference
  25013. * @returns a new Mesh
  25014. */
  25015. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25016. /**
  25017. * Creates an extruded shape mesh.
  25018. * 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
  25019. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25020. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25021. * @param name defines the name of the mesh to create
  25022. * @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
  25023. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25024. * @param scale is the value to scale the shape
  25025. * @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
  25026. * @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
  25027. * @param scene defines the hosting scene
  25028. * @param updatable defines if the mesh must be flagged as updatable
  25029. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25030. * @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)
  25031. * @returns a new Mesh
  25032. */
  25033. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25034. /**
  25035. * Creates an custom extruded shape mesh.
  25036. * The custom extrusion is a parametric shape.
  25037. * It has no predefined shape. Its final shape will depend on the input parameters.
  25038. * Please consider using the same method from the MeshBuilder class instead
  25039. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25040. * @param name defines the name of the mesh to create
  25041. * @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
  25042. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25043. * @param scaleFunction is a custom Javascript function called on each path point
  25044. * @param rotationFunction is a custom Javascript function called on each path point
  25045. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25046. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25047. * @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
  25048. * @param scene defines the hosting scene
  25049. * @param updatable defines if the mesh must be flagged as updatable
  25050. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25051. * @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)
  25052. * @returns a new Mesh
  25053. */
  25054. 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;
  25055. /**
  25056. * Creates lathe mesh.
  25057. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25058. * Please consider using the same method from the MeshBuilder class instead
  25059. * @param name defines the name of the mesh to create
  25060. * @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
  25061. * @param radius is the radius value of the lathe
  25062. * @param tessellation is the side number of the lathe.
  25063. * @param scene defines the hosting scene
  25064. * @param updatable defines if the mesh must be flagged as updatable
  25065. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25066. * @returns a new Mesh
  25067. */
  25068. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25069. /**
  25070. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25071. * @param name defines the name of the mesh to create
  25072. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25073. * @param scene defines the hosting scene
  25074. * @param updatable defines if the mesh must be flagged as updatable
  25075. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25076. * @returns a new Mesh
  25077. */
  25078. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25079. /**
  25080. * Creates a ground mesh.
  25081. * Please consider using the same method from the MeshBuilder class instead
  25082. * @param name defines the name of the mesh to create
  25083. * @param width set the width of the ground
  25084. * @param height set the height of the ground
  25085. * @param subdivisions sets the number of subdivisions per side
  25086. * @param scene defines the hosting scene
  25087. * @param updatable defines if the mesh must be flagged as updatable
  25088. * @returns a new Mesh
  25089. */
  25090. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25091. /**
  25092. * Creates a tiled ground mesh.
  25093. * Please consider using the same method from the MeshBuilder class instead
  25094. * @param name defines the name of the mesh to create
  25095. * @param xmin set the ground minimum X coordinate
  25096. * @param zmin set the ground minimum Y coordinate
  25097. * @param xmax set the ground maximum X coordinate
  25098. * @param zmax set the ground maximum Z coordinate
  25099. * @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
  25100. * @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
  25101. * @param scene defines the hosting scene
  25102. * @param updatable defines if the mesh must be flagged as updatable
  25103. * @returns a new Mesh
  25104. */
  25105. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25106. w: number;
  25107. h: number;
  25108. }, precision: {
  25109. w: number;
  25110. h: number;
  25111. }, scene: Scene, updatable?: boolean): Mesh;
  25112. /**
  25113. * Creates a ground mesh from a height map.
  25114. * Please consider using the same method from the MeshBuilder class instead
  25115. * @see http://doc.babylonjs.com/babylon101/height_map
  25116. * @param name defines the name of the mesh to create
  25117. * @param url sets the URL of the height map image resource
  25118. * @param width set the ground width size
  25119. * @param height set the ground height size
  25120. * @param subdivisions sets the number of subdivision per side
  25121. * @param minHeight is the minimum altitude on the ground
  25122. * @param maxHeight is the maximum altitude on the ground
  25123. * @param scene defines the hosting scene
  25124. * @param updatable defines if the mesh must be flagged as updatable
  25125. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25126. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25127. * @returns a new Mesh
  25128. */
  25129. 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;
  25130. /**
  25131. * Creates a tube mesh.
  25132. * The tube is a parametric shape.
  25133. * It has no predefined shape. Its final shape will depend on the input parameters.
  25134. * Please consider using the same method from the MeshBuilder class instead
  25135. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25136. * @param name defines the name of the mesh to create
  25137. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25138. * @param radius sets the tube radius size
  25139. * @param tessellation is the number of sides on the tubular surface
  25140. * @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
  25141. * @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
  25142. * @param scene defines the hosting scene
  25143. * @param updatable defines if the mesh must be flagged as updatable
  25144. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25145. * @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)
  25146. * @returns a new Mesh
  25147. */
  25148. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25149. (i: number, distance: number): number;
  25150. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25151. /**
  25152. * Creates a polyhedron mesh.
  25153. * Please consider using the same method from the MeshBuilder class instead.
  25154. * * 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
  25155. * * The parameter `size` (positive float, default 1) sets the polygon size
  25156. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25157. * * 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`
  25158. * * 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
  25159. * * 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)`)
  25160. * * 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
  25161. * * 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
  25162. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25163. * * If you create a double-sided mesh, you can choose what parts of 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
  25164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25165. * @param name defines the name of the mesh to create
  25166. * @param options defines the options used to create the mesh
  25167. * @param scene defines the hosting scene
  25168. * @returns a new Mesh
  25169. */
  25170. static CreatePolyhedron(name: string, options: {
  25171. type?: number;
  25172. size?: number;
  25173. sizeX?: number;
  25174. sizeY?: number;
  25175. sizeZ?: number;
  25176. custom?: any;
  25177. faceUV?: Vector4[];
  25178. faceColors?: Color4[];
  25179. updatable?: boolean;
  25180. sideOrientation?: number;
  25181. }, scene: Scene): Mesh;
  25182. /**
  25183. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25184. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25185. * * 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`)
  25186. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25187. * * 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
  25188. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25189. * * If you create a double-sided mesh, you can choose what parts of 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
  25190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25191. * @param name defines the name of the mesh
  25192. * @param options defines the options used to create the mesh
  25193. * @param scene defines the hosting scene
  25194. * @returns a new Mesh
  25195. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25196. */
  25197. static CreateIcoSphere(name: string, options: {
  25198. radius?: number;
  25199. flat?: boolean;
  25200. subdivisions?: number;
  25201. sideOrientation?: number;
  25202. updatable?: boolean;
  25203. }, scene: Scene): Mesh;
  25204. /**
  25205. * Creates a decal mesh.
  25206. * Please consider using the same method from the MeshBuilder class instead.
  25207. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25208. * @param name defines the name of the mesh
  25209. * @param sourceMesh defines the mesh receiving the decal
  25210. * @param position sets the position of the decal in world coordinates
  25211. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25212. * @param size sets the decal scaling
  25213. * @param angle sets the angle to rotate the decal
  25214. * @returns a new Mesh
  25215. */
  25216. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25217. /**
  25218. * Prepare internal position array for software CPU skinning
  25219. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25220. */
  25221. setPositionsForCPUSkinning(): Float32Array;
  25222. /**
  25223. * Prepare internal normal array for software CPU skinning
  25224. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25225. */
  25226. setNormalsForCPUSkinning(): Float32Array;
  25227. /**
  25228. * Updates the vertex buffer by applying transformation from the bones
  25229. * @param skeleton defines the skeleton to apply to current mesh
  25230. * @returns the current mesh
  25231. */
  25232. applySkeleton(skeleton: Skeleton): Mesh;
  25233. /**
  25234. * 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
  25235. * @param meshes defines the list of meshes to scan
  25236. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25237. */
  25238. static MinMax(meshes: AbstractMesh[]): {
  25239. min: Vector3;
  25240. max: Vector3;
  25241. };
  25242. /**
  25243. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25244. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25245. * @returns a vector3
  25246. */
  25247. static Center(meshesOrMinMaxVector: {
  25248. min: Vector3;
  25249. max: Vector3;
  25250. } | AbstractMesh[]): Vector3;
  25251. /**
  25252. * Merge the array of meshes into a single mesh for performance reasons.
  25253. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25254. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25255. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25256. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25257. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25258. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25259. * @returns a new mesh
  25260. */
  25261. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25262. /** @hidden */
  25263. addInstance(instance: InstancedMesh): void;
  25264. /** @hidden */
  25265. removeInstance(instance: InstancedMesh): void;
  25266. }
  25267. }
  25268. declare module "babylonjs/Cameras/camera" {
  25269. import { SmartArray } from "babylonjs/Misc/smartArray";
  25270. import { Observable } from "babylonjs/Misc/observable";
  25271. import { Nullable } from "babylonjs/types";
  25272. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25273. import { Scene } from "babylonjs/scene";
  25274. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25275. import { Node } from "babylonjs/node";
  25276. import { Mesh } from "babylonjs/Meshes/mesh";
  25277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25278. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25279. import { Viewport } from "babylonjs/Maths/math.viewport";
  25280. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25281. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25282. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25283. import { Ray } from "babylonjs/Culling/ray";
  25284. /**
  25285. * This is the base class of all the camera used in the application.
  25286. * @see http://doc.babylonjs.com/features/cameras
  25287. */
  25288. export class Camera extends Node {
  25289. /** @hidden */
  25290. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25291. /**
  25292. * This is the default projection mode used by the cameras.
  25293. * It helps recreating a feeling of perspective and better appreciate depth.
  25294. * This is the best way to simulate real life cameras.
  25295. */
  25296. static readonly PERSPECTIVE_CAMERA: number;
  25297. /**
  25298. * This helps creating camera with an orthographic mode.
  25299. * 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.
  25300. */
  25301. static readonly ORTHOGRAPHIC_CAMERA: number;
  25302. /**
  25303. * This is the default FOV mode for perspective cameras.
  25304. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25305. */
  25306. static readonly FOVMODE_VERTICAL_FIXED: number;
  25307. /**
  25308. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25309. */
  25310. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25311. /**
  25312. * This specifies ther is no need for a camera rig.
  25313. * Basically only one eye is rendered corresponding to the camera.
  25314. */
  25315. static readonly RIG_MODE_NONE: number;
  25316. /**
  25317. * Simulates a camera Rig with one blue eye and one red eye.
  25318. * This can be use with 3d blue and red glasses.
  25319. */
  25320. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25321. /**
  25322. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25323. */
  25324. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25325. /**
  25326. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25327. */
  25328. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25329. /**
  25330. * Defines that both eyes of the camera will be rendered over under each other.
  25331. */
  25332. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25333. /**
  25334. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25335. */
  25336. static readonly RIG_MODE_VR: number;
  25337. /**
  25338. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25339. */
  25340. static readonly RIG_MODE_WEBVR: number;
  25341. /**
  25342. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25343. */
  25344. static readonly RIG_MODE_CUSTOM: number;
  25345. /**
  25346. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25347. */
  25348. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25349. /**
  25350. * Define the input manager associated with the camera.
  25351. */
  25352. inputs: CameraInputsManager<Camera>;
  25353. /** @hidden */
  25354. _position: Vector3;
  25355. /**
  25356. * Define the current local position of the camera in the scene
  25357. */
  25358. position: Vector3;
  25359. /**
  25360. * The vector the camera should consider as up.
  25361. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25362. */
  25363. upVector: Vector3;
  25364. /**
  25365. * Define the current limit on the left side for an orthographic camera
  25366. * In scene unit
  25367. */
  25368. orthoLeft: Nullable<number>;
  25369. /**
  25370. * Define the current limit on the right side for an orthographic camera
  25371. * In scene unit
  25372. */
  25373. orthoRight: Nullable<number>;
  25374. /**
  25375. * Define the current limit on the bottom side for an orthographic camera
  25376. * In scene unit
  25377. */
  25378. orthoBottom: Nullable<number>;
  25379. /**
  25380. * Define the current limit on the top side for an orthographic camera
  25381. * In scene unit
  25382. */
  25383. orthoTop: Nullable<number>;
  25384. /**
  25385. * Field Of View is set in Radians. (default is 0.8)
  25386. */
  25387. fov: number;
  25388. /**
  25389. * Define the minimum distance the camera can see from.
  25390. * This is important to note that the depth buffer are not infinite and the closer it starts
  25391. * the more your scene might encounter depth fighting issue.
  25392. */
  25393. minZ: number;
  25394. /**
  25395. * Define the maximum distance the camera can see to.
  25396. * This is important to note that the depth buffer are not infinite and the further it end
  25397. * the more your scene might encounter depth fighting issue.
  25398. */
  25399. maxZ: number;
  25400. /**
  25401. * Define the default inertia of the camera.
  25402. * This helps giving a smooth feeling to the camera movement.
  25403. */
  25404. inertia: number;
  25405. /**
  25406. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25407. */
  25408. mode: number;
  25409. /**
  25410. * Define wether the camera is intermediate.
  25411. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25412. */
  25413. isIntermediate: boolean;
  25414. /**
  25415. * Define the viewport of the camera.
  25416. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25417. */
  25418. viewport: Viewport;
  25419. /**
  25420. * Restricts the camera to viewing objects with the same layerMask.
  25421. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25422. */
  25423. layerMask: number;
  25424. /**
  25425. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25426. */
  25427. fovMode: number;
  25428. /**
  25429. * Rig mode of the camera.
  25430. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25431. * This is normally controlled byt the camera themselves as internal use.
  25432. */
  25433. cameraRigMode: number;
  25434. /**
  25435. * Defines the distance between both "eyes" in case of a RIG
  25436. */
  25437. interaxialDistance: number;
  25438. /**
  25439. * Defines if stereoscopic rendering is done side by side or over under.
  25440. */
  25441. isStereoscopicSideBySide: boolean;
  25442. /**
  25443. * 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
  25444. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25445. * else in the scene. (Eg. security camera)
  25446. *
  25447. * 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)
  25448. */
  25449. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25450. /**
  25451. * When set, the camera will render to this render target instead of the default canvas
  25452. *
  25453. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25454. */
  25455. outputRenderTarget: Nullable<RenderTargetTexture>;
  25456. /**
  25457. * Observable triggered when the camera view matrix has changed.
  25458. */
  25459. onViewMatrixChangedObservable: Observable<Camera>;
  25460. /**
  25461. * Observable triggered when the camera Projection matrix has changed.
  25462. */
  25463. onProjectionMatrixChangedObservable: Observable<Camera>;
  25464. /**
  25465. * Observable triggered when the inputs have been processed.
  25466. */
  25467. onAfterCheckInputsObservable: Observable<Camera>;
  25468. /**
  25469. * Observable triggered when reset has been called and applied to the camera.
  25470. */
  25471. onRestoreStateObservable: Observable<Camera>;
  25472. /** @hidden */
  25473. _cameraRigParams: any;
  25474. /** @hidden */
  25475. _rigCameras: Camera[];
  25476. /** @hidden */
  25477. _rigPostProcess: Nullable<PostProcess>;
  25478. protected _webvrViewMatrix: Matrix;
  25479. /** @hidden */
  25480. _skipRendering: boolean;
  25481. /** @hidden */
  25482. _projectionMatrix: Matrix;
  25483. /** @hidden */
  25484. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25485. /** @hidden */
  25486. _activeMeshes: SmartArray<AbstractMesh>;
  25487. protected _globalPosition: Vector3;
  25488. /** @hidden */
  25489. _computedViewMatrix: Matrix;
  25490. private _doNotComputeProjectionMatrix;
  25491. private _transformMatrix;
  25492. private _frustumPlanes;
  25493. private _refreshFrustumPlanes;
  25494. private _storedFov;
  25495. private _stateStored;
  25496. /**
  25497. * Instantiates a new camera object.
  25498. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25499. * @see http://doc.babylonjs.com/features/cameras
  25500. * @param name Defines the name of the camera in the scene
  25501. * @param position Defines the position of the camera
  25502. * @param scene Defines the scene the camera belongs too
  25503. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25504. */
  25505. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25506. /**
  25507. * Store current camera state (fov, position, etc..)
  25508. * @returns the camera
  25509. */
  25510. storeState(): Camera;
  25511. /**
  25512. * Restores the camera state values if it has been stored. You must call storeState() first
  25513. */
  25514. protected _restoreStateValues(): boolean;
  25515. /**
  25516. * Restored camera state. You must call storeState() first.
  25517. * @returns true if restored and false otherwise
  25518. */
  25519. restoreState(): boolean;
  25520. /**
  25521. * Gets the class name of the camera.
  25522. * @returns the class name
  25523. */
  25524. getClassName(): string;
  25525. /** @hidden */
  25526. readonly _isCamera: boolean;
  25527. /**
  25528. * Gets a string representation of the camera useful for debug purpose.
  25529. * @param fullDetails Defines that a more verboe level of logging is required
  25530. * @returns the string representation
  25531. */
  25532. toString(fullDetails?: boolean): string;
  25533. /**
  25534. * Gets the current world space position of the camera.
  25535. */
  25536. readonly globalPosition: Vector3;
  25537. /**
  25538. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25539. * @returns the active meshe list
  25540. */
  25541. getActiveMeshes(): SmartArray<AbstractMesh>;
  25542. /**
  25543. * Check wether a mesh is part of the current active mesh list of the camera
  25544. * @param mesh Defines the mesh to check
  25545. * @returns true if active, false otherwise
  25546. */
  25547. isActiveMesh(mesh: Mesh): boolean;
  25548. /**
  25549. * Is this camera ready to be used/rendered
  25550. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25551. * @return true if the camera is ready
  25552. */
  25553. isReady(completeCheck?: boolean): boolean;
  25554. /** @hidden */
  25555. _initCache(): void;
  25556. /** @hidden */
  25557. _updateCache(ignoreParentClass?: boolean): void;
  25558. /** @hidden */
  25559. _isSynchronized(): boolean;
  25560. /** @hidden */
  25561. _isSynchronizedViewMatrix(): boolean;
  25562. /** @hidden */
  25563. _isSynchronizedProjectionMatrix(): boolean;
  25564. /**
  25565. * Attach the input controls to a specific dom element to get the input from.
  25566. * @param element Defines the element the controls should be listened from
  25567. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25568. */
  25569. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25570. /**
  25571. * Detach the current controls from the specified dom element.
  25572. * @param element Defines the element to stop listening the inputs from
  25573. */
  25574. detachControl(element: HTMLElement): void;
  25575. /**
  25576. * Update the camera state according to the different inputs gathered during the frame.
  25577. */
  25578. update(): void;
  25579. /** @hidden */
  25580. _checkInputs(): void;
  25581. /** @hidden */
  25582. readonly rigCameras: Camera[];
  25583. /**
  25584. * Gets the post process used by the rig cameras
  25585. */
  25586. readonly rigPostProcess: Nullable<PostProcess>;
  25587. /**
  25588. * Internal, gets the first post proces.
  25589. * @returns the first post process to be run on this camera.
  25590. */
  25591. _getFirstPostProcess(): Nullable<PostProcess>;
  25592. private _cascadePostProcessesToRigCams;
  25593. /**
  25594. * Attach a post process to the camera.
  25595. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25596. * @param postProcess The post process to attach to the camera
  25597. * @param insertAt The position of the post process in case several of them are in use in the scene
  25598. * @returns the position the post process has been inserted at
  25599. */
  25600. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25601. /**
  25602. * Detach a post process to the camera.
  25603. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25604. * @param postProcess The post process to detach from the camera
  25605. */
  25606. detachPostProcess(postProcess: PostProcess): void;
  25607. /**
  25608. * Gets the current world matrix of the camera
  25609. */
  25610. getWorldMatrix(): Matrix;
  25611. /** @hidden */
  25612. _getViewMatrix(): Matrix;
  25613. /**
  25614. * Gets the current view matrix of the camera.
  25615. * @param force forces the camera to recompute the matrix without looking at the cached state
  25616. * @returns the view matrix
  25617. */
  25618. getViewMatrix(force?: boolean): Matrix;
  25619. /**
  25620. * Freeze the projection matrix.
  25621. * It will prevent the cache check of the camera projection compute and can speed up perf
  25622. * if no parameter of the camera are meant to change
  25623. * @param projection Defines manually a projection if necessary
  25624. */
  25625. freezeProjectionMatrix(projection?: Matrix): void;
  25626. /**
  25627. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25628. */
  25629. unfreezeProjectionMatrix(): void;
  25630. /**
  25631. * Gets the current projection matrix of the camera.
  25632. * @param force forces the camera to recompute the matrix without looking at the cached state
  25633. * @returns the projection matrix
  25634. */
  25635. getProjectionMatrix(force?: boolean): Matrix;
  25636. /**
  25637. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25638. * @returns a Matrix
  25639. */
  25640. getTransformationMatrix(): Matrix;
  25641. private _updateFrustumPlanes;
  25642. /**
  25643. * Checks if a cullable object (mesh...) is in the camera frustum
  25644. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25645. * @param target The object to check
  25646. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25647. * @returns true if the object is in frustum otherwise false
  25648. */
  25649. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25650. /**
  25651. * Checks if a cullable object (mesh...) is in the camera frustum
  25652. * Unlike isInFrustum this cheks the full bounding box
  25653. * @param target The object to check
  25654. * @returns true if the object is in frustum otherwise false
  25655. */
  25656. isCompletelyInFrustum(target: ICullable): boolean;
  25657. /**
  25658. * Gets a ray in the forward direction from the camera.
  25659. * @param length Defines the length of the ray to create
  25660. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25661. * @param origin Defines the start point of the ray which defaults to the camera position
  25662. * @returns the forward ray
  25663. */
  25664. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25665. /**
  25666. * Releases resources associated with this node.
  25667. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25668. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25669. */
  25670. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25671. /** @hidden */
  25672. _isLeftCamera: boolean;
  25673. /**
  25674. * Gets the left camera of a rig setup in case of Rigged Camera
  25675. */
  25676. readonly isLeftCamera: boolean;
  25677. /** @hidden */
  25678. _isRightCamera: boolean;
  25679. /**
  25680. * Gets the right camera of a rig setup in case of Rigged Camera
  25681. */
  25682. readonly isRightCamera: boolean;
  25683. /**
  25684. * Gets the left camera of a rig setup in case of Rigged Camera
  25685. */
  25686. readonly leftCamera: Nullable<FreeCamera>;
  25687. /**
  25688. * Gets the right camera of a rig setup in case of Rigged Camera
  25689. */
  25690. readonly rightCamera: Nullable<FreeCamera>;
  25691. /**
  25692. * Gets the left camera target of a rig setup in case of Rigged Camera
  25693. * @returns the target position
  25694. */
  25695. getLeftTarget(): Nullable<Vector3>;
  25696. /**
  25697. * Gets the right camera target of a rig setup in case of Rigged Camera
  25698. * @returns the target position
  25699. */
  25700. getRightTarget(): Nullable<Vector3>;
  25701. /**
  25702. * @hidden
  25703. */
  25704. setCameraRigMode(mode: number, rigParams: any): void;
  25705. /** @hidden */
  25706. static _setStereoscopicRigMode(camera: Camera): void;
  25707. /** @hidden */
  25708. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25709. /** @hidden */
  25710. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25711. /** @hidden */
  25712. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25713. /** @hidden */
  25714. _getVRProjectionMatrix(): Matrix;
  25715. protected _updateCameraRotationMatrix(): void;
  25716. protected _updateWebVRCameraRotationMatrix(): void;
  25717. /**
  25718. * This function MUST be overwritten by the different WebVR cameras available.
  25719. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25720. * @hidden
  25721. */
  25722. _getWebVRProjectionMatrix(): Matrix;
  25723. /**
  25724. * This function MUST be overwritten by the different WebVR cameras available.
  25725. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25726. * @hidden
  25727. */
  25728. _getWebVRViewMatrix(): Matrix;
  25729. /** @hidden */
  25730. setCameraRigParameter(name: string, value: any): void;
  25731. /**
  25732. * needs to be overridden by children so sub has required properties to be copied
  25733. * @hidden
  25734. */
  25735. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25736. /**
  25737. * May need to be overridden by children
  25738. * @hidden
  25739. */
  25740. _updateRigCameras(): void;
  25741. /** @hidden */
  25742. _setupInputs(): void;
  25743. /**
  25744. * Serialiaze the camera setup to a json represention
  25745. * @returns the JSON representation
  25746. */
  25747. serialize(): any;
  25748. /**
  25749. * Clones the current camera.
  25750. * @param name The cloned camera name
  25751. * @returns the cloned camera
  25752. */
  25753. clone(name: string): Camera;
  25754. /**
  25755. * Gets the direction of the camera relative to a given local axis.
  25756. * @param localAxis Defines the reference axis to provide a relative direction.
  25757. * @return the direction
  25758. */
  25759. getDirection(localAxis: Vector3): Vector3;
  25760. /**
  25761. * Returns the current camera absolute rotation
  25762. */
  25763. readonly absoluteRotation: Quaternion;
  25764. /**
  25765. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25766. * @param localAxis Defines the reference axis to provide a relative direction.
  25767. * @param result Defines the vector to store the result in
  25768. */
  25769. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25770. /**
  25771. * Gets a camera constructor for a given camera type
  25772. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25773. * @param name The name of the camera the result will be able to instantiate
  25774. * @param scene The scene the result will construct the camera in
  25775. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25776. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25777. * @returns a factory method to construc the camera
  25778. */
  25779. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25780. /**
  25781. * Compute the world matrix of the camera.
  25782. * @returns the camera workd matrix
  25783. */
  25784. computeWorldMatrix(): Matrix;
  25785. /**
  25786. * Parse a JSON and creates the camera from the parsed information
  25787. * @param parsedCamera The JSON to parse
  25788. * @param scene The scene to instantiate the camera in
  25789. * @returns the newly constructed camera
  25790. */
  25791. static Parse(parsedCamera: any, scene: Scene): Camera;
  25792. }
  25793. }
  25794. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25795. import { Nullable } from "babylonjs/types";
  25796. import { Scene } from "babylonjs/scene";
  25797. import { Vector4 } from "babylonjs/Maths/math.vector";
  25798. import { Mesh } from "babylonjs/Meshes/mesh";
  25799. /**
  25800. * Class containing static functions to help procedurally build meshes
  25801. */
  25802. export class DiscBuilder {
  25803. /**
  25804. * Creates a plane polygonal mesh. By default, this is a disc
  25805. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25806. * * 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
  25807. * * 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
  25808. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25809. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25811. * @param name defines the name of the mesh
  25812. * @param options defines the options used to create the mesh
  25813. * @param scene defines the hosting scene
  25814. * @returns the plane polygonal mesh
  25815. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25816. */
  25817. static CreateDisc(name: string, options: {
  25818. radius?: number;
  25819. tessellation?: number;
  25820. arc?: number;
  25821. updatable?: boolean;
  25822. sideOrientation?: number;
  25823. frontUVs?: Vector4;
  25824. backUVs?: Vector4;
  25825. }, scene?: Nullable<Scene>): Mesh;
  25826. }
  25827. }
  25828. declare module "babylonjs/Particles/solidParticleSystem" {
  25829. import { Vector3 } from "babylonjs/Maths/math.vector";
  25830. import { Mesh } from "babylonjs/Meshes/mesh";
  25831. import { Scene, IDisposable } from "babylonjs/scene";
  25832. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25833. /**
  25834. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25835. *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.
  25836. * The SPS is also a particle system. It provides some methods to manage the particles.
  25837. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25838. *
  25839. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25840. */
  25841. export class SolidParticleSystem implements IDisposable {
  25842. /**
  25843. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25844. * Example : var p = SPS.particles[i];
  25845. */
  25846. particles: SolidParticle[];
  25847. /**
  25848. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25849. */
  25850. nbParticles: number;
  25851. /**
  25852. * If the particles must ever face the camera (default false). Useful for planar particles.
  25853. */
  25854. billboard: boolean;
  25855. /**
  25856. * Recompute normals when adding a shape
  25857. */
  25858. recomputeNormals: boolean;
  25859. /**
  25860. * This a counter ofr your own usage. It's not set by any SPS functions.
  25861. */
  25862. counter: number;
  25863. /**
  25864. * The SPS name. This name is also given to the underlying mesh.
  25865. */
  25866. name: string;
  25867. /**
  25868. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25869. */
  25870. mesh: Mesh;
  25871. /**
  25872. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25873. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25874. */
  25875. vars: any;
  25876. /**
  25877. * This array is populated when the SPS is set as 'pickable'.
  25878. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25879. * Each element of this array is an object `{idx: int, faceId: int}`.
  25880. * `idx` is the picked particle index in the `SPS.particles` array
  25881. * `faceId` is the picked face index counted within this particle.
  25882. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25883. */
  25884. pickedParticles: {
  25885. idx: number;
  25886. faceId: number;
  25887. }[];
  25888. /**
  25889. * This array is populated when `enableDepthSort` is set to true.
  25890. * Each element of this array is an instance of the class DepthSortedParticle.
  25891. */
  25892. depthSortedParticles: DepthSortedParticle[];
  25893. /**
  25894. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25895. * @hidden
  25896. */
  25897. _bSphereOnly: boolean;
  25898. /**
  25899. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25900. * @hidden
  25901. */
  25902. _bSphereRadiusFactor: number;
  25903. private _scene;
  25904. private _positions;
  25905. private _indices;
  25906. private _normals;
  25907. private _colors;
  25908. private _uvs;
  25909. private _indices32;
  25910. private _positions32;
  25911. private _normals32;
  25912. private _fixedNormal32;
  25913. private _colors32;
  25914. private _uvs32;
  25915. private _index;
  25916. private _updatable;
  25917. private _pickable;
  25918. private _isVisibilityBoxLocked;
  25919. private _alwaysVisible;
  25920. private _depthSort;
  25921. private _shapeCounter;
  25922. private _copy;
  25923. private _color;
  25924. private _computeParticleColor;
  25925. private _computeParticleTexture;
  25926. private _computeParticleRotation;
  25927. private _computeParticleVertex;
  25928. private _computeBoundingBox;
  25929. private _depthSortParticles;
  25930. private _camera;
  25931. private _mustUnrotateFixedNormals;
  25932. private _particlesIntersect;
  25933. private _needs32Bits;
  25934. /**
  25935. * Creates a SPS (Solid Particle System) object.
  25936. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25937. * @param scene (Scene) is the scene in which the SPS is added.
  25938. * @param options defines the options of the sps e.g.
  25939. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25940. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25941. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25942. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25943. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25944. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25945. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25946. */
  25947. constructor(name: string, scene: Scene, options?: {
  25948. updatable?: boolean;
  25949. isPickable?: boolean;
  25950. enableDepthSort?: boolean;
  25951. particleIntersection?: boolean;
  25952. boundingSphereOnly?: boolean;
  25953. bSphereRadiusFactor?: number;
  25954. });
  25955. /**
  25956. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25957. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25958. * @returns the created mesh
  25959. */
  25960. buildMesh(): Mesh;
  25961. /**
  25962. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25963. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25964. * Thus the particles generated from `digest()` have their property `position` set yet.
  25965. * @param mesh ( Mesh ) is the mesh to be digested
  25966. * @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
  25967. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25968. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25969. * @returns the current SPS
  25970. */
  25971. digest(mesh: Mesh, options?: {
  25972. facetNb?: number;
  25973. number?: number;
  25974. delta?: number;
  25975. }): SolidParticleSystem;
  25976. private _unrotateFixedNormals;
  25977. private _resetCopy;
  25978. private _meshBuilder;
  25979. private _posToShape;
  25980. private _uvsToShapeUV;
  25981. private _addParticle;
  25982. /**
  25983. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25984. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25985. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25986. * @param nb (positive integer) the number of particles to be created from this model
  25987. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25988. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25989. * @returns the number of shapes in the system
  25990. */
  25991. addShape(mesh: Mesh, nb: number, options?: {
  25992. positionFunction?: any;
  25993. vertexFunction?: any;
  25994. }): number;
  25995. private _rebuildParticle;
  25996. /**
  25997. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25998. * @returns the SPS.
  25999. */
  26000. rebuildMesh(): SolidParticleSystem;
  26001. /**
  26002. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26003. * This method calls `updateParticle()` for each particle of the SPS.
  26004. * For an animated SPS, it is usually called within the render loop.
  26005. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26006. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26007. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26008. * @returns the SPS.
  26009. */
  26010. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26011. /**
  26012. * Disposes the SPS.
  26013. */
  26014. dispose(): void;
  26015. /**
  26016. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26017. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26018. * @returns the SPS.
  26019. */
  26020. refreshVisibleSize(): SolidParticleSystem;
  26021. /**
  26022. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26023. * @param size the size (float) of the visibility box
  26024. * note : this doesn't lock the SPS mesh bounding box.
  26025. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26026. */
  26027. setVisibilityBox(size: number): void;
  26028. /**
  26029. * Gets whether the SPS as always visible or not
  26030. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26031. */
  26032. /**
  26033. * Sets the SPS as always visible or not
  26034. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26035. */
  26036. isAlwaysVisible: boolean;
  26037. /**
  26038. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26039. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26040. */
  26041. /**
  26042. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26043. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26044. */
  26045. isVisibilityBoxLocked: boolean;
  26046. /**
  26047. * Tells to `setParticles()` to compute the particle rotations or not.
  26048. * Default value : true. The SPS is faster when it's set to false.
  26049. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26050. */
  26051. /**
  26052. * Gets if `setParticles()` computes the particle rotations or not.
  26053. * Default value : true. The SPS is faster when it's set to false.
  26054. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26055. */
  26056. computeParticleRotation: boolean;
  26057. /**
  26058. * Tells to `setParticles()` to compute the particle colors or not.
  26059. * Default value : true. The SPS is faster when it's set to false.
  26060. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26061. */
  26062. /**
  26063. * Gets if `setParticles()` computes the particle colors or not.
  26064. * Default value : true. The SPS is faster when it's set to false.
  26065. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26066. */
  26067. computeParticleColor: boolean;
  26068. /**
  26069. * Gets if `setParticles()` computes the particle textures or not.
  26070. * Default value : true. The SPS is faster when it's set to false.
  26071. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26072. */
  26073. computeParticleTexture: boolean;
  26074. /**
  26075. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26076. * Default value : false. The SPS is faster when it's set to false.
  26077. * Note : the particle custom vertex positions aren't stored values.
  26078. */
  26079. /**
  26080. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26081. * Default value : false. The SPS is faster when it's set to false.
  26082. * Note : the particle custom vertex positions aren't stored values.
  26083. */
  26084. computeParticleVertex: boolean;
  26085. /**
  26086. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26087. */
  26088. /**
  26089. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26090. */
  26091. computeBoundingBox: boolean;
  26092. /**
  26093. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26094. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26095. * Default : `true`
  26096. */
  26097. /**
  26098. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26099. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26100. * Default : `true`
  26101. */
  26102. depthSortParticles: boolean;
  26103. /**
  26104. * This function does nothing. It may be overwritten to set all the particle first values.
  26105. * The SPS doesn't call this function, you may have to call it by your own.
  26106. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26107. */
  26108. initParticles(): void;
  26109. /**
  26110. * This function does nothing. It may be overwritten to recycle a particle.
  26111. * The SPS doesn't call this function, you may have to call it by your own.
  26112. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26113. * @param particle The particle to recycle
  26114. * @returns the recycled particle
  26115. */
  26116. recycleParticle(particle: SolidParticle): SolidParticle;
  26117. /**
  26118. * Updates a particle : this function should be overwritten by the user.
  26119. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26120. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26121. * @example : just set a particle position or velocity and recycle conditions
  26122. * @param particle The particle to update
  26123. * @returns the updated particle
  26124. */
  26125. updateParticle(particle: SolidParticle): SolidParticle;
  26126. /**
  26127. * Updates a vertex of a particle : it can be overwritten by the user.
  26128. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26129. * @param particle the current particle
  26130. * @param vertex the current index of the current particle
  26131. * @param pt the index of the current vertex in the particle shape
  26132. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26133. * @example : just set a vertex particle position
  26134. * @returns the updated vertex
  26135. */
  26136. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26137. /**
  26138. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26139. * This does nothing and may be overwritten by the user.
  26140. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26141. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26142. * @param update the boolean update value actually passed to setParticles()
  26143. */
  26144. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26145. /**
  26146. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26147. * This will be passed three parameters.
  26148. * This does nothing and may be overwritten by the user.
  26149. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26150. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26151. * @param update the boolean update value actually passed to setParticles()
  26152. */
  26153. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26154. }
  26155. }
  26156. declare module "babylonjs/Particles/solidParticle" {
  26157. import { Nullable } from "babylonjs/types";
  26158. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26159. import { Color4 } from "babylonjs/Maths/math.color";
  26160. import { Mesh } from "babylonjs/Meshes/mesh";
  26161. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26162. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26163. import { Plane } from "babylonjs/Maths/math.plane";
  26164. /**
  26165. * Represents one particle of a solid particle system.
  26166. */
  26167. export class SolidParticle {
  26168. /**
  26169. * particle global index
  26170. */
  26171. idx: number;
  26172. /**
  26173. * The color of the particle
  26174. */
  26175. color: Nullable<Color4>;
  26176. /**
  26177. * The world space position of the particle.
  26178. */
  26179. position: Vector3;
  26180. /**
  26181. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26182. */
  26183. rotation: Vector3;
  26184. /**
  26185. * The world space rotation quaternion of the particle.
  26186. */
  26187. rotationQuaternion: Nullable<Quaternion>;
  26188. /**
  26189. * The scaling of the particle.
  26190. */
  26191. scaling: Vector3;
  26192. /**
  26193. * The uvs of the particle.
  26194. */
  26195. uvs: Vector4;
  26196. /**
  26197. * The current speed of the particle.
  26198. */
  26199. velocity: Vector3;
  26200. /**
  26201. * The pivot point in the particle local space.
  26202. */
  26203. pivot: Vector3;
  26204. /**
  26205. * Must the particle be translated from its pivot point in its local space ?
  26206. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26207. * Default : false
  26208. */
  26209. translateFromPivot: boolean;
  26210. /**
  26211. * Is the particle active or not ?
  26212. */
  26213. alive: boolean;
  26214. /**
  26215. * Is the particle visible or not ?
  26216. */
  26217. isVisible: boolean;
  26218. /**
  26219. * Index of this particle in the global "positions" array (Internal use)
  26220. * @hidden
  26221. */
  26222. _pos: number;
  26223. /**
  26224. * @hidden Index of this particle in the global "indices" array (Internal use)
  26225. */
  26226. _ind: number;
  26227. /**
  26228. * @hidden ModelShape of this particle (Internal use)
  26229. */
  26230. _model: ModelShape;
  26231. /**
  26232. * ModelShape id of this particle
  26233. */
  26234. shapeId: number;
  26235. /**
  26236. * Index of the particle in its shape id
  26237. */
  26238. idxInShape: number;
  26239. /**
  26240. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26241. */
  26242. _modelBoundingInfo: BoundingInfo;
  26243. /**
  26244. * @hidden Particle BoundingInfo object (Internal use)
  26245. */
  26246. _boundingInfo: BoundingInfo;
  26247. /**
  26248. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26249. */
  26250. _sps: SolidParticleSystem;
  26251. /**
  26252. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26253. */
  26254. _stillInvisible: boolean;
  26255. /**
  26256. * @hidden Last computed particle rotation matrix
  26257. */
  26258. _rotationMatrix: number[];
  26259. /**
  26260. * Parent particle Id, if any.
  26261. * Default null.
  26262. */
  26263. parentId: Nullable<number>;
  26264. /**
  26265. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26266. * The possible values are :
  26267. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26268. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26269. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26270. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26271. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26272. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26273. * */
  26274. cullingStrategy: number;
  26275. /**
  26276. * @hidden Internal global position in the SPS.
  26277. */
  26278. _globalPosition: Vector3;
  26279. /**
  26280. * Creates a Solid Particle object.
  26281. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26282. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26283. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26284. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26285. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26286. * @param shapeId (integer) is the model shape identifier in the SPS.
  26287. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26288. * @param sps defines the sps it is associated to
  26289. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26290. */
  26291. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26292. /**
  26293. * Legacy support, changed scale to scaling
  26294. */
  26295. /**
  26296. * Legacy support, changed scale to scaling
  26297. */
  26298. scale: Vector3;
  26299. /**
  26300. * Legacy support, changed quaternion to rotationQuaternion
  26301. */
  26302. /**
  26303. * Legacy support, changed quaternion to rotationQuaternion
  26304. */
  26305. quaternion: Nullable<Quaternion>;
  26306. /**
  26307. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26308. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26309. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26310. * @returns true if it intersects
  26311. */
  26312. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26313. /**
  26314. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26315. * A particle is in the frustum if its bounding box intersects the frustum
  26316. * @param frustumPlanes defines the frustum to test
  26317. * @returns true if the particle is in the frustum planes
  26318. */
  26319. isInFrustum(frustumPlanes: Plane[]): boolean;
  26320. /**
  26321. * get the rotation matrix of the particle
  26322. * @hidden
  26323. */
  26324. getRotationMatrix(m: Matrix): void;
  26325. }
  26326. /**
  26327. * Represents the shape of the model used by one particle of a solid particle system.
  26328. * SPS internal tool, don't use it manually.
  26329. */
  26330. export class ModelShape {
  26331. /**
  26332. * The shape id
  26333. * @hidden
  26334. */
  26335. shapeID: number;
  26336. /**
  26337. * flat array of model positions (internal use)
  26338. * @hidden
  26339. */
  26340. _shape: Vector3[];
  26341. /**
  26342. * flat array of model UVs (internal use)
  26343. * @hidden
  26344. */
  26345. _shapeUV: number[];
  26346. /**
  26347. * length of the shape in the model indices array (internal use)
  26348. * @hidden
  26349. */
  26350. _indicesLength: number;
  26351. /**
  26352. * Custom position function (internal use)
  26353. * @hidden
  26354. */
  26355. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26356. /**
  26357. * Custom vertex function (internal use)
  26358. * @hidden
  26359. */
  26360. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26361. /**
  26362. * 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.
  26363. * SPS internal tool, don't use it manually.
  26364. * @hidden
  26365. */
  26366. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  26367. }
  26368. /**
  26369. * Represents a Depth Sorted Particle in the solid particle system.
  26370. */
  26371. export class DepthSortedParticle {
  26372. /**
  26373. * Index of the particle in the "indices" array
  26374. */
  26375. ind: number;
  26376. /**
  26377. * Length of the particle shape in the "indices" array
  26378. */
  26379. indicesLength: number;
  26380. /**
  26381. * Squared distance from the particle to the camera
  26382. */
  26383. sqDistance: number;
  26384. }
  26385. }
  26386. declare module "babylonjs/Collisions/meshCollisionData" {
  26387. import { Collider } from "babylonjs/Collisions/collider";
  26388. import { Vector3 } from "babylonjs/Maths/math.vector";
  26389. import { Nullable } from "babylonjs/types";
  26390. import { Observer } from "babylonjs/Misc/observable";
  26391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26392. /**
  26393. * @hidden
  26394. */
  26395. export class _MeshCollisionData {
  26396. _checkCollisions: boolean;
  26397. _collisionMask: number;
  26398. _collisionGroup: number;
  26399. _collider: Nullable<Collider>;
  26400. _oldPositionForCollisions: Vector3;
  26401. _diffPositionForCollisions: Vector3;
  26402. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26403. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26404. }
  26405. }
  26406. declare module "babylonjs/Meshes/abstractMesh" {
  26407. import { Observable } from "babylonjs/Misc/observable";
  26408. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26409. import { Camera } from "babylonjs/Cameras/camera";
  26410. import { Scene, IDisposable } from "babylonjs/scene";
  26411. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26412. import { Node } from "babylonjs/node";
  26413. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26414. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26415. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26416. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26417. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26418. import { Material } from "babylonjs/Materials/material";
  26419. import { Light } from "babylonjs/Lights/light";
  26420. import { Skeleton } from "babylonjs/Bones/skeleton";
  26421. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26422. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26423. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26424. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26425. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26426. import { Plane } from "babylonjs/Maths/math.plane";
  26427. import { Ray } from "babylonjs/Culling/ray";
  26428. import { Collider } from "babylonjs/Collisions/collider";
  26429. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26430. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26431. /** @hidden */
  26432. class _FacetDataStorage {
  26433. facetPositions: Vector3[];
  26434. facetNormals: Vector3[];
  26435. facetPartitioning: number[][];
  26436. facetNb: number;
  26437. partitioningSubdivisions: number;
  26438. partitioningBBoxRatio: number;
  26439. facetDataEnabled: boolean;
  26440. facetParameters: any;
  26441. bbSize: Vector3;
  26442. subDiv: {
  26443. max: number;
  26444. X: number;
  26445. Y: number;
  26446. Z: number;
  26447. };
  26448. facetDepthSort: boolean;
  26449. facetDepthSortEnabled: boolean;
  26450. depthSortedIndices: IndicesArray;
  26451. depthSortedFacets: {
  26452. ind: number;
  26453. sqDistance: number;
  26454. }[];
  26455. facetDepthSortFunction: (f1: {
  26456. ind: number;
  26457. sqDistance: number;
  26458. }, f2: {
  26459. ind: number;
  26460. sqDistance: number;
  26461. }) => number;
  26462. facetDepthSortFrom: Vector3;
  26463. facetDepthSortOrigin: Vector3;
  26464. invertedMatrix: Matrix;
  26465. }
  26466. /**
  26467. * @hidden
  26468. **/
  26469. class _InternalAbstractMeshDataInfo {
  26470. _hasVertexAlpha: boolean;
  26471. _useVertexColors: boolean;
  26472. _numBoneInfluencers: number;
  26473. _applyFog: boolean;
  26474. _receiveShadows: boolean;
  26475. _facetData: _FacetDataStorage;
  26476. _visibility: number;
  26477. _skeleton: Nullable<Skeleton>;
  26478. _layerMask: number;
  26479. _computeBonesUsingShaders: boolean;
  26480. _isActive: boolean;
  26481. _onlyForInstances: boolean;
  26482. _isActiveIntermediate: boolean;
  26483. _onlyForInstancesIntermediate: boolean;
  26484. }
  26485. /**
  26486. * Class used to store all common mesh properties
  26487. */
  26488. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26489. /** No occlusion */
  26490. static OCCLUSION_TYPE_NONE: number;
  26491. /** Occlusion set to optimisitic */
  26492. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26493. /** Occlusion set to strict */
  26494. static OCCLUSION_TYPE_STRICT: number;
  26495. /** Use an accurante occlusion algorithm */
  26496. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26497. /** Use a conservative occlusion algorithm */
  26498. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26499. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26500. * Test order :
  26501. * Is the bounding sphere outside the frustum ?
  26502. * If not, are the bounding box vertices outside the frustum ?
  26503. * It not, then the cullable object is in the frustum.
  26504. */
  26505. static readonly CULLINGSTRATEGY_STANDARD: number;
  26506. /** Culling strategy : Bounding Sphere Only.
  26507. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26508. * It's also less accurate than the standard because some not visible objects can still be selected.
  26509. * Test : is the bounding sphere outside the frustum ?
  26510. * If not, then the cullable object is in the frustum.
  26511. */
  26512. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26513. /** Culling strategy : Optimistic Inclusion.
  26514. * This in an inclusion test first, then the standard exclusion test.
  26515. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26516. * 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.
  26517. * Anyway, it's as accurate as the standard strategy.
  26518. * Test :
  26519. * Is the cullable object bounding sphere center in the frustum ?
  26520. * If not, apply the default culling strategy.
  26521. */
  26522. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26523. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26524. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26525. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26526. * 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.
  26527. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26528. * Test :
  26529. * Is the cullable object bounding sphere center in the frustum ?
  26530. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26531. */
  26532. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26533. /**
  26534. * No billboard
  26535. */
  26536. static readonly BILLBOARDMODE_NONE: number;
  26537. /** Billboard on X axis */
  26538. static readonly BILLBOARDMODE_X: number;
  26539. /** Billboard on Y axis */
  26540. static readonly BILLBOARDMODE_Y: number;
  26541. /** Billboard on Z axis */
  26542. static readonly BILLBOARDMODE_Z: number;
  26543. /** Billboard on all axes */
  26544. static readonly BILLBOARDMODE_ALL: number;
  26545. /** Billboard on using position instead of orientation */
  26546. static readonly BILLBOARDMODE_USE_POSITION: number;
  26547. /** @hidden */
  26548. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26549. /**
  26550. * The culling strategy to use to check whether the mesh must be rendered or not.
  26551. * This value can be changed at any time and will be used on the next render mesh selection.
  26552. * The possible values are :
  26553. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26554. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26555. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26556. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26557. * Please read each static variable documentation to get details about the culling process.
  26558. * */
  26559. cullingStrategy: number;
  26560. /**
  26561. * Gets the number of facets in the mesh
  26562. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26563. */
  26564. readonly facetNb: number;
  26565. /**
  26566. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26567. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26568. */
  26569. partitioningSubdivisions: number;
  26570. /**
  26571. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26572. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26573. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26574. */
  26575. partitioningBBoxRatio: number;
  26576. /**
  26577. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26578. * Works only for updatable meshes.
  26579. * Doesn't work with multi-materials
  26580. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26581. */
  26582. mustDepthSortFacets: boolean;
  26583. /**
  26584. * The location (Vector3) where the facet depth sort must be computed from.
  26585. * By default, the active camera position.
  26586. * Used only when facet depth sort is enabled
  26587. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26588. */
  26589. facetDepthSortFrom: Vector3;
  26590. /**
  26591. * gets a boolean indicating if facetData is enabled
  26592. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26593. */
  26594. readonly isFacetDataEnabled: boolean;
  26595. /** @hidden */
  26596. _updateNonUniformScalingState(value: boolean): boolean;
  26597. /**
  26598. * An event triggered when this mesh collides with another one
  26599. */
  26600. onCollideObservable: Observable<AbstractMesh>;
  26601. /** Set a function to call when this mesh collides with another one */
  26602. onCollide: () => void;
  26603. /**
  26604. * An event triggered when the collision's position changes
  26605. */
  26606. onCollisionPositionChangeObservable: Observable<Vector3>;
  26607. /** Set a function to call when the collision's position changes */
  26608. onCollisionPositionChange: () => void;
  26609. /**
  26610. * An event triggered when material is changed
  26611. */
  26612. onMaterialChangedObservable: Observable<AbstractMesh>;
  26613. /**
  26614. * Gets or sets the orientation for POV movement & rotation
  26615. */
  26616. definedFacingForward: boolean;
  26617. /** @hidden */
  26618. _occlusionQuery: Nullable<WebGLQuery>;
  26619. /** @hidden */
  26620. _renderingGroup: Nullable<RenderingGroup>;
  26621. /**
  26622. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26623. */
  26624. /**
  26625. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26626. */
  26627. visibility: number;
  26628. /** Gets or sets the alpha index used to sort transparent meshes
  26629. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26630. */
  26631. alphaIndex: number;
  26632. /**
  26633. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26634. */
  26635. isVisible: boolean;
  26636. /**
  26637. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26638. */
  26639. isPickable: boolean;
  26640. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26641. showSubMeshesBoundingBox: boolean;
  26642. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26643. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26644. */
  26645. isBlocker: boolean;
  26646. /**
  26647. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26648. */
  26649. enablePointerMoveEvents: boolean;
  26650. /**
  26651. * Specifies the rendering group id for this mesh (0 by default)
  26652. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26653. */
  26654. renderingGroupId: number;
  26655. private _material;
  26656. /** Gets or sets current material */
  26657. material: Nullable<Material>;
  26658. /**
  26659. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26660. * @see http://doc.babylonjs.com/babylon101/shadows
  26661. */
  26662. receiveShadows: boolean;
  26663. /** Defines color to use when rendering outline */
  26664. outlineColor: Color3;
  26665. /** Define width to use when rendering outline */
  26666. outlineWidth: number;
  26667. /** Defines color to use when rendering overlay */
  26668. overlayColor: Color3;
  26669. /** Defines alpha to use when rendering overlay */
  26670. overlayAlpha: number;
  26671. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26672. hasVertexAlpha: boolean;
  26673. /** 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) */
  26674. useVertexColors: boolean;
  26675. /**
  26676. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26677. */
  26678. computeBonesUsingShaders: boolean;
  26679. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26680. numBoneInfluencers: number;
  26681. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26682. applyFog: boolean;
  26683. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26684. useOctreeForRenderingSelection: boolean;
  26685. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26686. useOctreeForPicking: boolean;
  26687. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26688. useOctreeForCollisions: boolean;
  26689. /**
  26690. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26691. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26692. */
  26693. layerMask: number;
  26694. /**
  26695. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26696. */
  26697. alwaysSelectAsActiveMesh: boolean;
  26698. /**
  26699. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26700. */
  26701. doNotSyncBoundingInfo: boolean;
  26702. /**
  26703. * Gets or sets the current action manager
  26704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26705. */
  26706. actionManager: Nullable<AbstractActionManager>;
  26707. private _meshCollisionData;
  26708. /**
  26709. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26710. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26711. */
  26712. ellipsoid: Vector3;
  26713. /**
  26714. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26715. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26716. */
  26717. ellipsoidOffset: Vector3;
  26718. /**
  26719. * Gets or sets a collision mask used to mask collisions (default is -1).
  26720. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26721. */
  26722. collisionMask: number;
  26723. /**
  26724. * Gets or sets the current collision group mask (-1 by default).
  26725. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26726. */
  26727. collisionGroup: number;
  26728. /**
  26729. * Defines edge width used when edgesRenderer is enabled
  26730. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26731. */
  26732. edgesWidth: number;
  26733. /**
  26734. * Defines edge color used when edgesRenderer is enabled
  26735. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26736. */
  26737. edgesColor: Color4;
  26738. /** @hidden */
  26739. _edgesRenderer: Nullable<IEdgesRenderer>;
  26740. /** @hidden */
  26741. _masterMesh: Nullable<AbstractMesh>;
  26742. /** @hidden */
  26743. _boundingInfo: Nullable<BoundingInfo>;
  26744. /** @hidden */
  26745. _renderId: number;
  26746. /**
  26747. * Gets or sets the list of subMeshes
  26748. * @see http://doc.babylonjs.com/how_to/multi_materials
  26749. */
  26750. subMeshes: SubMesh[];
  26751. /** @hidden */
  26752. _intersectionsInProgress: AbstractMesh[];
  26753. /** @hidden */
  26754. _unIndexed: boolean;
  26755. /** @hidden */
  26756. _lightSources: Light[];
  26757. /** Gets the list of lights affecting that mesh */
  26758. readonly lightSources: Light[];
  26759. /** @hidden */
  26760. readonly _positions: Nullable<Vector3[]>;
  26761. /** @hidden */
  26762. _waitingData: {
  26763. lods: Nullable<any>;
  26764. actions: Nullable<any>;
  26765. freezeWorldMatrix: Nullable<boolean>;
  26766. };
  26767. /** @hidden */
  26768. _bonesTransformMatrices: Nullable<Float32Array>;
  26769. /** @hidden */
  26770. _transformMatrixTexture: Nullable<RawTexture>;
  26771. /**
  26772. * Gets or sets a skeleton to apply skining transformations
  26773. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26774. */
  26775. skeleton: Nullable<Skeleton>;
  26776. /**
  26777. * An event triggered when the mesh is rebuilt.
  26778. */
  26779. onRebuildObservable: Observable<AbstractMesh>;
  26780. /**
  26781. * Creates a new AbstractMesh
  26782. * @param name defines the name of the mesh
  26783. * @param scene defines the hosting scene
  26784. */
  26785. constructor(name: string, scene?: Nullable<Scene>);
  26786. /**
  26787. * Returns the string "AbstractMesh"
  26788. * @returns "AbstractMesh"
  26789. */
  26790. getClassName(): string;
  26791. /**
  26792. * Gets a string representation of the current mesh
  26793. * @param fullDetails defines a boolean indicating if full details must be included
  26794. * @returns a string representation of the current mesh
  26795. */
  26796. toString(fullDetails?: boolean): string;
  26797. /**
  26798. * @hidden
  26799. */
  26800. protected _getEffectiveParent(): Nullable<Node>;
  26801. /** @hidden */
  26802. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26803. /** @hidden */
  26804. _rebuild(): void;
  26805. /** @hidden */
  26806. _resyncLightSources(): void;
  26807. /** @hidden */
  26808. _resyncLighSource(light: Light): void;
  26809. /** @hidden */
  26810. _unBindEffect(): void;
  26811. /** @hidden */
  26812. _removeLightSource(light: Light, dispose: boolean): void;
  26813. private _markSubMeshesAsDirty;
  26814. /** @hidden */
  26815. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26816. /** @hidden */
  26817. _markSubMeshesAsAttributesDirty(): void;
  26818. /** @hidden */
  26819. _markSubMeshesAsMiscDirty(): void;
  26820. /**
  26821. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26822. */
  26823. scaling: Vector3;
  26824. /**
  26825. * Returns true if the mesh is blocked. Implemented by child classes
  26826. */
  26827. readonly isBlocked: boolean;
  26828. /**
  26829. * Returns the mesh itself by default. Implemented by child classes
  26830. * @param camera defines the camera to use to pick the right LOD level
  26831. * @returns the currentAbstractMesh
  26832. */
  26833. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26834. /**
  26835. * Returns 0 by default. Implemented by child classes
  26836. * @returns an integer
  26837. */
  26838. getTotalVertices(): number;
  26839. /**
  26840. * Returns a positive integer : the total number of indices in this mesh geometry.
  26841. * @returns the numner of indices or zero if the mesh has no geometry.
  26842. */
  26843. getTotalIndices(): number;
  26844. /**
  26845. * Returns null by default. Implemented by child classes
  26846. * @returns null
  26847. */
  26848. getIndices(): Nullable<IndicesArray>;
  26849. /**
  26850. * Returns the array of the requested vertex data kind. Implemented by child classes
  26851. * @param kind defines the vertex data kind to use
  26852. * @returns null
  26853. */
  26854. getVerticesData(kind: string): Nullable<FloatArray>;
  26855. /**
  26856. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26857. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26858. * Note that a new underlying VertexBuffer object is created each call.
  26859. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26860. * @param kind defines vertex data kind:
  26861. * * VertexBuffer.PositionKind
  26862. * * VertexBuffer.UVKind
  26863. * * VertexBuffer.UV2Kind
  26864. * * VertexBuffer.UV3Kind
  26865. * * VertexBuffer.UV4Kind
  26866. * * VertexBuffer.UV5Kind
  26867. * * VertexBuffer.UV6Kind
  26868. * * VertexBuffer.ColorKind
  26869. * * VertexBuffer.MatricesIndicesKind
  26870. * * VertexBuffer.MatricesIndicesExtraKind
  26871. * * VertexBuffer.MatricesWeightsKind
  26872. * * VertexBuffer.MatricesWeightsExtraKind
  26873. * @param data defines the data source
  26874. * @param updatable defines if the data must be flagged as updatable (or static)
  26875. * @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
  26876. * @returns the current mesh
  26877. */
  26878. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26879. /**
  26880. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26881. * If the mesh has no geometry, it is simply returned as it is.
  26882. * @param kind defines vertex data kind:
  26883. * * VertexBuffer.PositionKind
  26884. * * VertexBuffer.UVKind
  26885. * * VertexBuffer.UV2Kind
  26886. * * VertexBuffer.UV3Kind
  26887. * * VertexBuffer.UV4Kind
  26888. * * VertexBuffer.UV5Kind
  26889. * * VertexBuffer.UV6Kind
  26890. * * VertexBuffer.ColorKind
  26891. * * VertexBuffer.MatricesIndicesKind
  26892. * * VertexBuffer.MatricesIndicesExtraKind
  26893. * * VertexBuffer.MatricesWeightsKind
  26894. * * VertexBuffer.MatricesWeightsExtraKind
  26895. * @param data defines the data source
  26896. * @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
  26897. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26898. * @returns the current mesh
  26899. */
  26900. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26901. /**
  26902. * Sets the mesh indices,
  26903. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26904. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26905. * @param totalVertices Defines the total number of vertices
  26906. * @returns the current mesh
  26907. */
  26908. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26909. /**
  26910. * Gets a boolean indicating if specific vertex data is present
  26911. * @param kind defines the vertex data kind to use
  26912. * @returns true is data kind is present
  26913. */
  26914. isVerticesDataPresent(kind: string): boolean;
  26915. /**
  26916. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26917. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26918. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26919. * @returns a BoundingInfo
  26920. */
  26921. getBoundingInfo(): BoundingInfo;
  26922. /**
  26923. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26924. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26925. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26926. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26927. * @returns the current mesh
  26928. */
  26929. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26930. /**
  26931. * Overwrite the current bounding info
  26932. * @param boundingInfo defines the new bounding info
  26933. * @returns the current mesh
  26934. */
  26935. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26936. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26937. readonly useBones: boolean;
  26938. /** @hidden */
  26939. _preActivate(): void;
  26940. /** @hidden */
  26941. _preActivateForIntermediateRendering(renderId: number): void;
  26942. /** @hidden */
  26943. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26944. /** @hidden */
  26945. _postActivate(): void;
  26946. /** @hidden */
  26947. _freeze(): void;
  26948. /** @hidden */
  26949. _unFreeze(): void;
  26950. /**
  26951. * Gets the current world matrix
  26952. * @returns a Matrix
  26953. */
  26954. getWorldMatrix(): Matrix;
  26955. /** @hidden */
  26956. _getWorldMatrixDeterminant(): number;
  26957. /**
  26958. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26959. */
  26960. readonly isAnInstance: boolean;
  26961. /**
  26962. * Gets a boolean indicating if this mesh has instances
  26963. */
  26964. readonly hasInstances: boolean;
  26965. /**
  26966. * Perform relative position change from the point of view of behind the front of the mesh.
  26967. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26968. * Supports definition of mesh facing forward or backward
  26969. * @param amountRight defines the distance on the right axis
  26970. * @param amountUp defines the distance on the up axis
  26971. * @param amountForward defines the distance on the forward axis
  26972. * @returns the current mesh
  26973. */
  26974. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26975. /**
  26976. * Calculate relative position change from the point of view of behind the front of the mesh.
  26977. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26978. * Supports definition of mesh facing forward or backward
  26979. * @param amountRight defines the distance on the right axis
  26980. * @param amountUp defines the distance on the up axis
  26981. * @param amountForward defines the distance on the forward axis
  26982. * @returns the new displacement vector
  26983. */
  26984. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26985. /**
  26986. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26987. * Supports definition of mesh facing forward or backward
  26988. * @param flipBack defines the flip
  26989. * @param twirlClockwise defines the twirl
  26990. * @param tiltRight defines the tilt
  26991. * @returns the current mesh
  26992. */
  26993. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26994. /**
  26995. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26996. * Supports definition of mesh facing forward or backward.
  26997. * @param flipBack defines the flip
  26998. * @param twirlClockwise defines the twirl
  26999. * @param tiltRight defines the tilt
  27000. * @returns the new rotation vector
  27001. */
  27002. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27003. /**
  27004. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27005. * This means the mesh underlying bounding box and sphere are recomputed.
  27006. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27007. * @returns the current mesh
  27008. */
  27009. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27010. /** @hidden */
  27011. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27012. /** @hidden */
  27013. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27014. /** @hidden */
  27015. _updateBoundingInfo(): AbstractMesh;
  27016. /** @hidden */
  27017. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27018. /** @hidden */
  27019. protected _afterComputeWorldMatrix(): void;
  27020. /** @hidden */
  27021. readonly _effectiveMesh: AbstractMesh;
  27022. /**
  27023. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27024. * A mesh is in the frustum if its bounding box intersects the frustum
  27025. * @param frustumPlanes defines the frustum to test
  27026. * @returns true if the mesh is in the frustum planes
  27027. */
  27028. isInFrustum(frustumPlanes: Plane[]): boolean;
  27029. /**
  27030. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27031. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27032. * @param frustumPlanes defines the frustum to test
  27033. * @returns true if the mesh is completely in the frustum planes
  27034. */
  27035. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27036. /**
  27037. * True if the mesh intersects another mesh or a SolidParticle object
  27038. * @param mesh defines a target mesh or SolidParticle to test
  27039. * @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)
  27040. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27041. * @returns true if there is an intersection
  27042. */
  27043. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27044. /**
  27045. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27046. * @param point defines the point to test
  27047. * @returns true if there is an intersection
  27048. */
  27049. intersectsPoint(point: Vector3): boolean;
  27050. /**
  27051. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27052. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27053. */
  27054. checkCollisions: boolean;
  27055. /**
  27056. * Gets Collider object used to compute collisions (not physics)
  27057. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27058. */
  27059. readonly collider: Nullable<Collider>;
  27060. /**
  27061. * Move the mesh using collision engine
  27062. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27063. * @param displacement defines the requested displacement vector
  27064. * @returns the current mesh
  27065. */
  27066. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27067. private _onCollisionPositionChange;
  27068. /** @hidden */
  27069. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27070. /** @hidden */
  27071. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27072. /** @hidden */
  27073. _checkCollision(collider: Collider): AbstractMesh;
  27074. /** @hidden */
  27075. _generatePointsArray(): boolean;
  27076. /**
  27077. * Checks if the passed Ray intersects with the mesh
  27078. * @param ray defines the ray to use
  27079. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27080. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27081. * @returns the picking info
  27082. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27083. */
  27084. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27085. /**
  27086. * Clones the current mesh
  27087. * @param name defines the mesh name
  27088. * @param newParent defines the new mesh parent
  27089. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27090. * @returns the new mesh
  27091. */
  27092. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27093. /**
  27094. * Disposes all the submeshes of the current meshnp
  27095. * @returns the current mesh
  27096. */
  27097. releaseSubMeshes(): AbstractMesh;
  27098. /**
  27099. * Releases resources associated with this abstract mesh.
  27100. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27101. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27102. */
  27103. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27104. /**
  27105. * Adds the passed mesh as a child to the current mesh
  27106. * @param mesh defines the child mesh
  27107. * @returns the current mesh
  27108. */
  27109. addChild(mesh: AbstractMesh): AbstractMesh;
  27110. /**
  27111. * Removes the passed mesh from the current mesh children list
  27112. * @param mesh defines the child mesh
  27113. * @returns the current mesh
  27114. */
  27115. removeChild(mesh: AbstractMesh): AbstractMesh;
  27116. /** @hidden */
  27117. private _initFacetData;
  27118. /**
  27119. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27120. * This method can be called within the render loop.
  27121. * 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
  27122. * @returns the current mesh
  27123. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27124. */
  27125. updateFacetData(): AbstractMesh;
  27126. /**
  27127. * Returns the facetLocalNormals array.
  27128. * The normals are expressed in the mesh local spac
  27129. * @returns an array of Vector3
  27130. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27131. */
  27132. getFacetLocalNormals(): Vector3[];
  27133. /**
  27134. * Returns the facetLocalPositions array.
  27135. * The facet positions are expressed in the mesh local space
  27136. * @returns an array of Vector3
  27137. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27138. */
  27139. getFacetLocalPositions(): Vector3[];
  27140. /**
  27141. * Returns the facetLocalPartioning array
  27142. * @returns an array of array of numbers
  27143. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27144. */
  27145. getFacetLocalPartitioning(): number[][];
  27146. /**
  27147. * Returns the i-th facet position in the world system.
  27148. * This method allocates a new Vector3 per call
  27149. * @param i defines the facet index
  27150. * @returns a new Vector3
  27151. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27152. */
  27153. getFacetPosition(i: number): Vector3;
  27154. /**
  27155. * Sets the reference Vector3 with the i-th facet position in the world system
  27156. * @param i defines the facet index
  27157. * @param ref defines the target vector
  27158. * @returns the current mesh
  27159. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27160. */
  27161. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27162. /**
  27163. * Returns the i-th facet normal in the world system.
  27164. * This method allocates a new Vector3 per call
  27165. * @param i defines the facet index
  27166. * @returns a new Vector3
  27167. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27168. */
  27169. getFacetNormal(i: number): Vector3;
  27170. /**
  27171. * Sets the reference Vector3 with the i-th facet normal in the world system
  27172. * @param i defines the facet index
  27173. * @param ref defines the target vector
  27174. * @returns the current mesh
  27175. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27176. */
  27177. getFacetNormalToRef(i: number, ref: Vector3): this;
  27178. /**
  27179. * 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)
  27180. * @param x defines x coordinate
  27181. * @param y defines y coordinate
  27182. * @param z defines z coordinate
  27183. * @returns the array of facet indexes
  27184. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27185. */
  27186. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27187. /**
  27188. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27189. * @param projected sets as the (x,y,z) world projection on the facet
  27190. * @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
  27191. * @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
  27192. * @param x defines x coordinate
  27193. * @param y defines y coordinate
  27194. * @param z defines z coordinate
  27195. * @returns the face index if found (or null instead)
  27196. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27197. */
  27198. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27199. /**
  27200. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27201. * @param projected sets as the (x,y,z) local projection on the facet
  27202. * @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
  27203. * @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
  27204. * @param x defines x coordinate
  27205. * @param y defines y coordinate
  27206. * @param z defines z coordinate
  27207. * @returns the face index if found (or null instead)
  27208. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27209. */
  27210. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27211. /**
  27212. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27213. * @returns the parameters
  27214. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27215. */
  27216. getFacetDataParameters(): any;
  27217. /**
  27218. * Disables the feature FacetData and frees the related memory
  27219. * @returns the current mesh
  27220. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27221. */
  27222. disableFacetData(): AbstractMesh;
  27223. /**
  27224. * Updates the AbstractMesh indices array
  27225. * @param indices defines the data source
  27226. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27227. * @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)
  27228. * @returns the current mesh
  27229. */
  27230. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27231. /**
  27232. * Creates new normals data for the mesh
  27233. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27234. * @returns the current mesh
  27235. */
  27236. createNormals(updatable: boolean): AbstractMesh;
  27237. /**
  27238. * Align the mesh with a normal
  27239. * @param normal defines the normal to use
  27240. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27241. * @returns the current mesh
  27242. */
  27243. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27244. /** @hidden */
  27245. _checkOcclusionQuery(): boolean;
  27246. /**
  27247. * Disables the mesh edge rendering mode
  27248. * @returns the currentAbstractMesh
  27249. */
  27250. disableEdgesRendering(): AbstractMesh;
  27251. /**
  27252. * Enables the edge rendering mode on the mesh.
  27253. * This mode makes the mesh edges visible
  27254. * @param epsilon defines the maximal distance between two angles to detect a face
  27255. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27256. * @returns the currentAbstractMesh
  27257. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27258. */
  27259. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27260. }
  27261. }
  27262. declare module "babylonjs/Actions/actionEvent" {
  27263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27264. import { Nullable } from "babylonjs/types";
  27265. import { Sprite } from "babylonjs/Sprites/sprite";
  27266. import { Scene } from "babylonjs/scene";
  27267. import { Vector2 } from "babylonjs/Maths/math.vector";
  27268. /**
  27269. * Interface used to define ActionEvent
  27270. */
  27271. export interface IActionEvent {
  27272. /** The mesh or sprite that triggered the action */
  27273. source: any;
  27274. /** The X mouse cursor position at the time of the event */
  27275. pointerX: number;
  27276. /** The Y mouse cursor position at the time of the event */
  27277. pointerY: number;
  27278. /** The mesh that is currently pointed at (can be null) */
  27279. meshUnderPointer: Nullable<AbstractMesh>;
  27280. /** the original (browser) event that triggered the ActionEvent */
  27281. sourceEvent?: any;
  27282. /** additional data for the event */
  27283. additionalData?: any;
  27284. }
  27285. /**
  27286. * ActionEvent is the event being sent when an action is triggered.
  27287. */
  27288. export class ActionEvent implements IActionEvent {
  27289. /** The mesh or sprite that triggered the action */
  27290. source: any;
  27291. /** The X mouse cursor position at the time of the event */
  27292. pointerX: number;
  27293. /** The Y mouse cursor position at the time of the event */
  27294. pointerY: number;
  27295. /** The mesh that is currently pointed at (can be null) */
  27296. meshUnderPointer: Nullable<AbstractMesh>;
  27297. /** the original (browser) event that triggered the ActionEvent */
  27298. sourceEvent?: any;
  27299. /** additional data for the event */
  27300. additionalData?: any;
  27301. /**
  27302. * Creates a new ActionEvent
  27303. * @param source The mesh or sprite that triggered the action
  27304. * @param pointerX The X mouse cursor position at the time of the event
  27305. * @param pointerY The Y mouse cursor position at the time of the event
  27306. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27307. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27308. * @param additionalData additional data for the event
  27309. */
  27310. constructor(
  27311. /** The mesh or sprite that triggered the action */
  27312. source: any,
  27313. /** The X mouse cursor position at the time of the event */
  27314. pointerX: number,
  27315. /** The Y mouse cursor position at the time of the event */
  27316. pointerY: number,
  27317. /** The mesh that is currently pointed at (can be null) */
  27318. meshUnderPointer: Nullable<AbstractMesh>,
  27319. /** the original (browser) event that triggered the ActionEvent */
  27320. sourceEvent?: any,
  27321. /** additional data for the event */
  27322. additionalData?: any);
  27323. /**
  27324. * Helper function to auto-create an ActionEvent from a source mesh.
  27325. * @param source The source mesh that triggered the event
  27326. * @param evt The original (browser) event
  27327. * @param additionalData additional data for the event
  27328. * @returns the new ActionEvent
  27329. */
  27330. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27331. /**
  27332. * Helper function to auto-create an ActionEvent from a source sprite
  27333. * @param source The source sprite that triggered the event
  27334. * @param scene Scene associated with the sprite
  27335. * @param evt The original (browser) event
  27336. * @param additionalData additional data for the event
  27337. * @returns the new ActionEvent
  27338. */
  27339. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27340. /**
  27341. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27342. * @param scene the scene where the event occurred
  27343. * @param evt The original (browser) event
  27344. * @returns the new ActionEvent
  27345. */
  27346. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27347. /**
  27348. * Helper function to auto-create an ActionEvent from a primitive
  27349. * @param prim defines the target primitive
  27350. * @param pointerPos defines the pointer position
  27351. * @param evt The original (browser) event
  27352. * @param additionalData additional data for the event
  27353. * @returns the new ActionEvent
  27354. */
  27355. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27356. }
  27357. }
  27358. declare module "babylonjs/Actions/abstractActionManager" {
  27359. import { IDisposable } from "babylonjs/scene";
  27360. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27361. import { IAction } from "babylonjs/Actions/action";
  27362. import { Nullable } from "babylonjs/types";
  27363. /**
  27364. * Abstract class used to decouple action Manager from scene and meshes.
  27365. * Do not instantiate.
  27366. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27367. */
  27368. export abstract class AbstractActionManager implements IDisposable {
  27369. /** Gets the list of active triggers */
  27370. static Triggers: {
  27371. [key: string]: number;
  27372. };
  27373. /** Gets the cursor to use when hovering items */
  27374. hoverCursor: string;
  27375. /** Gets the list of actions */
  27376. actions: IAction[];
  27377. /**
  27378. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27379. */
  27380. isRecursive: boolean;
  27381. /**
  27382. * Releases all associated resources
  27383. */
  27384. abstract dispose(): void;
  27385. /**
  27386. * Does this action manager has pointer triggers
  27387. */
  27388. abstract readonly hasPointerTriggers: boolean;
  27389. /**
  27390. * Does this action manager has pick triggers
  27391. */
  27392. abstract readonly hasPickTriggers: boolean;
  27393. /**
  27394. * Process a specific trigger
  27395. * @param trigger defines the trigger to process
  27396. * @param evt defines the event details to be processed
  27397. */
  27398. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27399. /**
  27400. * Does this action manager handles actions of any of the given triggers
  27401. * @param triggers defines the triggers to be tested
  27402. * @return a boolean indicating whether one (or more) of the triggers is handled
  27403. */
  27404. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27405. /**
  27406. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27407. * speed.
  27408. * @param triggerA defines the trigger to be tested
  27409. * @param triggerB defines the trigger to be tested
  27410. * @return a boolean indicating whether one (or more) of the triggers is handled
  27411. */
  27412. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27413. /**
  27414. * Does this action manager handles actions of a given trigger
  27415. * @param trigger defines the trigger to be tested
  27416. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27417. * @return whether the trigger is handled
  27418. */
  27419. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27420. /**
  27421. * Serialize this manager to a JSON object
  27422. * @param name defines the property name to store this manager
  27423. * @returns a JSON representation of this manager
  27424. */
  27425. abstract serialize(name: string): any;
  27426. /**
  27427. * Registers an action to this action manager
  27428. * @param action defines the action to be registered
  27429. * @return the action amended (prepared) after registration
  27430. */
  27431. abstract registerAction(action: IAction): Nullable<IAction>;
  27432. /**
  27433. * Unregisters an action to this action manager
  27434. * @param action defines the action to be unregistered
  27435. * @return a boolean indicating whether the action has been unregistered
  27436. */
  27437. abstract unregisterAction(action: IAction): Boolean;
  27438. /**
  27439. * Does exist one action manager with at least one trigger
  27440. **/
  27441. static readonly HasTriggers: boolean;
  27442. /**
  27443. * Does exist one action manager with at least one pick trigger
  27444. **/
  27445. static readonly HasPickTriggers: boolean;
  27446. /**
  27447. * Does exist one action manager that handles actions of a given trigger
  27448. * @param trigger defines the trigger to be tested
  27449. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27450. **/
  27451. static HasSpecificTrigger(trigger: number): boolean;
  27452. }
  27453. }
  27454. declare module "babylonjs/node" {
  27455. import { Scene } from "babylonjs/scene";
  27456. import { Nullable } from "babylonjs/types";
  27457. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27458. import { Engine } from "babylonjs/Engines/engine";
  27459. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27460. import { Observable } from "babylonjs/Misc/observable";
  27461. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27462. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27463. import { Animatable } from "babylonjs/Animations/animatable";
  27464. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27465. import { Animation } from "babylonjs/Animations/animation";
  27466. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27468. /**
  27469. * Defines how a node can be built from a string name.
  27470. */
  27471. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27472. /**
  27473. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27474. */
  27475. export class Node implements IBehaviorAware<Node> {
  27476. /** @hidden */
  27477. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27478. private static _NodeConstructors;
  27479. /**
  27480. * Add a new node constructor
  27481. * @param type defines the type name of the node to construct
  27482. * @param constructorFunc defines the constructor function
  27483. */
  27484. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27485. /**
  27486. * Returns a node constructor based on type name
  27487. * @param type defines the type name
  27488. * @param name defines the new node name
  27489. * @param scene defines the hosting scene
  27490. * @param options defines optional options to transmit to constructors
  27491. * @returns the new constructor or null
  27492. */
  27493. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27494. /**
  27495. * Gets or sets the name of the node
  27496. */
  27497. name: string;
  27498. /**
  27499. * Gets or sets the id of the node
  27500. */
  27501. id: string;
  27502. /**
  27503. * Gets or sets the unique id of the node
  27504. */
  27505. uniqueId: number;
  27506. /**
  27507. * Gets or sets a string used to store user defined state for the node
  27508. */
  27509. state: string;
  27510. /**
  27511. * Gets or sets an object used to store user defined information for the node
  27512. */
  27513. metadata: any;
  27514. /**
  27515. * For internal use only. Please do not use.
  27516. */
  27517. reservedDataStore: any;
  27518. /**
  27519. * List of inspectable custom properties (used by the Inspector)
  27520. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27521. */
  27522. inspectableCustomProperties: IInspectable[];
  27523. /**
  27524. * Gets or sets a boolean used to define if the node must be serialized
  27525. */
  27526. doNotSerialize: boolean;
  27527. /** @hidden */
  27528. _isDisposed: boolean;
  27529. /**
  27530. * Gets a list of Animations associated with the node
  27531. */
  27532. animations: import("babylonjs/Animations/animation").Animation[];
  27533. protected _ranges: {
  27534. [name: string]: Nullable<AnimationRange>;
  27535. };
  27536. /**
  27537. * Callback raised when the node is ready to be used
  27538. */
  27539. onReady: Nullable<(node: Node) => void>;
  27540. private _isEnabled;
  27541. private _isParentEnabled;
  27542. private _isReady;
  27543. /** @hidden */
  27544. _currentRenderId: number;
  27545. private _parentUpdateId;
  27546. /** @hidden */
  27547. _childUpdateId: number;
  27548. /** @hidden */
  27549. _waitingParentId: Nullable<string>;
  27550. /** @hidden */
  27551. _scene: Scene;
  27552. /** @hidden */
  27553. _cache: any;
  27554. private _parentNode;
  27555. private _children;
  27556. /** @hidden */
  27557. _worldMatrix: Matrix;
  27558. /** @hidden */
  27559. _worldMatrixDeterminant: number;
  27560. /** @hidden */
  27561. _worldMatrixDeterminantIsDirty: boolean;
  27562. /** @hidden */
  27563. private _sceneRootNodesIndex;
  27564. /**
  27565. * Gets a boolean indicating if the node has been disposed
  27566. * @returns true if the node was disposed
  27567. */
  27568. isDisposed(): boolean;
  27569. /**
  27570. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27571. * @see https://doc.babylonjs.com/how_to/parenting
  27572. */
  27573. parent: Nullable<Node>;
  27574. private addToSceneRootNodes;
  27575. private removeFromSceneRootNodes;
  27576. private _animationPropertiesOverride;
  27577. /**
  27578. * Gets or sets the animation properties override
  27579. */
  27580. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27581. /**
  27582. * Gets a string idenfifying the name of the class
  27583. * @returns "Node" string
  27584. */
  27585. getClassName(): string;
  27586. /** @hidden */
  27587. readonly _isNode: boolean;
  27588. /**
  27589. * An event triggered when the mesh is disposed
  27590. */
  27591. onDisposeObservable: Observable<Node>;
  27592. private _onDisposeObserver;
  27593. /**
  27594. * Sets a callback that will be raised when the node will be disposed
  27595. */
  27596. onDispose: () => void;
  27597. /**
  27598. * Creates a new Node
  27599. * @param name the name and id to be given to this node
  27600. * @param scene the scene this node will be added to
  27601. * @param addToRootNodes the node will be added to scene.rootNodes
  27602. */
  27603. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27604. /**
  27605. * Gets the scene of the node
  27606. * @returns a scene
  27607. */
  27608. getScene(): Scene;
  27609. /**
  27610. * Gets the engine of the node
  27611. * @returns a Engine
  27612. */
  27613. getEngine(): Engine;
  27614. private _behaviors;
  27615. /**
  27616. * Attach a behavior to the node
  27617. * @see http://doc.babylonjs.com/features/behaviour
  27618. * @param behavior defines the behavior to attach
  27619. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27620. * @returns the current Node
  27621. */
  27622. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27623. /**
  27624. * Remove an attached behavior
  27625. * @see http://doc.babylonjs.com/features/behaviour
  27626. * @param behavior defines the behavior to attach
  27627. * @returns the current Node
  27628. */
  27629. removeBehavior(behavior: Behavior<Node>): Node;
  27630. /**
  27631. * Gets the list of attached behaviors
  27632. * @see http://doc.babylonjs.com/features/behaviour
  27633. */
  27634. readonly behaviors: Behavior<Node>[];
  27635. /**
  27636. * Gets an attached behavior by name
  27637. * @param name defines the name of the behavior to look for
  27638. * @see http://doc.babylonjs.com/features/behaviour
  27639. * @returns null if behavior was not found else the requested behavior
  27640. */
  27641. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27642. /**
  27643. * Returns the latest update of the World matrix
  27644. * @returns a Matrix
  27645. */
  27646. getWorldMatrix(): Matrix;
  27647. /** @hidden */
  27648. _getWorldMatrixDeterminant(): number;
  27649. /**
  27650. * Returns directly the latest state of the mesh World matrix.
  27651. * A Matrix is returned.
  27652. */
  27653. readonly worldMatrixFromCache: Matrix;
  27654. /** @hidden */
  27655. _initCache(): void;
  27656. /** @hidden */
  27657. updateCache(force?: boolean): void;
  27658. /** @hidden */
  27659. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27660. /** @hidden */
  27661. _updateCache(ignoreParentClass?: boolean): void;
  27662. /** @hidden */
  27663. _isSynchronized(): boolean;
  27664. /** @hidden */
  27665. _markSyncedWithParent(): void;
  27666. /** @hidden */
  27667. isSynchronizedWithParent(): boolean;
  27668. /** @hidden */
  27669. isSynchronized(): boolean;
  27670. /**
  27671. * Is this node ready to be used/rendered
  27672. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27673. * @return true if the node is ready
  27674. */
  27675. isReady(completeCheck?: boolean): boolean;
  27676. /**
  27677. * Is this node enabled?
  27678. * 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
  27679. * @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
  27680. * @return whether this node (and its parent) is enabled
  27681. */
  27682. isEnabled(checkAncestors?: boolean): boolean;
  27683. /** @hidden */
  27684. protected _syncParentEnabledState(): void;
  27685. /**
  27686. * Set the enabled state of this node
  27687. * @param value defines the new enabled state
  27688. */
  27689. setEnabled(value: boolean): void;
  27690. /**
  27691. * Is this node a descendant of the given node?
  27692. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27693. * @param ancestor defines the parent node to inspect
  27694. * @returns a boolean indicating if this node is a descendant of the given node
  27695. */
  27696. isDescendantOf(ancestor: Node): boolean;
  27697. /** @hidden */
  27698. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27699. /**
  27700. * Will return all nodes that have this node as ascendant
  27701. * @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
  27702. * @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
  27703. * @return all children nodes of all types
  27704. */
  27705. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27706. /**
  27707. * Get all child-meshes of this node
  27708. * @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)
  27709. * @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
  27710. * @returns an array of AbstractMesh
  27711. */
  27712. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27713. /**
  27714. * Get all direct children of this node
  27715. * @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
  27716. * @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)
  27717. * @returns an array of Node
  27718. */
  27719. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27720. /** @hidden */
  27721. _setReady(state: boolean): void;
  27722. /**
  27723. * Get an animation by name
  27724. * @param name defines the name of the animation to look for
  27725. * @returns null if not found else the requested animation
  27726. */
  27727. getAnimationByName(name: string): Nullable<Animation>;
  27728. /**
  27729. * Creates an animation range for this node
  27730. * @param name defines the name of the range
  27731. * @param from defines the starting key
  27732. * @param to defines the end key
  27733. */
  27734. createAnimationRange(name: string, from: number, to: number): void;
  27735. /**
  27736. * Delete a specific animation range
  27737. * @param name defines the name of the range to delete
  27738. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27739. */
  27740. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27741. /**
  27742. * Get an animation range by name
  27743. * @param name defines the name of the animation range to look for
  27744. * @returns null if not found else the requested animation range
  27745. */
  27746. getAnimationRange(name: string): Nullable<AnimationRange>;
  27747. /**
  27748. * Gets the list of all animation ranges defined on this node
  27749. * @returns an array
  27750. */
  27751. getAnimationRanges(): Nullable<AnimationRange>[];
  27752. /**
  27753. * Will start the animation sequence
  27754. * @param name defines the range frames for animation sequence
  27755. * @param loop defines if the animation should loop (false by default)
  27756. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27757. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27758. * @returns the object created for this animation. If range does not exist, it will return null
  27759. */
  27760. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27761. /**
  27762. * Serialize animation ranges into a JSON compatible object
  27763. * @returns serialization object
  27764. */
  27765. serializeAnimationRanges(): any;
  27766. /**
  27767. * Computes the world matrix of the node
  27768. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27769. * @returns the world matrix
  27770. */
  27771. computeWorldMatrix(force?: boolean): Matrix;
  27772. /**
  27773. * Releases resources associated with this node.
  27774. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27775. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27776. */
  27777. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27778. /**
  27779. * Parse animation range data from a serialization object and store them into a given node
  27780. * @param node defines where to store the animation ranges
  27781. * @param parsedNode defines the serialization object to read data from
  27782. * @param scene defines the hosting scene
  27783. */
  27784. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27785. /**
  27786. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27787. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27788. * @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
  27789. * @returns the new bounding vectors
  27790. */
  27791. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27792. min: Vector3;
  27793. max: Vector3;
  27794. };
  27795. }
  27796. }
  27797. declare module "babylonjs/Animations/animation" {
  27798. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27799. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27800. import { Color3 } from "babylonjs/Maths/math.color";
  27801. import { Nullable } from "babylonjs/types";
  27802. import { Scene } from "babylonjs/scene";
  27803. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27804. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27805. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27806. import { Node } from "babylonjs/node";
  27807. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27808. import { Size } from "babylonjs/Maths/math.size";
  27809. import { Animatable } from "babylonjs/Animations/animatable";
  27810. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27811. /**
  27812. * @hidden
  27813. */
  27814. export class _IAnimationState {
  27815. key: number;
  27816. repeatCount: number;
  27817. workValue?: any;
  27818. loopMode?: number;
  27819. offsetValue?: any;
  27820. highLimitValue?: any;
  27821. }
  27822. /**
  27823. * Class used to store any kind of animation
  27824. */
  27825. export class Animation {
  27826. /**Name of the animation */
  27827. name: string;
  27828. /**Property to animate */
  27829. targetProperty: string;
  27830. /**The frames per second of the animation */
  27831. framePerSecond: number;
  27832. /**The data type of the animation */
  27833. dataType: number;
  27834. /**The loop mode of the animation */
  27835. loopMode?: number | undefined;
  27836. /**Specifies if blending should be enabled */
  27837. enableBlending?: boolean | undefined;
  27838. /**
  27839. * Use matrix interpolation instead of using direct key value when animating matrices
  27840. */
  27841. static AllowMatricesInterpolation: boolean;
  27842. /**
  27843. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27844. */
  27845. static AllowMatrixDecomposeForInterpolation: boolean;
  27846. /**
  27847. * Stores the key frames of the animation
  27848. */
  27849. private _keys;
  27850. /**
  27851. * Stores the easing function of the animation
  27852. */
  27853. private _easingFunction;
  27854. /**
  27855. * @hidden Internal use only
  27856. */
  27857. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27858. /**
  27859. * The set of event that will be linked to this animation
  27860. */
  27861. private _events;
  27862. /**
  27863. * Stores an array of target property paths
  27864. */
  27865. targetPropertyPath: string[];
  27866. /**
  27867. * Stores the blending speed of the animation
  27868. */
  27869. blendingSpeed: number;
  27870. /**
  27871. * Stores the animation ranges for the animation
  27872. */
  27873. private _ranges;
  27874. /**
  27875. * @hidden Internal use
  27876. */
  27877. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27878. /**
  27879. * Sets up an animation
  27880. * @param property The property to animate
  27881. * @param animationType The animation type to apply
  27882. * @param framePerSecond The frames per second of the animation
  27883. * @param easingFunction The easing function used in the animation
  27884. * @returns The created animation
  27885. */
  27886. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27887. /**
  27888. * Create and start an animation on a node
  27889. * @param name defines the name of the global animation that will be run on all nodes
  27890. * @param node defines the root node where the animation will take place
  27891. * @param targetProperty defines property to animate
  27892. * @param framePerSecond defines the number of frame per second yo use
  27893. * @param totalFrame defines the number of frames in total
  27894. * @param from defines the initial value
  27895. * @param to defines the final value
  27896. * @param loopMode defines which loop mode you want to use (off by default)
  27897. * @param easingFunction defines the easing function to use (linear by default)
  27898. * @param onAnimationEnd defines the callback to call when animation end
  27899. * @returns the animatable created for this animation
  27900. */
  27901. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27902. /**
  27903. * Create and start an animation on a node and its descendants
  27904. * @param name defines the name of the global animation that will be run on all nodes
  27905. * @param node defines the root node where the animation will take place
  27906. * @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
  27907. * @param targetProperty defines property to animate
  27908. * @param framePerSecond defines the number of frame per second to use
  27909. * @param totalFrame defines the number of frames in total
  27910. * @param from defines the initial value
  27911. * @param to defines the final value
  27912. * @param loopMode defines which loop mode you want to use (off by default)
  27913. * @param easingFunction defines the easing function to use (linear by default)
  27914. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27915. * @returns the list of animatables created for all nodes
  27916. * @example https://www.babylonjs-playground.com/#MH0VLI
  27917. */
  27918. 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[]>;
  27919. /**
  27920. * Creates a new animation, merges it with the existing animations and starts it
  27921. * @param name Name of the animation
  27922. * @param node Node which contains the scene that begins the animations
  27923. * @param targetProperty Specifies which property to animate
  27924. * @param framePerSecond The frames per second of the animation
  27925. * @param totalFrame The total number of frames
  27926. * @param from The frame at the beginning of the animation
  27927. * @param to The frame at the end of the animation
  27928. * @param loopMode Specifies the loop mode of the animation
  27929. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27930. * @param onAnimationEnd Callback to run once the animation is complete
  27931. * @returns Nullable animation
  27932. */
  27933. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27934. /**
  27935. * Transition property of an host to the target Value
  27936. * @param property The property to transition
  27937. * @param targetValue The target Value of the property
  27938. * @param host The object where the property to animate belongs
  27939. * @param scene Scene used to run the animation
  27940. * @param frameRate Framerate (in frame/s) to use
  27941. * @param transition The transition type we want to use
  27942. * @param duration The duration of the animation, in milliseconds
  27943. * @param onAnimationEnd Callback trigger at the end of the animation
  27944. * @returns Nullable animation
  27945. */
  27946. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27947. /**
  27948. * Return the array of runtime animations currently using this animation
  27949. */
  27950. readonly runtimeAnimations: RuntimeAnimation[];
  27951. /**
  27952. * Specifies if any of the runtime animations are currently running
  27953. */
  27954. readonly hasRunningRuntimeAnimations: boolean;
  27955. /**
  27956. * Initializes the animation
  27957. * @param name Name of the animation
  27958. * @param targetProperty Property to animate
  27959. * @param framePerSecond The frames per second of the animation
  27960. * @param dataType The data type of the animation
  27961. * @param loopMode The loop mode of the animation
  27962. * @param enableBlending Specifies if blending should be enabled
  27963. */
  27964. constructor(
  27965. /**Name of the animation */
  27966. name: string,
  27967. /**Property to animate */
  27968. targetProperty: string,
  27969. /**The frames per second of the animation */
  27970. framePerSecond: number,
  27971. /**The data type of the animation */
  27972. dataType: number,
  27973. /**The loop mode of the animation */
  27974. loopMode?: number | undefined,
  27975. /**Specifies if blending should be enabled */
  27976. enableBlending?: boolean | undefined);
  27977. /**
  27978. * Converts the animation to a string
  27979. * @param fullDetails support for multiple levels of logging within scene loading
  27980. * @returns String form of the animation
  27981. */
  27982. toString(fullDetails?: boolean): string;
  27983. /**
  27984. * Add an event to this animation
  27985. * @param event Event to add
  27986. */
  27987. addEvent(event: AnimationEvent): void;
  27988. /**
  27989. * Remove all events found at the given frame
  27990. * @param frame The frame to remove events from
  27991. */
  27992. removeEvents(frame: number): void;
  27993. /**
  27994. * Retrieves all the events from the animation
  27995. * @returns Events from the animation
  27996. */
  27997. getEvents(): AnimationEvent[];
  27998. /**
  27999. * Creates an animation range
  28000. * @param name Name of the animation range
  28001. * @param from Starting frame of the animation range
  28002. * @param to Ending frame of the animation
  28003. */
  28004. createRange(name: string, from: number, to: number): void;
  28005. /**
  28006. * Deletes an animation range by name
  28007. * @param name Name of the animation range to delete
  28008. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28009. */
  28010. deleteRange(name: string, deleteFrames?: boolean): void;
  28011. /**
  28012. * Gets the animation range by name, or null if not defined
  28013. * @param name Name of the animation range
  28014. * @returns Nullable animation range
  28015. */
  28016. getRange(name: string): Nullable<AnimationRange>;
  28017. /**
  28018. * Gets the key frames from the animation
  28019. * @returns The key frames of the animation
  28020. */
  28021. getKeys(): Array<IAnimationKey>;
  28022. /**
  28023. * Gets the highest frame rate of the animation
  28024. * @returns Highest frame rate of the animation
  28025. */
  28026. getHighestFrame(): number;
  28027. /**
  28028. * Gets the easing function of the animation
  28029. * @returns Easing function of the animation
  28030. */
  28031. getEasingFunction(): IEasingFunction;
  28032. /**
  28033. * Sets the easing function of the animation
  28034. * @param easingFunction A custom mathematical formula for animation
  28035. */
  28036. setEasingFunction(easingFunction: EasingFunction): void;
  28037. /**
  28038. * Interpolates a scalar linearly
  28039. * @param startValue Start value of the animation curve
  28040. * @param endValue End value of the animation curve
  28041. * @param gradient Scalar amount to interpolate
  28042. * @returns Interpolated scalar value
  28043. */
  28044. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28045. /**
  28046. * Interpolates a scalar cubically
  28047. * @param startValue Start value of the animation curve
  28048. * @param outTangent End tangent of the animation
  28049. * @param endValue End value of the animation curve
  28050. * @param inTangent Start tangent of the animation curve
  28051. * @param gradient Scalar amount to interpolate
  28052. * @returns Interpolated scalar value
  28053. */
  28054. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28055. /**
  28056. * Interpolates a quaternion using a spherical linear interpolation
  28057. * @param startValue Start value of the animation curve
  28058. * @param endValue End value of the animation curve
  28059. * @param gradient Scalar amount to interpolate
  28060. * @returns Interpolated quaternion value
  28061. */
  28062. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28063. /**
  28064. * Interpolates a quaternion cubically
  28065. * @param startValue Start value of the animation curve
  28066. * @param outTangent End tangent of the animation curve
  28067. * @param endValue End value of the animation curve
  28068. * @param inTangent Start tangent of the animation curve
  28069. * @param gradient Scalar amount to interpolate
  28070. * @returns Interpolated quaternion value
  28071. */
  28072. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28073. /**
  28074. * Interpolates a Vector3 linearl
  28075. * @param startValue Start value of the animation curve
  28076. * @param endValue End value of the animation curve
  28077. * @param gradient Scalar amount to interpolate
  28078. * @returns Interpolated scalar value
  28079. */
  28080. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28081. /**
  28082. * Interpolates a Vector3 cubically
  28083. * @param startValue Start value of the animation curve
  28084. * @param outTangent End tangent of the animation
  28085. * @param endValue End value of the animation curve
  28086. * @param inTangent Start tangent of the animation curve
  28087. * @param gradient Scalar amount to interpolate
  28088. * @returns InterpolatedVector3 value
  28089. */
  28090. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28091. /**
  28092. * Interpolates a Vector2 linearly
  28093. * @param startValue Start value of the animation curve
  28094. * @param endValue End value of the animation curve
  28095. * @param gradient Scalar amount to interpolate
  28096. * @returns Interpolated Vector2 value
  28097. */
  28098. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28099. /**
  28100. * Interpolates a Vector2 cubically
  28101. * @param startValue Start value of the animation curve
  28102. * @param outTangent End tangent of the animation
  28103. * @param endValue End value of the animation curve
  28104. * @param inTangent Start tangent of the animation curve
  28105. * @param gradient Scalar amount to interpolate
  28106. * @returns Interpolated Vector2 value
  28107. */
  28108. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28109. /**
  28110. * Interpolates a size linearly
  28111. * @param startValue Start value of the animation curve
  28112. * @param endValue End value of the animation curve
  28113. * @param gradient Scalar amount to interpolate
  28114. * @returns Interpolated Size value
  28115. */
  28116. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28117. /**
  28118. * Interpolates a Color3 linearly
  28119. * @param startValue Start value of the animation curve
  28120. * @param endValue End value of the animation curve
  28121. * @param gradient Scalar amount to interpolate
  28122. * @returns Interpolated Color3 value
  28123. */
  28124. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28125. /**
  28126. * @hidden Internal use only
  28127. */
  28128. _getKeyValue(value: any): any;
  28129. /**
  28130. * @hidden Internal use only
  28131. */
  28132. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28133. /**
  28134. * Defines the function to use to interpolate matrices
  28135. * @param startValue defines the start matrix
  28136. * @param endValue defines the end matrix
  28137. * @param gradient defines the gradient between both matrices
  28138. * @param result defines an optional target matrix where to store the interpolation
  28139. * @returns the interpolated matrix
  28140. */
  28141. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28142. /**
  28143. * Makes a copy of the animation
  28144. * @returns Cloned animation
  28145. */
  28146. clone(): Animation;
  28147. /**
  28148. * Sets the key frames of the animation
  28149. * @param values The animation key frames to set
  28150. */
  28151. setKeys(values: Array<IAnimationKey>): void;
  28152. /**
  28153. * Serializes the animation to an object
  28154. * @returns Serialized object
  28155. */
  28156. serialize(): any;
  28157. /**
  28158. * Float animation type
  28159. */
  28160. private static _ANIMATIONTYPE_FLOAT;
  28161. /**
  28162. * Vector3 animation type
  28163. */
  28164. private static _ANIMATIONTYPE_VECTOR3;
  28165. /**
  28166. * Quaternion animation type
  28167. */
  28168. private static _ANIMATIONTYPE_QUATERNION;
  28169. /**
  28170. * Matrix animation type
  28171. */
  28172. private static _ANIMATIONTYPE_MATRIX;
  28173. /**
  28174. * Color3 animation type
  28175. */
  28176. private static _ANIMATIONTYPE_COLOR3;
  28177. /**
  28178. * Vector2 animation type
  28179. */
  28180. private static _ANIMATIONTYPE_VECTOR2;
  28181. /**
  28182. * Size animation type
  28183. */
  28184. private static _ANIMATIONTYPE_SIZE;
  28185. /**
  28186. * Relative Loop Mode
  28187. */
  28188. private static _ANIMATIONLOOPMODE_RELATIVE;
  28189. /**
  28190. * Cycle Loop Mode
  28191. */
  28192. private static _ANIMATIONLOOPMODE_CYCLE;
  28193. /**
  28194. * Constant Loop Mode
  28195. */
  28196. private static _ANIMATIONLOOPMODE_CONSTANT;
  28197. /**
  28198. * Get the float animation type
  28199. */
  28200. static readonly ANIMATIONTYPE_FLOAT: number;
  28201. /**
  28202. * Get the Vector3 animation type
  28203. */
  28204. static readonly ANIMATIONTYPE_VECTOR3: number;
  28205. /**
  28206. * Get the Vector2 animation type
  28207. */
  28208. static readonly ANIMATIONTYPE_VECTOR2: number;
  28209. /**
  28210. * Get the Size animation type
  28211. */
  28212. static readonly ANIMATIONTYPE_SIZE: number;
  28213. /**
  28214. * Get the Quaternion animation type
  28215. */
  28216. static readonly ANIMATIONTYPE_QUATERNION: number;
  28217. /**
  28218. * Get the Matrix animation type
  28219. */
  28220. static readonly ANIMATIONTYPE_MATRIX: number;
  28221. /**
  28222. * Get the Color3 animation type
  28223. */
  28224. static readonly ANIMATIONTYPE_COLOR3: number;
  28225. /**
  28226. * Get the Relative Loop Mode
  28227. */
  28228. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28229. /**
  28230. * Get the Cycle Loop Mode
  28231. */
  28232. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28233. /**
  28234. * Get the Constant Loop Mode
  28235. */
  28236. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28237. /** @hidden */
  28238. static _UniversalLerp(left: any, right: any, amount: number): any;
  28239. /**
  28240. * Parses an animation object and creates an animation
  28241. * @param parsedAnimation Parsed animation object
  28242. * @returns Animation object
  28243. */
  28244. static Parse(parsedAnimation: any): Animation;
  28245. /**
  28246. * Appends the serialized animations from the source animations
  28247. * @param source Source containing the animations
  28248. * @param destination Target to store the animations
  28249. */
  28250. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28251. }
  28252. }
  28253. declare module "babylonjs/Animations/animatable.interface" {
  28254. import { Nullable } from "babylonjs/types";
  28255. import { Animation } from "babylonjs/Animations/animation";
  28256. /**
  28257. * Interface containing an array of animations
  28258. */
  28259. export interface IAnimatable {
  28260. /**
  28261. * Array of animations
  28262. */
  28263. animations: Nullable<Array<Animation>>;
  28264. }
  28265. }
  28266. declare module "babylonjs/Materials/fresnelParameters" {
  28267. import { Color3 } from "babylonjs/Maths/math.color";
  28268. /**
  28269. * This represents all the required information to add a fresnel effect on a material:
  28270. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28271. */
  28272. export class FresnelParameters {
  28273. private _isEnabled;
  28274. /**
  28275. * Define if the fresnel effect is enable or not.
  28276. */
  28277. isEnabled: boolean;
  28278. /**
  28279. * Define the color used on edges (grazing angle)
  28280. */
  28281. leftColor: Color3;
  28282. /**
  28283. * Define the color used on center
  28284. */
  28285. rightColor: Color3;
  28286. /**
  28287. * Define bias applied to computed fresnel term
  28288. */
  28289. bias: number;
  28290. /**
  28291. * Defined the power exponent applied to fresnel term
  28292. */
  28293. power: number;
  28294. /**
  28295. * Clones the current fresnel and its valuues
  28296. * @returns a clone fresnel configuration
  28297. */
  28298. clone(): FresnelParameters;
  28299. /**
  28300. * Serializes the current fresnel parameters to a JSON representation.
  28301. * @return the JSON serialization
  28302. */
  28303. serialize(): any;
  28304. /**
  28305. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28306. * @param parsedFresnelParameters Define the JSON representation
  28307. * @returns the parsed parameters
  28308. */
  28309. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28310. }
  28311. }
  28312. declare module "babylonjs/Misc/decorators" {
  28313. import { Nullable } from "babylonjs/types";
  28314. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28315. import { Scene } from "babylonjs/scene";
  28316. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28317. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28318. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28319. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28320. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28321. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28322. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28323. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28324. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28325. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28326. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28327. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28328. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28329. /**
  28330. * Decorator used to define property that can be serialized as reference to a camera
  28331. * @param sourceName defines the name of the property to decorate
  28332. */
  28333. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28334. /**
  28335. * Class used to help serialization objects
  28336. */
  28337. export class SerializationHelper {
  28338. /** @hidden */
  28339. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28340. /** @hidden */
  28341. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28342. /** @hidden */
  28343. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28344. /** @hidden */
  28345. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28346. /**
  28347. * Appends the serialized animations from the source animations
  28348. * @param source Source containing the animations
  28349. * @param destination Target to store the animations
  28350. */
  28351. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28352. /**
  28353. * Static function used to serialized a specific entity
  28354. * @param entity defines the entity to serialize
  28355. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28356. * @returns a JSON compatible object representing the serialization of the entity
  28357. */
  28358. static Serialize<T>(entity: T, serializationObject?: any): any;
  28359. /**
  28360. * Creates a new entity from a serialization data object
  28361. * @param creationFunction defines a function used to instanciated the new entity
  28362. * @param source defines the source serialization data
  28363. * @param scene defines the hosting scene
  28364. * @param rootUrl defines the root url for resources
  28365. * @returns a new entity
  28366. */
  28367. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28368. /**
  28369. * Clones an object
  28370. * @param creationFunction defines the function used to instanciate the new object
  28371. * @param source defines the source object
  28372. * @returns the cloned object
  28373. */
  28374. static Clone<T>(creationFunction: () => T, source: T): T;
  28375. /**
  28376. * Instanciates a new object based on a source one (some data will be shared between both object)
  28377. * @param creationFunction defines the function used to instanciate the new object
  28378. * @param source defines the source object
  28379. * @returns the new object
  28380. */
  28381. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28382. }
  28383. }
  28384. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28385. import { Nullable } from "babylonjs/types";
  28386. /**
  28387. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28388. */
  28389. export interface CubeMapInfo {
  28390. /**
  28391. * The pixel array for the front face.
  28392. * This is stored in format, left to right, up to down format.
  28393. */
  28394. front: Nullable<ArrayBufferView>;
  28395. /**
  28396. * The pixel array for the back face.
  28397. * This is stored in format, left to right, up to down format.
  28398. */
  28399. back: Nullable<ArrayBufferView>;
  28400. /**
  28401. * The pixel array for the left face.
  28402. * This is stored in format, left to right, up to down format.
  28403. */
  28404. left: Nullable<ArrayBufferView>;
  28405. /**
  28406. * The pixel array for the right face.
  28407. * This is stored in format, left to right, up to down format.
  28408. */
  28409. right: Nullable<ArrayBufferView>;
  28410. /**
  28411. * The pixel array for the up face.
  28412. * This is stored in format, left to right, up to down format.
  28413. */
  28414. up: Nullable<ArrayBufferView>;
  28415. /**
  28416. * The pixel array for the down face.
  28417. * This is stored in format, left to right, up to down format.
  28418. */
  28419. down: Nullable<ArrayBufferView>;
  28420. /**
  28421. * The size of the cubemap stored.
  28422. *
  28423. * Each faces will be size * size pixels.
  28424. */
  28425. size: number;
  28426. /**
  28427. * The format of the texture.
  28428. *
  28429. * RGBA, RGB.
  28430. */
  28431. format: number;
  28432. /**
  28433. * The type of the texture data.
  28434. *
  28435. * UNSIGNED_INT, FLOAT.
  28436. */
  28437. type: number;
  28438. /**
  28439. * Specifies whether the texture is in gamma space.
  28440. */
  28441. gammaSpace: boolean;
  28442. }
  28443. /**
  28444. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28445. */
  28446. export class PanoramaToCubeMapTools {
  28447. private static FACE_FRONT;
  28448. private static FACE_BACK;
  28449. private static FACE_RIGHT;
  28450. private static FACE_LEFT;
  28451. private static FACE_DOWN;
  28452. private static FACE_UP;
  28453. /**
  28454. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28455. *
  28456. * @param float32Array The source data.
  28457. * @param inputWidth The width of the input panorama.
  28458. * @param inputHeight The height of the input panorama.
  28459. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28460. * @return The cubemap data
  28461. */
  28462. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28463. private static CreateCubemapTexture;
  28464. private static CalcProjectionSpherical;
  28465. }
  28466. }
  28467. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28468. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28469. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28470. import { Nullable } from "babylonjs/types";
  28471. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28472. /**
  28473. * Helper class dealing with the extraction of spherical polynomial dataArray
  28474. * from a cube map.
  28475. */
  28476. export class CubeMapToSphericalPolynomialTools {
  28477. private static FileFaces;
  28478. /**
  28479. * Converts a texture to the according Spherical Polynomial data.
  28480. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28481. *
  28482. * @param texture The texture to extract the information from.
  28483. * @return The Spherical Polynomial data.
  28484. */
  28485. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28486. /**
  28487. * Converts a cubemap to the according Spherical Polynomial data.
  28488. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28489. *
  28490. * @param cubeInfo The Cube map to extract the information from.
  28491. * @return The Spherical Polynomial data.
  28492. */
  28493. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28494. }
  28495. }
  28496. declare module "babylonjs/Misc/guid" {
  28497. /**
  28498. * Class used to manipulate GUIDs
  28499. */
  28500. export class GUID {
  28501. /**
  28502. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28503. * Be aware Math.random() could cause collisions, but:
  28504. * "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"
  28505. * @returns a pseudo random id
  28506. */
  28507. static RandomId(): string;
  28508. }
  28509. }
  28510. declare module "babylonjs/Materials/Textures/baseTexture" {
  28511. import { Observable } from "babylonjs/Misc/observable";
  28512. import { Nullable } from "babylonjs/types";
  28513. import { Scene } from "babylonjs/scene";
  28514. import { Matrix } from "babylonjs/Maths/math.vector";
  28515. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28516. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28517. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28518. import { ISize } from "babylonjs/Maths/math.size";
  28519. /**
  28520. * Base class of all the textures in babylon.
  28521. * It groups all the common properties the materials, post process, lights... might need
  28522. * in order to make a correct use of the texture.
  28523. */
  28524. export class BaseTexture implements IAnimatable {
  28525. /**
  28526. * Default anisotropic filtering level for the application.
  28527. * It is set to 4 as a good tradeoff between perf and quality.
  28528. */
  28529. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28530. /**
  28531. * Gets or sets the unique id of the texture
  28532. */
  28533. uniqueId: number;
  28534. /**
  28535. * Define the name of the texture.
  28536. */
  28537. name: string;
  28538. /**
  28539. * Gets or sets an object used to store user defined information.
  28540. */
  28541. metadata: any;
  28542. /**
  28543. * For internal use only. Please do not use.
  28544. */
  28545. reservedDataStore: any;
  28546. private _hasAlpha;
  28547. /**
  28548. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28549. */
  28550. hasAlpha: boolean;
  28551. /**
  28552. * Defines if the alpha value should be determined via the rgb values.
  28553. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28554. */
  28555. getAlphaFromRGB: boolean;
  28556. /**
  28557. * Intensity or strength of the texture.
  28558. * It is commonly used by materials to fine tune the intensity of the texture
  28559. */
  28560. level: number;
  28561. /**
  28562. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28563. * This is part of the texture as textures usually maps to one uv set.
  28564. */
  28565. coordinatesIndex: number;
  28566. private _coordinatesMode;
  28567. /**
  28568. * How a texture is mapped.
  28569. *
  28570. * | Value | Type | Description |
  28571. * | ----- | ----------------------------------- | ----------- |
  28572. * | 0 | EXPLICIT_MODE | |
  28573. * | 1 | SPHERICAL_MODE | |
  28574. * | 2 | PLANAR_MODE | |
  28575. * | 3 | CUBIC_MODE | |
  28576. * | 4 | PROJECTION_MODE | |
  28577. * | 5 | SKYBOX_MODE | |
  28578. * | 6 | INVCUBIC_MODE | |
  28579. * | 7 | EQUIRECTANGULAR_MODE | |
  28580. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28581. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28582. */
  28583. coordinatesMode: number;
  28584. /**
  28585. * | Value | Type | Description |
  28586. * | ----- | ------------------ | ----------- |
  28587. * | 0 | CLAMP_ADDRESSMODE | |
  28588. * | 1 | WRAP_ADDRESSMODE | |
  28589. * | 2 | MIRROR_ADDRESSMODE | |
  28590. */
  28591. wrapU: number;
  28592. /**
  28593. * | Value | Type | Description |
  28594. * | ----- | ------------------ | ----------- |
  28595. * | 0 | CLAMP_ADDRESSMODE | |
  28596. * | 1 | WRAP_ADDRESSMODE | |
  28597. * | 2 | MIRROR_ADDRESSMODE | |
  28598. */
  28599. wrapV: number;
  28600. /**
  28601. * | Value | Type | Description |
  28602. * | ----- | ------------------ | ----------- |
  28603. * | 0 | CLAMP_ADDRESSMODE | |
  28604. * | 1 | WRAP_ADDRESSMODE | |
  28605. * | 2 | MIRROR_ADDRESSMODE | |
  28606. */
  28607. wrapR: number;
  28608. /**
  28609. * With compliant hardware and browser (supporting anisotropic filtering)
  28610. * this defines the level of anisotropic filtering in the texture.
  28611. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28612. */
  28613. anisotropicFilteringLevel: number;
  28614. /**
  28615. * Define if the texture is a cube texture or if false a 2d texture.
  28616. */
  28617. isCube: boolean;
  28618. /**
  28619. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28620. */
  28621. is3D: boolean;
  28622. /**
  28623. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28624. * HDR texture are usually stored in linear space.
  28625. * This only impacts the PBR and Background materials
  28626. */
  28627. gammaSpace: boolean;
  28628. /**
  28629. * Gets or sets whether or not the texture contains RGBD data.
  28630. */
  28631. isRGBD: boolean;
  28632. /**
  28633. * Is Z inverted in the texture (useful in a cube texture).
  28634. */
  28635. invertZ: boolean;
  28636. /**
  28637. * Are mip maps generated for this texture or not.
  28638. */
  28639. readonly noMipmap: boolean;
  28640. /**
  28641. * @hidden
  28642. */
  28643. lodLevelInAlpha: boolean;
  28644. /**
  28645. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28646. */
  28647. lodGenerationOffset: number;
  28648. /**
  28649. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28650. */
  28651. lodGenerationScale: number;
  28652. /**
  28653. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28654. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28655. * average roughness values.
  28656. */
  28657. linearSpecularLOD: boolean;
  28658. /**
  28659. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28660. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28661. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28662. */
  28663. irradianceTexture: Nullable<BaseTexture>;
  28664. /**
  28665. * Define if the texture is a render target.
  28666. */
  28667. isRenderTarget: boolean;
  28668. /**
  28669. * Define the unique id of the texture in the scene.
  28670. */
  28671. readonly uid: string;
  28672. /**
  28673. * Return a string representation of the texture.
  28674. * @returns the texture as a string
  28675. */
  28676. toString(): string;
  28677. /**
  28678. * Get the class name of the texture.
  28679. * @returns "BaseTexture"
  28680. */
  28681. getClassName(): string;
  28682. /**
  28683. * Define the list of animation attached to the texture.
  28684. */
  28685. animations: import("babylonjs/Animations/animation").Animation[];
  28686. /**
  28687. * An event triggered when the texture is disposed.
  28688. */
  28689. onDisposeObservable: Observable<BaseTexture>;
  28690. private _onDisposeObserver;
  28691. /**
  28692. * Callback triggered when the texture has been disposed.
  28693. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28694. */
  28695. onDispose: () => void;
  28696. /**
  28697. * Define the current state of the loading sequence when in delayed load mode.
  28698. */
  28699. delayLoadState: number;
  28700. private _scene;
  28701. /** @hidden */
  28702. _texture: Nullable<InternalTexture>;
  28703. private _uid;
  28704. /**
  28705. * Define if the texture is preventinga material to render or not.
  28706. * If not and the texture is not ready, the engine will use a default black texture instead.
  28707. */
  28708. readonly isBlocking: boolean;
  28709. /**
  28710. * Instantiates a new BaseTexture.
  28711. * Base class of all the textures in babylon.
  28712. * It groups all the common properties the materials, post process, lights... might need
  28713. * in order to make a correct use of the texture.
  28714. * @param scene Define the scene the texture blongs to
  28715. */
  28716. constructor(scene: Nullable<Scene>);
  28717. /**
  28718. * Get the scene the texture belongs to.
  28719. * @returns the scene or null if undefined
  28720. */
  28721. getScene(): Nullable<Scene>;
  28722. /**
  28723. * Get the texture transform matrix used to offset tile the texture for istance.
  28724. * @returns the transformation matrix
  28725. */
  28726. getTextureMatrix(): Matrix;
  28727. /**
  28728. * Get the texture reflection matrix used to rotate/transform the reflection.
  28729. * @returns the reflection matrix
  28730. */
  28731. getReflectionTextureMatrix(): Matrix;
  28732. /**
  28733. * Get the underlying lower level texture from Babylon.
  28734. * @returns the insternal texture
  28735. */
  28736. getInternalTexture(): Nullable<InternalTexture>;
  28737. /**
  28738. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28739. * @returns true if ready or not blocking
  28740. */
  28741. isReadyOrNotBlocking(): boolean;
  28742. /**
  28743. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28744. * @returns true if fully ready
  28745. */
  28746. isReady(): boolean;
  28747. private _cachedSize;
  28748. /**
  28749. * Get the size of the texture.
  28750. * @returns the texture size.
  28751. */
  28752. getSize(): ISize;
  28753. /**
  28754. * Get the base size of the texture.
  28755. * It can be different from the size if the texture has been resized for POT for instance
  28756. * @returns the base size
  28757. */
  28758. getBaseSize(): ISize;
  28759. /**
  28760. * Update the sampling mode of the texture.
  28761. * Default is Trilinear mode.
  28762. *
  28763. * | Value | Type | Description |
  28764. * | ----- | ------------------ | ----------- |
  28765. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28766. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28767. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28768. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28769. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28770. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28771. * | 7 | NEAREST_LINEAR | |
  28772. * | 8 | NEAREST_NEAREST | |
  28773. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28774. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28775. * | 11 | LINEAR_LINEAR | |
  28776. * | 12 | LINEAR_NEAREST | |
  28777. *
  28778. * > _mag_: magnification filter (close to the viewer)
  28779. * > _min_: minification filter (far from the viewer)
  28780. * > _mip_: filter used between mip map levels
  28781. *@param samplingMode Define the new sampling mode of the texture
  28782. */
  28783. updateSamplingMode(samplingMode: number): void;
  28784. /**
  28785. * Scales the texture if is `canRescale()`
  28786. * @param ratio the resize factor we want to use to rescale
  28787. */
  28788. scale(ratio: number): void;
  28789. /**
  28790. * Get if the texture can rescale.
  28791. */
  28792. readonly canRescale: boolean;
  28793. /** @hidden */
  28794. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28795. /** @hidden */
  28796. _rebuild(): void;
  28797. /**
  28798. * Triggers the load sequence in delayed load mode.
  28799. */
  28800. delayLoad(): void;
  28801. /**
  28802. * Clones the texture.
  28803. * @returns the cloned texture
  28804. */
  28805. clone(): Nullable<BaseTexture>;
  28806. /**
  28807. * Get the texture underlying type (INT, FLOAT...)
  28808. */
  28809. readonly textureType: number;
  28810. /**
  28811. * Get the texture underlying format (RGB, RGBA...)
  28812. */
  28813. readonly textureFormat: number;
  28814. /**
  28815. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28816. * This will returns an RGBA array buffer containing either in values (0-255) or
  28817. * float values (0-1) depending of the underlying buffer type.
  28818. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28819. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28820. * @param buffer defines a user defined buffer to fill with data (can be null)
  28821. * @returns The Array buffer containing the pixels data.
  28822. */
  28823. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28824. /**
  28825. * Release and destroy the underlying lower level texture aka internalTexture.
  28826. */
  28827. releaseInternalTexture(): void;
  28828. /**
  28829. * Get the polynomial representation of the texture data.
  28830. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28831. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28832. */
  28833. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28834. /** @hidden */
  28835. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28836. /** @hidden */
  28837. readonly _lodTextureMid: Nullable<BaseTexture>;
  28838. /** @hidden */
  28839. readonly _lodTextureLow: Nullable<BaseTexture>;
  28840. /**
  28841. * Dispose the texture and release its associated resources.
  28842. */
  28843. dispose(): void;
  28844. /**
  28845. * Serialize the texture into a JSON representation that can be parsed later on.
  28846. * @returns the JSON representation of the texture
  28847. */
  28848. serialize(): any;
  28849. /**
  28850. * Helper function to be called back once a list of texture contains only ready textures.
  28851. * @param textures Define the list of textures to wait for
  28852. * @param callback Define the callback triggered once the entire list will be ready
  28853. */
  28854. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28855. }
  28856. }
  28857. declare module "babylonjs/Materials/Textures/internalTexture" {
  28858. import { Observable } from "babylonjs/Misc/observable";
  28859. import { Nullable, int } from "babylonjs/types";
  28860. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28861. import { Engine } from "babylonjs/Engines/engine";
  28862. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28863. /**
  28864. * Class used to store data associated with WebGL texture data for the engine
  28865. * This class should not be used directly
  28866. */
  28867. export class InternalTexture {
  28868. /** @hidden */
  28869. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28870. /**
  28871. * The source of the texture data is unknown
  28872. */
  28873. static DATASOURCE_UNKNOWN: number;
  28874. /**
  28875. * Texture data comes from an URL
  28876. */
  28877. static DATASOURCE_URL: number;
  28878. /**
  28879. * Texture data is only used for temporary storage
  28880. */
  28881. static DATASOURCE_TEMP: number;
  28882. /**
  28883. * Texture data comes from raw data (ArrayBuffer)
  28884. */
  28885. static DATASOURCE_RAW: number;
  28886. /**
  28887. * Texture content is dynamic (video or dynamic texture)
  28888. */
  28889. static DATASOURCE_DYNAMIC: number;
  28890. /**
  28891. * Texture content is generated by rendering to it
  28892. */
  28893. static DATASOURCE_RENDERTARGET: number;
  28894. /**
  28895. * Texture content is part of a multi render target process
  28896. */
  28897. static DATASOURCE_MULTIRENDERTARGET: number;
  28898. /**
  28899. * Texture data comes from a cube data file
  28900. */
  28901. static DATASOURCE_CUBE: number;
  28902. /**
  28903. * Texture data comes from a raw cube data
  28904. */
  28905. static DATASOURCE_CUBERAW: number;
  28906. /**
  28907. * Texture data come from a prefiltered cube data file
  28908. */
  28909. static DATASOURCE_CUBEPREFILTERED: number;
  28910. /**
  28911. * Texture content is raw 3D data
  28912. */
  28913. static DATASOURCE_RAW3D: number;
  28914. /**
  28915. * Texture content is a depth texture
  28916. */
  28917. static DATASOURCE_DEPTHTEXTURE: number;
  28918. /**
  28919. * Texture data comes from a raw cube data encoded with RGBD
  28920. */
  28921. static DATASOURCE_CUBERAW_RGBD: number;
  28922. /**
  28923. * Defines if the texture is ready
  28924. */
  28925. isReady: boolean;
  28926. /**
  28927. * Defines if the texture is a cube texture
  28928. */
  28929. isCube: boolean;
  28930. /**
  28931. * Defines if the texture contains 3D data
  28932. */
  28933. is3D: boolean;
  28934. /**
  28935. * Defines if the texture contains multiview data
  28936. */
  28937. isMultiview: boolean;
  28938. /**
  28939. * Gets the URL used to load this texture
  28940. */
  28941. url: string;
  28942. /**
  28943. * Gets the sampling mode of the texture
  28944. */
  28945. samplingMode: number;
  28946. /**
  28947. * Gets a boolean indicating if the texture needs mipmaps generation
  28948. */
  28949. generateMipMaps: boolean;
  28950. /**
  28951. * Gets the number of samples used by the texture (WebGL2+ only)
  28952. */
  28953. samples: number;
  28954. /**
  28955. * Gets the type of the texture (int, float...)
  28956. */
  28957. type: number;
  28958. /**
  28959. * Gets the format of the texture (RGB, RGBA...)
  28960. */
  28961. format: number;
  28962. /**
  28963. * Observable called when the texture is loaded
  28964. */
  28965. onLoadedObservable: Observable<InternalTexture>;
  28966. /**
  28967. * Gets the width of the texture
  28968. */
  28969. width: number;
  28970. /**
  28971. * Gets the height of the texture
  28972. */
  28973. height: number;
  28974. /**
  28975. * Gets the depth of the texture
  28976. */
  28977. depth: number;
  28978. /**
  28979. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28980. */
  28981. baseWidth: number;
  28982. /**
  28983. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28984. */
  28985. baseHeight: number;
  28986. /**
  28987. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28988. */
  28989. baseDepth: number;
  28990. /**
  28991. * Gets a boolean indicating if the texture is inverted on Y axis
  28992. */
  28993. invertY: boolean;
  28994. /** @hidden */
  28995. _invertVScale: boolean;
  28996. /** @hidden */
  28997. _associatedChannel: number;
  28998. /** @hidden */
  28999. _dataSource: number;
  29000. /** @hidden */
  29001. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  29002. /** @hidden */
  29003. _bufferView: Nullable<ArrayBufferView>;
  29004. /** @hidden */
  29005. _bufferViewArray: Nullable<ArrayBufferView[]>;
  29006. /** @hidden */
  29007. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  29008. /** @hidden */
  29009. _size: number;
  29010. /** @hidden */
  29011. _extension: string;
  29012. /** @hidden */
  29013. _files: Nullable<string[]>;
  29014. /** @hidden */
  29015. _workingCanvas: Nullable<HTMLCanvasElement>;
  29016. /** @hidden */
  29017. _workingContext: Nullable<CanvasRenderingContext2D>;
  29018. /** @hidden */
  29019. _framebuffer: Nullable<WebGLFramebuffer>;
  29020. /** @hidden */
  29021. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  29022. /** @hidden */
  29023. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  29024. /** @hidden */
  29025. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  29026. /** @hidden */
  29027. _attachments: Nullable<number[]>;
  29028. /** @hidden */
  29029. _cachedCoordinatesMode: Nullable<number>;
  29030. /** @hidden */
  29031. _cachedWrapU: Nullable<number>;
  29032. /** @hidden */
  29033. _cachedWrapV: Nullable<number>;
  29034. /** @hidden */
  29035. _cachedWrapR: Nullable<number>;
  29036. /** @hidden */
  29037. _cachedAnisotropicFilteringLevel: Nullable<number>;
  29038. /** @hidden */
  29039. _isDisabled: boolean;
  29040. /** @hidden */
  29041. _compression: Nullable<string>;
  29042. /** @hidden */
  29043. _generateStencilBuffer: boolean;
  29044. /** @hidden */
  29045. _generateDepthBuffer: boolean;
  29046. /** @hidden */
  29047. _comparisonFunction: number;
  29048. /** @hidden */
  29049. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  29050. /** @hidden */
  29051. _lodGenerationScale: number;
  29052. /** @hidden */
  29053. _lodGenerationOffset: number;
  29054. /** @hidden */
  29055. _colorTextureArray: Nullable<WebGLTexture>;
  29056. /** @hidden */
  29057. _depthStencilTextureArray: Nullable<WebGLTexture>;
  29058. /** @hidden */
  29059. _lodTextureHigh: Nullable<BaseTexture>;
  29060. /** @hidden */
  29061. _lodTextureMid: Nullable<BaseTexture>;
  29062. /** @hidden */
  29063. _lodTextureLow: Nullable<BaseTexture>;
  29064. /** @hidden */
  29065. _isRGBD: boolean;
  29066. /** @hidden */
  29067. _linearSpecularLOD: boolean;
  29068. /** @hidden */
  29069. _irradianceTexture: Nullable<BaseTexture>;
  29070. /** @hidden */
  29071. _webGLTexture: Nullable<WebGLTexture>;
  29072. /** @hidden */
  29073. _references: number;
  29074. private _engine;
  29075. /**
  29076. * Gets the Engine the texture belongs to.
  29077. * @returns The babylon engine
  29078. */
  29079. getEngine(): Engine;
  29080. /**
  29081. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  29082. */
  29083. readonly dataSource: number;
  29084. /**
  29085. * Creates a new InternalTexture
  29086. * @param engine defines the engine to use
  29087. * @param dataSource defines the type of data that will be used
  29088. * @param delayAllocation if the texture allocation should be delayed (default: false)
  29089. */
  29090. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  29091. /**
  29092. * Increments the number of references (ie. the number of Texture that point to it)
  29093. */
  29094. incrementReferences(): void;
  29095. /**
  29096. * Change the size of the texture (not the size of the content)
  29097. * @param width defines the new width
  29098. * @param height defines the new height
  29099. * @param depth defines the new depth (1 by default)
  29100. */
  29101. updateSize(width: int, height: int, depth?: int): void;
  29102. /** @hidden */
  29103. _rebuild(): void;
  29104. /** @hidden */
  29105. _swapAndDie(target: InternalTexture): void;
  29106. /**
  29107. * Dispose the current allocated resources
  29108. */
  29109. dispose(): void;
  29110. }
  29111. }
  29112. declare module "babylonjs/Materials/effect" {
  29113. import { Observable } from "babylonjs/Misc/observable";
  29114. import { Nullable } from "babylonjs/types";
  29115. import { IDisposable } from "babylonjs/scene";
  29116. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29117. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29118. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29119. import { Engine } from "babylonjs/Engines/engine";
  29120. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29121. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29122. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29123. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29125. /**
  29126. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29127. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29128. */
  29129. export class EffectFallbacks {
  29130. private _defines;
  29131. private _currentRank;
  29132. private _maxRank;
  29133. private _mesh;
  29134. /**
  29135. * Removes the fallback from the bound mesh.
  29136. */
  29137. unBindMesh(): void;
  29138. /**
  29139. * Adds a fallback on the specified property.
  29140. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29141. * @param define The name of the define in the shader
  29142. */
  29143. addFallback(rank: number, define: string): void;
  29144. /**
  29145. * Sets the mesh to use CPU skinning when needing to fallback.
  29146. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29147. * @param mesh The mesh to use the fallbacks.
  29148. */
  29149. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29150. /**
  29151. * Checks to see if more fallbacks are still availible.
  29152. */
  29153. readonly hasMoreFallbacks: boolean;
  29154. /**
  29155. * Removes the defines that should be removed when falling back.
  29156. * @param currentDefines defines the current define statements for the shader.
  29157. * @param effect defines the current effect we try to compile
  29158. * @returns The resulting defines with defines of the current rank removed.
  29159. */
  29160. reduce(currentDefines: string, effect: Effect): string;
  29161. }
  29162. /**
  29163. * Options to be used when creating an effect.
  29164. */
  29165. export class EffectCreationOptions {
  29166. /**
  29167. * Atrributes that will be used in the shader.
  29168. */
  29169. attributes: string[];
  29170. /**
  29171. * Uniform varible names that will be set in the shader.
  29172. */
  29173. uniformsNames: string[];
  29174. /**
  29175. * Uniform buffer varible names that will be set in the shader.
  29176. */
  29177. uniformBuffersNames: string[];
  29178. /**
  29179. * Sampler texture variable names that will be set in the shader.
  29180. */
  29181. samplers: string[];
  29182. /**
  29183. * Define statements that will be set in the shader.
  29184. */
  29185. defines: any;
  29186. /**
  29187. * Possible fallbacks for this effect to improve performance when needed.
  29188. */
  29189. fallbacks: Nullable<EffectFallbacks>;
  29190. /**
  29191. * Callback that will be called when the shader is compiled.
  29192. */
  29193. onCompiled: Nullable<(effect: Effect) => void>;
  29194. /**
  29195. * Callback that will be called if an error occurs during shader compilation.
  29196. */
  29197. onError: Nullable<(effect: Effect, errors: string) => void>;
  29198. /**
  29199. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29200. */
  29201. indexParameters: any;
  29202. /**
  29203. * Max number of lights that can be used in the shader.
  29204. */
  29205. maxSimultaneousLights: number;
  29206. /**
  29207. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29208. */
  29209. transformFeedbackVaryings: Nullable<string[]>;
  29210. }
  29211. /**
  29212. * Effect containing vertex and fragment shader that can be executed on an object.
  29213. */
  29214. export class Effect implements IDisposable {
  29215. /**
  29216. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29217. */
  29218. static ShadersRepository: string;
  29219. /**
  29220. * Name of the effect.
  29221. */
  29222. name: any;
  29223. /**
  29224. * String container all the define statements that should be set on the shader.
  29225. */
  29226. defines: string;
  29227. /**
  29228. * Callback that will be called when the shader is compiled.
  29229. */
  29230. onCompiled: Nullable<(effect: Effect) => void>;
  29231. /**
  29232. * Callback that will be called if an error occurs during shader compilation.
  29233. */
  29234. onError: Nullable<(effect: Effect, errors: string) => void>;
  29235. /**
  29236. * Callback that will be called when effect is bound.
  29237. */
  29238. onBind: Nullable<(effect: Effect) => void>;
  29239. /**
  29240. * Unique ID of the effect.
  29241. */
  29242. uniqueId: number;
  29243. /**
  29244. * Observable that will be called when the shader is compiled.
  29245. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29246. */
  29247. onCompileObservable: Observable<Effect>;
  29248. /**
  29249. * Observable that will be called if an error occurs during shader compilation.
  29250. */
  29251. onErrorObservable: Observable<Effect>;
  29252. /** @hidden */
  29253. _onBindObservable: Nullable<Observable<Effect>>;
  29254. /**
  29255. * Observable that will be called when effect is bound.
  29256. */
  29257. readonly onBindObservable: Observable<Effect>;
  29258. /** @hidden */
  29259. _bonesComputationForcedToCPU: boolean;
  29260. private static _uniqueIdSeed;
  29261. private _engine;
  29262. private _uniformBuffersNames;
  29263. private _uniformsNames;
  29264. private _samplerList;
  29265. private _samplers;
  29266. private _isReady;
  29267. private _compilationError;
  29268. private _attributesNames;
  29269. private _attributes;
  29270. private _uniforms;
  29271. /**
  29272. * Key for the effect.
  29273. * @hidden
  29274. */
  29275. _key: string;
  29276. private _indexParameters;
  29277. private _fallbacks;
  29278. private _vertexSourceCode;
  29279. private _fragmentSourceCode;
  29280. private _vertexSourceCodeOverride;
  29281. private _fragmentSourceCodeOverride;
  29282. private _transformFeedbackVaryings;
  29283. /**
  29284. * Compiled shader to webGL program.
  29285. * @hidden
  29286. */
  29287. _pipelineContext: Nullable<IPipelineContext>;
  29288. private _valueCache;
  29289. private static _baseCache;
  29290. /**
  29291. * Instantiates an effect.
  29292. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29293. * @param baseName Name of the effect.
  29294. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29295. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29296. * @param samplers List of sampler variables that will be passed to the shader.
  29297. * @param engine Engine to be used to render the effect
  29298. * @param defines Define statements to be added to the shader.
  29299. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29300. * @param onCompiled Callback that will be called when the shader is compiled.
  29301. * @param onError Callback that will be called if an error occurs during shader compilation.
  29302. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29303. */
  29304. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29305. private _useFinalCode;
  29306. /**
  29307. * Unique key for this effect
  29308. */
  29309. readonly key: string;
  29310. /**
  29311. * If the effect has been compiled and prepared.
  29312. * @returns if the effect is compiled and prepared.
  29313. */
  29314. isReady(): boolean;
  29315. private _isReadyInternal;
  29316. /**
  29317. * The engine the effect was initialized with.
  29318. * @returns the engine.
  29319. */
  29320. getEngine(): Engine;
  29321. /**
  29322. * The pipeline context for this effect
  29323. * @returns the associated pipeline context
  29324. */
  29325. getPipelineContext(): Nullable<IPipelineContext>;
  29326. /**
  29327. * The set of names of attribute variables for the shader.
  29328. * @returns An array of attribute names.
  29329. */
  29330. getAttributesNames(): string[];
  29331. /**
  29332. * Returns the attribute at the given index.
  29333. * @param index The index of the attribute.
  29334. * @returns The location of the attribute.
  29335. */
  29336. getAttributeLocation(index: number): number;
  29337. /**
  29338. * Returns the attribute based on the name of the variable.
  29339. * @param name of the attribute to look up.
  29340. * @returns the attribute location.
  29341. */
  29342. getAttributeLocationByName(name: string): number;
  29343. /**
  29344. * The number of attributes.
  29345. * @returns the numnber of attributes.
  29346. */
  29347. getAttributesCount(): number;
  29348. /**
  29349. * Gets the index of a uniform variable.
  29350. * @param uniformName of the uniform to look up.
  29351. * @returns the index.
  29352. */
  29353. getUniformIndex(uniformName: string): number;
  29354. /**
  29355. * Returns the attribute based on the name of the variable.
  29356. * @param uniformName of the uniform to look up.
  29357. * @returns the location of the uniform.
  29358. */
  29359. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29360. /**
  29361. * Returns an array of sampler variable names
  29362. * @returns The array of sampler variable neames.
  29363. */
  29364. getSamplers(): string[];
  29365. /**
  29366. * The error from the last compilation.
  29367. * @returns the error string.
  29368. */
  29369. getCompilationError(): string;
  29370. /**
  29371. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29372. * @param func The callback to be used.
  29373. */
  29374. executeWhenCompiled(func: (effect: Effect) => void): void;
  29375. private _checkIsReady;
  29376. /** @hidden */
  29377. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29378. /** @hidden */
  29379. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29380. /** @hidden */
  29381. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29382. /**
  29383. * Recompiles the webGL program
  29384. * @param vertexSourceCode The source code for the vertex shader.
  29385. * @param fragmentSourceCode The source code for the fragment shader.
  29386. * @param onCompiled Callback called when completed.
  29387. * @param onError Callback called on error.
  29388. * @hidden
  29389. */
  29390. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29391. /**
  29392. * Prepares the effect
  29393. * @hidden
  29394. */
  29395. _prepareEffect(): void;
  29396. private _processCompilationErrors;
  29397. /**
  29398. * Checks if the effect is supported. (Must be called after compilation)
  29399. */
  29400. readonly isSupported: boolean;
  29401. /**
  29402. * Binds a texture to the engine to be used as output of the shader.
  29403. * @param channel Name of the output variable.
  29404. * @param texture Texture to bind.
  29405. * @hidden
  29406. */
  29407. _bindTexture(channel: string, texture: InternalTexture): void;
  29408. /**
  29409. * Sets a texture on the engine to be used in the shader.
  29410. * @param channel Name of the sampler variable.
  29411. * @param texture Texture to set.
  29412. */
  29413. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29414. /**
  29415. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29416. * @param channel Name of the sampler variable.
  29417. * @param texture Texture to set.
  29418. */
  29419. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29420. /**
  29421. * Sets an array of textures on the engine to be used in the shader.
  29422. * @param channel Name of the variable.
  29423. * @param textures Textures to set.
  29424. */
  29425. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29426. /**
  29427. * 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)
  29428. * @param channel Name of the sampler variable.
  29429. * @param postProcess Post process to get the input texture from.
  29430. */
  29431. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29432. /**
  29433. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29434. * 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)
  29435. * @param channel Name of the sampler variable.
  29436. * @param postProcess Post process to get the output texture from.
  29437. */
  29438. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29439. /** @hidden */
  29440. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29441. /** @hidden */
  29442. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29443. /** @hidden */
  29444. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29445. /** @hidden */
  29446. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29447. /**
  29448. * Binds a buffer to a uniform.
  29449. * @param buffer Buffer to bind.
  29450. * @param name Name of the uniform variable to bind to.
  29451. */
  29452. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29453. /**
  29454. * Binds block to a uniform.
  29455. * @param blockName Name of the block to bind.
  29456. * @param index Index to bind.
  29457. */
  29458. bindUniformBlock(blockName: string, index: number): void;
  29459. /**
  29460. * Sets an interger value on a uniform variable.
  29461. * @param uniformName Name of the variable.
  29462. * @param value Value to be set.
  29463. * @returns this effect.
  29464. */
  29465. setInt(uniformName: string, value: number): Effect;
  29466. /**
  29467. * Sets an int array on a uniform variable.
  29468. * @param uniformName Name of the variable.
  29469. * @param array array to be set.
  29470. * @returns this effect.
  29471. */
  29472. setIntArray(uniformName: string, array: Int32Array): Effect;
  29473. /**
  29474. * 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)
  29475. * @param uniformName Name of the variable.
  29476. * @param array array to be set.
  29477. * @returns this effect.
  29478. */
  29479. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29480. /**
  29481. * 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)
  29482. * @param uniformName Name of the variable.
  29483. * @param array array to be set.
  29484. * @returns this effect.
  29485. */
  29486. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29487. /**
  29488. * 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)
  29489. * @param uniformName Name of the variable.
  29490. * @param array array to be set.
  29491. * @returns this effect.
  29492. */
  29493. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29494. /**
  29495. * Sets an float array on a uniform variable.
  29496. * @param uniformName Name of the variable.
  29497. * @param array array to be set.
  29498. * @returns this effect.
  29499. */
  29500. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29501. /**
  29502. * 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)
  29503. * @param uniformName Name of the variable.
  29504. * @param array array to be set.
  29505. * @returns this effect.
  29506. */
  29507. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29508. /**
  29509. * 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)
  29510. * @param uniformName Name of the variable.
  29511. * @param array array to be set.
  29512. * @returns this effect.
  29513. */
  29514. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29515. /**
  29516. * 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)
  29517. * @param uniformName Name of the variable.
  29518. * @param array array to be set.
  29519. * @returns this effect.
  29520. */
  29521. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29522. /**
  29523. * Sets an array on a uniform variable.
  29524. * @param uniformName Name of the variable.
  29525. * @param array array to be set.
  29526. * @returns this effect.
  29527. */
  29528. setArray(uniformName: string, array: number[]): Effect;
  29529. /**
  29530. * 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)
  29531. * @param uniformName Name of the variable.
  29532. * @param array array to be set.
  29533. * @returns this effect.
  29534. */
  29535. setArray2(uniformName: string, array: number[]): Effect;
  29536. /**
  29537. * 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)
  29538. * @param uniformName Name of the variable.
  29539. * @param array array to be set.
  29540. * @returns this effect.
  29541. */
  29542. setArray3(uniformName: string, array: number[]): Effect;
  29543. /**
  29544. * 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)
  29545. * @param uniformName Name of the variable.
  29546. * @param array array to be set.
  29547. * @returns this effect.
  29548. */
  29549. setArray4(uniformName: string, array: number[]): Effect;
  29550. /**
  29551. * Sets matrices on a uniform variable.
  29552. * @param uniformName Name of the variable.
  29553. * @param matrices matrices to be set.
  29554. * @returns this effect.
  29555. */
  29556. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29557. /**
  29558. * Sets matrix on a uniform variable.
  29559. * @param uniformName Name of the variable.
  29560. * @param matrix matrix to be set.
  29561. * @returns this effect.
  29562. */
  29563. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29564. /**
  29565. * 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)
  29566. * @param uniformName Name of the variable.
  29567. * @param matrix matrix to be set.
  29568. * @returns this effect.
  29569. */
  29570. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29571. /**
  29572. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29573. * @param uniformName Name of the variable.
  29574. * @param matrix matrix to be set.
  29575. * @returns this effect.
  29576. */
  29577. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29578. /**
  29579. * Sets a float on a uniform variable.
  29580. * @param uniformName Name of the variable.
  29581. * @param value value to be set.
  29582. * @returns this effect.
  29583. */
  29584. setFloat(uniformName: string, value: number): Effect;
  29585. /**
  29586. * Sets a boolean on a uniform variable.
  29587. * @param uniformName Name of the variable.
  29588. * @param bool value to be set.
  29589. * @returns this effect.
  29590. */
  29591. setBool(uniformName: string, bool: boolean): Effect;
  29592. /**
  29593. * Sets a Vector2 on a uniform variable.
  29594. * @param uniformName Name of the variable.
  29595. * @param vector2 vector2 to be set.
  29596. * @returns this effect.
  29597. */
  29598. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29599. /**
  29600. * Sets a float2 on a uniform variable.
  29601. * @param uniformName Name of the variable.
  29602. * @param x First float in float2.
  29603. * @param y Second float in float2.
  29604. * @returns this effect.
  29605. */
  29606. setFloat2(uniformName: string, x: number, y: number): Effect;
  29607. /**
  29608. * Sets a Vector3 on a uniform variable.
  29609. * @param uniformName Name of the variable.
  29610. * @param vector3 Value to be set.
  29611. * @returns this effect.
  29612. */
  29613. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29614. /**
  29615. * Sets a float3 on a uniform variable.
  29616. * @param uniformName Name of the variable.
  29617. * @param x First float in float3.
  29618. * @param y Second float in float3.
  29619. * @param z Third float in float3.
  29620. * @returns this effect.
  29621. */
  29622. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29623. /**
  29624. * Sets a Vector4 on a uniform variable.
  29625. * @param uniformName Name of the variable.
  29626. * @param vector4 Value to be set.
  29627. * @returns this effect.
  29628. */
  29629. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29630. /**
  29631. * Sets a float4 on a uniform variable.
  29632. * @param uniformName Name of the variable.
  29633. * @param x First float in float4.
  29634. * @param y Second float in float4.
  29635. * @param z Third float in float4.
  29636. * @param w Fourth float in float4.
  29637. * @returns this effect.
  29638. */
  29639. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29640. /**
  29641. * Sets a Color3 on a uniform variable.
  29642. * @param uniformName Name of the variable.
  29643. * @param color3 Value to be set.
  29644. * @returns this effect.
  29645. */
  29646. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29647. /**
  29648. * Sets a Color4 on a uniform variable.
  29649. * @param uniformName Name of the variable.
  29650. * @param color3 Value to be set.
  29651. * @param alpha Alpha value to be set.
  29652. * @returns this effect.
  29653. */
  29654. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29655. /**
  29656. * Sets a Color4 on a uniform variable
  29657. * @param uniformName defines the name of the variable
  29658. * @param color4 defines the value to be set
  29659. * @returns this effect.
  29660. */
  29661. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29662. /** Release all associated resources */
  29663. dispose(): void;
  29664. /**
  29665. * This function will add a new shader to the shader store
  29666. * @param name the name of the shader
  29667. * @param pixelShader optional pixel shader content
  29668. * @param vertexShader optional vertex shader content
  29669. */
  29670. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29671. /**
  29672. * Store of each shader (The can be looked up using effect.key)
  29673. */
  29674. static ShadersStore: {
  29675. [key: string]: string;
  29676. };
  29677. /**
  29678. * Store of each included file for a shader (The can be looked up using effect.key)
  29679. */
  29680. static IncludesShadersStore: {
  29681. [key: string]: string;
  29682. };
  29683. /**
  29684. * Resets the cache of effects.
  29685. */
  29686. static ResetCache(): void;
  29687. }
  29688. }
  29689. declare module "babylonjs/Materials/uniformBuffer" {
  29690. import { Nullable, FloatArray } from "babylonjs/types";
  29691. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29692. import { Engine } from "babylonjs/Engines/engine";
  29693. import { Effect } from "babylonjs/Materials/effect";
  29694. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29695. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29696. import { Color3 } from "babylonjs/Maths/math.color";
  29697. /**
  29698. * Uniform buffer objects.
  29699. *
  29700. * Handles blocks of uniform on the GPU.
  29701. *
  29702. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29703. *
  29704. * For more information, please refer to :
  29705. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29706. */
  29707. export class UniformBuffer {
  29708. private _engine;
  29709. private _buffer;
  29710. private _data;
  29711. private _bufferData;
  29712. private _dynamic?;
  29713. private _uniformLocations;
  29714. private _uniformSizes;
  29715. private _uniformLocationPointer;
  29716. private _needSync;
  29717. private _noUBO;
  29718. private _currentEffect;
  29719. private static _MAX_UNIFORM_SIZE;
  29720. private static _tempBuffer;
  29721. /**
  29722. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29723. * This is dynamic to allow compat with webgl 1 and 2.
  29724. * You will need to pass the name of the uniform as well as the value.
  29725. */
  29726. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29727. /**
  29728. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29729. * This is dynamic to allow compat with webgl 1 and 2.
  29730. * You will need to pass the name of the uniform as well as the value.
  29731. */
  29732. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29733. /**
  29734. * Lambda to Update a single float in a uniform buffer.
  29735. * This is dynamic to allow compat with webgl 1 and 2.
  29736. * You will need to pass the name of the uniform as well as the value.
  29737. */
  29738. updateFloat: (name: string, x: number) => void;
  29739. /**
  29740. * Lambda to Update a vec2 of float in a uniform buffer.
  29741. * This is dynamic to allow compat with webgl 1 and 2.
  29742. * You will need to pass the name of the uniform as well as the value.
  29743. */
  29744. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29745. /**
  29746. * Lambda to Update a vec3 of float in a uniform buffer.
  29747. * This is dynamic to allow compat with webgl 1 and 2.
  29748. * You will need to pass the name of the uniform as well as the value.
  29749. */
  29750. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29751. /**
  29752. * Lambda to Update a vec4 of float in a uniform buffer.
  29753. * This is dynamic to allow compat with webgl 1 and 2.
  29754. * You will need to pass the name of the uniform as well as the value.
  29755. */
  29756. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29757. /**
  29758. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29759. * This is dynamic to allow compat with webgl 1 and 2.
  29760. * You will need to pass the name of the uniform as well as the value.
  29761. */
  29762. updateMatrix: (name: string, mat: Matrix) => void;
  29763. /**
  29764. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29765. * This is dynamic to allow compat with webgl 1 and 2.
  29766. * You will need to pass the name of the uniform as well as the value.
  29767. */
  29768. updateVector3: (name: string, vector: Vector3) => void;
  29769. /**
  29770. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29771. * This is dynamic to allow compat with webgl 1 and 2.
  29772. * You will need to pass the name of the uniform as well as the value.
  29773. */
  29774. updateVector4: (name: string, vector: Vector4) => void;
  29775. /**
  29776. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29777. * This is dynamic to allow compat with webgl 1 and 2.
  29778. * You will need to pass the name of the uniform as well as the value.
  29779. */
  29780. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29781. /**
  29782. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29783. * This is dynamic to allow compat with webgl 1 and 2.
  29784. * You will need to pass the name of the uniform as well as the value.
  29785. */
  29786. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29787. /**
  29788. * Instantiates a new Uniform buffer objects.
  29789. *
  29790. * Handles blocks of uniform on the GPU.
  29791. *
  29792. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29793. *
  29794. * For more information, please refer to :
  29795. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29796. * @param engine Define the engine the buffer is associated with
  29797. * @param data Define the data contained in the buffer
  29798. * @param dynamic Define if the buffer is updatable
  29799. */
  29800. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29801. /**
  29802. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29803. * or just falling back on setUniformXXX calls.
  29804. */
  29805. readonly useUbo: boolean;
  29806. /**
  29807. * Indicates if the WebGL underlying uniform buffer is in sync
  29808. * with the javascript cache data.
  29809. */
  29810. readonly isSync: boolean;
  29811. /**
  29812. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29813. * Also, a dynamic UniformBuffer will disable cache verification and always
  29814. * update the underlying WebGL uniform buffer to the GPU.
  29815. * @returns if Dynamic, otherwise false
  29816. */
  29817. isDynamic(): boolean;
  29818. /**
  29819. * The data cache on JS side.
  29820. * @returns the underlying data as a float array
  29821. */
  29822. getData(): Float32Array;
  29823. /**
  29824. * The underlying WebGL Uniform buffer.
  29825. * @returns the webgl buffer
  29826. */
  29827. getBuffer(): Nullable<DataBuffer>;
  29828. /**
  29829. * std140 layout specifies how to align data within an UBO structure.
  29830. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29831. * for specs.
  29832. */
  29833. private _fillAlignment;
  29834. /**
  29835. * Adds an uniform in the buffer.
  29836. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29837. * for the layout to be correct !
  29838. * @param name Name of the uniform, as used in the uniform block in the shader.
  29839. * @param size Data size, or data directly.
  29840. */
  29841. addUniform(name: string, size: number | number[]): void;
  29842. /**
  29843. * Adds a Matrix 4x4 to the uniform buffer.
  29844. * @param name Name of the uniform, as used in the uniform block in the shader.
  29845. * @param mat A 4x4 matrix.
  29846. */
  29847. addMatrix(name: string, mat: Matrix): void;
  29848. /**
  29849. * Adds a vec2 to the uniform buffer.
  29850. * @param name Name of the uniform, as used in the uniform block in the shader.
  29851. * @param x Define the x component value of the vec2
  29852. * @param y Define the y component value of the vec2
  29853. */
  29854. addFloat2(name: string, x: number, y: number): void;
  29855. /**
  29856. * Adds a vec3 to the uniform buffer.
  29857. * @param name Name of the uniform, as used in the uniform block in the shader.
  29858. * @param x Define the x component value of the vec3
  29859. * @param y Define the y component value of the vec3
  29860. * @param z Define the z component value of the vec3
  29861. */
  29862. addFloat3(name: string, x: number, y: number, z: number): void;
  29863. /**
  29864. * Adds a vec3 to the uniform buffer.
  29865. * @param name Name of the uniform, as used in the uniform block in the shader.
  29866. * @param color Define the vec3 from a Color
  29867. */
  29868. addColor3(name: string, color: Color3): void;
  29869. /**
  29870. * Adds a vec4 to the uniform buffer.
  29871. * @param name Name of the uniform, as used in the uniform block in the shader.
  29872. * @param color Define the rgb components from a Color
  29873. * @param alpha Define the a component of the vec4
  29874. */
  29875. addColor4(name: string, color: Color3, alpha: number): void;
  29876. /**
  29877. * Adds a vec3 to the uniform buffer.
  29878. * @param name Name of the uniform, as used in the uniform block in the shader.
  29879. * @param vector Define the vec3 components from a Vector
  29880. */
  29881. addVector3(name: string, vector: Vector3): void;
  29882. /**
  29883. * Adds a Matrix 3x3 to the uniform buffer.
  29884. * @param name Name of the uniform, as used in the uniform block in the shader.
  29885. */
  29886. addMatrix3x3(name: string): void;
  29887. /**
  29888. * Adds a Matrix 2x2 to the uniform buffer.
  29889. * @param name Name of the uniform, as used in the uniform block in the shader.
  29890. */
  29891. addMatrix2x2(name: string): void;
  29892. /**
  29893. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29894. */
  29895. create(): void;
  29896. /** @hidden */
  29897. _rebuild(): void;
  29898. /**
  29899. * Updates the WebGL Uniform Buffer on the GPU.
  29900. * If the `dynamic` flag is set to true, no cache comparison is done.
  29901. * Otherwise, the buffer will be updated only if the cache differs.
  29902. */
  29903. update(): void;
  29904. /**
  29905. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29906. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29907. * @param data Define the flattened data
  29908. * @param size Define the size of the data.
  29909. */
  29910. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29911. private _valueCache;
  29912. private _cacheMatrix;
  29913. private _updateMatrix3x3ForUniform;
  29914. private _updateMatrix3x3ForEffect;
  29915. private _updateMatrix2x2ForEffect;
  29916. private _updateMatrix2x2ForUniform;
  29917. private _updateFloatForEffect;
  29918. private _updateFloatForUniform;
  29919. private _updateFloat2ForEffect;
  29920. private _updateFloat2ForUniform;
  29921. private _updateFloat3ForEffect;
  29922. private _updateFloat3ForUniform;
  29923. private _updateFloat4ForEffect;
  29924. private _updateFloat4ForUniform;
  29925. private _updateMatrixForEffect;
  29926. private _updateMatrixForUniform;
  29927. private _updateVector3ForEffect;
  29928. private _updateVector3ForUniform;
  29929. private _updateVector4ForEffect;
  29930. private _updateVector4ForUniform;
  29931. private _updateColor3ForEffect;
  29932. private _updateColor3ForUniform;
  29933. private _updateColor4ForEffect;
  29934. private _updateColor4ForUniform;
  29935. /**
  29936. * Sets a sampler uniform on the effect.
  29937. * @param name Define the name of the sampler.
  29938. * @param texture Define the texture to set in the sampler
  29939. */
  29940. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29941. /**
  29942. * Directly updates the value of the uniform in the cache AND on the GPU.
  29943. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29944. * @param data Define the flattened data
  29945. */
  29946. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29947. /**
  29948. * Binds this uniform buffer to an effect.
  29949. * @param effect Define the effect to bind the buffer to
  29950. * @param name Name of the uniform block in the shader.
  29951. */
  29952. bindToEffect(effect: Effect, name: string): void;
  29953. /**
  29954. * Disposes the uniform buffer.
  29955. */
  29956. dispose(): void;
  29957. }
  29958. }
  29959. declare module "babylonjs/Audio/analyser" {
  29960. import { Scene } from "babylonjs/scene";
  29961. /**
  29962. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29963. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29964. */
  29965. export class Analyser {
  29966. /**
  29967. * Gets or sets the smoothing
  29968. * @ignorenaming
  29969. */
  29970. SMOOTHING: number;
  29971. /**
  29972. * Gets or sets the FFT table size
  29973. * @ignorenaming
  29974. */
  29975. FFT_SIZE: number;
  29976. /**
  29977. * Gets or sets the bar graph amplitude
  29978. * @ignorenaming
  29979. */
  29980. BARGRAPHAMPLITUDE: number;
  29981. /**
  29982. * Gets or sets the position of the debug canvas
  29983. * @ignorenaming
  29984. */
  29985. DEBUGCANVASPOS: {
  29986. x: number;
  29987. y: number;
  29988. };
  29989. /**
  29990. * Gets or sets the debug canvas size
  29991. * @ignorenaming
  29992. */
  29993. DEBUGCANVASSIZE: {
  29994. width: number;
  29995. height: number;
  29996. };
  29997. private _byteFreqs;
  29998. private _byteTime;
  29999. private _floatFreqs;
  30000. private _webAudioAnalyser;
  30001. private _debugCanvas;
  30002. private _debugCanvasContext;
  30003. private _scene;
  30004. private _registerFunc;
  30005. private _audioEngine;
  30006. /**
  30007. * Creates a new analyser
  30008. * @param scene defines hosting scene
  30009. */
  30010. constructor(scene: Scene);
  30011. /**
  30012. * Get the number of data values you will have to play with for the visualization
  30013. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  30014. * @returns a number
  30015. */
  30016. getFrequencyBinCount(): number;
  30017. /**
  30018. * Gets the current frequency data as a byte array
  30019. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30020. * @returns a Uint8Array
  30021. */
  30022. getByteFrequencyData(): Uint8Array;
  30023. /**
  30024. * Gets the current waveform as a byte array
  30025. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  30026. * @returns a Uint8Array
  30027. */
  30028. getByteTimeDomainData(): Uint8Array;
  30029. /**
  30030. * Gets the current frequency data as a float array
  30031. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  30032. * @returns a Float32Array
  30033. */
  30034. getFloatFrequencyData(): Float32Array;
  30035. /**
  30036. * Renders the debug canvas
  30037. */
  30038. drawDebugCanvas(): void;
  30039. /**
  30040. * Stops rendering the debug canvas and removes it
  30041. */
  30042. stopDebugCanvas(): void;
  30043. /**
  30044. * Connects two audio nodes
  30045. * @param inputAudioNode defines first node to connect
  30046. * @param outputAudioNode defines second node to connect
  30047. */
  30048. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  30049. /**
  30050. * Releases all associated resources
  30051. */
  30052. dispose(): void;
  30053. }
  30054. }
  30055. declare module "babylonjs/Audio/audioEngine" {
  30056. import { IDisposable } from "babylonjs/scene";
  30057. import { Analyser } from "babylonjs/Audio/analyser";
  30058. import { Nullable } from "babylonjs/types";
  30059. import { Observable } from "babylonjs/Misc/observable";
  30060. /**
  30061. * This represents an audio engine and it is responsible
  30062. * to play, synchronize and analyse sounds throughout the application.
  30063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30064. */
  30065. export interface IAudioEngine extends IDisposable {
  30066. /**
  30067. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30068. */
  30069. readonly canUseWebAudio: boolean;
  30070. /**
  30071. * Gets the current AudioContext if available.
  30072. */
  30073. readonly audioContext: Nullable<AudioContext>;
  30074. /**
  30075. * The master gain node defines the global audio volume of your audio engine.
  30076. */
  30077. readonly masterGain: GainNode;
  30078. /**
  30079. * Gets whether or not mp3 are supported by your browser.
  30080. */
  30081. readonly isMP3supported: boolean;
  30082. /**
  30083. * Gets whether or not ogg are supported by your browser.
  30084. */
  30085. readonly isOGGsupported: boolean;
  30086. /**
  30087. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30088. * @ignoreNaming
  30089. */
  30090. WarnedWebAudioUnsupported: boolean;
  30091. /**
  30092. * Defines if the audio engine relies on a custom unlocked button.
  30093. * In this case, the embedded button will not be displayed.
  30094. */
  30095. useCustomUnlockedButton: boolean;
  30096. /**
  30097. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  30098. */
  30099. readonly unlocked: boolean;
  30100. /**
  30101. * Event raised when audio has been unlocked on the browser.
  30102. */
  30103. onAudioUnlockedObservable: Observable<AudioEngine>;
  30104. /**
  30105. * Event raised when audio has been locked on the browser.
  30106. */
  30107. onAudioLockedObservable: Observable<AudioEngine>;
  30108. /**
  30109. * Flags the audio engine in Locked state.
  30110. * This happens due to new browser policies preventing audio to autoplay.
  30111. */
  30112. lock(): void;
  30113. /**
  30114. * Unlocks the audio engine once a user action has been done on the dom.
  30115. * This is helpful to resume play once browser policies have been satisfied.
  30116. */
  30117. unlock(): void;
  30118. }
  30119. /**
  30120. * This represents the default audio engine used in babylon.
  30121. * It is responsible to play, synchronize and analyse sounds throughout the application.
  30122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30123. */
  30124. export class AudioEngine implements IAudioEngine {
  30125. private _audioContext;
  30126. private _audioContextInitialized;
  30127. private _muteButton;
  30128. private _hostElement;
  30129. /**
  30130. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  30131. */
  30132. canUseWebAudio: boolean;
  30133. /**
  30134. * The master gain node defines the global audio volume of your audio engine.
  30135. */
  30136. masterGain: GainNode;
  30137. /**
  30138. * Defines if Babylon should emit a warning if WebAudio is not supported.
  30139. * @ignoreNaming
  30140. */
  30141. WarnedWebAudioUnsupported: boolean;
  30142. /**
  30143. * Gets whether or not mp3 are supported by your browser.
  30144. */
  30145. isMP3supported: boolean;
  30146. /**
  30147. * Gets whether or not ogg are supported by your browser.
  30148. */
  30149. isOGGsupported: boolean;
  30150. /**
  30151. * Gets whether audio has been unlocked on the device.
  30152. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  30153. * a user interaction has happened.
  30154. */
  30155. unlocked: boolean;
  30156. /**
  30157. * Defines if the audio engine relies on a custom unlocked button.
  30158. * In this case, the embedded button will not be displayed.
  30159. */
  30160. useCustomUnlockedButton: boolean;
  30161. /**
  30162. * Event raised when audio has been unlocked on the browser.
  30163. */
  30164. onAudioUnlockedObservable: Observable<AudioEngine>;
  30165. /**
  30166. * Event raised when audio has been locked on the browser.
  30167. */
  30168. onAudioLockedObservable: Observable<AudioEngine>;
  30169. /**
  30170. * Gets the current AudioContext if available.
  30171. */
  30172. readonly audioContext: Nullable<AudioContext>;
  30173. private _connectedAnalyser;
  30174. /**
  30175. * Instantiates a new audio engine.
  30176. *
  30177. * There should be only one per page as some browsers restrict the number
  30178. * of audio contexts you can create.
  30179. * @param hostElement defines the host element where to display the mute icon if necessary
  30180. */
  30181. constructor(hostElement?: Nullable<HTMLElement>);
  30182. /**
  30183. * Flags the audio engine in Locked state.
  30184. * This happens due to new browser policies preventing audio to autoplay.
  30185. */
  30186. lock(): void;
  30187. /**
  30188. * Unlocks the audio engine once a user action has been done on the dom.
  30189. * This is helpful to resume play once browser policies have been satisfied.
  30190. */
  30191. unlock(): void;
  30192. private _resumeAudioContext;
  30193. private _initializeAudioContext;
  30194. private _tryToRun;
  30195. private _triggerRunningState;
  30196. private _triggerSuspendedState;
  30197. private _displayMuteButton;
  30198. private _moveButtonToTopLeft;
  30199. private _onResize;
  30200. private _hideMuteButton;
  30201. /**
  30202. * Destroy and release the resources associated with the audio ccontext.
  30203. */
  30204. dispose(): void;
  30205. /**
  30206. * Gets the global volume sets on the master gain.
  30207. * @returns the global volume if set or -1 otherwise
  30208. */
  30209. getGlobalVolume(): number;
  30210. /**
  30211. * Sets the global volume of your experience (sets on the master gain).
  30212. * @param newVolume Defines the new global volume of the application
  30213. */
  30214. setGlobalVolume(newVolume: number): void;
  30215. /**
  30216. * Connect the audio engine to an audio analyser allowing some amazing
  30217. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  30218. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  30219. * @param analyser The analyser to connect to the engine
  30220. */
  30221. connectToAnalyser(analyser: Analyser): void;
  30222. }
  30223. }
  30224. declare module "babylonjs/Loading/loadingScreen" {
  30225. /**
  30226. * Interface used to present a loading screen while loading a scene
  30227. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30228. */
  30229. export interface ILoadingScreen {
  30230. /**
  30231. * Function called to display the loading screen
  30232. */
  30233. displayLoadingUI: () => void;
  30234. /**
  30235. * Function called to hide the loading screen
  30236. */
  30237. hideLoadingUI: () => void;
  30238. /**
  30239. * Gets or sets the color to use for the background
  30240. */
  30241. loadingUIBackgroundColor: string;
  30242. /**
  30243. * Gets or sets the text to display while loading
  30244. */
  30245. loadingUIText: string;
  30246. }
  30247. /**
  30248. * Class used for the default loading screen
  30249. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30250. */
  30251. export class DefaultLoadingScreen implements ILoadingScreen {
  30252. private _renderingCanvas;
  30253. private _loadingText;
  30254. private _loadingDivBackgroundColor;
  30255. private _loadingDiv;
  30256. private _loadingTextDiv;
  30257. /** Gets or sets the logo url to use for the default loading screen */
  30258. static DefaultLogoUrl: string;
  30259. /** Gets or sets the spinner url to use for the default loading screen */
  30260. static DefaultSpinnerUrl: string;
  30261. /**
  30262. * Creates a new default loading screen
  30263. * @param _renderingCanvas defines the canvas used to render the scene
  30264. * @param _loadingText defines the default text to display
  30265. * @param _loadingDivBackgroundColor defines the default background color
  30266. */
  30267. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30268. /**
  30269. * Function called to display the loading screen
  30270. */
  30271. displayLoadingUI(): void;
  30272. /**
  30273. * Function called to hide the loading screen
  30274. */
  30275. hideLoadingUI(): void;
  30276. /**
  30277. * Gets or sets the text to display while loading
  30278. */
  30279. loadingUIText: string;
  30280. /**
  30281. * Gets or sets the color to use for the background
  30282. */
  30283. loadingUIBackgroundColor: string;
  30284. private _resizeLoadingUI;
  30285. }
  30286. }
  30287. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30288. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30289. import { Engine } from "babylonjs/Engines/engine";
  30290. import { Nullable } from "babylonjs/types";
  30291. /** @hidden */
  30292. export class WebGLPipelineContext implements IPipelineContext {
  30293. engine: Engine;
  30294. program: Nullable<WebGLProgram>;
  30295. context?: WebGLRenderingContext;
  30296. vertexShader?: WebGLShader;
  30297. fragmentShader?: WebGLShader;
  30298. isParallelCompiled: boolean;
  30299. onCompiled?: () => void;
  30300. transformFeedback?: WebGLTransformFeedback | null;
  30301. readonly isAsync: boolean;
  30302. readonly isReady: boolean;
  30303. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30304. }
  30305. }
  30306. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30307. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30308. /** @hidden */
  30309. export class WebGLDataBuffer extends DataBuffer {
  30310. private _buffer;
  30311. constructor(resource: WebGLBuffer);
  30312. readonly underlyingResource: any;
  30313. }
  30314. }
  30315. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30316. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30317. /** @hidden */
  30318. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30319. attributeProcessor(attribute: string): string;
  30320. varyingProcessor(varying: string, isFragment: boolean): string;
  30321. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30322. }
  30323. }
  30324. declare module "babylonjs/Misc/perfCounter" {
  30325. /**
  30326. * This class is used to track a performance counter which is number based.
  30327. * The user has access to many properties which give statistics of different nature.
  30328. *
  30329. * The implementer can track two kinds of Performance Counter: time and count.
  30330. * 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.
  30331. * 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.
  30332. */
  30333. export class PerfCounter {
  30334. /**
  30335. * Gets or sets a global boolean to turn on and off all the counters
  30336. */
  30337. static Enabled: boolean;
  30338. /**
  30339. * Returns the smallest value ever
  30340. */
  30341. readonly min: number;
  30342. /**
  30343. * Returns the biggest value ever
  30344. */
  30345. readonly max: number;
  30346. /**
  30347. * Returns the average value since the performance counter is running
  30348. */
  30349. readonly average: number;
  30350. /**
  30351. * Returns the average value of the last second the counter was monitored
  30352. */
  30353. readonly lastSecAverage: number;
  30354. /**
  30355. * Returns the current value
  30356. */
  30357. readonly current: number;
  30358. /**
  30359. * Gets the accumulated total
  30360. */
  30361. readonly total: number;
  30362. /**
  30363. * Gets the total value count
  30364. */
  30365. readonly count: number;
  30366. /**
  30367. * Creates a new counter
  30368. */
  30369. constructor();
  30370. /**
  30371. * Call this method to start monitoring a new frame.
  30372. * 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.
  30373. */
  30374. fetchNewFrame(): void;
  30375. /**
  30376. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30377. * @param newCount the count value to add to the monitored count
  30378. * @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.
  30379. */
  30380. addCount(newCount: number, fetchResult: boolean): void;
  30381. /**
  30382. * Start monitoring this performance counter
  30383. */
  30384. beginMonitoring(): void;
  30385. /**
  30386. * Compute the time lapsed since the previous beginMonitoring() call.
  30387. * @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
  30388. */
  30389. endMonitoring(newFrame?: boolean): void;
  30390. private _fetchResult;
  30391. private _startMonitoringTime;
  30392. private _min;
  30393. private _max;
  30394. private _average;
  30395. private _current;
  30396. private _totalValueCount;
  30397. private _totalAccumulated;
  30398. private _lastSecAverage;
  30399. private _lastSecAccumulated;
  30400. private _lastSecTime;
  30401. private _lastSecValueCount;
  30402. }
  30403. }
  30404. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30405. /**
  30406. * Interface for any object that can request an animation frame
  30407. */
  30408. export interface ICustomAnimationFrameRequester {
  30409. /**
  30410. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30411. */
  30412. renderFunction?: Function;
  30413. /**
  30414. * Called to request the next frame to render to
  30415. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30416. */
  30417. requestAnimationFrame: Function;
  30418. /**
  30419. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30420. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30421. */
  30422. requestID?: number;
  30423. }
  30424. }
  30425. declare module "babylonjs/Materials/Textures/videoTexture" {
  30426. import { Observable } from "babylonjs/Misc/observable";
  30427. import { Nullable } from "babylonjs/types";
  30428. import { Scene } from "babylonjs/scene";
  30429. import { Texture } from "babylonjs/Materials/Textures/texture";
  30430. /**
  30431. * Settings for finer control over video usage
  30432. */
  30433. export interface VideoTextureSettings {
  30434. /**
  30435. * Applies `autoplay` to video, if specified
  30436. */
  30437. autoPlay?: boolean;
  30438. /**
  30439. * Applies `loop` to video, if specified
  30440. */
  30441. loop?: boolean;
  30442. /**
  30443. * Automatically updates internal texture from video at every frame in the render loop
  30444. */
  30445. autoUpdateTexture: boolean;
  30446. /**
  30447. * Image src displayed during the video loading or until the user interacts with the video.
  30448. */
  30449. poster?: string;
  30450. }
  30451. /**
  30452. * If you want to display a video in your scene, this is the special texture for that.
  30453. * This special texture works similar to other textures, with the exception of a few parameters.
  30454. * @see https://doc.babylonjs.com/how_to/video_texture
  30455. */
  30456. export class VideoTexture extends Texture {
  30457. /**
  30458. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30459. */
  30460. readonly autoUpdateTexture: boolean;
  30461. /**
  30462. * The video instance used by the texture internally
  30463. */
  30464. readonly video: HTMLVideoElement;
  30465. private _onUserActionRequestedObservable;
  30466. /**
  30467. * Event triggerd when a dom action is required by the user to play the video.
  30468. * This happens due to recent changes in browser policies preventing video to auto start.
  30469. */
  30470. readonly onUserActionRequestedObservable: Observable<Texture>;
  30471. private _generateMipMaps;
  30472. private _engine;
  30473. private _stillImageCaptured;
  30474. private _displayingPosterTexture;
  30475. private _settings;
  30476. private _createInternalTextureOnEvent;
  30477. private _frameId;
  30478. /**
  30479. * Creates a video texture.
  30480. * If you want to display a video in your scene, this is the special texture for that.
  30481. * This special texture works similar to other textures, with the exception of a few parameters.
  30482. * @see https://doc.babylonjs.com/how_to/video_texture
  30483. * @param name optional name, will detect from video source, if not defined
  30484. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30485. * @param scene is obviously the current scene.
  30486. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30487. * @param invertY is false by default but can be used to invert video on Y axis
  30488. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30489. * @param settings allows finer control over video usage
  30490. */
  30491. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30492. private _getName;
  30493. private _getVideo;
  30494. private _createInternalTexture;
  30495. private reset;
  30496. /**
  30497. * @hidden Internal method to initiate `update`.
  30498. */
  30499. _rebuild(): void;
  30500. /**
  30501. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30502. */
  30503. update(): void;
  30504. /**
  30505. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30506. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30507. */
  30508. updateTexture(isVisible: boolean): void;
  30509. protected _updateInternalTexture: () => void;
  30510. /**
  30511. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30512. * @param url New url.
  30513. */
  30514. updateURL(url: string): void;
  30515. /**
  30516. * Dispose the texture and release its associated resources.
  30517. */
  30518. dispose(): void;
  30519. /**
  30520. * Creates a video texture straight from a stream.
  30521. * @param scene Define the scene the texture should be created in
  30522. * @param stream Define the stream the texture should be created from
  30523. * @returns The created video texture as a promise
  30524. */
  30525. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30526. /**
  30527. * Creates a video texture straight from your WebCam video feed.
  30528. * @param scene Define the scene the texture should be created in
  30529. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30530. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30531. * @returns The created video texture as a promise
  30532. */
  30533. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30534. minWidth: number;
  30535. maxWidth: number;
  30536. minHeight: number;
  30537. maxHeight: number;
  30538. deviceId: string;
  30539. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30540. /**
  30541. * Creates a video texture straight from your WebCam video feed.
  30542. * @param scene Define the scene the texture should be created in
  30543. * @param onReady Define a callback to triggered once the texture will be ready
  30544. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30545. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30546. */
  30547. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30548. minWidth: number;
  30549. maxWidth: number;
  30550. minHeight: number;
  30551. maxHeight: number;
  30552. deviceId: string;
  30553. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30554. }
  30555. }
  30556. declare module "babylonjs/Engines/engine" {
  30557. import { Observable } from "babylonjs/Misc/observable";
  30558. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30559. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30560. import { Scene } from "babylonjs/scene";
  30561. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30562. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30563. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30564. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30565. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30566. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30567. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30568. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30569. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30570. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30571. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30572. import { WebRequest } from "babylonjs/Misc/webRequest";
  30573. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30574. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30575. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30576. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30577. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30578. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30579. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30580. import { Material } from "babylonjs/Materials/material";
  30581. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30582. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30583. /**
  30584. * Defines the interface used by objects containing a viewport (like a camera)
  30585. */
  30586. interface IViewportOwnerLike {
  30587. /**
  30588. * Gets or sets the viewport
  30589. */
  30590. viewport: IViewportLike;
  30591. }
  30592. /**
  30593. * Interface for attribute information associated with buffer instanciation
  30594. */
  30595. export class InstancingAttributeInfo {
  30596. /**
  30597. * Index/offset of the attribute in the vertex shader
  30598. */
  30599. index: number;
  30600. /**
  30601. * size of the attribute, 1, 2, 3 or 4
  30602. */
  30603. attributeSize: number;
  30604. /**
  30605. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30606. * default is FLOAT
  30607. */
  30608. attribyteType: number;
  30609. /**
  30610. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30611. */
  30612. normalized: boolean;
  30613. /**
  30614. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30615. */
  30616. offset: number;
  30617. /**
  30618. * Name of the GLSL attribute, for debugging purpose only
  30619. */
  30620. attributeName: string;
  30621. }
  30622. /**
  30623. * Define options used to create a depth texture
  30624. */
  30625. export class DepthTextureCreationOptions {
  30626. /** Specifies whether or not a stencil should be allocated in the texture */
  30627. generateStencil?: boolean;
  30628. /** Specifies whether or not bilinear filtering is enable on the texture */
  30629. bilinearFiltering?: boolean;
  30630. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30631. comparisonFunction?: number;
  30632. /** Specifies if the created texture is a cube texture */
  30633. isCube?: boolean;
  30634. }
  30635. /**
  30636. * Class used to describe the capabilities of the engine relatively to the current browser
  30637. */
  30638. export class EngineCapabilities {
  30639. /** Maximum textures units per fragment shader */
  30640. maxTexturesImageUnits: number;
  30641. /** Maximum texture units per vertex shader */
  30642. maxVertexTextureImageUnits: number;
  30643. /** Maximum textures units in the entire pipeline */
  30644. maxCombinedTexturesImageUnits: number;
  30645. /** Maximum texture size */
  30646. maxTextureSize: number;
  30647. /** Maximum cube texture size */
  30648. maxCubemapTextureSize: number;
  30649. /** Maximum render texture size */
  30650. maxRenderTextureSize: number;
  30651. /** Maximum number of vertex attributes */
  30652. maxVertexAttribs: number;
  30653. /** Maximum number of varyings */
  30654. maxVaryingVectors: number;
  30655. /** Maximum number of uniforms per vertex shader */
  30656. maxVertexUniformVectors: number;
  30657. /** Maximum number of uniforms per fragment shader */
  30658. maxFragmentUniformVectors: number;
  30659. /** Defines if standard derivates (dx/dy) are supported */
  30660. standardDerivatives: boolean;
  30661. /** Defines if s3tc texture compression is supported */
  30662. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30663. /** Defines if pvrtc texture compression is supported */
  30664. pvrtc: any;
  30665. /** Defines if etc1 texture compression is supported */
  30666. etc1: any;
  30667. /** Defines if etc2 texture compression is supported */
  30668. etc2: any;
  30669. /** Defines if astc texture compression is supported */
  30670. astc: any;
  30671. /** Defines if float textures are supported */
  30672. textureFloat: boolean;
  30673. /** Defines if vertex array objects are supported */
  30674. vertexArrayObject: boolean;
  30675. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30676. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30677. /** Gets the maximum level of anisotropy supported */
  30678. maxAnisotropy: number;
  30679. /** Defines if instancing is supported */
  30680. instancedArrays: boolean;
  30681. /** Defines if 32 bits indices are supported */
  30682. uintIndices: boolean;
  30683. /** Defines if high precision shaders are supported */
  30684. highPrecisionShaderSupported: boolean;
  30685. /** Defines if depth reading in the fragment shader is supported */
  30686. fragmentDepthSupported: boolean;
  30687. /** Defines if float texture linear filtering is supported*/
  30688. textureFloatLinearFiltering: boolean;
  30689. /** Defines if rendering to float textures is supported */
  30690. textureFloatRender: boolean;
  30691. /** Defines if half float textures are supported*/
  30692. textureHalfFloat: boolean;
  30693. /** Defines if half float texture linear filtering is supported*/
  30694. textureHalfFloatLinearFiltering: boolean;
  30695. /** Defines if rendering to half float textures is supported */
  30696. textureHalfFloatRender: boolean;
  30697. /** Defines if textureLOD shader command is supported */
  30698. textureLOD: boolean;
  30699. /** Defines if draw buffers extension is supported */
  30700. drawBuffersExtension: boolean;
  30701. /** Defines if depth textures are supported */
  30702. depthTextureExtension: boolean;
  30703. /** Defines if float color buffer are supported */
  30704. colorBufferFloat: boolean;
  30705. /** Gets disjoint timer query extension (null if not supported) */
  30706. timerQuery: EXT_disjoint_timer_query;
  30707. /** Defines if timestamp can be used with timer query */
  30708. canUseTimestampForTimerQuery: boolean;
  30709. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30710. multiview: any;
  30711. /** Function used to let the system compiles shaders in background */
  30712. parallelShaderCompile: {
  30713. COMPLETION_STATUS_KHR: number;
  30714. };
  30715. /** Max number of texture samples for MSAA */
  30716. maxMSAASamples: number;
  30717. /** Defines if the blend min max extension is supported */
  30718. blendMinMax: boolean;
  30719. }
  30720. /** Interface defining initialization parameters for Engine class */
  30721. export interface EngineOptions extends WebGLContextAttributes {
  30722. /**
  30723. * Defines if the engine should no exceed a specified device ratio
  30724. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30725. */
  30726. limitDeviceRatio?: number;
  30727. /**
  30728. * Defines if webvr should be enabled automatically
  30729. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30730. */
  30731. autoEnableWebVR?: boolean;
  30732. /**
  30733. * Defines if webgl2 should be turned off even if supported
  30734. * @see http://doc.babylonjs.com/features/webgl2
  30735. */
  30736. disableWebGL2Support?: boolean;
  30737. /**
  30738. * Defines if webaudio should be initialized as well
  30739. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30740. */
  30741. audioEngine?: boolean;
  30742. /**
  30743. * Defines if animations should run using a deterministic lock step
  30744. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30745. */
  30746. deterministicLockstep?: boolean;
  30747. /** Defines the maximum steps to use with deterministic lock step mode */
  30748. lockstepMaxSteps?: number;
  30749. /**
  30750. * Defines that engine should ignore context lost events
  30751. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30752. */
  30753. doNotHandleContextLost?: boolean;
  30754. /**
  30755. * Defines that engine should ignore modifying touch action attribute and style
  30756. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30757. */
  30758. doNotHandleTouchAction?: boolean;
  30759. /**
  30760. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30761. */
  30762. useHighPrecisionFloats?: boolean;
  30763. }
  30764. /**
  30765. * Defines the interface used by display changed events
  30766. */
  30767. export interface IDisplayChangedEventArgs {
  30768. /** Gets the vrDisplay object (if any) */
  30769. vrDisplay: Nullable<any>;
  30770. /** Gets a boolean indicating if webVR is supported */
  30771. vrSupported: boolean;
  30772. }
  30773. /**
  30774. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30775. */
  30776. export class Engine {
  30777. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30778. static ExceptionList: ({
  30779. key: string;
  30780. capture: string;
  30781. captureConstraint: number;
  30782. targets: string[];
  30783. } | {
  30784. key: string;
  30785. capture: null;
  30786. captureConstraint: null;
  30787. targets: string[];
  30788. })[];
  30789. /** Gets the list of created engines */
  30790. static readonly Instances: Engine[];
  30791. /**
  30792. * Gets the latest created engine
  30793. */
  30794. static readonly LastCreatedEngine: Nullable<Engine>;
  30795. /**
  30796. * Gets the latest created scene
  30797. */
  30798. static readonly LastCreatedScene: Nullable<Scene>;
  30799. /**
  30800. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30801. * @param flag defines which part of the materials must be marked as dirty
  30802. * @param predicate defines a predicate used to filter which materials should be affected
  30803. */
  30804. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30805. /** @hidden */
  30806. static _TextureLoaders: IInternalTextureLoader[];
  30807. /** Defines that alpha blending is disabled */
  30808. static readonly ALPHA_DISABLE: number;
  30809. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30810. static readonly ALPHA_ADD: number;
  30811. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30812. static readonly ALPHA_COMBINE: number;
  30813. /** Defines that alpha blending to DEST - SRC * DEST */
  30814. static readonly ALPHA_SUBTRACT: number;
  30815. /** Defines that alpha blending to SRC * DEST */
  30816. static readonly ALPHA_MULTIPLY: number;
  30817. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30818. static readonly ALPHA_MAXIMIZED: number;
  30819. /** Defines that alpha blending to SRC + DEST */
  30820. static readonly ALPHA_ONEONE: number;
  30821. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30822. static readonly ALPHA_PREMULTIPLIED: number;
  30823. /**
  30824. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30825. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30826. */
  30827. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30828. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30829. static readonly ALPHA_INTERPOLATE: number;
  30830. /**
  30831. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30832. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30833. */
  30834. static readonly ALPHA_SCREENMODE: number;
  30835. /** Defines that the ressource is not delayed*/
  30836. static readonly DELAYLOADSTATE_NONE: number;
  30837. /** Defines that the ressource was successfully delay loaded */
  30838. static readonly DELAYLOADSTATE_LOADED: number;
  30839. /** Defines that the ressource is currently delay loading */
  30840. static readonly DELAYLOADSTATE_LOADING: number;
  30841. /** Defines that the ressource is delayed and has not started loading */
  30842. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30843. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30844. static readonly NEVER: number;
  30845. /** 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 */
  30846. static readonly ALWAYS: number;
  30847. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30848. static readonly LESS: number;
  30849. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30850. static readonly EQUAL: number;
  30851. /** 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 */
  30852. static readonly LEQUAL: number;
  30853. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30854. static readonly GREATER: number;
  30855. /** 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 */
  30856. static readonly GEQUAL: number;
  30857. /** 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 */
  30858. static readonly NOTEQUAL: number;
  30859. /** Passed to stencilOperation to specify that stencil value must be kept */
  30860. static readonly KEEP: number;
  30861. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30862. static readonly REPLACE: number;
  30863. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30864. static readonly INCR: number;
  30865. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30866. static readonly DECR: number;
  30867. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30868. static readonly INVERT: number;
  30869. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30870. static readonly INCR_WRAP: number;
  30871. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30872. static readonly DECR_WRAP: number;
  30873. /** Texture is not repeating outside of 0..1 UVs */
  30874. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30875. /** Texture is repeating outside of 0..1 UVs */
  30876. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30877. /** Texture is repeating and mirrored */
  30878. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30879. /** ALPHA */
  30880. static readonly TEXTUREFORMAT_ALPHA: number;
  30881. /** LUMINANCE */
  30882. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30883. /** LUMINANCE_ALPHA */
  30884. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30885. /** RGB */
  30886. static readonly TEXTUREFORMAT_RGB: number;
  30887. /** RGBA */
  30888. static readonly TEXTUREFORMAT_RGBA: number;
  30889. /** RED */
  30890. static readonly TEXTUREFORMAT_RED: number;
  30891. /** RED (2nd reference) */
  30892. static readonly TEXTUREFORMAT_R: number;
  30893. /** RG */
  30894. static readonly TEXTUREFORMAT_RG: number;
  30895. /** RED_INTEGER */
  30896. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30897. /** RED_INTEGER (2nd reference) */
  30898. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30899. /** RG_INTEGER */
  30900. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30901. /** RGB_INTEGER */
  30902. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30903. /** RGBA_INTEGER */
  30904. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30905. /** UNSIGNED_BYTE */
  30906. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30907. /** UNSIGNED_BYTE (2nd reference) */
  30908. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30909. /** FLOAT */
  30910. static readonly TEXTURETYPE_FLOAT: number;
  30911. /** HALF_FLOAT */
  30912. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30913. /** BYTE */
  30914. static readonly TEXTURETYPE_BYTE: number;
  30915. /** SHORT */
  30916. static readonly TEXTURETYPE_SHORT: number;
  30917. /** UNSIGNED_SHORT */
  30918. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30919. /** INT */
  30920. static readonly TEXTURETYPE_INT: number;
  30921. /** UNSIGNED_INT */
  30922. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30923. /** UNSIGNED_SHORT_4_4_4_4 */
  30924. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30925. /** UNSIGNED_SHORT_5_5_5_1 */
  30926. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30927. /** UNSIGNED_SHORT_5_6_5 */
  30928. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30929. /** UNSIGNED_INT_2_10_10_10_REV */
  30930. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30931. /** UNSIGNED_INT_24_8 */
  30932. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30933. /** UNSIGNED_INT_10F_11F_11F_REV */
  30934. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30935. /** UNSIGNED_INT_5_9_9_9_REV */
  30936. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30937. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30938. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30939. /** nearest is mag = nearest and min = nearest and mip = linear */
  30940. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30941. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30942. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30943. /** Trilinear is mag = linear and min = linear and mip = linear */
  30944. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30945. /** nearest is mag = nearest and min = nearest and mip = linear */
  30946. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30947. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30948. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30949. /** Trilinear is mag = linear and min = linear and mip = linear */
  30950. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30951. /** mag = nearest and min = nearest and mip = nearest */
  30952. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30953. /** mag = nearest and min = linear and mip = nearest */
  30954. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30955. /** mag = nearest and min = linear and mip = linear */
  30956. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30957. /** mag = nearest and min = linear and mip = none */
  30958. static readonly TEXTURE_NEAREST_LINEAR: number;
  30959. /** mag = nearest and min = nearest and mip = none */
  30960. static readonly TEXTURE_NEAREST_NEAREST: number;
  30961. /** mag = linear and min = nearest and mip = nearest */
  30962. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30963. /** mag = linear and min = nearest and mip = linear */
  30964. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30965. /** mag = linear and min = linear and mip = none */
  30966. static readonly TEXTURE_LINEAR_LINEAR: number;
  30967. /** mag = linear and min = nearest and mip = none */
  30968. static readonly TEXTURE_LINEAR_NEAREST: number;
  30969. /** Explicit coordinates mode */
  30970. static readonly TEXTURE_EXPLICIT_MODE: number;
  30971. /** Spherical coordinates mode */
  30972. static readonly TEXTURE_SPHERICAL_MODE: number;
  30973. /** Planar coordinates mode */
  30974. static readonly TEXTURE_PLANAR_MODE: number;
  30975. /** Cubic coordinates mode */
  30976. static readonly TEXTURE_CUBIC_MODE: number;
  30977. /** Projection coordinates mode */
  30978. static readonly TEXTURE_PROJECTION_MODE: number;
  30979. /** Skybox coordinates mode */
  30980. static readonly TEXTURE_SKYBOX_MODE: number;
  30981. /** Inverse Cubic coordinates mode */
  30982. static readonly TEXTURE_INVCUBIC_MODE: number;
  30983. /** Equirectangular coordinates mode */
  30984. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30985. /** Equirectangular Fixed coordinates mode */
  30986. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30987. /** Equirectangular Fixed Mirrored coordinates mode */
  30988. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30989. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30990. static readonly SCALEMODE_FLOOR: number;
  30991. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30992. static readonly SCALEMODE_NEAREST: number;
  30993. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30994. static readonly SCALEMODE_CEILING: number;
  30995. /**
  30996. * Returns the current npm package of the sdk
  30997. */
  30998. static readonly NpmPackage: string;
  30999. /**
  31000. * Returns the current version of the framework
  31001. */
  31002. static readonly Version: string;
  31003. /**
  31004. * Returns a string describing the current engine
  31005. */
  31006. readonly description: string;
  31007. /**
  31008. * Gets or sets the epsilon value used by collision engine
  31009. */
  31010. static CollisionsEpsilon: number;
  31011. /**
  31012. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31013. */
  31014. static ShadersRepository: string;
  31015. /**
  31016. * Method called to create the default loading screen.
  31017. * This can be overriden in your own app.
  31018. * @param canvas The rendering canvas element
  31019. * @returns The loading screen
  31020. */
  31021. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  31022. /**
  31023. * Method called to create the default rescale post process on each engine.
  31024. */
  31025. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  31026. /** @hidden */
  31027. _shaderProcessor: IShaderProcessor;
  31028. /**
  31029. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31030. */
  31031. forcePOTTextures: boolean;
  31032. /**
  31033. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31034. */
  31035. isFullscreen: boolean;
  31036. /**
  31037. * Gets a boolean indicating if the pointer is currently locked
  31038. */
  31039. isPointerLock: boolean;
  31040. /**
  31041. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31042. */
  31043. cullBackFaces: boolean;
  31044. /**
  31045. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31046. */
  31047. renderEvenInBackground: boolean;
  31048. /**
  31049. * Gets or sets a boolean indicating that cache can be kept between frames
  31050. */
  31051. preventCacheWipeBetweenFrames: boolean;
  31052. /**
  31053. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  31054. **/
  31055. enableOfflineSupport: boolean;
  31056. /**
  31057. * 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)
  31058. **/
  31059. disableManifestCheck: boolean;
  31060. /**
  31061. * Gets the list of created scenes
  31062. */
  31063. scenes: Scene[];
  31064. /**
  31065. * Event raised when a new scene is created
  31066. */
  31067. onNewSceneAddedObservable: Observable<Scene>;
  31068. /**
  31069. * Gets the list of created postprocesses
  31070. */
  31071. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  31072. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31073. validateShaderPrograms: boolean;
  31074. /**
  31075. * Observable event triggered each time the rendering canvas is resized
  31076. */
  31077. onResizeObservable: Observable<Engine>;
  31078. /**
  31079. * Observable event triggered each time the canvas loses focus
  31080. */
  31081. onCanvasBlurObservable: Observable<Engine>;
  31082. /**
  31083. * Observable event triggered each time the canvas gains focus
  31084. */
  31085. onCanvasFocusObservable: Observable<Engine>;
  31086. /**
  31087. * Observable event triggered each time the canvas receives pointerout event
  31088. */
  31089. onCanvasPointerOutObservable: Observable<PointerEvent>;
  31090. /**
  31091. * Observable event triggered before each texture is initialized
  31092. */
  31093. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31094. /**
  31095. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31096. */
  31097. disableUniformBuffers: boolean;
  31098. /** @hidden */
  31099. _uniformBuffers: UniformBuffer[];
  31100. /**
  31101. * Gets a boolean indicating that the engine supports uniform buffers
  31102. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31103. */
  31104. readonly supportsUniformBuffers: boolean;
  31105. /**
  31106. * Observable raised when the engine begins a new frame
  31107. */
  31108. onBeginFrameObservable: Observable<Engine>;
  31109. /**
  31110. * If set, will be used to request the next animation frame for the render loop
  31111. */
  31112. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  31113. /**
  31114. * Observable raised when the engine ends the current frame
  31115. */
  31116. onEndFrameObservable: Observable<Engine>;
  31117. /**
  31118. * Observable raised when the engine is about to compile a shader
  31119. */
  31120. onBeforeShaderCompilationObservable: Observable<Engine>;
  31121. /**
  31122. * Observable raised when the engine has jsut compiled a shader
  31123. */
  31124. onAfterShaderCompilationObservable: Observable<Engine>;
  31125. /** @hidden */
  31126. _gl: WebGLRenderingContext;
  31127. private _renderingCanvas;
  31128. private _windowIsBackground;
  31129. protected _webGLVersion: number;
  31130. protected _highPrecisionShadersAllowed: boolean;
  31131. /** @hidden */
  31132. readonly _shouldUseHighPrecisionShader: boolean;
  31133. /**
  31134. * Gets a boolean indicating that only power of 2 textures are supported
  31135. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31136. */
  31137. readonly needPOTTextures: boolean;
  31138. /** @hidden */
  31139. _badOS: boolean;
  31140. /** @hidden */
  31141. _badDesktopOS: boolean;
  31142. /**
  31143. * Gets the audio engine
  31144. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31145. * @ignorenaming
  31146. */
  31147. static audioEngine: IAudioEngine;
  31148. /**
  31149. * Default AudioEngine factory responsible of creating the Audio Engine.
  31150. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  31151. */
  31152. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  31153. /**
  31154. * Default offline support factory responsible of creating a tool used to store data locally.
  31155. * By default, this will create a Database object if the workload has been embedded.
  31156. */
  31157. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  31158. private _onFocus;
  31159. private _onBlur;
  31160. private _onCanvasPointerOut;
  31161. private _onCanvasBlur;
  31162. private _onCanvasFocus;
  31163. private _onFullscreenChange;
  31164. private _onPointerLockChange;
  31165. private _hardwareScalingLevel;
  31166. /** @hidden */
  31167. _caps: EngineCapabilities;
  31168. private _pointerLockRequested;
  31169. private _isStencilEnable;
  31170. protected _colorWrite: boolean;
  31171. private _loadingScreen;
  31172. /** @hidden */
  31173. _drawCalls: PerfCounter;
  31174. private _glVersion;
  31175. private _glRenderer;
  31176. private _glVendor;
  31177. private _videoTextureSupported;
  31178. private _renderingQueueLaunched;
  31179. private _activeRenderLoops;
  31180. private _deterministicLockstep;
  31181. private _lockstepMaxSteps;
  31182. /**
  31183. * Observable signaled when a context lost event is raised
  31184. */
  31185. onContextLostObservable: Observable<Engine>;
  31186. /**
  31187. * Observable signaled when a context restored event is raised
  31188. */
  31189. onContextRestoredObservable: Observable<Engine>;
  31190. private _onContextLost;
  31191. private _onContextRestored;
  31192. private _contextWasLost;
  31193. /** @hidden */
  31194. _doNotHandleContextLost: boolean;
  31195. /**
  31196. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31197. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31198. */
  31199. doNotHandleContextLost: boolean;
  31200. private _performanceMonitor;
  31201. private _fps;
  31202. private _deltaTime;
  31203. /**
  31204. * Turn this value on if you want to pause FPS computation when in background
  31205. */
  31206. disablePerformanceMonitorInBackground: boolean;
  31207. /**
  31208. * Gets the performance monitor attached to this engine
  31209. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  31210. */
  31211. readonly performanceMonitor: PerformanceMonitor;
  31212. /**
  31213. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31214. */
  31215. disableVertexArrayObjects: boolean;
  31216. /** @hidden */
  31217. protected _depthCullingState: _DepthCullingState;
  31218. /** @hidden */
  31219. protected _stencilState: _StencilState;
  31220. /** @hidden */
  31221. protected _alphaState: _AlphaState;
  31222. /** @hidden */
  31223. protected _alphaMode: number;
  31224. /** @hidden */
  31225. protected _alphaEquation: number;
  31226. /** @hidden */
  31227. _internalTexturesCache: InternalTexture[];
  31228. /** @hidden */
  31229. protected _activeChannel: number;
  31230. private _currentTextureChannel;
  31231. /** @hidden */
  31232. protected _boundTexturesCache: {
  31233. [key: string]: Nullable<InternalTexture>;
  31234. };
  31235. /** @hidden */
  31236. protected _currentEffect: Nullable<Effect>;
  31237. /** @hidden */
  31238. protected _currentProgram: Nullable<WebGLProgram>;
  31239. private _compiledEffects;
  31240. private _vertexAttribArraysEnabled;
  31241. /** @hidden */
  31242. protected _cachedViewport: Nullable<IViewportLike>;
  31243. private _cachedVertexArrayObject;
  31244. /** @hidden */
  31245. protected _cachedVertexBuffers: any;
  31246. /** @hidden */
  31247. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31248. /** @hidden */
  31249. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31250. /** @hidden */
  31251. _currentRenderTarget: Nullable<InternalTexture>;
  31252. private _uintIndicesCurrentlySet;
  31253. private _currentBoundBuffer;
  31254. /** @hidden */
  31255. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31256. private _currentBufferPointers;
  31257. private _currentInstanceLocations;
  31258. private _currentInstanceBuffers;
  31259. private _textureUnits;
  31260. /** @hidden */
  31261. _workingCanvas: Nullable<HTMLCanvasElement>;
  31262. /** @hidden */
  31263. _workingContext: Nullable<CanvasRenderingContext2D>;
  31264. private _rescalePostProcess;
  31265. private _dummyFramebuffer;
  31266. private _externalData;
  31267. /** @hidden */
  31268. _bindedRenderFunction: any;
  31269. private _vaoRecordInProgress;
  31270. private _mustWipeVertexAttributes;
  31271. private _emptyTexture;
  31272. private _emptyCubeTexture;
  31273. private _emptyTexture3D;
  31274. /** @hidden */
  31275. _frameHandler: number;
  31276. private _nextFreeTextureSlots;
  31277. private _maxSimultaneousTextures;
  31278. private _activeRequests;
  31279. private _texturesSupported;
  31280. /** @hidden */
  31281. _textureFormatInUse: Nullable<string>;
  31282. /**
  31283. * Gets the list of texture formats supported
  31284. */
  31285. readonly texturesSupported: Array<string>;
  31286. /**
  31287. * Gets the list of texture formats in use
  31288. */
  31289. readonly textureFormatInUse: Nullable<string>;
  31290. /**
  31291. * Gets the current viewport
  31292. */
  31293. readonly currentViewport: Nullable<IViewportLike>;
  31294. /**
  31295. * Gets the default empty texture
  31296. */
  31297. readonly emptyTexture: InternalTexture;
  31298. /**
  31299. * Gets the default empty 3D texture
  31300. */
  31301. readonly emptyTexture3D: InternalTexture;
  31302. /**
  31303. * Gets the default empty cube texture
  31304. */
  31305. readonly emptyCubeTexture: InternalTexture;
  31306. /**
  31307. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31308. */
  31309. readonly premultipliedAlpha: boolean;
  31310. /**
  31311. * Creates a new engine
  31312. * @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
  31313. * @param antialias defines enable antialiasing (default: false)
  31314. * @param options defines further options to be sent to the getContext() function
  31315. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31316. */
  31317. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31318. /**
  31319. * Initializes a webVR display and starts listening to display change events
  31320. * The onVRDisplayChangedObservable will be notified upon these changes
  31321. * @returns The onVRDisplayChangedObservable
  31322. */
  31323. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31324. /** @hidden */
  31325. _prepareVRComponent(): void;
  31326. /** @hidden */
  31327. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31328. /** @hidden */
  31329. _submitVRFrame(): void;
  31330. /**
  31331. * Call this function to leave webVR mode
  31332. * Will do nothing if webVR is not supported or if there is no webVR device
  31333. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31334. */
  31335. disableVR(): void;
  31336. /**
  31337. * Gets a boolean indicating that the system is in VR mode and is presenting
  31338. * @returns true if VR mode is engaged
  31339. */
  31340. isVRPresenting(): boolean;
  31341. /** @hidden */
  31342. _requestVRFrame(): void;
  31343. private _disableTouchAction;
  31344. private _rebuildInternalTextures;
  31345. private _rebuildEffects;
  31346. /**
  31347. * Gets a boolean indicating if all created effects are ready
  31348. * @returns true if all effects are ready
  31349. */
  31350. areAllEffectsReady(): boolean;
  31351. private _rebuildBuffers;
  31352. private _initGLContext;
  31353. /**
  31354. * Gets version of the current webGL context
  31355. */
  31356. readonly webGLVersion: number;
  31357. /**
  31358. * Gets a string idenfifying the name of the class
  31359. * @returns "Engine" string
  31360. */
  31361. getClassName(): string;
  31362. /**
  31363. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31364. */
  31365. readonly isStencilEnable: boolean;
  31366. /** @hidden */
  31367. _prepareWorkingCanvas(): void;
  31368. /**
  31369. * Reset the texture cache to empty state
  31370. */
  31371. resetTextureCache(): void;
  31372. /**
  31373. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31374. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31375. * @returns true if engine is in deterministic lock step mode
  31376. */
  31377. isDeterministicLockStep(): boolean;
  31378. /**
  31379. * Gets the max steps when engine is running in deterministic lock step
  31380. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31381. * @returns the max steps
  31382. */
  31383. getLockstepMaxSteps(): number;
  31384. /**
  31385. * Gets an object containing information about the current webGL context
  31386. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31387. */
  31388. getGlInfo(): {
  31389. vendor: string;
  31390. renderer: string;
  31391. version: string;
  31392. };
  31393. /**
  31394. * Gets current aspect ratio
  31395. * @param viewportOwner defines the camera to use to get the aspect ratio
  31396. * @param useScreen defines if screen size must be used (or the current render target if any)
  31397. * @returns a number defining the aspect ratio
  31398. */
  31399. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31400. /**
  31401. * Gets current screen aspect ratio
  31402. * @returns a number defining the aspect ratio
  31403. */
  31404. getScreenAspectRatio(): number;
  31405. /**
  31406. * Gets the current render width
  31407. * @param useScreen defines if screen size must be used (or the current render target if any)
  31408. * @returns a number defining the current render width
  31409. */
  31410. getRenderWidth(useScreen?: boolean): number;
  31411. /**
  31412. * Gets the current render height
  31413. * @param useScreen defines if screen size must be used (or the current render target if any)
  31414. * @returns a number defining the current render height
  31415. */
  31416. getRenderHeight(useScreen?: boolean): number;
  31417. /**
  31418. * Gets the HTML canvas attached with the current webGL context
  31419. * @returns a HTML canvas
  31420. */
  31421. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31422. /**
  31423. * Gets host window
  31424. * @returns the host window object
  31425. */
  31426. getHostWindow(): Window;
  31427. /**
  31428. * Gets host document
  31429. * @returns the host document object
  31430. */
  31431. getHostDocument(): Document;
  31432. /**
  31433. * Gets the client rect of the HTML canvas attached with the current webGL context
  31434. * @returns a client rectanglee
  31435. */
  31436. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31437. /**
  31438. * Defines the hardware scaling level.
  31439. * By default the hardware scaling level is computed from the window device ratio.
  31440. * 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.
  31441. * @param level defines the level to use
  31442. */
  31443. setHardwareScalingLevel(level: number): void;
  31444. /**
  31445. * Gets the current hardware scaling level.
  31446. * By default the hardware scaling level is computed from the window device ratio.
  31447. * 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.
  31448. * @returns a number indicating the current hardware scaling level
  31449. */
  31450. getHardwareScalingLevel(): number;
  31451. /**
  31452. * Gets the list of loaded textures
  31453. * @returns an array containing all loaded textures
  31454. */
  31455. getLoadedTexturesCache(): InternalTexture[];
  31456. /**
  31457. * Gets the object containing all engine capabilities
  31458. * @returns the EngineCapabilities object
  31459. */
  31460. getCaps(): EngineCapabilities;
  31461. /**
  31462. * Gets the current depth function
  31463. * @returns a number defining the depth function
  31464. */
  31465. getDepthFunction(): Nullable<number>;
  31466. /**
  31467. * Sets the current depth function
  31468. * @param depthFunc defines the function to use
  31469. */
  31470. setDepthFunction(depthFunc: number): void;
  31471. /**
  31472. * Sets the current depth function to GREATER
  31473. */
  31474. setDepthFunctionToGreater(): void;
  31475. /**
  31476. * Sets the current depth function to GEQUAL
  31477. */
  31478. setDepthFunctionToGreaterOrEqual(): void;
  31479. /**
  31480. * Sets the current depth function to LESS
  31481. */
  31482. setDepthFunctionToLess(): void;
  31483. private _cachedStencilBuffer;
  31484. private _cachedStencilFunction;
  31485. private _cachedStencilMask;
  31486. private _cachedStencilOperationPass;
  31487. private _cachedStencilOperationFail;
  31488. private _cachedStencilOperationDepthFail;
  31489. private _cachedStencilReference;
  31490. /**
  31491. * Caches the the state of the stencil buffer
  31492. */
  31493. cacheStencilState(): void;
  31494. /**
  31495. * Restores the state of the stencil buffer
  31496. */
  31497. restoreStencilState(): void;
  31498. /**
  31499. * Sets the current depth function to LEQUAL
  31500. */
  31501. setDepthFunctionToLessOrEqual(): void;
  31502. /**
  31503. * Gets a boolean indicating if stencil buffer is enabled
  31504. * @returns the current stencil buffer state
  31505. */
  31506. getStencilBuffer(): boolean;
  31507. /**
  31508. * Enable or disable the stencil buffer
  31509. * @param enable defines if the stencil buffer must be enabled or disabled
  31510. */
  31511. setStencilBuffer(enable: boolean): void;
  31512. /**
  31513. * Gets the current stencil mask
  31514. * @returns a number defining the new stencil mask to use
  31515. */
  31516. getStencilMask(): number;
  31517. /**
  31518. * Sets the current stencil mask
  31519. * @param mask defines the new stencil mask to use
  31520. */
  31521. setStencilMask(mask: number): void;
  31522. /**
  31523. * Gets the current stencil function
  31524. * @returns a number defining the stencil function to use
  31525. */
  31526. getStencilFunction(): number;
  31527. /**
  31528. * Gets the current stencil reference value
  31529. * @returns a number defining the stencil reference value to use
  31530. */
  31531. getStencilFunctionReference(): number;
  31532. /**
  31533. * Gets the current stencil mask
  31534. * @returns a number defining the stencil mask to use
  31535. */
  31536. getStencilFunctionMask(): number;
  31537. /**
  31538. * Sets the current stencil function
  31539. * @param stencilFunc defines the new stencil function to use
  31540. */
  31541. setStencilFunction(stencilFunc: number): void;
  31542. /**
  31543. * Sets the current stencil reference
  31544. * @param reference defines the new stencil reference to use
  31545. */
  31546. setStencilFunctionReference(reference: number): void;
  31547. /**
  31548. * Sets the current stencil mask
  31549. * @param mask defines the new stencil mask to use
  31550. */
  31551. setStencilFunctionMask(mask: number): void;
  31552. /**
  31553. * Gets the current stencil operation when stencil fails
  31554. * @returns a number defining stencil operation to use when stencil fails
  31555. */
  31556. getStencilOperationFail(): number;
  31557. /**
  31558. * Gets the current stencil operation when depth fails
  31559. * @returns a number defining stencil operation to use when depth fails
  31560. */
  31561. getStencilOperationDepthFail(): number;
  31562. /**
  31563. * Gets the current stencil operation when stencil passes
  31564. * @returns a number defining stencil operation to use when stencil passes
  31565. */
  31566. getStencilOperationPass(): number;
  31567. /**
  31568. * Sets the stencil operation to use when stencil fails
  31569. * @param operation defines the stencil operation to use when stencil fails
  31570. */
  31571. setStencilOperationFail(operation: number): void;
  31572. /**
  31573. * Sets the stencil operation to use when depth fails
  31574. * @param operation defines the stencil operation to use when depth fails
  31575. */
  31576. setStencilOperationDepthFail(operation: number): void;
  31577. /**
  31578. * Sets the stencil operation to use when stencil passes
  31579. * @param operation defines the stencil operation to use when stencil passes
  31580. */
  31581. setStencilOperationPass(operation: number): void;
  31582. /**
  31583. * Sets a boolean indicating if the dithering state is enabled or disabled
  31584. * @param value defines the dithering state
  31585. */
  31586. setDitheringState(value: boolean): void;
  31587. /**
  31588. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31589. * @param value defines the rasterizer state
  31590. */
  31591. setRasterizerState(value: boolean): void;
  31592. /**
  31593. * stop executing a render loop function and remove it from the execution array
  31594. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31595. */
  31596. stopRenderLoop(renderFunction?: () => void): void;
  31597. /** @hidden */
  31598. _renderLoop(): void;
  31599. /**
  31600. * Can be used to override the current requestAnimationFrame requester.
  31601. * @hidden
  31602. */
  31603. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31604. /**
  31605. * Register and execute a render loop. The engine can have more than one render function
  31606. * @param renderFunction defines the function to continuously execute
  31607. */
  31608. runRenderLoop(renderFunction: () => void): void;
  31609. /**
  31610. * Toggle full screen mode
  31611. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31612. */
  31613. switchFullscreen(requestPointerLock: boolean): void;
  31614. /**
  31615. * Enters full screen mode
  31616. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31617. */
  31618. enterFullscreen(requestPointerLock: boolean): void;
  31619. /**
  31620. * Exits full screen mode
  31621. */
  31622. exitFullscreen(): void;
  31623. /**
  31624. * Enters Pointerlock mode
  31625. */
  31626. enterPointerlock(): void;
  31627. /**
  31628. * Exits Pointerlock mode
  31629. */
  31630. exitPointerlock(): void;
  31631. /**
  31632. * Clear the current render buffer or the current render target (if any is set up)
  31633. * @param color defines the color to use
  31634. * @param backBuffer defines if the back buffer must be cleared
  31635. * @param depth defines if the depth buffer must be cleared
  31636. * @param stencil defines if the stencil buffer must be cleared
  31637. */
  31638. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31639. /**
  31640. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31641. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31642. * @param y defines the y-coordinate of the corner of the clear rectangle
  31643. * @param width defines the width of the clear rectangle
  31644. * @param height defines the height of the clear rectangle
  31645. * @param clearColor defines the clear color
  31646. */
  31647. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31648. /**
  31649. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31650. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31651. * @param y defines the y-coordinate of the corner of the clear rectangle
  31652. * @param width defines the width of the clear rectangle
  31653. * @param height defines the height of the clear rectangle
  31654. */
  31655. enableScissor(x: number, y: number, width: number, height: number): void;
  31656. /**
  31657. * Disable previously set scissor test rectangle
  31658. */
  31659. disableScissor(): void;
  31660. private _viewportCached;
  31661. /** @hidden */
  31662. _viewport(x: number, y: number, width: number, height: number): void;
  31663. /**
  31664. * Set the WebGL's viewport
  31665. * @param viewport defines the viewport element to be used
  31666. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31667. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31668. */
  31669. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31670. /**
  31671. * Directly set the WebGL Viewport
  31672. * @param x defines the x coordinate of the viewport (in screen space)
  31673. * @param y defines the y coordinate of the viewport (in screen space)
  31674. * @param width defines the width of the viewport (in screen space)
  31675. * @param height defines the height of the viewport (in screen space)
  31676. * @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
  31677. */
  31678. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31679. /**
  31680. * Begin a new frame
  31681. */
  31682. beginFrame(): void;
  31683. /**
  31684. * Enf the current frame
  31685. */
  31686. endFrame(): void;
  31687. /**
  31688. * Resize the view according to the canvas' size
  31689. */
  31690. resize(): void;
  31691. /**
  31692. * Force a specific size of the canvas
  31693. * @param width defines the new canvas' width
  31694. * @param height defines the new canvas' height
  31695. */
  31696. setSize(width: number, height: number): void;
  31697. /**
  31698. * Binds the frame buffer to the specified texture.
  31699. * @param texture The texture to render to or null for the default canvas
  31700. * @param faceIndex The face of the texture to render to in case of cube texture
  31701. * @param requiredWidth The width of the target to render to
  31702. * @param requiredHeight The height of the target to render to
  31703. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31704. * @param depthStencilTexture The depth stencil texture to use to render
  31705. * @param lodLevel defines le lod level to bind to the frame buffer
  31706. */
  31707. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31708. /** @hidden */
  31709. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31710. /**
  31711. * Unbind the current render target texture from the webGL context
  31712. * @param texture defines the render target texture to unbind
  31713. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31714. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31715. */
  31716. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31717. /**
  31718. * Force the mipmap generation for the given render target texture
  31719. * @param texture defines the render target texture to use
  31720. */
  31721. generateMipMapsForCubemap(texture: InternalTexture): void;
  31722. /**
  31723. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31724. */
  31725. flushFramebuffer(): void;
  31726. /**
  31727. * Unbind the current render target and bind the default framebuffer
  31728. */
  31729. restoreDefaultFramebuffer(): void;
  31730. /**
  31731. * Create an uniform buffer
  31732. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31733. * @param elements defines the content of the uniform buffer
  31734. * @returns the webGL uniform buffer
  31735. */
  31736. createUniformBuffer(elements: FloatArray): DataBuffer;
  31737. /**
  31738. * Create a dynamic uniform buffer
  31739. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31740. * @param elements defines the content of the uniform buffer
  31741. * @returns the webGL uniform buffer
  31742. */
  31743. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31744. /**
  31745. * Update an existing uniform buffer
  31746. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31747. * @param uniformBuffer defines the target uniform buffer
  31748. * @param elements defines the content to update
  31749. * @param offset defines the offset in the uniform buffer where update should start
  31750. * @param count defines the size of the data to update
  31751. */
  31752. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31753. private _resetVertexBufferBinding;
  31754. /**
  31755. * Creates a vertex buffer
  31756. * @param data the data for the vertex buffer
  31757. * @returns the new WebGL static buffer
  31758. */
  31759. createVertexBuffer(data: DataArray): DataBuffer;
  31760. /**
  31761. * Creates a dynamic vertex buffer
  31762. * @param data the data for the dynamic vertex buffer
  31763. * @returns the new WebGL dynamic buffer
  31764. */
  31765. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31766. /**
  31767. * Update a dynamic index buffer
  31768. * @param indexBuffer defines the target index buffer
  31769. * @param indices defines the data to update
  31770. * @param offset defines the offset in the target index buffer where update should start
  31771. */
  31772. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31773. /**
  31774. * Updates a dynamic vertex buffer.
  31775. * @param vertexBuffer the vertex buffer to update
  31776. * @param data the data used to update the vertex buffer
  31777. * @param byteOffset the byte offset of the data
  31778. * @param byteLength the byte length of the data
  31779. */
  31780. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31781. private _resetIndexBufferBinding;
  31782. /**
  31783. * Creates a new index buffer
  31784. * @param indices defines the content of the index buffer
  31785. * @param updatable defines if the index buffer must be updatable
  31786. * @returns a new webGL buffer
  31787. */
  31788. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31789. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31790. /**
  31791. * Bind a webGL buffer to the webGL context
  31792. * @param buffer defines the buffer to bind
  31793. */
  31794. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31795. /**
  31796. * Bind an uniform buffer to the current webGL context
  31797. * @param buffer defines the buffer to bind
  31798. */
  31799. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31800. /**
  31801. * Bind a buffer to the current webGL context at a given location
  31802. * @param buffer defines the buffer to bind
  31803. * @param location defines the index where to bind the buffer
  31804. */
  31805. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31806. /**
  31807. * Bind a specific block at a given index in a specific shader program
  31808. * @param pipelineContext defines the pipeline context to use
  31809. * @param blockName defines the block name
  31810. * @param index defines the index where to bind the block
  31811. */
  31812. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31813. private bindIndexBuffer;
  31814. private bindBuffer;
  31815. /**
  31816. * update the bound buffer with the given data
  31817. * @param data defines the data to update
  31818. */
  31819. updateArrayBuffer(data: Float32Array): void;
  31820. private _vertexAttribPointer;
  31821. private _bindIndexBufferWithCache;
  31822. private _bindVertexBuffersAttributes;
  31823. /**
  31824. * Records a vertex array object
  31825. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31826. * @param vertexBuffers defines the list of vertex buffers to store
  31827. * @param indexBuffer defines the index buffer to store
  31828. * @param effect defines the effect to store
  31829. * @returns the new vertex array object
  31830. */
  31831. recordVertexArrayObject(vertexBuffers: {
  31832. [key: string]: VertexBuffer;
  31833. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31834. /**
  31835. * Bind a specific vertex array object
  31836. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31837. * @param vertexArrayObject defines the vertex array object to bind
  31838. * @param indexBuffer defines the index buffer to bind
  31839. */
  31840. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31841. /**
  31842. * Bind webGl buffers directly to the webGL context
  31843. * @param vertexBuffer defines the vertex buffer to bind
  31844. * @param indexBuffer defines the index buffer to bind
  31845. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31846. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31847. * @param effect defines the effect associated with the vertex buffer
  31848. */
  31849. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31850. private _unbindVertexArrayObject;
  31851. /**
  31852. * Bind a list of vertex buffers to the webGL context
  31853. * @param vertexBuffers defines the list of vertex buffers to bind
  31854. * @param indexBuffer defines the index buffer to bind
  31855. * @param effect defines the effect associated with the vertex buffers
  31856. */
  31857. bindBuffers(vertexBuffers: {
  31858. [key: string]: Nullable<VertexBuffer>;
  31859. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31860. /**
  31861. * Unbind all instance attributes
  31862. */
  31863. unbindInstanceAttributes(): void;
  31864. /**
  31865. * Release and free the memory of a vertex array object
  31866. * @param vao defines the vertex array object to delete
  31867. */
  31868. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31869. /** @hidden */
  31870. _releaseBuffer(buffer: DataBuffer): boolean;
  31871. protected _deleteBuffer(buffer: DataBuffer): void;
  31872. /**
  31873. * Creates a webGL buffer to use with instanciation
  31874. * @param capacity defines the size of the buffer
  31875. * @returns the webGL buffer
  31876. */
  31877. createInstancesBuffer(capacity: number): DataBuffer;
  31878. /**
  31879. * Delete a webGL buffer used with instanciation
  31880. * @param buffer defines the webGL buffer to delete
  31881. */
  31882. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31883. /**
  31884. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31885. * @param instancesBuffer defines the webGL buffer to update and bind
  31886. * @param data defines the data to store in the buffer
  31887. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31888. */
  31889. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31890. /**
  31891. * Apply all cached states (depth, culling, stencil and alpha)
  31892. */
  31893. applyStates(): void;
  31894. /**
  31895. * Send a draw order
  31896. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31897. * @param indexStart defines the starting index
  31898. * @param indexCount defines the number of index to draw
  31899. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31900. */
  31901. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31902. /**
  31903. * Draw a list of points
  31904. * @param verticesStart defines the index of first vertex to draw
  31905. * @param verticesCount defines the count of vertices to draw
  31906. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31907. */
  31908. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31909. /**
  31910. * Draw a list of unindexed primitives
  31911. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31912. * @param verticesStart defines the index of first vertex to draw
  31913. * @param verticesCount defines the count of vertices to draw
  31914. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31915. */
  31916. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31917. /**
  31918. * Draw a list of indexed primitives
  31919. * @param fillMode defines the primitive to use
  31920. * @param indexStart defines the starting index
  31921. * @param indexCount defines the number of index to draw
  31922. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31923. */
  31924. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31925. /**
  31926. * Draw a list of unindexed primitives
  31927. * @param fillMode defines the primitive to use
  31928. * @param verticesStart defines the index of first vertex to draw
  31929. * @param verticesCount defines the count of vertices to draw
  31930. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31931. */
  31932. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31933. private _drawMode;
  31934. /** @hidden */
  31935. _releaseEffect(effect: Effect): void;
  31936. /** @hidden */
  31937. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31938. /**
  31939. * Create a new effect (used to store vertex/fragment shaders)
  31940. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31941. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31942. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31943. * @param samplers defines an array of string used to represent textures
  31944. * @param defines defines the string containing the defines to use to compile the shaders
  31945. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31946. * @param onCompiled defines a function to call when the effect creation is successful
  31947. * @param onError defines a function to call when the effect creation has failed
  31948. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31949. * @returns the new Effect
  31950. */
  31951. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  31952. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31953. private _compileShader;
  31954. private _compileRawShader;
  31955. /**
  31956. * Directly creates a webGL program
  31957. * @param pipelineContext defines the pipeline context to attach to
  31958. * @param vertexCode defines the vertex shader code to use
  31959. * @param fragmentCode defines the fragment shader code to use
  31960. * @param context defines the webGL context to use (if not set, the current one will be used)
  31961. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31962. * @returns the new webGL program
  31963. */
  31964. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31965. /**
  31966. * Creates a webGL program
  31967. * @param pipelineContext defines the pipeline context to attach to
  31968. * @param vertexCode defines the vertex shader code to use
  31969. * @param fragmentCode defines the fragment shader code to use
  31970. * @param defines defines the string containing the defines to use to compile the shaders
  31971. * @param context defines the webGL context to use (if not set, the current one will be used)
  31972. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31973. * @returns the new webGL program
  31974. */
  31975. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31976. /**
  31977. * Creates a new pipeline context
  31978. * @returns the new pipeline
  31979. */
  31980. createPipelineContext(): IPipelineContext;
  31981. private _createShaderProgram;
  31982. private _finalizePipelineContext;
  31983. /** @hidden */
  31984. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31985. /** @hidden */
  31986. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31987. /** @hidden */
  31988. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31989. /**
  31990. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31991. * @param pipelineContext defines the pipeline context to use
  31992. * @param uniformsNames defines the list of uniform names
  31993. * @returns an array of webGL uniform locations
  31994. */
  31995. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31996. /**
  31997. * Gets the lsit of active attributes for a given webGL program
  31998. * @param pipelineContext defines the pipeline context to use
  31999. * @param attributesNames defines the list of attribute names to get
  32000. * @returns an array of indices indicating the offset of each attribute
  32001. */
  32002. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32003. /**
  32004. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32005. * @param effect defines the effect to activate
  32006. */
  32007. enableEffect(effect: Nullable<Effect>): void;
  32008. /**
  32009. * Set the value of an uniform to an array of int32
  32010. * @param uniform defines the webGL uniform location where to store the value
  32011. * @param array defines the array of int32 to store
  32012. */
  32013. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32014. /**
  32015. * Set the value of an uniform to an array of int32 (stored as vec2)
  32016. * @param uniform defines the webGL uniform location where to store the value
  32017. * @param array defines the array of int32 to store
  32018. */
  32019. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32020. /**
  32021. * Set the value of an uniform to an array of int32 (stored as vec3)
  32022. * @param uniform defines the webGL uniform location where to store the value
  32023. * @param array defines the array of int32 to store
  32024. */
  32025. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32026. /**
  32027. * Set the value of an uniform to an array of int32 (stored as vec4)
  32028. * @param uniform defines the webGL uniform location where to store the value
  32029. * @param array defines the array of int32 to store
  32030. */
  32031. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32032. /**
  32033. * Set the value of an uniform to an array of float32
  32034. * @param uniform defines the webGL uniform location where to store the value
  32035. * @param array defines the array of float32 to store
  32036. */
  32037. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32038. /**
  32039. * Set the value of an uniform to an array of float32 (stored as vec2)
  32040. * @param uniform defines the webGL uniform location where to store the value
  32041. * @param array defines the array of float32 to store
  32042. */
  32043. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32044. /**
  32045. * Set the value of an uniform to an array of float32 (stored as vec3)
  32046. * @param uniform defines the webGL uniform location where to store the value
  32047. * @param array defines the array of float32 to store
  32048. */
  32049. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32050. /**
  32051. * Set the value of an uniform to an array of float32 (stored as vec4)
  32052. * @param uniform defines the webGL uniform location where to store the value
  32053. * @param array defines the array of float32 to store
  32054. */
  32055. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  32056. /**
  32057. * Set the value of an uniform to an array of number
  32058. * @param uniform defines the webGL uniform location where to store the value
  32059. * @param array defines the array of number to store
  32060. */
  32061. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32062. /**
  32063. * Set the value of an uniform to an array of number (stored as vec2)
  32064. * @param uniform defines the webGL uniform location where to store the value
  32065. * @param array defines the array of number to store
  32066. */
  32067. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32068. /**
  32069. * Set the value of an uniform to an array of number (stored as vec3)
  32070. * @param uniform defines the webGL uniform location where to store the value
  32071. * @param array defines the array of number to store
  32072. */
  32073. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32074. /**
  32075. * Set the value of an uniform to an array of number (stored as vec4)
  32076. * @param uniform defines the webGL uniform location where to store the value
  32077. * @param array defines the array of number to store
  32078. */
  32079. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  32080. /**
  32081. * Set the value of an uniform to an array of float32 (stored as matrices)
  32082. * @param uniform defines the webGL uniform location where to store the value
  32083. * @param matrices defines the array of float32 to store
  32084. */
  32085. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32086. /**
  32087. * Set the value of an uniform to a matrix (3x3)
  32088. * @param uniform defines the webGL uniform location where to store the value
  32089. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32090. */
  32091. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32092. /**
  32093. * Set the value of an uniform to a matrix (2x2)
  32094. * @param uniform defines the webGL uniform location where to store the value
  32095. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32096. */
  32097. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32098. /**
  32099. * Set the value of an uniform to a number (int)
  32100. * @param uniform defines the webGL uniform location where to store the value
  32101. * @param value defines the int number to store
  32102. */
  32103. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32104. /**
  32105. * Set the value of an uniform to a number (float)
  32106. * @param uniform defines the webGL uniform location where to store the value
  32107. * @param value defines the float number to store
  32108. */
  32109. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32110. /**
  32111. * Set the value of an uniform to a vec2
  32112. * @param uniform defines the webGL uniform location where to store the value
  32113. * @param x defines the 1st component of the value
  32114. * @param y defines the 2nd component of the value
  32115. */
  32116. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32117. /**
  32118. * Set the value of an uniform to a vec3
  32119. * @param uniform defines the webGL uniform location where to store the value
  32120. * @param x defines the 1st component of the value
  32121. * @param y defines the 2nd component of the value
  32122. * @param z defines the 3rd component of the value
  32123. */
  32124. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32125. /**
  32126. * Set the value of an uniform to a boolean
  32127. * @param uniform defines the webGL uniform location where to store the value
  32128. * @param bool defines the boolean to store
  32129. */
  32130. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  32131. /**
  32132. * Set the value of an uniform to a vec4
  32133. * @param uniform defines the webGL uniform location where to store the value
  32134. * @param x defines the 1st component of the value
  32135. * @param y defines the 2nd component of the value
  32136. * @param z defines the 3rd component of the value
  32137. * @param w defines the 4th component of the value
  32138. */
  32139. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32140. /**
  32141. * Sets a Color4 on a uniform variable
  32142. * @param uniform defines the uniform location
  32143. * @param color4 defines the value to be set
  32144. */
  32145. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  32146. /**
  32147. * Set various states to the webGL context
  32148. * @param culling defines backface culling state
  32149. * @param zOffset defines the value to apply to zOffset (0 by default)
  32150. * @param force defines if states must be applied even if cache is up to date
  32151. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32152. */
  32153. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32154. /**
  32155. * Set the z offset to apply to current rendering
  32156. * @param value defines the offset to apply
  32157. */
  32158. setZOffset(value: number): void;
  32159. /**
  32160. * Gets the current value of the zOffset
  32161. * @returns the current zOffset state
  32162. */
  32163. getZOffset(): number;
  32164. /**
  32165. * Enable or disable depth buffering
  32166. * @param enable defines the state to set
  32167. */
  32168. setDepthBuffer(enable: boolean): void;
  32169. /**
  32170. * Gets a boolean indicating if depth writing is enabled
  32171. * @returns the current depth writing state
  32172. */
  32173. getDepthWrite(): boolean;
  32174. /**
  32175. * Enable or disable depth writing
  32176. * @param enable defines the state to set
  32177. */
  32178. setDepthWrite(enable: boolean): void;
  32179. /**
  32180. * Enable or disable color writing
  32181. * @param enable defines the state to set
  32182. */
  32183. setColorWrite(enable: boolean): void;
  32184. /**
  32185. * Gets a boolean indicating if color writing is enabled
  32186. * @returns the current color writing state
  32187. */
  32188. getColorWrite(): boolean;
  32189. /**
  32190. * Sets alpha constants used by some alpha blending modes
  32191. * @param r defines the red component
  32192. * @param g defines the green component
  32193. * @param b defines the blue component
  32194. * @param a defines the alpha component
  32195. */
  32196. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32197. /**
  32198. * Sets the current alpha mode
  32199. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32200. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32201. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32202. */
  32203. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32204. /**
  32205. * Gets the current alpha mode
  32206. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32207. * @returns the current alpha mode
  32208. */
  32209. getAlphaMode(): number;
  32210. /**
  32211. * Sets the current alpha equation
  32212. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32213. */
  32214. setAlphaEquation(equation: number): void;
  32215. /**
  32216. * Gets the current alpha equation.
  32217. * @returns the current alpha equation
  32218. */
  32219. getAlphaEquation(): number;
  32220. /**
  32221. * Clears the list of texture accessible through engine.
  32222. * This can help preventing texture load conflict due to name collision.
  32223. */
  32224. clearInternalTexturesCache(): void;
  32225. /**
  32226. * Force the entire cache to be cleared
  32227. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32228. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32229. */
  32230. wipeCaches(bruteForce?: boolean): void;
  32231. /**
  32232. * Set the compressed texture format to use, based on the formats you have, and the formats
  32233. * supported by the hardware / browser.
  32234. *
  32235. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32236. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32237. * to API arguments needed to compressed textures. This puts the burden on the container
  32238. * generator to house the arcane code for determining these for current & future formats.
  32239. *
  32240. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32241. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32242. *
  32243. * Note: The result of this call is not taken into account when a texture is base64.
  32244. *
  32245. * @param formatsAvailable defines the list of those format families you have created
  32246. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32247. *
  32248. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32249. * @returns The extension selected.
  32250. */
  32251. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32252. /** @hidden */
  32253. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32254. min: number;
  32255. mag: number;
  32256. };
  32257. /** @hidden */
  32258. _createTexture(): WebGLTexture;
  32259. /**
  32260. * Usually called from Texture.ts.
  32261. * Passed information to create a WebGLTexture
  32262. * @param urlArg defines a value which contains one of the following:
  32263. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32264. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32265. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32266. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32267. * @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)
  32268. * @param scene needed for loading to the correct scene
  32269. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32270. * @param onLoad optional callback to be called upon successful completion
  32271. * @param onError optional callback to be called upon failure
  32272. * @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
  32273. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32274. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32275. * @param forcedExtension defines the extension to use to pick the right loader
  32276. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32277. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32278. */
  32279. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  32280. /**
  32281. * @hidden
  32282. * Rescales a texture
  32283. * @param source input texutre
  32284. * @param destination destination texture
  32285. * @param scene scene to use to render the resize
  32286. * @param internalFormat format to use when resizing
  32287. * @param onComplete callback to be called when resize has completed
  32288. */
  32289. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32290. private _unpackFlipYCached;
  32291. /**
  32292. * In case you are sharing the context with other applications, it might
  32293. * be interested to not cache the unpack flip y state to ensure a consistent
  32294. * value would be set.
  32295. */
  32296. enableUnpackFlipYCached: boolean;
  32297. /** @hidden */
  32298. _unpackFlipY(value: boolean): void;
  32299. /** @hidden */
  32300. _getUnpackAlignement(): number;
  32301. /**
  32302. * Creates a dynamic texture
  32303. * @param width defines the width of the texture
  32304. * @param height defines the height of the texture
  32305. * @param generateMipMaps defines if the engine should generate the mip levels
  32306. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32307. * @returns the dynamic texture inside an InternalTexture
  32308. */
  32309. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32310. /**
  32311. * Update the sampling mode of a given texture
  32312. * @param samplingMode defines the required sampling mode
  32313. * @param texture defines the texture to update
  32314. */
  32315. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32316. /**
  32317. * Update the content of a dynamic texture
  32318. * @param texture defines the texture to update
  32319. * @param canvas defines the canvas containing the source
  32320. * @param invertY defines if data must be stored with Y axis inverted
  32321. * @param premulAlpha defines if alpha is stored as premultiplied
  32322. * @param format defines the format of the data
  32323. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32324. */
  32325. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32326. /**
  32327. * Update a video texture
  32328. * @param texture defines the texture to update
  32329. * @param video defines the video element to use
  32330. * @param invertY defines if data must be stored with Y axis inverted
  32331. */
  32332. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32333. /**
  32334. * Updates a depth texture Comparison Mode and Function.
  32335. * If the comparison Function is equal to 0, the mode will be set to none.
  32336. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32337. * @param texture The texture to set the comparison function for
  32338. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32339. */
  32340. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32341. /** @hidden */
  32342. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32343. width: number;
  32344. height: number;
  32345. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32346. /**
  32347. * Creates a depth stencil texture.
  32348. * This is only available in WebGL 2 or with the depth texture extension available.
  32349. * @param size The size of face edge in the texture.
  32350. * @param options The options defining the texture.
  32351. * @returns The texture
  32352. */
  32353. createDepthStencilTexture(size: number | {
  32354. width: number;
  32355. height: number;
  32356. }, options: DepthTextureCreationOptions): InternalTexture;
  32357. /**
  32358. * Creates a depth stencil texture.
  32359. * This is only available in WebGL 2 or with the depth texture extension available.
  32360. * @param size The size of face edge in the texture.
  32361. * @param options The options defining the texture.
  32362. * @returns The texture
  32363. */
  32364. private _createDepthStencilTexture;
  32365. /**
  32366. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32367. * @param renderTarget The render target to set the frame buffer for
  32368. */
  32369. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32370. /**
  32371. * Creates a new render target texture
  32372. * @param size defines the size of the texture
  32373. * @param options defines the options used to create the texture
  32374. * @returns a new render target texture stored in an InternalTexture
  32375. */
  32376. createRenderTargetTexture(size: number | {
  32377. width: number;
  32378. height: number;
  32379. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32380. /** @hidden */
  32381. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32382. /**
  32383. * Updates the sample count of a render target texture
  32384. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32385. * @param texture defines the texture to update
  32386. * @param samples defines the sample count to set
  32387. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32388. */
  32389. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32390. /** @hidden */
  32391. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32392. /** @hidden */
  32393. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32394. /** @hidden */
  32395. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32396. /** @hidden */
  32397. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32398. /**
  32399. * @hidden
  32400. */
  32401. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32402. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32403. private _prepareWebGLTexture;
  32404. /** @hidden */
  32405. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32406. /** @hidden */
  32407. _releaseFramebufferObjects(texture: InternalTexture): void;
  32408. /** @hidden */
  32409. _releaseTexture(texture: InternalTexture): void;
  32410. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32411. protected _setProgram(program: WebGLProgram): void;
  32412. protected _boundUniforms: {
  32413. [key: number]: WebGLUniformLocation;
  32414. };
  32415. /**
  32416. * Binds an effect to the webGL context
  32417. * @param effect defines the effect to bind
  32418. */
  32419. bindSamplers(effect: Effect): void;
  32420. private _activateCurrentTexture;
  32421. /** @hidden */
  32422. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32423. /** @hidden */
  32424. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32425. /**
  32426. * Sets a texture to the webGL context from a postprocess
  32427. * @param channel defines the channel to use
  32428. * @param postProcess defines the source postprocess
  32429. */
  32430. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32431. /**
  32432. * Binds the output of the passed in post process to the texture channel specified
  32433. * @param channel The channel the texture should be bound to
  32434. * @param postProcess The post process which's output should be bound
  32435. */
  32436. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32437. /**
  32438. * Unbind all textures from the webGL context
  32439. */
  32440. unbindAllTextures(): void;
  32441. /**
  32442. * Sets a texture to the according uniform.
  32443. * @param channel The texture channel
  32444. * @param uniform The uniform to set
  32445. * @param texture The texture to apply
  32446. */
  32447. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32448. /**
  32449. * Sets a depth stencil texture from a render target to the according uniform.
  32450. * @param channel The texture channel
  32451. * @param uniform The uniform to set
  32452. * @param texture The render target texture containing the depth stencil texture to apply
  32453. */
  32454. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32455. private _bindSamplerUniformToChannel;
  32456. private _getTextureWrapMode;
  32457. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32458. /**
  32459. * Sets an array of texture to the webGL context
  32460. * @param channel defines the channel where the texture array must be set
  32461. * @param uniform defines the associated uniform location
  32462. * @param textures defines the array of textures to bind
  32463. */
  32464. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32465. /** @hidden */
  32466. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32467. private _setTextureParameterFloat;
  32468. private _setTextureParameterInteger;
  32469. /**
  32470. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32471. * @param x defines the x coordinate of the rectangle where pixels must be read
  32472. * @param y defines the y coordinate of the rectangle where pixels must be read
  32473. * @param width defines the width of the rectangle where pixels must be read
  32474. * @param height defines the height of the rectangle where pixels must be read
  32475. * @returns a Uint8Array containing RGBA colors
  32476. */
  32477. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32478. /**
  32479. * Add an externaly attached data from its key.
  32480. * This method call will fail and return false, if such key already exists.
  32481. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32482. * @param key the unique key that identifies the data
  32483. * @param data the data object to associate to the key for this Engine instance
  32484. * @return true if no such key were already present and the data was added successfully, false otherwise
  32485. */
  32486. addExternalData<T>(key: string, data: T): boolean;
  32487. /**
  32488. * Get an externaly attached data from its key
  32489. * @param key the unique key that identifies the data
  32490. * @return the associated data, if present (can be null), or undefined if not present
  32491. */
  32492. getExternalData<T>(key: string): T;
  32493. /**
  32494. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32495. * @param key the unique key that identifies the data
  32496. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32497. * @return the associated data, can be null if the factory returned null.
  32498. */
  32499. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32500. /**
  32501. * Remove an externaly attached data from the Engine instance
  32502. * @param key the unique key that identifies the data
  32503. * @return true if the data was successfully removed, false if it doesn't exist
  32504. */
  32505. removeExternalData(key: string): boolean;
  32506. /**
  32507. * Unbind all vertex attributes from the webGL context
  32508. */
  32509. unbindAllAttributes(): void;
  32510. /**
  32511. * 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
  32512. */
  32513. releaseEffects(): void;
  32514. /**
  32515. * Dispose and release all associated resources
  32516. */
  32517. dispose(): void;
  32518. /**
  32519. * Display the loading screen
  32520. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32521. */
  32522. displayLoadingUI(): void;
  32523. /**
  32524. * Hide the loading screen
  32525. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32526. */
  32527. hideLoadingUI(): void;
  32528. /**
  32529. * Gets the current loading screen object
  32530. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32531. */
  32532. /**
  32533. * Sets the current loading screen object
  32534. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32535. */
  32536. loadingScreen: ILoadingScreen;
  32537. /**
  32538. * Sets the current loading screen text
  32539. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32540. */
  32541. loadingUIText: string;
  32542. /**
  32543. * Sets the current loading screen background color
  32544. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32545. */
  32546. loadingUIBackgroundColor: string;
  32547. /**
  32548. * Attach a new callback raised when context lost event is fired
  32549. * @param callback defines the callback to call
  32550. */
  32551. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32552. /**
  32553. * Attach a new callback raised when context restored event is fired
  32554. * @param callback defines the callback to call
  32555. */
  32556. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32557. /**
  32558. * Gets the source code of the vertex shader associated with a specific webGL program
  32559. * @param program defines the program to use
  32560. * @returns a string containing the source code of the vertex shader associated with the program
  32561. */
  32562. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32563. /**
  32564. * Gets the source code of the fragment shader associated with a specific webGL program
  32565. * @param program defines the program to use
  32566. * @returns a string containing the source code of the fragment shader associated with the program
  32567. */
  32568. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32569. /**
  32570. * Get the current error code of the webGL context
  32571. * @returns the error code
  32572. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32573. */
  32574. getError(): number;
  32575. /**
  32576. * Gets the current framerate
  32577. * @returns a number representing the framerate
  32578. */
  32579. getFps(): number;
  32580. /**
  32581. * Gets the time spent between current and previous frame
  32582. * @returns a number representing the delta time in ms
  32583. */
  32584. getDeltaTime(): number;
  32585. private _measureFps;
  32586. /** @hidden */
  32587. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32588. private _canRenderToFloatFramebuffer;
  32589. private _canRenderToHalfFloatFramebuffer;
  32590. private _canRenderToFramebuffer;
  32591. /** @hidden */
  32592. _getWebGLTextureType(type: number): number;
  32593. /** @hidden */
  32594. _getInternalFormat(format: number): number;
  32595. /** @hidden */
  32596. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32597. /** @hidden */
  32598. _getRGBAMultiSampleBufferFormat(type: number): number;
  32599. /** @hidden */
  32600. _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;
  32601. /** @hidden */
  32602. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32603. /**
  32604. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32605. * @returns true if the engine can be created
  32606. * @ignorenaming
  32607. */
  32608. static isSupported(): boolean;
  32609. /**
  32610. * Find the next highest power of two.
  32611. * @param x Number to start search from.
  32612. * @return Next highest power of two.
  32613. */
  32614. static CeilingPOT(x: number): number;
  32615. /**
  32616. * Find the next lowest power of two.
  32617. * @param x Number to start search from.
  32618. * @return Next lowest power of two.
  32619. */
  32620. static FloorPOT(x: number): number;
  32621. /**
  32622. * Find the nearest power of two.
  32623. * @param x Number to start search from.
  32624. * @return Next nearest power of two.
  32625. */
  32626. static NearestPOT(x: number): number;
  32627. /**
  32628. * Get the closest exponent of two
  32629. * @param value defines the value to approximate
  32630. * @param max defines the maximum value to return
  32631. * @param mode defines how to define the closest value
  32632. * @returns closest exponent of two of the given value
  32633. */
  32634. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32635. /**
  32636. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32637. * @param func - the function to be called
  32638. * @param requester - the object that will request the next frame. Falls back to window.
  32639. * @returns frame number
  32640. */
  32641. static QueueNewFrame(func: () => void, requester?: any): number;
  32642. /**
  32643. * Ask the browser to promote the current element to pointerlock mode
  32644. * @param element defines the DOM element to promote
  32645. */
  32646. static _RequestPointerlock(element: HTMLElement): void;
  32647. /**
  32648. * Asks the browser to exit pointerlock mode
  32649. */
  32650. static _ExitPointerlock(): void;
  32651. /**
  32652. * Ask the browser to promote the current element to fullscreen rendering mode
  32653. * @param element defines the DOM element to promote
  32654. */
  32655. static _RequestFullscreen(element: HTMLElement): void;
  32656. /**
  32657. * Asks the browser to exit fullscreen mode
  32658. */
  32659. static _ExitFullscreen(): void;
  32660. }
  32661. }
  32662. declare module "babylonjs/Engines/engineStore" {
  32663. import { Nullable } from "babylonjs/types";
  32664. import { Engine } from "babylonjs/Engines/engine";
  32665. import { Scene } from "babylonjs/scene";
  32666. /**
  32667. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32668. * during the life time of the application.
  32669. */
  32670. export class EngineStore {
  32671. /** Gets the list of created engines */
  32672. static Instances: import("babylonjs/Engines/engine").Engine[];
  32673. /** @hidden */
  32674. static _LastCreatedScene: Nullable<Scene>;
  32675. /**
  32676. * Gets the latest created engine
  32677. */
  32678. static readonly LastCreatedEngine: Nullable<Engine>;
  32679. /**
  32680. * Gets the latest created scene
  32681. */
  32682. static readonly LastCreatedScene: Nullable<Scene>;
  32683. /**
  32684. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32685. * @ignorenaming
  32686. */
  32687. static UseFallbackTexture: boolean;
  32688. /**
  32689. * Texture content used if a texture cannot loaded
  32690. * @ignorenaming
  32691. */
  32692. static FallbackTexture: string;
  32693. }
  32694. }
  32695. declare module "babylonjs/Misc/promise" {
  32696. /**
  32697. * Helper class that provides a small promise polyfill
  32698. */
  32699. export class PromisePolyfill {
  32700. /**
  32701. * Static function used to check if the polyfill is required
  32702. * If this is the case then the function will inject the polyfill to window.Promise
  32703. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32704. */
  32705. static Apply(force?: boolean): void;
  32706. }
  32707. }
  32708. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32709. /**
  32710. * Interface for screenshot methods with describe argument called `size` as object with options
  32711. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32712. */
  32713. export interface IScreenshotSize {
  32714. /**
  32715. * number in pixels for canvas height
  32716. */
  32717. height?: number;
  32718. /**
  32719. * multiplier allowing render at a higher or lower resolution
  32720. * If value is defined then height and width will be ignored and taken from camera
  32721. */
  32722. precision?: number;
  32723. /**
  32724. * number in pixels for canvas width
  32725. */
  32726. width?: number;
  32727. }
  32728. }
  32729. declare module "babylonjs/Misc/tools" {
  32730. import { Nullable, float } from "babylonjs/types";
  32731. import { DomManagement } from "babylonjs/Misc/domManagement";
  32732. import { WebRequest } from "babylonjs/Misc/webRequest";
  32733. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32734. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32735. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32736. import { Camera } from "babylonjs/Cameras/camera";
  32737. import { Engine } from "babylonjs/Engines/engine";
  32738. interface IColor4Like {
  32739. r: float;
  32740. g: float;
  32741. b: float;
  32742. a: float;
  32743. }
  32744. /**
  32745. * Class containing a set of static utilities functions
  32746. */
  32747. export class Tools {
  32748. /**
  32749. * Gets or sets the base URL to use to load assets
  32750. */
  32751. static BaseUrl: string;
  32752. /**
  32753. * Enable/Disable Custom HTTP Request Headers globally.
  32754. * default = false
  32755. * @see CustomRequestHeaders
  32756. */
  32757. static UseCustomRequestHeaders: boolean;
  32758. /**
  32759. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32760. * i.e. when loading files, where the server/service expects an Authorization header
  32761. */
  32762. static CustomRequestHeaders: {
  32763. [key: string]: string;
  32764. };
  32765. /**
  32766. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32767. */
  32768. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32769. /**
  32770. * Default behaviour for cors in the application.
  32771. * It can be a string if the expected behavior is identical in the entire app.
  32772. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32773. */
  32774. static CorsBehavior: string | ((url: string | string[]) => string);
  32775. /**
  32776. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32777. * @ignorenaming
  32778. */
  32779. static UseFallbackTexture: boolean;
  32780. /**
  32781. * Use this object to register external classes like custom textures or material
  32782. * to allow the laoders to instantiate them
  32783. */
  32784. static RegisteredExternalClasses: {
  32785. [key: string]: Object;
  32786. };
  32787. /**
  32788. * Texture content used if a texture cannot loaded
  32789. * @ignorenaming
  32790. */
  32791. static fallbackTexture: string;
  32792. /**
  32793. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32794. * @param u defines the coordinate on X axis
  32795. * @param v defines the coordinate on Y axis
  32796. * @param width defines the width of the source data
  32797. * @param height defines the height of the source data
  32798. * @param pixels defines the source byte array
  32799. * @param color defines the output color
  32800. */
  32801. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32802. /**
  32803. * Interpolates between a and b via alpha
  32804. * @param a The lower value (returned when alpha = 0)
  32805. * @param b The upper value (returned when alpha = 1)
  32806. * @param alpha The interpolation-factor
  32807. * @return The mixed value
  32808. */
  32809. static Mix(a: number, b: number, alpha: number): number;
  32810. /**
  32811. * Tries to instantiate a new object from a given class name
  32812. * @param className defines the class name to instantiate
  32813. * @returns the new object or null if the system was not able to do the instantiation
  32814. */
  32815. static Instantiate(className: string): any;
  32816. /**
  32817. * Provides a slice function that will work even on IE
  32818. * @param data defines the array to slice
  32819. * @param start defines the start of the data (optional)
  32820. * @param end defines the end of the data (optional)
  32821. * @returns the new sliced array
  32822. */
  32823. static Slice<T>(data: T, start?: number, end?: number): T;
  32824. /**
  32825. * Polyfill for setImmediate
  32826. * @param action defines the action to execute after the current execution block
  32827. */
  32828. static SetImmediate(action: () => void): void;
  32829. /**
  32830. * Function indicating if a number is an exponent of 2
  32831. * @param value defines the value to test
  32832. * @returns true if the value is an exponent of 2
  32833. */
  32834. static IsExponentOfTwo(value: number): boolean;
  32835. private static _tmpFloatArray;
  32836. /**
  32837. * Returns the nearest 32-bit single precision float representation of a Number
  32838. * @param value A Number. If the parameter is of a different type, it will get converted
  32839. * to a number or to NaN if it cannot be converted
  32840. * @returns number
  32841. */
  32842. static FloatRound(value: number): number;
  32843. /**
  32844. * Extracts the filename from a path
  32845. * @param path defines the path to use
  32846. * @returns the filename
  32847. */
  32848. static GetFilename(path: string): string;
  32849. /**
  32850. * Extracts the "folder" part of a path (everything before the filename).
  32851. * @param uri The URI to extract the info from
  32852. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32853. * @returns The "folder" part of the path
  32854. */
  32855. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32856. /**
  32857. * Extracts text content from a DOM element hierarchy
  32858. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32859. */
  32860. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32861. /**
  32862. * Convert an angle in radians to degrees
  32863. * @param angle defines the angle to convert
  32864. * @returns the angle in degrees
  32865. */
  32866. static ToDegrees(angle: number): number;
  32867. /**
  32868. * Convert an angle in degrees to radians
  32869. * @param angle defines the angle to convert
  32870. * @returns the angle in radians
  32871. */
  32872. static ToRadians(angle: number): number;
  32873. /**
  32874. * Encode a buffer to a base64 string
  32875. * @param buffer defines the buffer to encode
  32876. * @returns the encoded string
  32877. */
  32878. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32879. /**
  32880. * Returns an array if obj is not an array
  32881. * @param obj defines the object to evaluate as an array
  32882. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32883. * @returns either obj directly if obj is an array or a new array containing obj
  32884. */
  32885. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32886. /**
  32887. * Gets the pointer prefix to use
  32888. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32889. */
  32890. static GetPointerPrefix(): string;
  32891. /**
  32892. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32893. * @param url define the url we are trying
  32894. * @param element define the dom element where to configure the cors policy
  32895. */
  32896. static SetCorsBehavior(url: string | string[], element: {
  32897. crossOrigin: string | null;
  32898. }): void;
  32899. /**
  32900. * Removes unwanted characters from an url
  32901. * @param url defines the url to clean
  32902. * @returns the cleaned url
  32903. */
  32904. static CleanUrl(url: string): string;
  32905. /**
  32906. * Gets or sets a function used to pre-process url before using them to load assets
  32907. */
  32908. static PreprocessUrl: (url: string) => string;
  32909. /**
  32910. * Loads an image as an HTMLImageElement.
  32911. * @param input url string, ArrayBuffer, or Blob to load
  32912. * @param onLoad callback called when the image successfully loads
  32913. * @param onError callback called when the image fails to load
  32914. * @param offlineProvider offline provider for caching
  32915. * @returns the HTMLImageElement of the loaded image
  32916. */
  32917. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32918. /**
  32919. * Loads a file
  32920. * @param url url string, ArrayBuffer, or Blob to load
  32921. * @param onSuccess callback called when the file successfully loads
  32922. * @param onProgress callback called while file is loading (if the server supports this mode)
  32923. * @param offlineProvider defines the offline provider for caching
  32924. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32925. * @param onError callback called when the file fails to load
  32926. * @returns a file request object
  32927. */
  32928. 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;
  32929. /**
  32930. * Loads a file from a url
  32931. * @param url the file url to load
  32932. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32933. */
  32934. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32935. /**
  32936. * Load a script (identified by an url). When the url returns, the
  32937. * content of this file is added into a new script element, attached to the DOM (body element)
  32938. * @param scriptUrl defines the url of the script to laod
  32939. * @param onSuccess defines the callback called when the script is loaded
  32940. * @param onError defines the callback to call if an error occurs
  32941. * @param scriptId defines the id of the script element
  32942. */
  32943. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32944. /**
  32945. * Load an asynchronous script (identified by an url). When the url returns, the
  32946. * content of this file is added into a new script element, attached to the DOM (body element)
  32947. * @param scriptUrl defines the url of the script to laod
  32948. * @param scriptId defines the id of the script element
  32949. * @returns a promise request object
  32950. */
  32951. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32952. /**
  32953. * Loads a file from a blob
  32954. * @param fileToLoad defines the blob to use
  32955. * @param callback defines the callback to call when data is loaded
  32956. * @param progressCallback defines the callback to call during loading process
  32957. * @returns a file request object
  32958. */
  32959. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32960. /**
  32961. * Loads a file
  32962. * @param fileToLoad defines the file to load
  32963. * @param callback defines the callback to call when data is loaded
  32964. * @param progressCallBack defines the callback to call during loading process
  32965. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32966. * @returns a file request object
  32967. */
  32968. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32969. /**
  32970. * Creates a data url from a given string content
  32971. * @param content defines the content to convert
  32972. * @returns the new data url link
  32973. */
  32974. static FileAsURL(content: string): string;
  32975. /**
  32976. * Format the given number to a specific decimal format
  32977. * @param value defines the number to format
  32978. * @param decimals defines the number of decimals to use
  32979. * @returns the formatted string
  32980. */
  32981. static Format(value: number, decimals?: number): string;
  32982. /**
  32983. * Tries to copy an object by duplicating every property
  32984. * @param source defines the source object
  32985. * @param destination defines the target object
  32986. * @param doNotCopyList defines a list of properties to avoid
  32987. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32988. */
  32989. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32990. /**
  32991. * Gets a boolean indicating if the given object has no own property
  32992. * @param obj defines the object to test
  32993. * @returns true if object has no own property
  32994. */
  32995. static IsEmpty(obj: any): boolean;
  32996. /**
  32997. * Function used to register events at window level
  32998. * @param windowElement defines the Window object to use
  32999. * @param events defines the events to register
  33000. */
  33001. static RegisterTopRootEvents(windowElement: Window, events: {
  33002. name: string;
  33003. handler: Nullable<(e: FocusEvent) => any>;
  33004. }[]): void;
  33005. /**
  33006. * Function used to unregister events from window level
  33007. * @param windowElement defines the Window object to use
  33008. * @param events defines the events to unregister
  33009. */
  33010. static UnregisterTopRootEvents(windowElement: Window, events: {
  33011. name: string;
  33012. handler: Nullable<(e: FocusEvent) => any>;
  33013. }[]): void;
  33014. /**
  33015. * @ignore
  33016. */
  33017. static _ScreenshotCanvas: HTMLCanvasElement;
  33018. /**
  33019. * Dumps the current bound framebuffer
  33020. * @param width defines the rendering width
  33021. * @param height defines the rendering height
  33022. * @param engine defines the hosting engine
  33023. * @param successCallback defines the callback triggered once the data are available
  33024. * @param mimeType defines the mime type of the result
  33025. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33026. */
  33027. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33028. /**
  33029. * Converts the canvas data to blob.
  33030. * This acts as a polyfill for browsers not supporting the to blob function.
  33031. * @param canvas Defines the canvas to extract the data from
  33032. * @param successCallback Defines the callback triggered once the data are available
  33033. * @param mimeType Defines the mime type of the result
  33034. */
  33035. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33036. /**
  33037. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33038. * @param successCallback defines the callback triggered once the data are available
  33039. * @param mimeType defines the mime type of the result
  33040. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33041. */
  33042. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33043. /**
  33044. * Downloads a blob in the browser
  33045. * @param blob defines the blob to download
  33046. * @param fileName defines the name of the downloaded file
  33047. */
  33048. static Download(blob: Blob, fileName: string): void;
  33049. /**
  33050. * Captures a screenshot of the current rendering
  33051. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33052. * @param engine defines the rendering engine
  33053. * @param camera defines the source camera
  33054. * @param size This parameter can be set to a single number or to an object with the
  33055. * following (optional) properties: precision, width, height. If a single number is passed,
  33056. * it will be used for both width and height. If an object is passed, the screenshot size
  33057. * will be derived from the parameters. The precision property is a multiplier allowing
  33058. * rendering at a higher or lower resolution
  33059. * @param successCallback defines the callback receives a single parameter which contains the
  33060. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33061. * src parameter of an <img> to display it
  33062. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33063. * Check your browser for supported MIME types
  33064. */
  33065. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33066. /**
  33067. * Captures a screenshot of the current rendering
  33068. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33069. * @param engine defines the rendering engine
  33070. * @param camera defines the source camera
  33071. * @param size This parameter can be set to a single number or to an object with the
  33072. * following (optional) properties: precision, width, height. If a single number is passed,
  33073. * it will be used for both width and height. If an object is passed, the screenshot size
  33074. * will be derived from the parameters. The precision property is a multiplier allowing
  33075. * rendering at a higher or lower resolution
  33076. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33077. * Check your browser for supported MIME types
  33078. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33079. * to the src parameter of an <img> to display it
  33080. */
  33081. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33082. /**
  33083. * Generates an image screenshot from the specified camera.
  33084. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33085. * @param engine The engine to use for rendering
  33086. * @param camera The camera to use for rendering
  33087. * @param size This parameter can be set to a single number or to an object with the
  33088. * following (optional) properties: precision, width, height. If a single number is passed,
  33089. * it will be used for both width and height. If an object is passed, the screenshot size
  33090. * will be derived from the parameters. The precision property is a multiplier allowing
  33091. * rendering at a higher or lower resolution
  33092. * @param successCallback The callback receives a single parameter which contains the
  33093. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33094. * src parameter of an <img> to display it
  33095. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33096. * Check your browser for supported MIME types
  33097. * @param samples Texture samples (default: 1)
  33098. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33099. * @param fileName A name for for the downloaded file.
  33100. */
  33101. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33102. /**
  33103. * Generates an image screenshot from the specified camera.
  33104. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33105. * @param engine The engine to use for rendering
  33106. * @param camera The camera to use for rendering
  33107. * @param size This parameter can be set to a single number or to an object with the
  33108. * following (optional) properties: precision, width, height. If a single number is passed,
  33109. * it will be used for both width and height. If an object is passed, the screenshot size
  33110. * will be derived from the parameters. The precision property is a multiplier allowing
  33111. * rendering at a higher or lower resolution
  33112. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33113. * Check your browser for supported MIME types
  33114. * @param samples Texture samples (default: 1)
  33115. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33116. * @param fileName A name for for the downloaded file.
  33117. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33118. * to the src parameter of an <img> to display it
  33119. */
  33120. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33121. /**
  33122. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33123. * Be aware Math.random() could cause collisions, but:
  33124. * "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"
  33125. * @returns a pseudo random id
  33126. */
  33127. static RandomId(): string;
  33128. /**
  33129. * Test if the given uri is a base64 string
  33130. * @param uri The uri to test
  33131. * @return True if the uri is a base64 string or false otherwise
  33132. */
  33133. static IsBase64(uri: string): boolean;
  33134. /**
  33135. * Decode the given base64 uri.
  33136. * @param uri The uri to decode
  33137. * @return The decoded base64 data.
  33138. */
  33139. static DecodeBase64(uri: string): ArrayBuffer;
  33140. /**
  33141. * Gets the absolute url.
  33142. * @param url the input url
  33143. * @return the absolute url
  33144. */
  33145. static GetAbsoluteUrl(url: string): string;
  33146. /**
  33147. * No log
  33148. */
  33149. static readonly NoneLogLevel: number;
  33150. /**
  33151. * Only message logs
  33152. */
  33153. static readonly MessageLogLevel: number;
  33154. /**
  33155. * Only warning logs
  33156. */
  33157. static readonly WarningLogLevel: number;
  33158. /**
  33159. * Only error logs
  33160. */
  33161. static readonly ErrorLogLevel: number;
  33162. /**
  33163. * All logs
  33164. */
  33165. static readonly AllLogLevel: number;
  33166. /**
  33167. * Gets a value indicating the number of loading errors
  33168. * @ignorenaming
  33169. */
  33170. static readonly errorsCount: number;
  33171. /**
  33172. * Callback called when a new log is added
  33173. */
  33174. static OnNewCacheEntry: (entry: string) => void;
  33175. /**
  33176. * Log a message to the console
  33177. * @param message defines the message to log
  33178. */
  33179. static Log(message: string): void;
  33180. /**
  33181. * Write a warning message to the console
  33182. * @param message defines the message to log
  33183. */
  33184. static Warn(message: string): void;
  33185. /**
  33186. * Write an error message to the console
  33187. * @param message defines the message to log
  33188. */
  33189. static Error(message: string): void;
  33190. /**
  33191. * Gets current log cache (list of logs)
  33192. */
  33193. static readonly LogCache: string;
  33194. /**
  33195. * Clears the log cache
  33196. */
  33197. static ClearLogCache(): void;
  33198. /**
  33199. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33200. */
  33201. static LogLevels: number;
  33202. /**
  33203. * Checks if the window object exists
  33204. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33205. */
  33206. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33207. /**
  33208. * No performance log
  33209. */
  33210. static readonly PerformanceNoneLogLevel: number;
  33211. /**
  33212. * Use user marks to log performance
  33213. */
  33214. static readonly PerformanceUserMarkLogLevel: number;
  33215. /**
  33216. * Log performance to the console
  33217. */
  33218. static readonly PerformanceConsoleLogLevel: number;
  33219. private static _performance;
  33220. /**
  33221. * Sets the current performance log level
  33222. */
  33223. static PerformanceLogLevel: number;
  33224. private static _StartPerformanceCounterDisabled;
  33225. private static _EndPerformanceCounterDisabled;
  33226. private static _StartUserMark;
  33227. private static _EndUserMark;
  33228. private static _StartPerformanceConsole;
  33229. private static _EndPerformanceConsole;
  33230. /**
  33231. * Starts a performance counter
  33232. */
  33233. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33234. /**
  33235. * Ends a specific performance coutner
  33236. */
  33237. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33238. /**
  33239. * Gets either window.performance.now() if supported or Date.now() else
  33240. */
  33241. static readonly Now: number;
  33242. /**
  33243. * This method will return the name of the class used to create the instance of the given object.
  33244. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33245. * @param object the object to get the class name from
  33246. * @param isType defines if the object is actually a type
  33247. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33248. */
  33249. static GetClassName(object: any, isType?: boolean): string;
  33250. /**
  33251. * Gets the first element of an array satisfying a given predicate
  33252. * @param array defines the array to browse
  33253. * @param predicate defines the predicate to use
  33254. * @returns null if not found or the element
  33255. */
  33256. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33257. /**
  33258. * This method will return the name of the full name of the class, including its owning module (if any).
  33259. * 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).
  33260. * @param object the object to get the class name from
  33261. * @param isType defines if the object is actually a type
  33262. * @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.
  33263. * @ignorenaming
  33264. */
  33265. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33266. /**
  33267. * Returns a promise that resolves after the given amount of time.
  33268. * @param delay Number of milliseconds to delay
  33269. * @returns Promise that resolves after the given amount of time
  33270. */
  33271. static DelayAsync(delay: number): Promise<void>;
  33272. }
  33273. /**
  33274. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33275. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33276. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33277. * @param name The name of the class, case should be preserved
  33278. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33279. */
  33280. export function className(name: string, module?: string): (target: Object) => void;
  33281. /**
  33282. * An implementation of a loop for asynchronous functions.
  33283. */
  33284. export class AsyncLoop {
  33285. /**
  33286. * Defines the number of iterations for the loop
  33287. */
  33288. iterations: number;
  33289. /**
  33290. * Defines the current index of the loop.
  33291. */
  33292. index: number;
  33293. private _done;
  33294. private _fn;
  33295. private _successCallback;
  33296. /**
  33297. * Constructor.
  33298. * @param iterations the number of iterations.
  33299. * @param func the function to run each iteration
  33300. * @param successCallback the callback that will be called upon succesful execution
  33301. * @param offset starting offset.
  33302. */
  33303. constructor(
  33304. /**
  33305. * Defines the number of iterations for the loop
  33306. */
  33307. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33308. /**
  33309. * Execute the next iteration. Must be called after the last iteration was finished.
  33310. */
  33311. executeNext(): void;
  33312. /**
  33313. * Break the loop and run the success callback.
  33314. */
  33315. breakLoop(): void;
  33316. /**
  33317. * Create and run an async loop.
  33318. * @param iterations the number of iterations.
  33319. * @param fn the function to run each iteration
  33320. * @param successCallback the callback that will be called upon succesful execution
  33321. * @param offset starting offset.
  33322. * @returns the created async loop object
  33323. */
  33324. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33325. /**
  33326. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33327. * @param iterations total number of iterations
  33328. * @param syncedIterations number of synchronous iterations in each async iteration.
  33329. * @param fn the function to call each iteration.
  33330. * @param callback a success call back that will be called when iterating stops.
  33331. * @param breakFunction a break condition (optional)
  33332. * @param timeout timeout settings for the setTimeout function. default - 0.
  33333. * @returns the created async loop object
  33334. */
  33335. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33336. }
  33337. }
  33338. declare module "babylonjs/Collisions/collisionCoordinator" {
  33339. import { Nullable } from "babylonjs/types";
  33340. import { Scene } from "babylonjs/scene";
  33341. import { Vector3 } from "babylonjs/Maths/math.vector";
  33342. import { Collider } from "babylonjs/Collisions/collider";
  33343. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33344. /** @hidden */
  33345. export interface ICollisionCoordinator {
  33346. createCollider(): Collider;
  33347. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33348. init(scene: Scene): void;
  33349. }
  33350. /** @hidden */
  33351. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33352. private _scene;
  33353. private _scaledPosition;
  33354. private _scaledVelocity;
  33355. private _finalPosition;
  33356. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33357. createCollider(): Collider;
  33358. init(scene: Scene): void;
  33359. private _collideWithWorld;
  33360. }
  33361. }
  33362. declare module "babylonjs/Inputs/scene.inputManager" {
  33363. import { Nullable } from "babylonjs/types";
  33364. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33365. import { Vector2 } from "babylonjs/Maths/math.vector";
  33366. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33367. import { Scene } from "babylonjs/scene";
  33368. /**
  33369. * Class used to manage all inputs for the scene.
  33370. */
  33371. export class InputManager {
  33372. /** The distance in pixel that you have to move to prevent some events */
  33373. static DragMovementThreshold: number;
  33374. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33375. static LongPressDelay: number;
  33376. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33377. static DoubleClickDelay: number;
  33378. /** If you need to check double click without raising a single click at first click, enable this flag */
  33379. static ExclusiveDoubleClickMode: boolean;
  33380. private _wheelEventName;
  33381. private _onPointerMove;
  33382. private _onPointerDown;
  33383. private _onPointerUp;
  33384. private _initClickEvent;
  33385. private _initActionManager;
  33386. private _delayedSimpleClick;
  33387. private _delayedSimpleClickTimeout;
  33388. private _previousDelayedSimpleClickTimeout;
  33389. private _meshPickProceed;
  33390. private _previousButtonPressed;
  33391. private _currentPickResult;
  33392. private _previousPickResult;
  33393. private _totalPointersPressed;
  33394. private _doubleClickOccured;
  33395. private _pointerOverMesh;
  33396. private _pickedDownMesh;
  33397. private _pickedUpMesh;
  33398. private _pointerX;
  33399. private _pointerY;
  33400. private _unTranslatedPointerX;
  33401. private _unTranslatedPointerY;
  33402. private _startingPointerPosition;
  33403. private _previousStartingPointerPosition;
  33404. private _startingPointerTime;
  33405. private _previousStartingPointerTime;
  33406. private _pointerCaptures;
  33407. private _onKeyDown;
  33408. private _onKeyUp;
  33409. private _onCanvasFocusObserver;
  33410. private _onCanvasBlurObserver;
  33411. private _scene;
  33412. /**
  33413. * Creates a new InputManager
  33414. * @param scene defines the hosting scene
  33415. */
  33416. constructor(scene: Scene);
  33417. /**
  33418. * Gets the mesh that is currently under the pointer
  33419. */
  33420. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33421. /**
  33422. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33423. */
  33424. readonly unTranslatedPointer: Vector2;
  33425. /**
  33426. * Gets or sets the current on-screen X position of the pointer
  33427. */
  33428. pointerX: number;
  33429. /**
  33430. * Gets or sets the current on-screen Y position of the pointer
  33431. */
  33432. pointerY: number;
  33433. private _updatePointerPosition;
  33434. private _processPointerMove;
  33435. private _setRayOnPointerInfo;
  33436. private _checkPrePointerObservable;
  33437. /**
  33438. * Use this method to simulate a pointer move on a mesh
  33439. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33440. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33441. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33442. */
  33443. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33444. /**
  33445. * Use this method to simulate a pointer down on a mesh
  33446. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33447. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33448. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33449. */
  33450. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33451. private _processPointerDown;
  33452. /** @hidden */
  33453. _isPointerSwiping(): boolean;
  33454. /**
  33455. * Use this method to simulate a pointer up on a mesh
  33456. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33457. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33458. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33459. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33460. */
  33461. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33462. private _processPointerUp;
  33463. /**
  33464. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33465. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33466. * @returns true if the pointer was captured
  33467. */
  33468. isPointerCaptured(pointerId?: number): boolean;
  33469. /**
  33470. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33471. * @param attachUp defines if you want to attach events to pointerup
  33472. * @param attachDown defines if you want to attach events to pointerdown
  33473. * @param attachMove defines if you want to attach events to pointermove
  33474. */
  33475. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33476. /**
  33477. * Detaches all event handlers
  33478. */
  33479. detachControl(): void;
  33480. /**
  33481. * Force the value of meshUnderPointer
  33482. * @param mesh defines the mesh to use
  33483. */
  33484. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33485. /**
  33486. * Gets the mesh under the pointer
  33487. * @returns a Mesh or null if no mesh is under the pointer
  33488. */
  33489. getPointerOverMesh(): Nullable<AbstractMesh>;
  33490. }
  33491. }
  33492. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33493. /**
  33494. * Helper class used to generate session unique ID
  33495. */
  33496. export class UniqueIdGenerator {
  33497. private static _UniqueIdCounter;
  33498. /**
  33499. * Gets an unique (relatively to the current scene) Id
  33500. */
  33501. static readonly UniqueId: number;
  33502. }
  33503. }
  33504. declare module "babylonjs/Animations/animationGroup" {
  33505. import { Animatable } from "babylonjs/Animations/animatable";
  33506. import { Animation } from "babylonjs/Animations/animation";
  33507. import { Scene, IDisposable } from "babylonjs/scene";
  33508. import { Observable } from "babylonjs/Misc/observable";
  33509. import { Nullable } from "babylonjs/types";
  33510. import "babylonjs/Animations/animatable";
  33511. /**
  33512. * This class defines the direct association between an animation and a target
  33513. */
  33514. export class TargetedAnimation {
  33515. /**
  33516. * Animation to perform
  33517. */
  33518. animation: Animation;
  33519. /**
  33520. * Target to animate
  33521. */
  33522. target: any;
  33523. /**
  33524. * Serialize the object
  33525. * @returns the JSON object representing the current entity
  33526. */
  33527. serialize(): any;
  33528. }
  33529. /**
  33530. * Use this class to create coordinated animations on multiple targets
  33531. */
  33532. export class AnimationGroup implements IDisposable {
  33533. /** The name of the animation group */
  33534. name: string;
  33535. private _scene;
  33536. private _targetedAnimations;
  33537. private _animatables;
  33538. private _from;
  33539. private _to;
  33540. private _isStarted;
  33541. private _isPaused;
  33542. private _speedRatio;
  33543. private _loopAnimation;
  33544. /**
  33545. * Gets or sets the unique id of the node
  33546. */
  33547. uniqueId: number;
  33548. /**
  33549. * This observable will notify when one animation have ended
  33550. */
  33551. onAnimationEndObservable: Observable<TargetedAnimation>;
  33552. /**
  33553. * Observer raised when one animation loops
  33554. */
  33555. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33556. /**
  33557. * This observable will notify when all animations have ended.
  33558. */
  33559. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33560. /**
  33561. * This observable will notify when all animations have paused.
  33562. */
  33563. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33564. /**
  33565. * This observable will notify when all animations are playing.
  33566. */
  33567. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33568. /**
  33569. * Gets the first frame
  33570. */
  33571. readonly from: number;
  33572. /**
  33573. * Gets the last frame
  33574. */
  33575. readonly to: number;
  33576. /**
  33577. * Define if the animations are started
  33578. */
  33579. readonly isStarted: boolean;
  33580. /**
  33581. * Gets a value indicating that the current group is playing
  33582. */
  33583. readonly isPlaying: boolean;
  33584. /**
  33585. * Gets or sets the speed ratio to use for all animations
  33586. */
  33587. /**
  33588. * Gets or sets the speed ratio to use for all animations
  33589. */
  33590. speedRatio: number;
  33591. /**
  33592. * Gets or sets if all animations should loop or not
  33593. */
  33594. loopAnimation: boolean;
  33595. /**
  33596. * Gets the targeted animations for this animation group
  33597. */
  33598. readonly targetedAnimations: Array<TargetedAnimation>;
  33599. /**
  33600. * returning the list of animatables controlled by this animation group.
  33601. */
  33602. readonly animatables: Array<Animatable>;
  33603. /**
  33604. * Instantiates a new Animation Group.
  33605. * This helps managing several animations at once.
  33606. * @see http://doc.babylonjs.com/how_to/group
  33607. * @param name Defines the name of the group
  33608. * @param scene Defines the scene the group belongs to
  33609. */
  33610. constructor(
  33611. /** The name of the animation group */
  33612. name: string, scene?: Nullable<Scene>);
  33613. /**
  33614. * Add an animation (with its target) in the group
  33615. * @param animation defines the animation we want to add
  33616. * @param target defines the target of the animation
  33617. * @returns the TargetedAnimation object
  33618. */
  33619. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33620. /**
  33621. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33622. * It can add constant keys at begin or end
  33623. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33624. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33625. * @returns the animation group
  33626. */
  33627. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33628. /**
  33629. * Start all animations on given targets
  33630. * @param loop defines if animations must loop
  33631. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33632. * @param from defines the from key (optional)
  33633. * @param to defines the to key (optional)
  33634. * @returns the current animation group
  33635. */
  33636. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33637. /**
  33638. * Pause all animations
  33639. * @returns the animation group
  33640. */
  33641. pause(): AnimationGroup;
  33642. /**
  33643. * Play all animations to initial state
  33644. * This function will start() the animations if they were not started or will restart() them if they were paused
  33645. * @param loop defines if animations must loop
  33646. * @returns the animation group
  33647. */
  33648. play(loop?: boolean): AnimationGroup;
  33649. /**
  33650. * Reset all animations to initial state
  33651. * @returns the animation group
  33652. */
  33653. reset(): AnimationGroup;
  33654. /**
  33655. * Restart animations from key 0
  33656. * @returns the animation group
  33657. */
  33658. restart(): AnimationGroup;
  33659. /**
  33660. * Stop all animations
  33661. * @returns the animation group
  33662. */
  33663. stop(): AnimationGroup;
  33664. /**
  33665. * Set animation weight for all animatables
  33666. * @param weight defines the weight to use
  33667. * @return the animationGroup
  33668. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33669. */
  33670. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33671. /**
  33672. * Synchronize and normalize all animatables with a source animatable
  33673. * @param root defines the root animatable to synchronize with
  33674. * @return the animationGroup
  33675. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33676. */
  33677. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33678. /**
  33679. * Goes to a specific frame in this animation group
  33680. * @param frame the frame number to go to
  33681. * @return the animationGroup
  33682. */
  33683. goToFrame(frame: number): AnimationGroup;
  33684. /**
  33685. * Dispose all associated resources
  33686. */
  33687. dispose(): void;
  33688. private _checkAnimationGroupEnded;
  33689. /**
  33690. * Clone the current animation group and returns a copy
  33691. * @param newName defines the name of the new group
  33692. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33693. * @returns the new aniamtion group
  33694. */
  33695. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33696. /**
  33697. * Serializes the animationGroup to an object
  33698. * @returns Serialized object
  33699. */
  33700. serialize(): any;
  33701. /**
  33702. * Returns a new AnimationGroup object parsed from the source provided.
  33703. * @param parsedAnimationGroup defines the source
  33704. * @param scene defines the scene that will receive the animationGroup
  33705. * @returns a new AnimationGroup
  33706. */
  33707. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33708. /**
  33709. * Returns the string "AnimationGroup"
  33710. * @returns "AnimationGroup"
  33711. */
  33712. getClassName(): string;
  33713. /**
  33714. * Creates a detailled string about the object
  33715. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33716. * @returns a string representing the object
  33717. */
  33718. toString(fullDetails?: boolean): string;
  33719. }
  33720. }
  33721. declare module "babylonjs/scene" {
  33722. import { Nullable } from "babylonjs/types";
  33723. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33724. import { Observable } from "babylonjs/Misc/observable";
  33725. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33726. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33727. import { Geometry } from "babylonjs/Meshes/geometry";
  33728. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33729. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33731. import { Mesh } from "babylonjs/Meshes/mesh";
  33732. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33733. import { Bone } from "babylonjs/Bones/bone";
  33734. import { Skeleton } from "babylonjs/Bones/skeleton";
  33735. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33736. import { Camera } from "babylonjs/Cameras/camera";
  33737. import { AbstractScene } from "babylonjs/abstractScene";
  33738. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33739. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33740. import { Material } from "babylonjs/Materials/material";
  33741. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33742. import { Effect } from "babylonjs/Materials/effect";
  33743. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33744. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33745. import { Light } from "babylonjs/Lights/light";
  33746. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33747. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33748. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33749. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33750. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33751. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33752. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33753. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33754. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33755. import { Engine } from "babylonjs/Engines/engine";
  33756. import { Node } from "babylonjs/node";
  33757. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33758. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33759. import { WebRequest } from "babylonjs/Misc/webRequest";
  33760. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33761. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33762. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33763. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33764. import { Plane } from "babylonjs/Maths/math.plane";
  33765. import { Ray } from "babylonjs/Culling/ray";
  33766. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33767. import { Animation } from "babylonjs/Animations/animation";
  33768. import { Animatable } from "babylonjs/Animations/animatable";
  33769. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33770. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33771. import { Collider } from "babylonjs/Collisions/collider";
  33772. /**
  33773. * Define an interface for all classes that will hold resources
  33774. */
  33775. export interface IDisposable {
  33776. /**
  33777. * Releases all held resources
  33778. */
  33779. dispose(): void;
  33780. }
  33781. /** Interface defining initialization parameters for Scene class */
  33782. export interface SceneOptions {
  33783. /**
  33784. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33785. * It will improve performance when the number of geometries becomes important.
  33786. */
  33787. useGeometryUniqueIdsMap?: boolean;
  33788. /**
  33789. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33790. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33791. */
  33792. useMaterialMeshMap?: boolean;
  33793. /**
  33794. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33795. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33796. */
  33797. useClonedMeshhMap?: boolean;
  33798. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33799. virtual?: boolean;
  33800. }
  33801. /**
  33802. * Represents a scene to be rendered by the engine.
  33803. * @see http://doc.babylonjs.com/features/scene
  33804. */
  33805. export class Scene extends AbstractScene implements IAnimatable {
  33806. /** The fog is deactivated */
  33807. static readonly FOGMODE_NONE: number;
  33808. /** The fog density is following an exponential function */
  33809. static readonly FOGMODE_EXP: number;
  33810. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33811. static readonly FOGMODE_EXP2: number;
  33812. /** The fog density is following a linear function. */
  33813. static readonly FOGMODE_LINEAR: number;
  33814. /**
  33815. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33816. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33817. */
  33818. static MinDeltaTime: number;
  33819. /**
  33820. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33821. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33822. */
  33823. static MaxDeltaTime: number;
  33824. /**
  33825. * Factory used to create the default material.
  33826. * @param name The name of the material to create
  33827. * @param scene The scene to create the material for
  33828. * @returns The default material
  33829. */
  33830. static DefaultMaterialFactory(scene: Scene): Material;
  33831. /**
  33832. * Factory used to create the a collision coordinator.
  33833. * @returns The collision coordinator
  33834. */
  33835. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33836. /** @hidden */
  33837. _inputManager: InputManager;
  33838. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33839. cameraToUseForPointers: Nullable<Camera>;
  33840. /** @hidden */
  33841. readonly _isScene: boolean;
  33842. /**
  33843. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33844. */
  33845. autoClear: boolean;
  33846. /**
  33847. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33848. */
  33849. autoClearDepthAndStencil: boolean;
  33850. /**
  33851. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33852. */
  33853. clearColor: Color4;
  33854. /**
  33855. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33856. */
  33857. ambientColor: Color3;
  33858. /**
  33859. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33860. * It should only be one of the following (if not the default embedded one):
  33861. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33862. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33863. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33864. * The material properties need to be setup according to the type of texture in use.
  33865. */
  33866. environmentBRDFTexture: BaseTexture;
  33867. /** @hidden */
  33868. protected _environmentTexture: Nullable<BaseTexture>;
  33869. /**
  33870. * Texture used in all pbr material as the reflection texture.
  33871. * As in the majority of the scene they are the same (exception for multi room and so on),
  33872. * this is easier to reference from here than from all the materials.
  33873. */
  33874. /**
  33875. * Texture used in all pbr material as the reflection texture.
  33876. * As in the majority of the scene they are the same (exception for multi room and so on),
  33877. * this is easier to set here than in all the materials.
  33878. */
  33879. environmentTexture: Nullable<BaseTexture>;
  33880. /** @hidden */
  33881. protected _environmentIntensity: number;
  33882. /**
  33883. * Intensity of the environment in all pbr material.
  33884. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33885. * As in the majority of the scene they are the same (exception for multi room and so on),
  33886. * this is easier to reference from here than from all the materials.
  33887. */
  33888. /**
  33889. * Intensity of the environment in all pbr material.
  33890. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33891. * As in the majority of the scene they are the same (exception for multi room and so on),
  33892. * this is easier to set here than in all the materials.
  33893. */
  33894. environmentIntensity: number;
  33895. /** @hidden */
  33896. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33897. /**
  33898. * Default image processing configuration used either in the rendering
  33899. * Forward main pass or through the imageProcessingPostProcess if present.
  33900. * As in the majority of the scene they are the same (exception for multi camera),
  33901. * this is easier to reference from here than from all the materials and post process.
  33902. *
  33903. * No setter as we it is a shared configuration, you can set the values instead.
  33904. */
  33905. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33906. private _forceWireframe;
  33907. /**
  33908. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33909. */
  33910. forceWireframe: boolean;
  33911. private _forcePointsCloud;
  33912. /**
  33913. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33914. */
  33915. forcePointsCloud: boolean;
  33916. /**
  33917. * Gets or sets the active clipplane 1
  33918. */
  33919. clipPlane: Nullable<Plane>;
  33920. /**
  33921. * Gets or sets the active clipplane 2
  33922. */
  33923. clipPlane2: Nullable<Plane>;
  33924. /**
  33925. * Gets or sets the active clipplane 3
  33926. */
  33927. clipPlane3: Nullable<Plane>;
  33928. /**
  33929. * Gets or sets the active clipplane 4
  33930. */
  33931. clipPlane4: Nullable<Plane>;
  33932. /**
  33933. * Gets or sets a boolean indicating if animations are enabled
  33934. */
  33935. animationsEnabled: boolean;
  33936. private _animationPropertiesOverride;
  33937. /**
  33938. * Gets or sets the animation properties override
  33939. */
  33940. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33941. /**
  33942. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33943. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33944. */
  33945. useConstantAnimationDeltaTime: boolean;
  33946. /**
  33947. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33948. * Please note that it requires to run a ray cast through the scene on every frame
  33949. */
  33950. constantlyUpdateMeshUnderPointer: boolean;
  33951. /**
  33952. * Defines the HTML cursor to use when hovering over interactive elements
  33953. */
  33954. hoverCursor: string;
  33955. /**
  33956. * Defines the HTML default cursor to use (empty by default)
  33957. */
  33958. defaultCursor: string;
  33959. /**
  33960. * This is used to call preventDefault() on pointer down
  33961. * in order to block unwanted artifacts like system double clicks
  33962. */
  33963. preventDefaultOnPointerDown: boolean;
  33964. /**
  33965. * This is used to call preventDefault() on pointer up
  33966. * in order to block unwanted artifacts like system double clicks
  33967. */
  33968. preventDefaultOnPointerUp: boolean;
  33969. /**
  33970. * Gets or sets user defined metadata
  33971. */
  33972. metadata: any;
  33973. /**
  33974. * For internal use only. Please do not use.
  33975. */
  33976. reservedDataStore: any;
  33977. /**
  33978. * Gets the name of the plugin used to load this scene (null by default)
  33979. */
  33980. loadingPluginName: string;
  33981. /**
  33982. * Use this array to add regular expressions used to disable offline support for specific urls
  33983. */
  33984. disableOfflineSupportExceptionRules: RegExp[];
  33985. /**
  33986. * An event triggered when the scene is disposed.
  33987. */
  33988. onDisposeObservable: Observable<Scene>;
  33989. private _onDisposeObserver;
  33990. /** Sets a function to be executed when this scene is disposed. */
  33991. onDispose: () => void;
  33992. /**
  33993. * An event triggered before rendering the scene (right after animations and physics)
  33994. */
  33995. onBeforeRenderObservable: Observable<Scene>;
  33996. private _onBeforeRenderObserver;
  33997. /** Sets a function to be executed before rendering this scene */
  33998. beforeRender: Nullable<() => void>;
  33999. /**
  34000. * An event triggered after rendering the scene
  34001. */
  34002. onAfterRenderObservable: Observable<Scene>;
  34003. /**
  34004. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34005. */
  34006. onAfterRenderCameraObservable: Observable<Camera>;
  34007. private _onAfterRenderObserver;
  34008. /** Sets a function to be executed after rendering this scene */
  34009. afterRender: Nullable<() => void>;
  34010. /**
  34011. * An event triggered before animating the scene
  34012. */
  34013. onBeforeAnimationsObservable: Observable<Scene>;
  34014. /**
  34015. * An event triggered after animations processing
  34016. */
  34017. onAfterAnimationsObservable: Observable<Scene>;
  34018. /**
  34019. * An event triggered before draw calls are ready to be sent
  34020. */
  34021. onBeforeDrawPhaseObservable: Observable<Scene>;
  34022. /**
  34023. * An event triggered after draw calls have been sent
  34024. */
  34025. onAfterDrawPhaseObservable: Observable<Scene>;
  34026. /**
  34027. * An event triggered when the scene is ready
  34028. */
  34029. onReadyObservable: Observable<Scene>;
  34030. /**
  34031. * An event triggered before rendering a camera
  34032. */
  34033. onBeforeCameraRenderObservable: Observable<Camera>;
  34034. private _onBeforeCameraRenderObserver;
  34035. /** Sets a function to be executed before rendering a camera*/
  34036. beforeCameraRender: () => void;
  34037. /**
  34038. * An event triggered after rendering a camera
  34039. */
  34040. onAfterCameraRenderObservable: Observable<Camera>;
  34041. private _onAfterCameraRenderObserver;
  34042. /** Sets a function to be executed after rendering a camera*/
  34043. afterCameraRender: () => void;
  34044. /**
  34045. * An event triggered when active meshes evaluation is about to start
  34046. */
  34047. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34048. /**
  34049. * An event triggered when active meshes evaluation is done
  34050. */
  34051. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34052. /**
  34053. * An event triggered when particles rendering is about to start
  34054. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34055. */
  34056. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34057. /**
  34058. * An event triggered when particles rendering is done
  34059. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34060. */
  34061. onAfterParticlesRenderingObservable: Observable<Scene>;
  34062. /**
  34063. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34064. */
  34065. onDataLoadedObservable: Observable<Scene>;
  34066. /**
  34067. * An event triggered when a camera is created
  34068. */
  34069. onNewCameraAddedObservable: Observable<Camera>;
  34070. /**
  34071. * An event triggered when a camera is removed
  34072. */
  34073. onCameraRemovedObservable: Observable<Camera>;
  34074. /**
  34075. * An event triggered when a light is created
  34076. */
  34077. onNewLightAddedObservable: Observable<Light>;
  34078. /**
  34079. * An event triggered when a light is removed
  34080. */
  34081. onLightRemovedObservable: Observable<Light>;
  34082. /**
  34083. * An event triggered when a geometry is created
  34084. */
  34085. onNewGeometryAddedObservable: Observable<Geometry>;
  34086. /**
  34087. * An event triggered when a geometry is removed
  34088. */
  34089. onGeometryRemovedObservable: Observable<Geometry>;
  34090. /**
  34091. * An event triggered when a transform node is created
  34092. */
  34093. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34094. /**
  34095. * An event triggered when a transform node is removed
  34096. */
  34097. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34098. /**
  34099. * An event triggered when a mesh is created
  34100. */
  34101. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34102. /**
  34103. * An event triggered when a mesh is removed
  34104. */
  34105. onMeshRemovedObservable: Observable<AbstractMesh>;
  34106. /**
  34107. * An event triggered when a skeleton is created
  34108. */
  34109. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34110. /**
  34111. * An event triggered when a skeleton is removed
  34112. */
  34113. onSkeletonRemovedObservable: Observable<Skeleton>;
  34114. /**
  34115. * An event triggered when a material is created
  34116. */
  34117. onNewMaterialAddedObservable: Observable<Material>;
  34118. /**
  34119. * An event triggered when a material is removed
  34120. */
  34121. onMaterialRemovedObservable: Observable<Material>;
  34122. /**
  34123. * An event triggered when a texture is created
  34124. */
  34125. onNewTextureAddedObservable: Observable<BaseTexture>;
  34126. /**
  34127. * An event triggered when a texture is removed
  34128. */
  34129. onTextureRemovedObservable: Observable<BaseTexture>;
  34130. /**
  34131. * An event triggered when render targets are about to be rendered
  34132. * Can happen multiple times per frame.
  34133. */
  34134. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34135. /**
  34136. * An event triggered when render targets were rendered.
  34137. * Can happen multiple times per frame.
  34138. */
  34139. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34140. /**
  34141. * An event triggered before calculating deterministic simulation step
  34142. */
  34143. onBeforeStepObservable: Observable<Scene>;
  34144. /**
  34145. * An event triggered after calculating deterministic simulation step
  34146. */
  34147. onAfterStepObservable: Observable<Scene>;
  34148. /**
  34149. * An event triggered when the activeCamera property is updated
  34150. */
  34151. onActiveCameraChanged: Observable<Scene>;
  34152. /**
  34153. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34154. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34155. * 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)
  34156. */
  34157. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34158. /**
  34159. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34160. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34161. * 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)
  34162. */
  34163. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34164. /**
  34165. * This Observable will when a mesh has been imported into the scene.
  34166. */
  34167. onMeshImportedObservable: Observable<AbstractMesh>;
  34168. /**
  34169. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34170. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34171. */
  34172. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34173. /** @hidden */
  34174. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34175. /**
  34176. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34177. */
  34178. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34179. /**
  34180. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34181. */
  34182. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34183. /**
  34184. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34185. */
  34186. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34187. /** Callback called when a pointer move is detected */
  34188. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34189. /** Callback called when a pointer down is detected */
  34190. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34191. /** Callback called when a pointer up is detected */
  34192. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34193. /** Callback called when a pointer pick is detected */
  34194. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34195. /**
  34196. * 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).
  34197. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34198. */
  34199. onPrePointerObservable: Observable<PointerInfoPre>;
  34200. /**
  34201. * Observable event triggered each time an input event is received from the rendering canvas
  34202. */
  34203. onPointerObservable: Observable<PointerInfo>;
  34204. /**
  34205. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34206. */
  34207. readonly unTranslatedPointer: Vector2;
  34208. /**
  34209. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34210. */
  34211. static DragMovementThreshold: number;
  34212. /**
  34213. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34214. */
  34215. static LongPressDelay: number;
  34216. /**
  34217. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34218. */
  34219. static DoubleClickDelay: number;
  34220. /** If you need to check double click without raising a single click at first click, enable this flag */
  34221. static ExclusiveDoubleClickMode: boolean;
  34222. /** @hidden */
  34223. _mirroredCameraPosition: Nullable<Vector3>;
  34224. /**
  34225. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34226. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34227. */
  34228. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34229. /**
  34230. * Observable event triggered each time an keyboard event is received from the hosting window
  34231. */
  34232. onKeyboardObservable: Observable<KeyboardInfo>;
  34233. private _useRightHandedSystem;
  34234. /**
  34235. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34236. */
  34237. useRightHandedSystem: boolean;
  34238. private _timeAccumulator;
  34239. private _currentStepId;
  34240. private _currentInternalStep;
  34241. /**
  34242. * Sets the step Id used by deterministic lock step
  34243. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34244. * @param newStepId defines the step Id
  34245. */
  34246. setStepId(newStepId: number): void;
  34247. /**
  34248. * Gets the step Id used by deterministic lock step
  34249. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34250. * @returns the step Id
  34251. */
  34252. getStepId(): number;
  34253. /**
  34254. * Gets the internal step used by deterministic lock step
  34255. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34256. * @returns the internal step
  34257. */
  34258. getInternalStep(): number;
  34259. private _fogEnabled;
  34260. /**
  34261. * Gets or sets a boolean indicating if fog is enabled on this scene
  34262. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34263. * (Default is true)
  34264. */
  34265. fogEnabled: boolean;
  34266. private _fogMode;
  34267. /**
  34268. * Gets or sets the fog mode to use
  34269. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34270. * | mode | value |
  34271. * | --- | --- |
  34272. * | FOGMODE_NONE | 0 |
  34273. * | FOGMODE_EXP | 1 |
  34274. * | FOGMODE_EXP2 | 2 |
  34275. * | FOGMODE_LINEAR | 3 |
  34276. */
  34277. fogMode: number;
  34278. /**
  34279. * Gets or sets the fog color to use
  34280. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34281. * (Default is Color3(0.2, 0.2, 0.3))
  34282. */
  34283. fogColor: Color3;
  34284. /**
  34285. * Gets or sets the fog density to use
  34286. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34287. * (Default is 0.1)
  34288. */
  34289. fogDensity: number;
  34290. /**
  34291. * Gets or sets the fog start distance to use
  34292. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34293. * (Default is 0)
  34294. */
  34295. fogStart: number;
  34296. /**
  34297. * Gets or sets the fog end distance to use
  34298. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34299. * (Default is 1000)
  34300. */
  34301. fogEnd: number;
  34302. private _shadowsEnabled;
  34303. /**
  34304. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34305. */
  34306. shadowsEnabled: boolean;
  34307. private _lightsEnabled;
  34308. /**
  34309. * Gets or sets a boolean indicating if lights are enabled on this scene
  34310. */
  34311. lightsEnabled: boolean;
  34312. /** All of the active cameras added to this scene. */
  34313. activeCameras: Camera[];
  34314. /** @hidden */
  34315. _activeCamera: Nullable<Camera>;
  34316. /** Gets or sets the current active camera */
  34317. activeCamera: Nullable<Camera>;
  34318. private _defaultMaterial;
  34319. /** The default material used on meshes when no material is affected */
  34320. /** The default material used on meshes when no material is affected */
  34321. defaultMaterial: Material;
  34322. private _texturesEnabled;
  34323. /**
  34324. * Gets or sets a boolean indicating if textures are enabled on this scene
  34325. */
  34326. texturesEnabled: boolean;
  34327. /**
  34328. * Gets or sets a boolean indicating if particles are enabled on this scene
  34329. */
  34330. particlesEnabled: boolean;
  34331. /**
  34332. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34333. */
  34334. spritesEnabled: boolean;
  34335. private _skeletonsEnabled;
  34336. /**
  34337. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34338. */
  34339. skeletonsEnabled: boolean;
  34340. /**
  34341. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34342. */
  34343. lensFlaresEnabled: boolean;
  34344. /**
  34345. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34346. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34347. */
  34348. collisionsEnabled: boolean;
  34349. private _collisionCoordinator;
  34350. /** @hidden */
  34351. readonly collisionCoordinator: ICollisionCoordinator;
  34352. /**
  34353. * Defines the gravity applied to this scene (used only for collisions)
  34354. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34355. */
  34356. gravity: Vector3;
  34357. /**
  34358. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34359. */
  34360. postProcessesEnabled: boolean;
  34361. /**
  34362. * The list of postprocesses added to the scene
  34363. */
  34364. postProcesses: PostProcess[];
  34365. /**
  34366. * Gets the current postprocess manager
  34367. */
  34368. postProcessManager: PostProcessManager;
  34369. /**
  34370. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34371. */
  34372. renderTargetsEnabled: boolean;
  34373. /**
  34374. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34375. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34376. */
  34377. dumpNextRenderTargets: boolean;
  34378. /**
  34379. * The list of user defined render targets added to the scene
  34380. */
  34381. customRenderTargets: RenderTargetTexture[];
  34382. /**
  34383. * Defines if texture loading must be delayed
  34384. * If true, textures will only be loaded when they need to be rendered
  34385. */
  34386. useDelayedTextureLoading: boolean;
  34387. /**
  34388. * Gets the list of meshes imported to the scene through SceneLoader
  34389. */
  34390. importedMeshesFiles: String[];
  34391. /**
  34392. * Gets or sets a boolean indicating if probes are enabled on this scene
  34393. */
  34394. probesEnabled: boolean;
  34395. /**
  34396. * Gets or sets the current offline provider to use to store scene data
  34397. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34398. */
  34399. offlineProvider: IOfflineProvider;
  34400. /**
  34401. * Gets or sets the action manager associated with the scene
  34402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34403. */
  34404. actionManager: AbstractActionManager;
  34405. private _meshesForIntersections;
  34406. /**
  34407. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34408. */
  34409. proceduralTexturesEnabled: boolean;
  34410. private _engine;
  34411. private _totalVertices;
  34412. /** @hidden */
  34413. _activeIndices: PerfCounter;
  34414. /** @hidden */
  34415. _activeParticles: PerfCounter;
  34416. /** @hidden */
  34417. _activeBones: PerfCounter;
  34418. private _animationRatio;
  34419. /** @hidden */
  34420. _animationTimeLast: number;
  34421. /** @hidden */
  34422. _animationTime: number;
  34423. /**
  34424. * Gets or sets a general scale for animation speed
  34425. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34426. */
  34427. animationTimeScale: number;
  34428. /** @hidden */
  34429. _cachedMaterial: Nullable<Material>;
  34430. /** @hidden */
  34431. _cachedEffect: Nullable<Effect>;
  34432. /** @hidden */
  34433. _cachedVisibility: Nullable<number>;
  34434. private _renderId;
  34435. private _frameId;
  34436. private _executeWhenReadyTimeoutId;
  34437. private _intermediateRendering;
  34438. private _viewUpdateFlag;
  34439. private _projectionUpdateFlag;
  34440. /** @hidden */
  34441. _toBeDisposed: Nullable<IDisposable>[];
  34442. private _activeRequests;
  34443. /** @hidden */
  34444. _pendingData: any[];
  34445. private _isDisposed;
  34446. /**
  34447. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34448. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34449. */
  34450. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34451. private _activeMeshes;
  34452. private _processedMaterials;
  34453. private _renderTargets;
  34454. /** @hidden */
  34455. _activeParticleSystems: SmartArray<IParticleSystem>;
  34456. private _activeSkeletons;
  34457. private _softwareSkinnedMeshes;
  34458. private _renderingManager;
  34459. /** @hidden */
  34460. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34461. private _transformMatrix;
  34462. private _sceneUbo;
  34463. /** @hidden */
  34464. _viewMatrix: Matrix;
  34465. private _projectionMatrix;
  34466. /** @hidden */
  34467. _forcedViewPosition: Nullable<Vector3>;
  34468. /** @hidden */
  34469. _frustumPlanes: Plane[];
  34470. /**
  34471. * Gets the list of frustum planes (built from the active camera)
  34472. */
  34473. readonly frustumPlanes: Plane[];
  34474. /**
  34475. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34476. * This is useful if there are more lights that the maximum simulteanous authorized
  34477. */
  34478. requireLightSorting: boolean;
  34479. /** @hidden */
  34480. readonly useMaterialMeshMap: boolean;
  34481. /** @hidden */
  34482. readonly useClonedMeshhMap: boolean;
  34483. private _externalData;
  34484. private _uid;
  34485. /**
  34486. * @hidden
  34487. * Backing store of defined scene components.
  34488. */
  34489. _components: ISceneComponent[];
  34490. /**
  34491. * @hidden
  34492. * Backing store of defined scene components.
  34493. */
  34494. _serializableComponents: ISceneSerializableComponent[];
  34495. /**
  34496. * List of components to register on the next registration step.
  34497. */
  34498. private _transientComponents;
  34499. /**
  34500. * Registers the transient components if needed.
  34501. */
  34502. private _registerTransientComponents;
  34503. /**
  34504. * @hidden
  34505. * Add a component to the scene.
  34506. * Note that the ccomponent could be registered on th next frame if this is called after
  34507. * the register component stage.
  34508. * @param component Defines the component to add to the scene
  34509. */
  34510. _addComponent(component: ISceneComponent): void;
  34511. /**
  34512. * @hidden
  34513. * Gets a component from the scene.
  34514. * @param name defines the name of the component to retrieve
  34515. * @returns the component or null if not present
  34516. */
  34517. _getComponent(name: string): Nullable<ISceneComponent>;
  34518. /**
  34519. * @hidden
  34520. * Defines the actions happening before camera updates.
  34521. */
  34522. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34523. /**
  34524. * @hidden
  34525. * Defines the actions happening before clear the canvas.
  34526. */
  34527. _beforeClearStage: Stage<SimpleStageAction>;
  34528. /**
  34529. * @hidden
  34530. * Defines the actions when collecting render targets for the frame.
  34531. */
  34532. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34533. /**
  34534. * @hidden
  34535. * Defines the actions happening for one camera in the frame.
  34536. */
  34537. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34538. /**
  34539. * @hidden
  34540. * Defines the actions happening during the per mesh ready checks.
  34541. */
  34542. _isReadyForMeshStage: Stage<MeshStageAction>;
  34543. /**
  34544. * @hidden
  34545. * Defines the actions happening before evaluate active mesh checks.
  34546. */
  34547. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34548. /**
  34549. * @hidden
  34550. * Defines the actions happening during the evaluate sub mesh checks.
  34551. */
  34552. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34553. /**
  34554. * @hidden
  34555. * Defines the actions happening during the active mesh stage.
  34556. */
  34557. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34558. /**
  34559. * @hidden
  34560. * Defines the actions happening during the per camera render target step.
  34561. */
  34562. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34563. /**
  34564. * @hidden
  34565. * Defines the actions happening just before the active camera is drawing.
  34566. */
  34567. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34568. /**
  34569. * @hidden
  34570. * Defines the actions happening just before a render target is drawing.
  34571. */
  34572. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34573. /**
  34574. * @hidden
  34575. * Defines the actions happening just before a rendering group is drawing.
  34576. */
  34577. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34578. /**
  34579. * @hidden
  34580. * Defines the actions happening just before a mesh is drawing.
  34581. */
  34582. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34583. /**
  34584. * @hidden
  34585. * Defines the actions happening just after a mesh has been drawn.
  34586. */
  34587. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34588. /**
  34589. * @hidden
  34590. * Defines the actions happening just after a rendering group has been drawn.
  34591. */
  34592. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34593. /**
  34594. * @hidden
  34595. * Defines the actions happening just after the active camera has been drawn.
  34596. */
  34597. _afterCameraDrawStage: Stage<CameraStageAction>;
  34598. /**
  34599. * @hidden
  34600. * Defines the actions happening just after a render target has been drawn.
  34601. */
  34602. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34603. /**
  34604. * @hidden
  34605. * Defines the actions happening just after rendering all cameras and computing intersections.
  34606. */
  34607. _afterRenderStage: Stage<SimpleStageAction>;
  34608. /**
  34609. * @hidden
  34610. * Defines the actions happening when a pointer move event happens.
  34611. */
  34612. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34613. /**
  34614. * @hidden
  34615. * Defines the actions happening when a pointer down event happens.
  34616. */
  34617. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34618. /**
  34619. * @hidden
  34620. * Defines the actions happening when a pointer up event happens.
  34621. */
  34622. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34623. /**
  34624. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34625. */
  34626. private geometriesByUniqueId;
  34627. /**
  34628. * Creates a new Scene
  34629. * @param engine defines the engine to use to render this scene
  34630. * @param options defines the scene options
  34631. */
  34632. constructor(engine: Engine, options?: SceneOptions);
  34633. /**
  34634. * Gets a string idenfifying the name of the class
  34635. * @returns "Scene" string
  34636. */
  34637. getClassName(): string;
  34638. private _defaultMeshCandidates;
  34639. /**
  34640. * @hidden
  34641. */
  34642. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34643. private _defaultSubMeshCandidates;
  34644. /**
  34645. * @hidden
  34646. */
  34647. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34648. /**
  34649. * Sets the default candidate providers for the scene.
  34650. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34651. * and getCollidingSubMeshCandidates to their default function
  34652. */
  34653. setDefaultCandidateProviders(): void;
  34654. /**
  34655. * Gets the mesh that is currently under the pointer
  34656. */
  34657. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34658. /**
  34659. * Gets or sets the current on-screen X position of the pointer
  34660. */
  34661. pointerX: number;
  34662. /**
  34663. * Gets or sets the current on-screen Y position of the pointer
  34664. */
  34665. pointerY: number;
  34666. /**
  34667. * Gets the cached material (ie. the latest rendered one)
  34668. * @returns the cached material
  34669. */
  34670. getCachedMaterial(): Nullable<Material>;
  34671. /**
  34672. * Gets the cached effect (ie. the latest rendered one)
  34673. * @returns the cached effect
  34674. */
  34675. getCachedEffect(): Nullable<Effect>;
  34676. /**
  34677. * Gets the cached visibility state (ie. the latest rendered one)
  34678. * @returns the cached visibility state
  34679. */
  34680. getCachedVisibility(): Nullable<number>;
  34681. /**
  34682. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34683. * @param material defines the current material
  34684. * @param effect defines the current effect
  34685. * @param visibility defines the current visibility state
  34686. * @returns true if one parameter is not cached
  34687. */
  34688. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34689. /**
  34690. * Gets the engine associated with the scene
  34691. * @returns an Engine
  34692. */
  34693. getEngine(): Engine;
  34694. /**
  34695. * Gets the total number of vertices rendered per frame
  34696. * @returns the total number of vertices rendered per frame
  34697. */
  34698. getTotalVertices(): number;
  34699. /**
  34700. * Gets the performance counter for total vertices
  34701. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34702. */
  34703. readonly totalVerticesPerfCounter: PerfCounter;
  34704. /**
  34705. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34706. * @returns the total number of active indices rendered per frame
  34707. */
  34708. getActiveIndices(): number;
  34709. /**
  34710. * Gets the performance counter for active indices
  34711. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34712. */
  34713. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34714. /**
  34715. * Gets the total number of active particles rendered per frame
  34716. * @returns the total number of active particles rendered per frame
  34717. */
  34718. getActiveParticles(): number;
  34719. /**
  34720. * Gets the performance counter for active particles
  34721. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34722. */
  34723. readonly activeParticlesPerfCounter: PerfCounter;
  34724. /**
  34725. * Gets the total number of active bones rendered per frame
  34726. * @returns the total number of active bones rendered per frame
  34727. */
  34728. getActiveBones(): number;
  34729. /**
  34730. * Gets the performance counter for active bones
  34731. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34732. */
  34733. readonly activeBonesPerfCounter: PerfCounter;
  34734. /**
  34735. * Gets the array of active meshes
  34736. * @returns an array of AbstractMesh
  34737. */
  34738. getActiveMeshes(): SmartArray<AbstractMesh>;
  34739. /**
  34740. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34741. * @returns a number
  34742. */
  34743. getAnimationRatio(): number;
  34744. /**
  34745. * Gets an unique Id for the current render phase
  34746. * @returns a number
  34747. */
  34748. getRenderId(): number;
  34749. /**
  34750. * Gets an unique Id for the current frame
  34751. * @returns a number
  34752. */
  34753. getFrameId(): number;
  34754. /** Call this function if you want to manually increment the render Id*/
  34755. incrementRenderId(): void;
  34756. private _createUbo;
  34757. /**
  34758. * Use this method to simulate a pointer move on a mesh
  34759. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34760. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34761. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34762. * @returns the current scene
  34763. */
  34764. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34765. /**
  34766. * Use this method to simulate a pointer down on a mesh
  34767. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34768. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34769. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34770. * @returns the current scene
  34771. */
  34772. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34773. /**
  34774. * Use this method to simulate a pointer up on a mesh
  34775. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34776. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34777. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34778. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34779. * @returns the current scene
  34780. */
  34781. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34782. /**
  34783. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34784. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34785. * @returns true if the pointer was captured
  34786. */
  34787. isPointerCaptured(pointerId?: number): boolean;
  34788. /**
  34789. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34790. * @param attachUp defines if you want to attach events to pointerup
  34791. * @param attachDown defines if you want to attach events to pointerdown
  34792. * @param attachMove defines if you want to attach events to pointermove
  34793. */
  34794. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34795. /** Detaches all event handlers*/
  34796. detachControl(): void;
  34797. /**
  34798. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34799. * Delay loaded resources are not taking in account
  34800. * @return true if all required resources are ready
  34801. */
  34802. isReady(): boolean;
  34803. /** Resets all cached information relative to material (including effect and visibility) */
  34804. resetCachedMaterial(): void;
  34805. /**
  34806. * Registers a function to be called before every frame render
  34807. * @param func defines the function to register
  34808. */
  34809. registerBeforeRender(func: () => void): void;
  34810. /**
  34811. * Unregisters a function called before every frame render
  34812. * @param func defines the function to unregister
  34813. */
  34814. unregisterBeforeRender(func: () => void): void;
  34815. /**
  34816. * Registers a function to be called after every frame render
  34817. * @param func defines the function to register
  34818. */
  34819. registerAfterRender(func: () => void): void;
  34820. /**
  34821. * Unregisters a function called after every frame render
  34822. * @param func defines the function to unregister
  34823. */
  34824. unregisterAfterRender(func: () => void): void;
  34825. private _executeOnceBeforeRender;
  34826. /**
  34827. * The provided function will run before render once and will be disposed afterwards.
  34828. * A timeout delay can be provided so that the function will be executed in N ms.
  34829. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34830. * @param func The function to be executed.
  34831. * @param timeout optional delay in ms
  34832. */
  34833. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34834. /** @hidden */
  34835. _addPendingData(data: any): void;
  34836. /** @hidden */
  34837. _removePendingData(data: any): void;
  34838. /**
  34839. * Returns the number of items waiting to be loaded
  34840. * @returns the number of items waiting to be loaded
  34841. */
  34842. getWaitingItemsCount(): number;
  34843. /**
  34844. * Returns a boolean indicating if the scene is still loading data
  34845. */
  34846. readonly isLoading: boolean;
  34847. /**
  34848. * Registers a function to be executed when the scene is ready
  34849. * @param {Function} func - the function to be executed
  34850. */
  34851. executeWhenReady(func: () => void): void;
  34852. /**
  34853. * Returns a promise that resolves when the scene is ready
  34854. * @returns A promise that resolves when the scene is ready
  34855. */
  34856. whenReadyAsync(): Promise<void>;
  34857. /** @hidden */
  34858. _checkIsReady(): void;
  34859. /**
  34860. * Gets all animatable attached to the scene
  34861. */
  34862. readonly animatables: Animatable[];
  34863. /**
  34864. * Resets the last animation time frame.
  34865. * Useful to override when animations start running when loading a scene for the first time.
  34866. */
  34867. resetLastAnimationTimeFrame(): void;
  34868. /**
  34869. * Gets the current view matrix
  34870. * @returns a Matrix
  34871. */
  34872. getViewMatrix(): Matrix;
  34873. /**
  34874. * Gets the current projection matrix
  34875. * @returns a Matrix
  34876. */
  34877. getProjectionMatrix(): Matrix;
  34878. /**
  34879. * Gets the current transform matrix
  34880. * @returns a Matrix made of View * Projection
  34881. */
  34882. getTransformMatrix(): Matrix;
  34883. /**
  34884. * Sets the current transform matrix
  34885. * @param viewL defines the View matrix to use
  34886. * @param projectionL defines the Projection matrix to use
  34887. * @param viewR defines the right View matrix to use (if provided)
  34888. * @param projectionR defines the right Projection matrix to use (if provided)
  34889. */
  34890. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34891. /**
  34892. * Gets the uniform buffer used to store scene data
  34893. * @returns a UniformBuffer
  34894. */
  34895. getSceneUniformBuffer(): UniformBuffer;
  34896. /**
  34897. * Gets an unique (relatively to the current scene) Id
  34898. * @returns an unique number for the scene
  34899. */
  34900. getUniqueId(): number;
  34901. /**
  34902. * Add a mesh to the list of scene's meshes
  34903. * @param newMesh defines the mesh to add
  34904. * @param recursive if all child meshes should also be added to the scene
  34905. */
  34906. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34907. /**
  34908. * Remove a mesh for the list of scene's meshes
  34909. * @param toRemove defines the mesh to remove
  34910. * @param recursive if all child meshes should also be removed from the scene
  34911. * @returns the index where the mesh was in the mesh list
  34912. */
  34913. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34914. /**
  34915. * Add a transform node to the list of scene's transform nodes
  34916. * @param newTransformNode defines the transform node to add
  34917. */
  34918. addTransformNode(newTransformNode: TransformNode): void;
  34919. /**
  34920. * Remove a transform node for the list of scene's transform nodes
  34921. * @param toRemove defines the transform node to remove
  34922. * @returns the index where the transform node was in the transform node list
  34923. */
  34924. removeTransformNode(toRemove: TransformNode): number;
  34925. /**
  34926. * Remove a skeleton for the list of scene's skeletons
  34927. * @param toRemove defines the skeleton to remove
  34928. * @returns the index where the skeleton was in the skeleton list
  34929. */
  34930. removeSkeleton(toRemove: Skeleton): number;
  34931. /**
  34932. * Remove a morph target for the list of scene's morph targets
  34933. * @param toRemove defines the morph target to remove
  34934. * @returns the index where the morph target was in the morph target list
  34935. */
  34936. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34937. /**
  34938. * Remove a light for the list of scene's lights
  34939. * @param toRemove defines the light to remove
  34940. * @returns the index where the light was in the light list
  34941. */
  34942. removeLight(toRemove: Light): number;
  34943. /**
  34944. * Remove a camera for the list of scene's cameras
  34945. * @param toRemove defines the camera to remove
  34946. * @returns the index where the camera was in the camera list
  34947. */
  34948. removeCamera(toRemove: Camera): number;
  34949. /**
  34950. * Remove a particle system for the list of scene's particle systems
  34951. * @param toRemove defines the particle system to remove
  34952. * @returns the index where the particle system was in the particle system list
  34953. */
  34954. removeParticleSystem(toRemove: IParticleSystem): number;
  34955. /**
  34956. * Remove a animation for the list of scene's animations
  34957. * @param toRemove defines the animation to remove
  34958. * @returns the index where the animation was in the animation list
  34959. */
  34960. removeAnimation(toRemove: Animation): number;
  34961. /**
  34962. * Will stop the animation of the given target
  34963. * @param target - the target
  34964. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34965. * @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)
  34966. */
  34967. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34968. /**
  34969. * Removes the given animation group from this scene.
  34970. * @param toRemove The animation group to remove
  34971. * @returns The index of the removed animation group
  34972. */
  34973. removeAnimationGroup(toRemove: AnimationGroup): number;
  34974. /**
  34975. * Removes the given multi-material from this scene.
  34976. * @param toRemove The multi-material to remove
  34977. * @returns The index of the removed multi-material
  34978. */
  34979. removeMultiMaterial(toRemove: MultiMaterial): number;
  34980. /**
  34981. * Removes the given material from this scene.
  34982. * @param toRemove The material to remove
  34983. * @returns The index of the removed material
  34984. */
  34985. removeMaterial(toRemove: Material): number;
  34986. /**
  34987. * Removes the given action manager from this scene.
  34988. * @param toRemove The action manager to remove
  34989. * @returns The index of the removed action manager
  34990. */
  34991. removeActionManager(toRemove: AbstractActionManager): number;
  34992. /**
  34993. * Removes the given texture from this scene.
  34994. * @param toRemove The texture to remove
  34995. * @returns The index of the removed texture
  34996. */
  34997. removeTexture(toRemove: BaseTexture): number;
  34998. /**
  34999. * Adds the given light to this scene
  35000. * @param newLight The light to add
  35001. */
  35002. addLight(newLight: Light): void;
  35003. /**
  35004. * Sorts the list list based on light priorities
  35005. */
  35006. sortLightsByPriority(): void;
  35007. /**
  35008. * Adds the given camera to this scene
  35009. * @param newCamera The camera to add
  35010. */
  35011. addCamera(newCamera: Camera): void;
  35012. /**
  35013. * Adds the given skeleton to this scene
  35014. * @param newSkeleton The skeleton to add
  35015. */
  35016. addSkeleton(newSkeleton: Skeleton): void;
  35017. /**
  35018. * Adds the given particle system to this scene
  35019. * @param newParticleSystem The particle system to add
  35020. */
  35021. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35022. /**
  35023. * Adds the given animation to this scene
  35024. * @param newAnimation The animation to add
  35025. */
  35026. addAnimation(newAnimation: Animation): void;
  35027. /**
  35028. * Adds the given animation group to this scene.
  35029. * @param newAnimationGroup The animation group to add
  35030. */
  35031. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35032. /**
  35033. * Adds the given multi-material to this scene
  35034. * @param newMultiMaterial The multi-material to add
  35035. */
  35036. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35037. /**
  35038. * Adds the given material to this scene
  35039. * @param newMaterial The material to add
  35040. */
  35041. addMaterial(newMaterial: Material): void;
  35042. /**
  35043. * Adds the given morph target to this scene
  35044. * @param newMorphTargetManager The morph target to add
  35045. */
  35046. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35047. /**
  35048. * Adds the given geometry to this scene
  35049. * @param newGeometry The geometry to add
  35050. */
  35051. addGeometry(newGeometry: Geometry): void;
  35052. /**
  35053. * Adds the given action manager to this scene
  35054. * @param newActionManager The action manager to add
  35055. */
  35056. addActionManager(newActionManager: AbstractActionManager): void;
  35057. /**
  35058. * Adds the given texture to this scene.
  35059. * @param newTexture The texture to add
  35060. */
  35061. addTexture(newTexture: BaseTexture): void;
  35062. /**
  35063. * Switch active camera
  35064. * @param newCamera defines the new active camera
  35065. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35066. */
  35067. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35068. /**
  35069. * sets the active camera of the scene using its ID
  35070. * @param id defines the camera's ID
  35071. * @return the new active camera or null if none found.
  35072. */
  35073. setActiveCameraByID(id: string): Nullable<Camera>;
  35074. /**
  35075. * sets the active camera of the scene using its name
  35076. * @param name defines the camera's name
  35077. * @returns the new active camera or null if none found.
  35078. */
  35079. setActiveCameraByName(name: string): Nullable<Camera>;
  35080. /**
  35081. * get an animation group using its name
  35082. * @param name defines the material's name
  35083. * @return the animation group or null if none found.
  35084. */
  35085. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35086. /**
  35087. * Get a material using its unique id
  35088. * @param uniqueId defines the material's unique id
  35089. * @return the material or null if none found.
  35090. */
  35091. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35092. /**
  35093. * get a material using its id
  35094. * @param id defines the material's ID
  35095. * @return the material or null if none found.
  35096. */
  35097. getMaterialByID(id: string): Nullable<Material>;
  35098. /**
  35099. * Gets a the last added material using a given id
  35100. * @param id defines the material's ID
  35101. * @return the last material with the given id or null if none found.
  35102. */
  35103. getLastMaterialByID(id: string): Nullable<Material>;
  35104. /**
  35105. * Gets a material using its name
  35106. * @param name defines the material's name
  35107. * @return the material or null if none found.
  35108. */
  35109. getMaterialByName(name: string): Nullable<Material>;
  35110. /**
  35111. * Get a texture using its unique id
  35112. * @param uniqueId defines the texture's unique id
  35113. * @return the texture or null if none found.
  35114. */
  35115. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35116. /**
  35117. * Gets a camera using its id
  35118. * @param id defines the id to look for
  35119. * @returns the camera or null if not found
  35120. */
  35121. getCameraByID(id: string): Nullable<Camera>;
  35122. /**
  35123. * Gets a camera using its unique id
  35124. * @param uniqueId defines the unique id to look for
  35125. * @returns the camera or null if not found
  35126. */
  35127. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35128. /**
  35129. * Gets a camera using its name
  35130. * @param name defines the camera's name
  35131. * @return the camera or null if none found.
  35132. */
  35133. getCameraByName(name: string): Nullable<Camera>;
  35134. /**
  35135. * Gets a bone using its id
  35136. * @param id defines the bone's id
  35137. * @return the bone or null if not found
  35138. */
  35139. getBoneByID(id: string): Nullable<Bone>;
  35140. /**
  35141. * Gets a bone using its id
  35142. * @param name defines the bone's name
  35143. * @return the bone or null if not found
  35144. */
  35145. getBoneByName(name: string): Nullable<Bone>;
  35146. /**
  35147. * Gets a light node using its name
  35148. * @param name defines the the light's name
  35149. * @return the light or null if none found.
  35150. */
  35151. getLightByName(name: string): Nullable<Light>;
  35152. /**
  35153. * Gets a light node using its id
  35154. * @param id defines the light's id
  35155. * @return the light or null if none found.
  35156. */
  35157. getLightByID(id: string): Nullable<Light>;
  35158. /**
  35159. * Gets a light node using its scene-generated unique ID
  35160. * @param uniqueId defines the light's unique id
  35161. * @return the light or null if none found.
  35162. */
  35163. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35164. /**
  35165. * Gets a particle system by id
  35166. * @param id defines the particle system id
  35167. * @return the corresponding system or null if none found
  35168. */
  35169. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35170. /**
  35171. * Gets a geometry using its ID
  35172. * @param id defines the geometry's id
  35173. * @return the geometry or null if none found.
  35174. */
  35175. getGeometryByID(id: string): Nullable<Geometry>;
  35176. private _getGeometryByUniqueID;
  35177. /**
  35178. * Add a new geometry to this scene
  35179. * @param geometry defines the geometry to be added to the scene.
  35180. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35181. * @return a boolean defining if the geometry was added or not
  35182. */
  35183. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35184. /**
  35185. * Removes an existing geometry
  35186. * @param geometry defines the geometry to be removed from the scene
  35187. * @return a boolean defining if the geometry was removed or not
  35188. */
  35189. removeGeometry(geometry: Geometry): boolean;
  35190. /**
  35191. * Gets the list of geometries attached to the scene
  35192. * @returns an array of Geometry
  35193. */
  35194. getGeometries(): Geometry[];
  35195. /**
  35196. * Gets the first added mesh found of a given ID
  35197. * @param id defines the id to search for
  35198. * @return the mesh found or null if not found at all
  35199. */
  35200. getMeshByID(id: string): Nullable<AbstractMesh>;
  35201. /**
  35202. * Gets a list of meshes using their id
  35203. * @param id defines the id to search for
  35204. * @returns a list of meshes
  35205. */
  35206. getMeshesByID(id: string): Array<AbstractMesh>;
  35207. /**
  35208. * Gets the first added transform node found of a given ID
  35209. * @param id defines the id to search for
  35210. * @return the found transform node or null if not found at all.
  35211. */
  35212. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35213. /**
  35214. * Gets a transform node with its auto-generated unique id
  35215. * @param uniqueId efines the unique id to search for
  35216. * @return the found transform node or null if not found at all.
  35217. */
  35218. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35219. /**
  35220. * Gets a list of transform nodes using their id
  35221. * @param id defines the id to search for
  35222. * @returns a list of transform nodes
  35223. */
  35224. getTransformNodesByID(id: string): Array<TransformNode>;
  35225. /**
  35226. * Gets a mesh with its auto-generated unique id
  35227. * @param uniqueId defines the unique id to search for
  35228. * @return the found mesh or null if not found at all.
  35229. */
  35230. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35231. /**
  35232. * Gets a the last added mesh using a given id
  35233. * @param id defines the id to search for
  35234. * @return the found mesh or null if not found at all.
  35235. */
  35236. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35237. /**
  35238. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35239. * @param id defines the id to search for
  35240. * @return the found node or null if not found at all
  35241. */
  35242. getLastEntryByID(id: string): Nullable<Node>;
  35243. /**
  35244. * Gets a node (Mesh, Camera, Light) using a given id
  35245. * @param id defines the id to search for
  35246. * @return the found node or null if not found at all
  35247. */
  35248. getNodeByID(id: string): Nullable<Node>;
  35249. /**
  35250. * Gets a node (Mesh, Camera, Light) using a given name
  35251. * @param name defines the name to search for
  35252. * @return the found node or null if not found at all.
  35253. */
  35254. getNodeByName(name: string): Nullable<Node>;
  35255. /**
  35256. * Gets a mesh using a given name
  35257. * @param name defines the name to search for
  35258. * @return the found mesh or null if not found at all.
  35259. */
  35260. getMeshByName(name: string): Nullable<AbstractMesh>;
  35261. /**
  35262. * Gets a transform node using a given name
  35263. * @param name defines the name to search for
  35264. * @return the found transform node or null if not found at all.
  35265. */
  35266. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35267. /**
  35268. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35269. * @param id defines the id to search for
  35270. * @return the found skeleton or null if not found at all.
  35271. */
  35272. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35273. /**
  35274. * Gets a skeleton using a given auto generated unique id
  35275. * @param uniqueId defines the unique id to search for
  35276. * @return the found skeleton or null if not found at all.
  35277. */
  35278. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35279. /**
  35280. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35281. * @param id defines the id to search for
  35282. * @return the found skeleton or null if not found at all.
  35283. */
  35284. getSkeletonById(id: string): Nullable<Skeleton>;
  35285. /**
  35286. * Gets a skeleton using a given name
  35287. * @param name defines the name to search for
  35288. * @return the found skeleton or null if not found at all.
  35289. */
  35290. getSkeletonByName(name: string): Nullable<Skeleton>;
  35291. /**
  35292. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35293. * @param id defines the id to search for
  35294. * @return the found morph target manager or null if not found at all.
  35295. */
  35296. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35297. /**
  35298. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35299. * @param id defines the id to search for
  35300. * @return the found morph target or null if not found at all.
  35301. */
  35302. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35303. /**
  35304. * Gets a boolean indicating if the given mesh is active
  35305. * @param mesh defines the mesh to look for
  35306. * @returns true if the mesh is in the active list
  35307. */
  35308. isActiveMesh(mesh: AbstractMesh): boolean;
  35309. /**
  35310. * Return a unique id as a string which can serve as an identifier for the scene
  35311. */
  35312. readonly uid: string;
  35313. /**
  35314. * Add an externaly attached data from its key.
  35315. * This method call will fail and return false, if such key already exists.
  35316. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35317. * @param key the unique key that identifies the data
  35318. * @param data the data object to associate to the key for this Engine instance
  35319. * @return true if no such key were already present and the data was added successfully, false otherwise
  35320. */
  35321. addExternalData<T>(key: string, data: T): boolean;
  35322. /**
  35323. * Get an externaly attached data from its key
  35324. * @param key the unique key that identifies the data
  35325. * @return the associated data, if present (can be null), or undefined if not present
  35326. */
  35327. getExternalData<T>(key: string): Nullable<T>;
  35328. /**
  35329. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35330. * @param key the unique key that identifies the data
  35331. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35332. * @return the associated data, can be null if the factory returned null.
  35333. */
  35334. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35335. /**
  35336. * Remove an externaly attached data from the Engine instance
  35337. * @param key the unique key that identifies the data
  35338. * @return true if the data was successfully removed, false if it doesn't exist
  35339. */
  35340. removeExternalData(key: string): boolean;
  35341. private _evaluateSubMesh;
  35342. /**
  35343. * Clear the processed materials smart array preventing retention point in material dispose.
  35344. */
  35345. freeProcessedMaterials(): void;
  35346. private _preventFreeActiveMeshesAndRenderingGroups;
  35347. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35348. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35349. * when disposing several meshes in a row or a hierarchy of meshes.
  35350. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35351. */
  35352. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35353. /**
  35354. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35355. */
  35356. freeActiveMeshes(): void;
  35357. /**
  35358. * Clear the info related to rendering groups preventing retention points during dispose.
  35359. */
  35360. freeRenderingGroups(): void;
  35361. /** @hidden */
  35362. _isInIntermediateRendering(): boolean;
  35363. /**
  35364. * Lambda returning the list of potentially active meshes.
  35365. */
  35366. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35367. /**
  35368. * Lambda returning the list of potentially active sub meshes.
  35369. */
  35370. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35371. /**
  35372. * Lambda returning the list of potentially intersecting sub meshes.
  35373. */
  35374. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35375. /**
  35376. * Lambda returning the list of potentially colliding sub meshes.
  35377. */
  35378. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35379. private _activeMeshesFrozen;
  35380. /**
  35381. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35382. * @returns the current scene
  35383. */
  35384. freezeActiveMeshes(): Scene;
  35385. /**
  35386. * Use this function to restart evaluating active meshes on every frame
  35387. * @returns the current scene
  35388. */
  35389. unfreezeActiveMeshes(): Scene;
  35390. private _evaluateActiveMeshes;
  35391. private _activeMesh;
  35392. /**
  35393. * Update the transform matrix to update from the current active camera
  35394. * @param force defines a boolean used to force the update even if cache is up to date
  35395. */
  35396. updateTransformMatrix(force?: boolean): void;
  35397. private _bindFrameBuffer;
  35398. /** @hidden */
  35399. _allowPostProcessClearColor: boolean;
  35400. /** @hidden */
  35401. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35402. private _processSubCameras;
  35403. private _checkIntersections;
  35404. /** @hidden */
  35405. _advancePhysicsEngineStep(step: number): void;
  35406. /**
  35407. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35408. */
  35409. getDeterministicFrameTime: () => number;
  35410. /** @hidden */
  35411. _animate(): void;
  35412. /** Execute all animations (for a frame) */
  35413. animate(): void;
  35414. /**
  35415. * Render the scene
  35416. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35417. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35418. */
  35419. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35420. /**
  35421. * Freeze all materials
  35422. * A frozen material will not be updatable but should be faster to render
  35423. */
  35424. freezeMaterials(): void;
  35425. /**
  35426. * Unfreeze all materials
  35427. * A frozen material will not be updatable but should be faster to render
  35428. */
  35429. unfreezeMaterials(): void;
  35430. /**
  35431. * Releases all held ressources
  35432. */
  35433. dispose(): void;
  35434. /**
  35435. * Gets if the scene is already disposed
  35436. */
  35437. readonly isDisposed: boolean;
  35438. /**
  35439. * Call this function to reduce memory footprint of the scene.
  35440. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35441. */
  35442. clearCachedVertexData(): void;
  35443. /**
  35444. * This function will remove the local cached buffer data from texture.
  35445. * It will save memory but will prevent the texture from being rebuilt
  35446. */
  35447. cleanCachedTextureBuffer(): void;
  35448. /**
  35449. * Get the world extend vectors with an optional filter
  35450. *
  35451. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35452. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35453. */
  35454. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35455. min: Vector3;
  35456. max: Vector3;
  35457. };
  35458. /**
  35459. * Creates a ray that can be used to pick in the scene
  35460. * @param x defines the x coordinate of the origin (on-screen)
  35461. * @param y defines the y coordinate of the origin (on-screen)
  35462. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35463. * @param camera defines the camera to use for the picking
  35464. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35465. * @returns a Ray
  35466. */
  35467. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35468. /**
  35469. * Creates a ray that can be used to pick in the scene
  35470. * @param x defines the x coordinate of the origin (on-screen)
  35471. * @param y defines the y coordinate of the origin (on-screen)
  35472. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35473. * @param result defines the ray where to store the picking ray
  35474. * @param camera defines the camera to use for the picking
  35475. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35476. * @returns the current scene
  35477. */
  35478. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35479. /**
  35480. * Creates a ray that can be used to pick in the scene
  35481. * @param x defines the x coordinate of the origin (on-screen)
  35482. * @param y defines the y coordinate of the origin (on-screen)
  35483. * @param camera defines the camera to use for the picking
  35484. * @returns a Ray
  35485. */
  35486. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35487. /**
  35488. * Creates a ray that can be used to pick in the scene
  35489. * @param x defines the x coordinate of the origin (on-screen)
  35490. * @param y defines the y coordinate of the origin (on-screen)
  35491. * @param result defines the ray where to store the picking ray
  35492. * @param camera defines the camera to use for the picking
  35493. * @returns the current scene
  35494. */
  35495. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35496. /** Launch a ray to try to pick a mesh in the scene
  35497. * @param x position on screen
  35498. * @param y position on screen
  35499. * @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
  35500. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35501. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35502. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35503. * @returns a PickingInfo
  35504. */
  35505. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35506. /** Use the given ray to pick a mesh in the scene
  35507. * @param ray The ray to use to pick meshes
  35508. * @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
  35509. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35510. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35511. * @returns a PickingInfo
  35512. */
  35513. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35514. /**
  35515. * Launch a ray to try to pick a mesh in the scene
  35516. * @param x X position on screen
  35517. * @param y Y position on screen
  35518. * @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
  35519. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35520. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35521. * @returns an array of PickingInfo
  35522. */
  35523. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35524. /**
  35525. * Launch a ray to try to pick a mesh in the scene
  35526. * @param ray Ray to use
  35527. * @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
  35528. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35529. * @returns an array of PickingInfo
  35530. */
  35531. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35532. /**
  35533. * Force the value of meshUnderPointer
  35534. * @param mesh defines the mesh to use
  35535. */
  35536. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35537. /**
  35538. * Gets the mesh under the pointer
  35539. * @returns a Mesh or null if no mesh is under the pointer
  35540. */
  35541. getPointerOverMesh(): Nullable<AbstractMesh>;
  35542. /** @hidden */
  35543. _rebuildGeometries(): void;
  35544. /** @hidden */
  35545. _rebuildTextures(): void;
  35546. private _getByTags;
  35547. /**
  35548. * Get a list of meshes by tags
  35549. * @param tagsQuery defines the tags query to use
  35550. * @param forEach defines a predicate used to filter results
  35551. * @returns an array of Mesh
  35552. */
  35553. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35554. /**
  35555. * Get a list of cameras by tags
  35556. * @param tagsQuery defines the tags query to use
  35557. * @param forEach defines a predicate used to filter results
  35558. * @returns an array of Camera
  35559. */
  35560. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35561. /**
  35562. * Get a list of lights by tags
  35563. * @param tagsQuery defines the tags query to use
  35564. * @param forEach defines a predicate used to filter results
  35565. * @returns an array of Light
  35566. */
  35567. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35568. /**
  35569. * Get a list of materials by tags
  35570. * @param tagsQuery defines the tags query to use
  35571. * @param forEach defines a predicate used to filter results
  35572. * @returns an array of Material
  35573. */
  35574. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35575. /**
  35576. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35577. * This allowed control for front to back rendering or reversly depending of the special needs.
  35578. *
  35579. * @param renderingGroupId The rendering group id corresponding to its index
  35580. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35581. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35582. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35583. */
  35584. 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;
  35585. /**
  35586. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35587. *
  35588. * @param renderingGroupId The rendering group id corresponding to its index
  35589. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35590. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35591. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35592. */
  35593. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35594. /**
  35595. * Gets the current auto clear configuration for one rendering group of the rendering
  35596. * manager.
  35597. * @param index the rendering group index to get the information for
  35598. * @returns The auto clear setup for the requested rendering group
  35599. */
  35600. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35601. private _blockMaterialDirtyMechanism;
  35602. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35603. blockMaterialDirtyMechanism: boolean;
  35604. /**
  35605. * Will flag all materials as dirty to trigger new shader compilation
  35606. * @param flag defines the flag used to specify which material part must be marked as dirty
  35607. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35608. */
  35609. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35610. /** @hidden */
  35611. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  35612. /** @hidden */
  35613. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35614. }
  35615. }
  35616. declare module "babylonjs/assetContainer" {
  35617. import { AbstractScene } from "babylonjs/abstractScene";
  35618. import { Scene } from "babylonjs/scene";
  35619. import { Mesh } from "babylonjs/Meshes/mesh";
  35620. /**
  35621. * Set of assets to keep when moving a scene into an asset container.
  35622. */
  35623. export class KeepAssets extends AbstractScene {
  35624. }
  35625. /**
  35626. * Container with a set of assets that can be added or removed from a scene.
  35627. */
  35628. export class AssetContainer extends AbstractScene {
  35629. /**
  35630. * The scene the AssetContainer belongs to.
  35631. */
  35632. scene: Scene;
  35633. /**
  35634. * Instantiates an AssetContainer.
  35635. * @param scene The scene the AssetContainer belongs to.
  35636. */
  35637. constructor(scene: Scene);
  35638. /**
  35639. * Adds all the assets from the container to the scene.
  35640. */
  35641. addAllToScene(): void;
  35642. /**
  35643. * Removes all the assets in the container from the scene
  35644. */
  35645. removeAllFromScene(): void;
  35646. /**
  35647. * Disposes all the assets in the container
  35648. */
  35649. dispose(): void;
  35650. private _moveAssets;
  35651. /**
  35652. * Removes all the assets contained in the scene and adds them to the container.
  35653. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35654. */
  35655. moveAllFromScene(keepAssets?: KeepAssets): void;
  35656. /**
  35657. * 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.
  35658. * @returns the root mesh
  35659. */
  35660. createRootMesh(): Mesh;
  35661. }
  35662. }
  35663. declare module "babylonjs/abstractScene" {
  35664. import { Scene } from "babylonjs/scene";
  35665. import { Nullable } from "babylonjs/types";
  35666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35667. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35668. import { Geometry } from "babylonjs/Meshes/geometry";
  35669. import { Skeleton } from "babylonjs/Bones/skeleton";
  35670. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35671. import { AssetContainer } from "babylonjs/assetContainer";
  35672. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35673. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35674. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35675. import { Material } from "babylonjs/Materials/material";
  35676. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35677. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35678. import { Camera } from "babylonjs/Cameras/camera";
  35679. import { Light } from "babylonjs/Lights/light";
  35680. import { Node } from "babylonjs/node";
  35681. import { Animation } from "babylonjs/Animations/animation";
  35682. /**
  35683. * Defines how the parser contract is defined.
  35684. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35685. */
  35686. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35687. /**
  35688. * Defines how the individual parser contract is defined.
  35689. * These parser can parse an individual asset
  35690. */
  35691. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35692. /**
  35693. * Base class of the scene acting as a container for the different elements composing a scene.
  35694. * This class is dynamically extended by the different components of the scene increasing
  35695. * flexibility and reducing coupling
  35696. */
  35697. export abstract class AbstractScene {
  35698. /**
  35699. * Stores the list of available parsers in the application.
  35700. */
  35701. private static _BabylonFileParsers;
  35702. /**
  35703. * Stores the list of available individual parsers in the application.
  35704. */
  35705. private static _IndividualBabylonFileParsers;
  35706. /**
  35707. * Adds a parser in the list of available ones
  35708. * @param name Defines the name of the parser
  35709. * @param parser Defines the parser to add
  35710. */
  35711. static AddParser(name: string, parser: BabylonFileParser): void;
  35712. /**
  35713. * Gets a general parser from the list of avaialble ones
  35714. * @param name Defines the name of the parser
  35715. * @returns the requested parser or null
  35716. */
  35717. static GetParser(name: string): Nullable<BabylonFileParser>;
  35718. /**
  35719. * Adds n individual parser in the list of available ones
  35720. * @param name Defines the name of the parser
  35721. * @param parser Defines the parser to add
  35722. */
  35723. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35724. /**
  35725. * Gets an individual parser from the list of avaialble ones
  35726. * @param name Defines the name of the parser
  35727. * @returns the requested parser or null
  35728. */
  35729. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35730. /**
  35731. * Parser json data and populate both a scene and its associated container object
  35732. * @param jsonData Defines the data to parse
  35733. * @param scene Defines the scene to parse the data for
  35734. * @param container Defines the container attached to the parsing sequence
  35735. * @param rootUrl Defines the root url of the data
  35736. */
  35737. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35738. /**
  35739. * Gets the list of root nodes (ie. nodes with no parent)
  35740. */
  35741. rootNodes: Node[];
  35742. /** All of the cameras added to this scene
  35743. * @see http://doc.babylonjs.com/babylon101/cameras
  35744. */
  35745. cameras: Camera[];
  35746. /**
  35747. * All of the lights added to this scene
  35748. * @see http://doc.babylonjs.com/babylon101/lights
  35749. */
  35750. lights: Light[];
  35751. /**
  35752. * All of the (abstract) meshes added to this scene
  35753. */
  35754. meshes: AbstractMesh[];
  35755. /**
  35756. * The list of skeletons added to the scene
  35757. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35758. */
  35759. skeletons: Skeleton[];
  35760. /**
  35761. * All of the particle systems added to this scene
  35762. * @see http://doc.babylonjs.com/babylon101/particles
  35763. */
  35764. particleSystems: IParticleSystem[];
  35765. /**
  35766. * Gets a list of Animations associated with the scene
  35767. */
  35768. animations: Animation[];
  35769. /**
  35770. * All of the animation groups added to this scene
  35771. * @see http://doc.babylonjs.com/how_to/group
  35772. */
  35773. animationGroups: AnimationGroup[];
  35774. /**
  35775. * All of the multi-materials added to this scene
  35776. * @see http://doc.babylonjs.com/how_to/multi_materials
  35777. */
  35778. multiMaterials: MultiMaterial[];
  35779. /**
  35780. * All of the materials added to this scene
  35781. * In the context of a Scene, it is not supposed to be modified manually.
  35782. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35783. * Note also that the order of the Material wihin the array is not significant and might change.
  35784. * @see http://doc.babylonjs.com/babylon101/materials
  35785. */
  35786. materials: Material[];
  35787. /**
  35788. * The list of morph target managers added to the scene
  35789. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35790. */
  35791. morphTargetManagers: MorphTargetManager[];
  35792. /**
  35793. * The list of geometries used in the scene.
  35794. */
  35795. geometries: Geometry[];
  35796. /**
  35797. * All of the tranform nodes added to this scene
  35798. * In the context of a Scene, it is not supposed to be modified manually.
  35799. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35800. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35801. * @see http://doc.babylonjs.com/how_to/transformnode
  35802. */
  35803. transformNodes: TransformNode[];
  35804. /**
  35805. * ActionManagers available on the scene.
  35806. */
  35807. actionManagers: AbstractActionManager[];
  35808. /**
  35809. * Textures to keep.
  35810. */
  35811. textures: BaseTexture[];
  35812. /**
  35813. * Environment texture for the scene
  35814. */
  35815. environmentTexture: Nullable<BaseTexture>;
  35816. }
  35817. }
  35818. declare module "babylonjs/Audio/sound" {
  35819. import { Observable } from "babylonjs/Misc/observable";
  35820. import { Vector3 } from "babylonjs/Maths/math.vector";
  35821. import { Nullable } from "babylonjs/types";
  35822. import { Scene } from "babylonjs/scene";
  35823. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35824. /**
  35825. * Interface used to define options for Sound class
  35826. */
  35827. export interface ISoundOptions {
  35828. /**
  35829. * Does the sound autoplay once loaded.
  35830. */
  35831. autoplay?: boolean;
  35832. /**
  35833. * Does the sound loop after it finishes playing once.
  35834. */
  35835. loop?: boolean;
  35836. /**
  35837. * Sound's volume
  35838. */
  35839. volume?: number;
  35840. /**
  35841. * Is it a spatial sound?
  35842. */
  35843. spatialSound?: boolean;
  35844. /**
  35845. * Maximum distance to hear that sound
  35846. */
  35847. maxDistance?: number;
  35848. /**
  35849. * Uses user defined attenuation function
  35850. */
  35851. useCustomAttenuation?: boolean;
  35852. /**
  35853. * Define the roll off factor of spatial sounds.
  35854. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35855. */
  35856. rolloffFactor?: number;
  35857. /**
  35858. * Define the reference distance the sound should be heard perfectly.
  35859. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35860. */
  35861. refDistance?: number;
  35862. /**
  35863. * Define the distance attenuation model the sound will follow.
  35864. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35865. */
  35866. distanceModel?: string;
  35867. /**
  35868. * Defines the playback speed (1 by default)
  35869. */
  35870. playbackRate?: number;
  35871. /**
  35872. * Defines if the sound is from a streaming source
  35873. */
  35874. streaming?: boolean;
  35875. /**
  35876. * Defines an optional length (in seconds) inside the sound file
  35877. */
  35878. length?: number;
  35879. /**
  35880. * Defines an optional offset (in seconds) inside the sound file
  35881. */
  35882. offset?: number;
  35883. /**
  35884. * If true, URLs will not be required to state the audio file codec to use.
  35885. */
  35886. skipCodecCheck?: boolean;
  35887. }
  35888. /**
  35889. * Defines a sound that can be played in the application.
  35890. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35892. */
  35893. export class Sound {
  35894. /**
  35895. * The name of the sound in the scene.
  35896. */
  35897. name: string;
  35898. /**
  35899. * Does the sound autoplay once loaded.
  35900. */
  35901. autoplay: boolean;
  35902. /**
  35903. * Does the sound loop after it finishes playing once.
  35904. */
  35905. loop: boolean;
  35906. /**
  35907. * Does the sound use a custom attenuation curve to simulate the falloff
  35908. * happening when the source gets further away from the camera.
  35909. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35910. */
  35911. useCustomAttenuation: boolean;
  35912. /**
  35913. * The sound track id this sound belongs to.
  35914. */
  35915. soundTrackId: number;
  35916. /**
  35917. * Is this sound currently played.
  35918. */
  35919. isPlaying: boolean;
  35920. /**
  35921. * Is this sound currently paused.
  35922. */
  35923. isPaused: boolean;
  35924. /**
  35925. * Does this sound enables spatial sound.
  35926. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35927. */
  35928. spatialSound: boolean;
  35929. /**
  35930. * Define the reference distance the sound should be heard perfectly.
  35931. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35932. */
  35933. refDistance: number;
  35934. /**
  35935. * Define the roll off factor of spatial sounds.
  35936. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35937. */
  35938. rolloffFactor: number;
  35939. /**
  35940. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35941. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35942. */
  35943. maxDistance: number;
  35944. /**
  35945. * Define the distance attenuation model the sound will follow.
  35946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35947. */
  35948. distanceModel: string;
  35949. /**
  35950. * @hidden
  35951. * Back Compat
  35952. **/
  35953. onended: () => any;
  35954. /**
  35955. * Observable event when the current playing sound finishes.
  35956. */
  35957. onEndedObservable: Observable<Sound>;
  35958. private _panningModel;
  35959. private _playbackRate;
  35960. private _streaming;
  35961. private _startTime;
  35962. private _startOffset;
  35963. private _position;
  35964. /** @hidden */
  35965. _positionInEmitterSpace: boolean;
  35966. private _localDirection;
  35967. private _volume;
  35968. private _isReadyToPlay;
  35969. private _isDirectional;
  35970. private _readyToPlayCallback;
  35971. private _audioBuffer;
  35972. private _soundSource;
  35973. private _streamingSource;
  35974. private _soundPanner;
  35975. private _soundGain;
  35976. private _inputAudioNode;
  35977. private _outputAudioNode;
  35978. private _coneInnerAngle;
  35979. private _coneOuterAngle;
  35980. private _coneOuterGain;
  35981. private _scene;
  35982. private _connectedTransformNode;
  35983. private _customAttenuationFunction;
  35984. private _registerFunc;
  35985. private _isOutputConnected;
  35986. private _htmlAudioElement;
  35987. private _urlType;
  35988. private _length?;
  35989. private _offset?;
  35990. /** @hidden */
  35991. static _SceneComponentInitialization: (scene: Scene) => void;
  35992. /**
  35993. * Create a sound and attach it to a scene
  35994. * @param name Name of your sound
  35995. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35996. * @param scene defines the scene the sound belongs to
  35997. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35998. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35999. */
  36000. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36001. /**
  36002. * Release the sound and its associated resources
  36003. */
  36004. dispose(): void;
  36005. /**
  36006. * Gets if the sounds is ready to be played or not.
  36007. * @returns true if ready, otherwise false
  36008. */
  36009. isReady(): boolean;
  36010. private _soundLoaded;
  36011. /**
  36012. * Sets the data of the sound from an audiobuffer
  36013. * @param audioBuffer The audioBuffer containing the data
  36014. */
  36015. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36016. /**
  36017. * Updates the current sounds options such as maxdistance, loop...
  36018. * @param options A JSON object containing values named as the object properties
  36019. */
  36020. updateOptions(options: ISoundOptions): void;
  36021. private _createSpatialParameters;
  36022. private _updateSpatialParameters;
  36023. /**
  36024. * Switch the panning model to HRTF:
  36025. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36027. */
  36028. switchPanningModelToHRTF(): void;
  36029. /**
  36030. * Switch the panning model to Equal Power:
  36031. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36032. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36033. */
  36034. switchPanningModelToEqualPower(): void;
  36035. private _switchPanningModel;
  36036. /**
  36037. * Connect this sound to a sound track audio node like gain...
  36038. * @param soundTrackAudioNode the sound track audio node to connect to
  36039. */
  36040. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36041. /**
  36042. * Transform this sound into a directional source
  36043. * @param coneInnerAngle Size of the inner cone in degree
  36044. * @param coneOuterAngle Size of the outer cone in degree
  36045. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36046. */
  36047. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36048. /**
  36049. * Gets or sets the inner angle for the directional cone.
  36050. */
  36051. /**
  36052. * Gets or sets the inner angle for the directional cone.
  36053. */
  36054. directionalConeInnerAngle: number;
  36055. /**
  36056. * Gets or sets the outer angle for the directional cone.
  36057. */
  36058. /**
  36059. * Gets or sets the outer angle for the directional cone.
  36060. */
  36061. directionalConeOuterAngle: number;
  36062. /**
  36063. * Sets the position of the emitter if spatial sound is enabled
  36064. * @param newPosition Defines the new posisiton
  36065. */
  36066. setPosition(newPosition: Vector3): void;
  36067. /**
  36068. * Sets the local direction of the emitter if spatial sound is enabled
  36069. * @param newLocalDirection Defines the new local direction
  36070. */
  36071. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36072. private _updateDirection;
  36073. /** @hidden */
  36074. updateDistanceFromListener(): void;
  36075. /**
  36076. * Sets a new custom attenuation function for the sound.
  36077. * @param callback Defines the function used for the attenuation
  36078. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36079. */
  36080. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36081. /**
  36082. * Play the sound
  36083. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36084. * @param offset (optional) Start the sound at a specific time in seconds
  36085. * @param length (optional) Sound duration (in seconds)
  36086. */
  36087. play(time?: number, offset?: number, length?: number): void;
  36088. private _onended;
  36089. /**
  36090. * Stop the sound
  36091. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36092. */
  36093. stop(time?: number): void;
  36094. /**
  36095. * Put the sound in pause
  36096. */
  36097. pause(): void;
  36098. /**
  36099. * Sets a dedicated volume for this sounds
  36100. * @param newVolume Define the new volume of the sound
  36101. * @param time Define time for gradual change to new volume
  36102. */
  36103. setVolume(newVolume: number, time?: number): void;
  36104. /**
  36105. * Set the sound play back rate
  36106. * @param newPlaybackRate Define the playback rate the sound should be played at
  36107. */
  36108. setPlaybackRate(newPlaybackRate: number): void;
  36109. /**
  36110. * Gets the volume of the sound.
  36111. * @returns the volume of the sound
  36112. */
  36113. getVolume(): number;
  36114. /**
  36115. * Attach the sound to a dedicated mesh
  36116. * @param transformNode The transform node to connect the sound with
  36117. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36118. */
  36119. attachToMesh(transformNode: TransformNode): void;
  36120. /**
  36121. * Detach the sound from the previously attached mesh
  36122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36123. */
  36124. detachFromMesh(): void;
  36125. private _onRegisterAfterWorldMatrixUpdate;
  36126. /**
  36127. * Clone the current sound in the scene.
  36128. * @returns the new sound clone
  36129. */
  36130. clone(): Nullable<Sound>;
  36131. /**
  36132. * Gets the current underlying audio buffer containing the data
  36133. * @returns the audio buffer
  36134. */
  36135. getAudioBuffer(): Nullable<AudioBuffer>;
  36136. /**
  36137. * Serializes the Sound in a JSON representation
  36138. * @returns the JSON representation of the sound
  36139. */
  36140. serialize(): any;
  36141. /**
  36142. * Parse a JSON representation of a sound to innstantiate in a given scene
  36143. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36144. * @param scene Define the scene the new parsed sound should be created in
  36145. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36146. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36147. * @returns the newly parsed sound
  36148. */
  36149. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36150. }
  36151. }
  36152. declare module "babylonjs/Actions/directAudioActions" {
  36153. import { Action } from "babylonjs/Actions/action";
  36154. import { Condition } from "babylonjs/Actions/condition";
  36155. import { Sound } from "babylonjs/Audio/sound";
  36156. /**
  36157. * This defines an action helpful to play a defined sound on a triggered action.
  36158. */
  36159. export class PlaySoundAction extends Action {
  36160. private _sound;
  36161. /**
  36162. * Instantiate the action
  36163. * @param triggerOptions defines the trigger options
  36164. * @param sound defines the sound to play
  36165. * @param condition defines the trigger related conditions
  36166. */
  36167. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36168. /** @hidden */
  36169. _prepare(): void;
  36170. /**
  36171. * Execute the action and play the sound.
  36172. */
  36173. execute(): void;
  36174. /**
  36175. * Serializes the actions and its related information.
  36176. * @param parent defines the object to serialize in
  36177. * @returns the serialized object
  36178. */
  36179. serialize(parent: any): any;
  36180. }
  36181. /**
  36182. * This defines an action helpful to stop a defined sound on a triggered action.
  36183. */
  36184. export class StopSoundAction extends Action {
  36185. private _sound;
  36186. /**
  36187. * Instantiate the action
  36188. * @param triggerOptions defines the trigger options
  36189. * @param sound defines the sound to stop
  36190. * @param condition defines the trigger related conditions
  36191. */
  36192. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36193. /** @hidden */
  36194. _prepare(): void;
  36195. /**
  36196. * Execute the action and stop the sound.
  36197. */
  36198. execute(): void;
  36199. /**
  36200. * Serializes the actions and its related information.
  36201. * @param parent defines the object to serialize in
  36202. * @returns the serialized object
  36203. */
  36204. serialize(parent: any): any;
  36205. }
  36206. }
  36207. declare module "babylonjs/Actions/interpolateValueAction" {
  36208. import { Action } from "babylonjs/Actions/action";
  36209. import { Condition } from "babylonjs/Actions/condition";
  36210. import { Observable } from "babylonjs/Misc/observable";
  36211. /**
  36212. * This defines an action responsible to change the value of a property
  36213. * by interpolating between its current value and the newly set one once triggered.
  36214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36215. */
  36216. export class InterpolateValueAction extends Action {
  36217. /**
  36218. * Defines the path of the property where the value should be interpolated
  36219. */
  36220. propertyPath: string;
  36221. /**
  36222. * Defines the target value at the end of the interpolation.
  36223. */
  36224. value: any;
  36225. /**
  36226. * Defines the time it will take for the property to interpolate to the value.
  36227. */
  36228. duration: number;
  36229. /**
  36230. * Defines if the other scene animations should be stopped when the action has been triggered
  36231. */
  36232. stopOtherAnimations?: boolean;
  36233. /**
  36234. * Defines a callback raised once the interpolation animation has been done.
  36235. */
  36236. onInterpolationDone?: () => void;
  36237. /**
  36238. * Observable triggered once the interpolation animation has been done.
  36239. */
  36240. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36241. private _target;
  36242. private _effectiveTarget;
  36243. private _property;
  36244. /**
  36245. * Instantiate the action
  36246. * @param triggerOptions defines the trigger options
  36247. * @param target defines the object containing the value to interpolate
  36248. * @param propertyPath defines the path to the property in the target object
  36249. * @param value defines the target value at the end of the interpolation
  36250. * @param duration deines the time it will take for the property to interpolate to the value.
  36251. * @param condition defines the trigger related conditions
  36252. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36253. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36254. */
  36255. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36256. /** @hidden */
  36257. _prepare(): void;
  36258. /**
  36259. * Execute the action starts the value interpolation.
  36260. */
  36261. execute(): void;
  36262. /**
  36263. * Serializes the actions and its related information.
  36264. * @param parent defines the object to serialize in
  36265. * @returns the serialized object
  36266. */
  36267. serialize(parent: any): any;
  36268. }
  36269. }
  36270. declare module "babylonjs/Actions/index" {
  36271. export * from "babylonjs/Actions/abstractActionManager";
  36272. export * from "babylonjs/Actions/action";
  36273. export * from "babylonjs/Actions/actionEvent";
  36274. export * from "babylonjs/Actions/actionManager";
  36275. export * from "babylonjs/Actions/condition";
  36276. export * from "babylonjs/Actions/directActions";
  36277. export * from "babylonjs/Actions/directAudioActions";
  36278. export * from "babylonjs/Actions/interpolateValueAction";
  36279. }
  36280. declare module "babylonjs/Animations/index" {
  36281. export * from "babylonjs/Animations/animatable";
  36282. export * from "babylonjs/Animations/animation";
  36283. export * from "babylonjs/Animations/animationGroup";
  36284. export * from "babylonjs/Animations/animationPropertiesOverride";
  36285. export * from "babylonjs/Animations/easing";
  36286. export * from "babylonjs/Animations/runtimeAnimation";
  36287. export * from "babylonjs/Animations/animationEvent";
  36288. export * from "babylonjs/Animations/animationGroup";
  36289. export * from "babylonjs/Animations/animationKey";
  36290. export * from "babylonjs/Animations/animationRange";
  36291. export * from "babylonjs/Animations/animatable.interface";
  36292. }
  36293. declare module "babylonjs/Audio/soundTrack" {
  36294. import { Sound } from "babylonjs/Audio/sound";
  36295. import { Analyser } from "babylonjs/Audio/analyser";
  36296. import { Scene } from "babylonjs/scene";
  36297. /**
  36298. * Options allowed during the creation of a sound track.
  36299. */
  36300. export interface ISoundTrackOptions {
  36301. /**
  36302. * The volume the sound track should take during creation
  36303. */
  36304. volume?: number;
  36305. /**
  36306. * Define if the sound track is the main sound track of the scene
  36307. */
  36308. mainTrack?: boolean;
  36309. }
  36310. /**
  36311. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36312. * It will be also used in a future release to apply effects on a specific track.
  36313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36314. */
  36315. export class SoundTrack {
  36316. /**
  36317. * The unique identifier of the sound track in the scene.
  36318. */
  36319. id: number;
  36320. /**
  36321. * The list of sounds included in the sound track.
  36322. */
  36323. soundCollection: Array<Sound>;
  36324. private _outputAudioNode;
  36325. private _scene;
  36326. private _isMainTrack;
  36327. private _connectedAnalyser;
  36328. private _options;
  36329. private _isInitialized;
  36330. /**
  36331. * Creates a new sound track.
  36332. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36333. * @param scene Define the scene the sound track belongs to
  36334. * @param options
  36335. */
  36336. constructor(scene: Scene, options?: ISoundTrackOptions);
  36337. private _initializeSoundTrackAudioGraph;
  36338. /**
  36339. * Release the sound track and its associated resources
  36340. */
  36341. dispose(): void;
  36342. /**
  36343. * Adds a sound to this sound track
  36344. * @param sound define the cound to add
  36345. * @ignoreNaming
  36346. */
  36347. AddSound(sound: Sound): void;
  36348. /**
  36349. * Removes a sound to this sound track
  36350. * @param sound define the cound to remove
  36351. * @ignoreNaming
  36352. */
  36353. RemoveSound(sound: Sound): void;
  36354. /**
  36355. * Set a global volume for the full sound track.
  36356. * @param newVolume Define the new volume of the sound track
  36357. */
  36358. setVolume(newVolume: number): void;
  36359. /**
  36360. * Switch the panning model to HRTF:
  36361. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36363. */
  36364. switchPanningModelToHRTF(): void;
  36365. /**
  36366. * Switch the panning model to Equal Power:
  36367. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36368. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36369. */
  36370. switchPanningModelToEqualPower(): void;
  36371. /**
  36372. * Connect the sound track to an audio analyser allowing some amazing
  36373. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36374. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36375. * @param analyser The analyser to connect to the engine
  36376. */
  36377. connectToAnalyser(analyser: Analyser): void;
  36378. }
  36379. }
  36380. declare module "babylonjs/Audio/audioSceneComponent" {
  36381. import { Sound } from "babylonjs/Audio/sound";
  36382. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36383. import { Nullable } from "babylonjs/types";
  36384. import { Vector3 } from "babylonjs/Maths/math.vector";
  36385. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36386. import { Scene } from "babylonjs/scene";
  36387. import { AbstractScene } from "babylonjs/abstractScene";
  36388. import "babylonjs/Audio/audioEngine";
  36389. module "babylonjs/abstractScene" {
  36390. interface AbstractScene {
  36391. /**
  36392. * The list of sounds used in the scene.
  36393. */
  36394. sounds: Nullable<Array<Sound>>;
  36395. }
  36396. }
  36397. module "babylonjs/scene" {
  36398. interface Scene {
  36399. /**
  36400. * @hidden
  36401. * Backing field
  36402. */
  36403. _mainSoundTrack: SoundTrack;
  36404. /**
  36405. * The main sound track played by the scene.
  36406. * It cotains your primary collection of sounds.
  36407. */
  36408. mainSoundTrack: SoundTrack;
  36409. /**
  36410. * The list of sound tracks added to the scene
  36411. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36412. */
  36413. soundTracks: Nullable<Array<SoundTrack>>;
  36414. /**
  36415. * Gets a sound using a given name
  36416. * @param name defines the name to search for
  36417. * @return the found sound or null if not found at all.
  36418. */
  36419. getSoundByName(name: string): Nullable<Sound>;
  36420. /**
  36421. * Gets or sets if audio support is enabled
  36422. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36423. */
  36424. audioEnabled: boolean;
  36425. /**
  36426. * Gets or sets if audio will be output to headphones
  36427. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36428. */
  36429. headphone: boolean;
  36430. /**
  36431. * Gets or sets custom audio listener position provider
  36432. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36433. */
  36434. audioListenerPositionProvider: Nullable<() => Vector3>;
  36435. }
  36436. }
  36437. /**
  36438. * Defines the sound scene component responsible to manage any sounds
  36439. * in a given scene.
  36440. */
  36441. export class AudioSceneComponent implements ISceneSerializableComponent {
  36442. /**
  36443. * The component name helpfull to identify the component in the list of scene components.
  36444. */
  36445. readonly name: string;
  36446. /**
  36447. * The scene the component belongs to.
  36448. */
  36449. scene: Scene;
  36450. private _audioEnabled;
  36451. /**
  36452. * Gets whether audio is enabled or not.
  36453. * Please use related enable/disable method to switch state.
  36454. */
  36455. readonly audioEnabled: boolean;
  36456. private _headphone;
  36457. /**
  36458. * Gets whether audio is outputing to headphone or not.
  36459. * Please use the according Switch methods to change output.
  36460. */
  36461. readonly headphone: boolean;
  36462. private _audioListenerPositionProvider;
  36463. /**
  36464. * Gets the current audio listener position provider
  36465. */
  36466. /**
  36467. * Sets a custom listener position for all sounds in the scene
  36468. * By default, this is the position of the first active camera
  36469. */
  36470. audioListenerPositionProvider: Nullable<() => Vector3>;
  36471. /**
  36472. * Creates a new instance of the component for the given scene
  36473. * @param scene Defines the scene to register the component in
  36474. */
  36475. constructor(scene: Scene);
  36476. /**
  36477. * Registers the component in a given scene
  36478. */
  36479. register(): void;
  36480. /**
  36481. * Rebuilds the elements related to this component in case of
  36482. * context lost for instance.
  36483. */
  36484. rebuild(): void;
  36485. /**
  36486. * Serializes the component data to the specified json object
  36487. * @param serializationObject The object to serialize to
  36488. */
  36489. serialize(serializationObject: any): void;
  36490. /**
  36491. * Adds all the elements from the container to the scene
  36492. * @param container the container holding the elements
  36493. */
  36494. addFromContainer(container: AbstractScene): void;
  36495. /**
  36496. * Removes all the elements in the container from the scene
  36497. * @param container contains the elements to remove
  36498. * @param dispose if the removed element should be disposed (default: false)
  36499. */
  36500. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36501. /**
  36502. * Disposes the component and the associated ressources.
  36503. */
  36504. dispose(): void;
  36505. /**
  36506. * Disables audio in the associated scene.
  36507. */
  36508. disableAudio(): void;
  36509. /**
  36510. * Enables audio in the associated scene.
  36511. */
  36512. enableAudio(): void;
  36513. /**
  36514. * Switch audio to headphone output.
  36515. */
  36516. switchAudioModeForHeadphones(): void;
  36517. /**
  36518. * Switch audio to normal speakers.
  36519. */
  36520. switchAudioModeForNormalSpeakers(): void;
  36521. private _afterRender;
  36522. }
  36523. }
  36524. declare module "babylonjs/Audio/weightedsound" {
  36525. import { Sound } from "babylonjs/Audio/sound";
  36526. /**
  36527. * Wraps one or more Sound objects and selects one with random weight for playback.
  36528. */
  36529. export class WeightedSound {
  36530. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36531. loop: boolean;
  36532. private _coneInnerAngle;
  36533. private _coneOuterAngle;
  36534. private _volume;
  36535. /** A Sound is currently playing. */
  36536. isPlaying: boolean;
  36537. /** A Sound is currently paused. */
  36538. isPaused: boolean;
  36539. private _sounds;
  36540. private _weights;
  36541. private _currentIndex?;
  36542. /**
  36543. * Creates a new WeightedSound from the list of sounds given.
  36544. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36545. * @param sounds Array of Sounds that will be selected from.
  36546. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36547. */
  36548. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36549. /**
  36550. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36551. */
  36552. /**
  36553. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36554. */
  36555. directionalConeInnerAngle: number;
  36556. /**
  36557. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36558. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36559. */
  36560. /**
  36561. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36562. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36563. */
  36564. directionalConeOuterAngle: number;
  36565. /**
  36566. * Playback volume.
  36567. */
  36568. /**
  36569. * Playback volume.
  36570. */
  36571. volume: number;
  36572. private _onended;
  36573. /**
  36574. * Suspend playback
  36575. */
  36576. pause(): void;
  36577. /**
  36578. * Stop playback
  36579. */
  36580. stop(): void;
  36581. /**
  36582. * Start playback.
  36583. * @param startOffset Position the clip head at a specific time in seconds.
  36584. */
  36585. play(startOffset?: number): void;
  36586. }
  36587. }
  36588. declare module "babylonjs/Audio/index" {
  36589. export * from "babylonjs/Audio/analyser";
  36590. export * from "babylonjs/Audio/audioEngine";
  36591. export * from "babylonjs/Audio/audioSceneComponent";
  36592. export * from "babylonjs/Audio/sound";
  36593. export * from "babylonjs/Audio/soundTrack";
  36594. export * from "babylonjs/Audio/weightedsound";
  36595. }
  36596. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36597. import { Behavior } from "babylonjs/Behaviors/behavior";
  36598. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36599. import { BackEase } from "babylonjs/Animations/easing";
  36600. /**
  36601. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36602. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36603. */
  36604. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36605. /**
  36606. * Gets the name of the behavior.
  36607. */
  36608. readonly name: string;
  36609. /**
  36610. * The easing function used by animations
  36611. */
  36612. static EasingFunction: BackEase;
  36613. /**
  36614. * The easing mode used by animations
  36615. */
  36616. static EasingMode: number;
  36617. /**
  36618. * The duration of the animation, in milliseconds
  36619. */
  36620. transitionDuration: number;
  36621. /**
  36622. * Length of the distance animated by the transition when lower radius is reached
  36623. */
  36624. lowerRadiusTransitionRange: number;
  36625. /**
  36626. * Length of the distance animated by the transition when upper radius is reached
  36627. */
  36628. upperRadiusTransitionRange: number;
  36629. private _autoTransitionRange;
  36630. /**
  36631. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36632. */
  36633. /**
  36634. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36635. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36636. */
  36637. autoTransitionRange: boolean;
  36638. private _attachedCamera;
  36639. private _onAfterCheckInputsObserver;
  36640. private _onMeshTargetChangedObserver;
  36641. /**
  36642. * Initializes the behavior.
  36643. */
  36644. init(): void;
  36645. /**
  36646. * Attaches the behavior to its arc rotate camera.
  36647. * @param camera Defines the camera to attach the behavior to
  36648. */
  36649. attach(camera: ArcRotateCamera): void;
  36650. /**
  36651. * Detaches the behavior from its current arc rotate camera.
  36652. */
  36653. detach(): void;
  36654. private _radiusIsAnimating;
  36655. private _radiusBounceTransition;
  36656. private _animatables;
  36657. private _cachedWheelPrecision;
  36658. /**
  36659. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36660. * @param radiusLimit The limit to check against.
  36661. * @return Bool to indicate if at limit.
  36662. */
  36663. private _isRadiusAtLimit;
  36664. /**
  36665. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36666. * @param radiusDelta The delta by which to animate to. Can be negative.
  36667. */
  36668. private _applyBoundRadiusAnimation;
  36669. /**
  36670. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36671. */
  36672. protected _clearAnimationLocks(): void;
  36673. /**
  36674. * Stops and removes all animations that have been applied to the camera
  36675. */
  36676. stopAllAnimations(): void;
  36677. }
  36678. }
  36679. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36680. import { Behavior } from "babylonjs/Behaviors/behavior";
  36681. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36682. import { ExponentialEase } from "babylonjs/Animations/easing";
  36683. import { Nullable } from "babylonjs/types";
  36684. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36685. import { Vector3 } from "babylonjs/Maths/math.vector";
  36686. /**
  36687. * 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.
  36688. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36689. */
  36690. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36691. /**
  36692. * Gets the name of the behavior.
  36693. */
  36694. readonly name: string;
  36695. private _mode;
  36696. private _radiusScale;
  36697. private _positionScale;
  36698. private _defaultElevation;
  36699. private _elevationReturnTime;
  36700. private _elevationReturnWaitTime;
  36701. private _zoomStopsAnimation;
  36702. private _framingTime;
  36703. /**
  36704. * The easing function used by animations
  36705. */
  36706. static EasingFunction: ExponentialEase;
  36707. /**
  36708. * The easing mode used by animations
  36709. */
  36710. static EasingMode: number;
  36711. /**
  36712. * Sets the current mode used by the behavior
  36713. */
  36714. /**
  36715. * Gets current mode used by the behavior.
  36716. */
  36717. mode: number;
  36718. /**
  36719. * Sets the scale applied to the radius (1 by default)
  36720. */
  36721. /**
  36722. * Gets the scale applied to the radius
  36723. */
  36724. radiusScale: number;
  36725. /**
  36726. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36727. */
  36728. /**
  36729. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36730. */
  36731. positionScale: number;
  36732. /**
  36733. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36734. * behaviour is triggered, in radians.
  36735. */
  36736. /**
  36737. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36738. * behaviour is triggered, in radians.
  36739. */
  36740. defaultElevation: number;
  36741. /**
  36742. * Sets the time (in milliseconds) taken to return to the default beta position.
  36743. * Negative value indicates camera should not return to default.
  36744. */
  36745. /**
  36746. * Gets the time (in milliseconds) taken to return to the default beta position.
  36747. * Negative value indicates camera should not return to default.
  36748. */
  36749. elevationReturnTime: number;
  36750. /**
  36751. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36752. */
  36753. /**
  36754. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36755. */
  36756. elevationReturnWaitTime: number;
  36757. /**
  36758. * Sets the flag that indicates if user zooming should stop animation.
  36759. */
  36760. /**
  36761. * Gets the flag that indicates if user zooming should stop animation.
  36762. */
  36763. zoomStopsAnimation: boolean;
  36764. /**
  36765. * Sets the transition time when framing the mesh, in milliseconds
  36766. */
  36767. /**
  36768. * Gets the transition time when framing the mesh, in milliseconds
  36769. */
  36770. framingTime: number;
  36771. /**
  36772. * Define if the behavior should automatically change the configured
  36773. * camera limits and sensibilities.
  36774. */
  36775. autoCorrectCameraLimitsAndSensibility: boolean;
  36776. private _onPrePointerObservableObserver;
  36777. private _onAfterCheckInputsObserver;
  36778. private _onMeshTargetChangedObserver;
  36779. private _attachedCamera;
  36780. private _isPointerDown;
  36781. private _lastInteractionTime;
  36782. /**
  36783. * Initializes the behavior.
  36784. */
  36785. init(): void;
  36786. /**
  36787. * Attaches the behavior to its arc rotate camera.
  36788. * @param camera Defines the camera to attach the behavior to
  36789. */
  36790. attach(camera: ArcRotateCamera): void;
  36791. /**
  36792. * Detaches the behavior from its current arc rotate camera.
  36793. */
  36794. detach(): void;
  36795. private _animatables;
  36796. private _betaIsAnimating;
  36797. private _betaTransition;
  36798. private _radiusTransition;
  36799. private _vectorTransition;
  36800. /**
  36801. * Targets the given mesh and updates zoom level accordingly.
  36802. * @param mesh The mesh to target.
  36803. * @param radius Optional. If a cached radius position already exists, overrides default.
  36804. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36805. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36806. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36807. */
  36808. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36809. /**
  36810. * Targets the given mesh with its children and updates zoom level accordingly.
  36811. * @param mesh The mesh to target.
  36812. * @param radius Optional. If a cached radius position already exists, overrides default.
  36813. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36814. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36815. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36816. */
  36817. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36818. /**
  36819. * Targets the given meshes with their children and updates zoom level accordingly.
  36820. * @param meshes The mesh to target.
  36821. * @param radius Optional. If a cached radius position already exists, overrides default.
  36822. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36823. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36824. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36825. */
  36826. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36827. /**
  36828. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36829. * @param minimumWorld Determines the smaller position of the bounding box extend
  36830. * @param maximumWorld Determines the bigger position of the bounding box extend
  36831. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36832. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36833. */
  36834. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36835. /**
  36836. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36837. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36838. * frustum width.
  36839. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36840. * to fully enclose the mesh in the viewing frustum.
  36841. */
  36842. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36843. /**
  36844. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36845. * is automatically returned to its default position (expected to be above ground plane).
  36846. */
  36847. private _maintainCameraAboveGround;
  36848. /**
  36849. * Returns the frustum slope based on the canvas ratio and camera FOV
  36850. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36851. */
  36852. private _getFrustumSlope;
  36853. /**
  36854. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36855. */
  36856. private _clearAnimationLocks;
  36857. /**
  36858. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36859. */
  36860. private _applyUserInteraction;
  36861. /**
  36862. * Stops and removes all animations that have been applied to the camera
  36863. */
  36864. stopAllAnimations(): void;
  36865. /**
  36866. * Gets a value indicating if the user is moving the camera
  36867. */
  36868. readonly isUserIsMoving: boolean;
  36869. /**
  36870. * The camera can move all the way towards the mesh.
  36871. */
  36872. static IgnoreBoundsSizeMode: number;
  36873. /**
  36874. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36875. */
  36876. static FitFrustumSidesMode: number;
  36877. }
  36878. }
  36879. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36880. import { Nullable } from "babylonjs/types";
  36881. import { Camera } from "babylonjs/Cameras/camera";
  36882. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36883. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36884. /**
  36885. * Base class for Camera Pointer Inputs.
  36886. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36887. * for example usage.
  36888. */
  36889. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36890. /**
  36891. * Defines the camera the input is attached to.
  36892. */
  36893. abstract camera: Camera;
  36894. /**
  36895. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36896. */
  36897. protected _altKey: boolean;
  36898. protected _ctrlKey: boolean;
  36899. protected _metaKey: boolean;
  36900. protected _shiftKey: boolean;
  36901. /**
  36902. * Which mouse buttons were pressed at time of last mouse event.
  36903. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36904. */
  36905. protected _buttonsPressed: number;
  36906. /**
  36907. * Defines the buttons associated with the input to handle camera move.
  36908. */
  36909. buttons: number[];
  36910. /**
  36911. * Attach the input controls to a specific dom element to get the input from.
  36912. * @param element Defines the element the controls should be listened from
  36913. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36914. */
  36915. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36916. /**
  36917. * Detach the current controls from the specified dom element.
  36918. * @param element Defines the element to stop listening the inputs from
  36919. */
  36920. detachControl(element: Nullable<HTMLElement>): void;
  36921. /**
  36922. * Gets the class name of the current input.
  36923. * @returns the class name
  36924. */
  36925. getClassName(): string;
  36926. /**
  36927. * Get the friendly name associated with the input class.
  36928. * @returns the input friendly name
  36929. */
  36930. getSimpleName(): string;
  36931. /**
  36932. * Called on pointer POINTERDOUBLETAP event.
  36933. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36934. */
  36935. protected onDoubleTap(type: string): void;
  36936. /**
  36937. * Called on pointer POINTERMOVE event if only a single touch is active.
  36938. * Override this method to provide functionality.
  36939. */
  36940. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36941. /**
  36942. * Called on pointer POINTERMOVE event if multiple touches are active.
  36943. * Override this method to provide functionality.
  36944. */
  36945. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36946. /**
  36947. * Called on JS contextmenu event.
  36948. * Override this method to provide functionality.
  36949. */
  36950. protected onContextMenu(evt: PointerEvent): void;
  36951. /**
  36952. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36953. * press.
  36954. * Override this method to provide functionality.
  36955. */
  36956. protected onButtonDown(evt: PointerEvent): void;
  36957. /**
  36958. * Called each time a new POINTERUP event occurs. Ie, for each button
  36959. * release.
  36960. * Override this method to provide functionality.
  36961. */
  36962. protected onButtonUp(evt: PointerEvent): void;
  36963. /**
  36964. * Called when window becomes inactive.
  36965. * Override this method to provide functionality.
  36966. */
  36967. protected onLostFocus(): void;
  36968. private _pointerInput;
  36969. private _observer;
  36970. private _onLostFocus;
  36971. private pointA;
  36972. private pointB;
  36973. }
  36974. }
  36975. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36976. import { Nullable } from "babylonjs/types";
  36977. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36978. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36979. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36980. /**
  36981. * Manage the pointers inputs to control an arc rotate camera.
  36982. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36983. */
  36984. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36985. /**
  36986. * Defines the camera the input is attached to.
  36987. */
  36988. camera: ArcRotateCamera;
  36989. /**
  36990. * Gets the class name of the current input.
  36991. * @returns the class name
  36992. */
  36993. getClassName(): string;
  36994. /**
  36995. * Defines the buttons associated with the input to handle camera move.
  36996. */
  36997. buttons: number[];
  36998. /**
  36999. * Defines the pointer angular sensibility along the X axis or how fast is
  37000. * the camera rotating.
  37001. */
  37002. angularSensibilityX: number;
  37003. /**
  37004. * Defines the pointer angular sensibility along the Y axis or how fast is
  37005. * the camera rotating.
  37006. */
  37007. angularSensibilityY: number;
  37008. /**
  37009. * Defines the pointer pinch precision or how fast is the camera zooming.
  37010. */
  37011. pinchPrecision: number;
  37012. /**
  37013. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37014. * from 0.
  37015. * It defines the percentage of current camera.radius to use as delta when
  37016. * pinch zoom is used.
  37017. */
  37018. pinchDeltaPercentage: number;
  37019. /**
  37020. * Defines the pointer panning sensibility or how fast is the camera moving.
  37021. */
  37022. panningSensibility: number;
  37023. /**
  37024. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37025. */
  37026. multiTouchPanning: boolean;
  37027. /**
  37028. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37029. * zoom (pinch) through multitouch.
  37030. */
  37031. multiTouchPanAndZoom: boolean;
  37032. /**
  37033. * Revers pinch action direction.
  37034. */
  37035. pinchInwards: boolean;
  37036. private _isPanClick;
  37037. private _twoFingerActivityCount;
  37038. private _isPinching;
  37039. /**
  37040. * Called on pointer POINTERMOVE event if only a single touch is active.
  37041. */
  37042. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37043. /**
  37044. * Called on pointer POINTERDOUBLETAP event.
  37045. */
  37046. protected onDoubleTap(type: string): void;
  37047. /**
  37048. * Called on pointer POINTERMOVE event if multiple touches are active.
  37049. */
  37050. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37051. /**
  37052. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37053. * press.
  37054. */
  37055. protected onButtonDown(evt: PointerEvent): void;
  37056. /**
  37057. * Called each time a new POINTERUP event occurs. Ie, for each button
  37058. * release.
  37059. */
  37060. protected onButtonUp(evt: PointerEvent): void;
  37061. /**
  37062. * Called when window becomes inactive.
  37063. */
  37064. protected onLostFocus(): void;
  37065. }
  37066. }
  37067. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37068. import { Nullable } from "babylonjs/types";
  37069. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37070. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37071. /**
  37072. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37074. */
  37075. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37076. /**
  37077. * Defines the camera the input is attached to.
  37078. */
  37079. camera: ArcRotateCamera;
  37080. /**
  37081. * Defines the list of key codes associated with the up action (increase alpha)
  37082. */
  37083. keysUp: number[];
  37084. /**
  37085. * Defines the list of key codes associated with the down action (decrease alpha)
  37086. */
  37087. keysDown: number[];
  37088. /**
  37089. * Defines the list of key codes associated with the left action (increase beta)
  37090. */
  37091. keysLeft: number[];
  37092. /**
  37093. * Defines the list of key codes associated with the right action (decrease beta)
  37094. */
  37095. keysRight: number[];
  37096. /**
  37097. * Defines the list of key codes associated with the reset action.
  37098. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37099. */
  37100. keysReset: number[];
  37101. /**
  37102. * Defines the panning sensibility of the inputs.
  37103. * (How fast is the camera paning)
  37104. */
  37105. panningSensibility: number;
  37106. /**
  37107. * Defines the zooming sensibility of the inputs.
  37108. * (How fast is the camera zooming)
  37109. */
  37110. zoomingSensibility: number;
  37111. /**
  37112. * Defines wether maintaining the alt key down switch the movement mode from
  37113. * orientation to zoom.
  37114. */
  37115. useAltToZoom: boolean;
  37116. /**
  37117. * Rotation speed of the camera
  37118. */
  37119. angularSpeed: number;
  37120. private _keys;
  37121. private _ctrlPressed;
  37122. private _altPressed;
  37123. private _onCanvasBlurObserver;
  37124. private _onKeyboardObserver;
  37125. private _engine;
  37126. private _scene;
  37127. /**
  37128. * Attach the input controls to a specific dom element to get the input from.
  37129. * @param element Defines the element the controls should be listened from
  37130. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37131. */
  37132. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37133. /**
  37134. * Detach the current controls from the specified dom element.
  37135. * @param element Defines the element to stop listening the inputs from
  37136. */
  37137. detachControl(element: Nullable<HTMLElement>): void;
  37138. /**
  37139. * Update the current camera state depending on the inputs that have been used this frame.
  37140. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37141. */
  37142. checkInputs(): void;
  37143. /**
  37144. * Gets the class name of the current intput.
  37145. * @returns the class name
  37146. */
  37147. getClassName(): string;
  37148. /**
  37149. * Get the friendly name associated with the input class.
  37150. * @returns the input friendly name
  37151. */
  37152. getSimpleName(): string;
  37153. }
  37154. }
  37155. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37156. import { Nullable } from "babylonjs/types";
  37157. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37158. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37159. /**
  37160. * Manage the mouse wheel inputs to control an arc rotate camera.
  37161. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37162. */
  37163. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37164. /**
  37165. * Defines the camera the input is attached to.
  37166. */
  37167. camera: ArcRotateCamera;
  37168. /**
  37169. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37170. */
  37171. wheelPrecision: number;
  37172. /**
  37173. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37174. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37175. */
  37176. wheelDeltaPercentage: number;
  37177. private _wheel;
  37178. private _observer;
  37179. private computeDeltaFromMouseWheelLegacyEvent;
  37180. /**
  37181. * Attach the input controls to a specific dom element to get the input from.
  37182. * @param element Defines the element the controls should be listened from
  37183. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37184. */
  37185. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37186. /**
  37187. * Detach the current controls from the specified dom element.
  37188. * @param element Defines the element to stop listening the inputs from
  37189. */
  37190. detachControl(element: Nullable<HTMLElement>): void;
  37191. /**
  37192. * Gets the class name of the current intput.
  37193. * @returns the class name
  37194. */
  37195. getClassName(): string;
  37196. /**
  37197. * Get the friendly name associated with the input class.
  37198. * @returns the input friendly name
  37199. */
  37200. getSimpleName(): string;
  37201. }
  37202. }
  37203. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37204. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37205. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37206. /**
  37207. * Default Inputs manager for the ArcRotateCamera.
  37208. * It groups all the default supported inputs for ease of use.
  37209. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37210. */
  37211. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37212. /**
  37213. * Instantiates a new ArcRotateCameraInputsManager.
  37214. * @param camera Defines the camera the inputs belong to
  37215. */
  37216. constructor(camera: ArcRotateCamera);
  37217. /**
  37218. * Add mouse wheel input support to the input manager.
  37219. * @returns the current input manager
  37220. */
  37221. addMouseWheel(): ArcRotateCameraInputsManager;
  37222. /**
  37223. * Add pointers input support to the input manager.
  37224. * @returns the current input manager
  37225. */
  37226. addPointers(): ArcRotateCameraInputsManager;
  37227. /**
  37228. * Add keyboard input support to the input manager.
  37229. * @returns the current input manager
  37230. */
  37231. addKeyboard(): ArcRotateCameraInputsManager;
  37232. }
  37233. }
  37234. declare module "babylonjs/Cameras/arcRotateCamera" {
  37235. import { Observable } from "babylonjs/Misc/observable";
  37236. import { Nullable } from "babylonjs/types";
  37237. import { Scene } from "babylonjs/scene";
  37238. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37240. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37241. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37242. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37243. import { Camera } from "babylonjs/Cameras/camera";
  37244. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37245. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37246. import { Collider } from "babylonjs/Collisions/collider";
  37247. /**
  37248. * This represents an orbital type of camera.
  37249. *
  37250. * 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.
  37251. * 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.
  37252. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37253. */
  37254. export class ArcRotateCamera extends TargetCamera {
  37255. /**
  37256. * Defines the rotation angle of the camera along the longitudinal axis.
  37257. */
  37258. alpha: number;
  37259. /**
  37260. * Defines the rotation angle of the camera along the latitudinal axis.
  37261. */
  37262. beta: number;
  37263. /**
  37264. * Defines the radius of the camera from it s target point.
  37265. */
  37266. radius: number;
  37267. protected _target: Vector3;
  37268. protected _targetHost: Nullable<AbstractMesh>;
  37269. /**
  37270. * Defines the target point of the camera.
  37271. * The camera looks towards it form the radius distance.
  37272. */
  37273. target: Vector3;
  37274. /**
  37275. * Define the current local position of the camera in the scene
  37276. */
  37277. position: Vector3;
  37278. protected _upVector: Vector3;
  37279. protected _upToYMatrix: Matrix;
  37280. protected _YToUpMatrix: Matrix;
  37281. /**
  37282. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37283. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37284. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37285. */
  37286. upVector: Vector3;
  37287. /**
  37288. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37289. */
  37290. setMatUp(): void;
  37291. /**
  37292. * Current inertia value on the longitudinal axis.
  37293. * The bigger this number the longer it will take for the camera to stop.
  37294. */
  37295. inertialAlphaOffset: number;
  37296. /**
  37297. * Current inertia value on the latitudinal axis.
  37298. * The bigger this number the longer it will take for the camera to stop.
  37299. */
  37300. inertialBetaOffset: number;
  37301. /**
  37302. * Current inertia value on the radius axis.
  37303. * The bigger this number the longer it will take for the camera to stop.
  37304. */
  37305. inertialRadiusOffset: number;
  37306. /**
  37307. * Minimum allowed angle on the longitudinal axis.
  37308. * This can help limiting how the Camera is able to move in the scene.
  37309. */
  37310. lowerAlphaLimit: Nullable<number>;
  37311. /**
  37312. * Maximum allowed angle on the longitudinal axis.
  37313. * This can help limiting how the Camera is able to move in the scene.
  37314. */
  37315. upperAlphaLimit: Nullable<number>;
  37316. /**
  37317. * Minimum allowed angle on the latitudinal axis.
  37318. * This can help limiting how the Camera is able to move in the scene.
  37319. */
  37320. lowerBetaLimit: number;
  37321. /**
  37322. * Maximum allowed angle on the latitudinal axis.
  37323. * This can help limiting how the Camera is able to move in the scene.
  37324. */
  37325. upperBetaLimit: number;
  37326. /**
  37327. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37328. * This can help limiting how the Camera is able to move in the scene.
  37329. */
  37330. lowerRadiusLimit: Nullable<number>;
  37331. /**
  37332. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37333. * This can help limiting how the Camera is able to move in the scene.
  37334. */
  37335. upperRadiusLimit: Nullable<number>;
  37336. /**
  37337. * Defines the current inertia value used during panning of the camera along the X axis.
  37338. */
  37339. inertialPanningX: number;
  37340. /**
  37341. * Defines the current inertia value used during panning of the camera along the Y axis.
  37342. */
  37343. inertialPanningY: number;
  37344. /**
  37345. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37346. * Basically if your fingers moves away from more than this distance you will be considered
  37347. * in pinch mode.
  37348. */
  37349. pinchToPanMaxDistance: number;
  37350. /**
  37351. * Defines the maximum distance the camera can pan.
  37352. * This could help keeping the cammera always in your scene.
  37353. */
  37354. panningDistanceLimit: Nullable<number>;
  37355. /**
  37356. * Defines the target of the camera before paning.
  37357. */
  37358. panningOriginTarget: Vector3;
  37359. /**
  37360. * Defines the value of the inertia used during panning.
  37361. * 0 would mean stop inertia and one would mean no decelleration at all.
  37362. */
  37363. panningInertia: number;
  37364. /**
  37365. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37366. */
  37367. angularSensibilityX: number;
  37368. /**
  37369. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37370. */
  37371. angularSensibilityY: number;
  37372. /**
  37373. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37374. */
  37375. pinchPrecision: number;
  37376. /**
  37377. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37378. * It will be used instead of pinchDeltaPrecision if different from 0.
  37379. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37380. */
  37381. pinchDeltaPercentage: number;
  37382. /**
  37383. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37384. */
  37385. panningSensibility: number;
  37386. /**
  37387. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37388. */
  37389. keysUp: number[];
  37390. /**
  37391. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37392. */
  37393. keysDown: number[];
  37394. /**
  37395. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37396. */
  37397. keysLeft: number[];
  37398. /**
  37399. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37400. */
  37401. keysRight: number[];
  37402. /**
  37403. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37404. */
  37405. wheelPrecision: number;
  37406. /**
  37407. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37408. * It will be used instead of pinchDeltaPrecision if different from 0.
  37409. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37410. */
  37411. wheelDeltaPercentage: number;
  37412. /**
  37413. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37414. */
  37415. zoomOnFactor: number;
  37416. /**
  37417. * Defines a screen offset for the camera position.
  37418. */
  37419. targetScreenOffset: Vector2;
  37420. /**
  37421. * Allows the camera to be completely reversed.
  37422. * If false the camera can not arrive upside down.
  37423. */
  37424. allowUpsideDown: boolean;
  37425. /**
  37426. * Define if double tap/click is used to restore the previously saved state of the camera.
  37427. */
  37428. useInputToRestoreState: boolean;
  37429. /** @hidden */
  37430. _viewMatrix: Matrix;
  37431. /** @hidden */
  37432. _useCtrlForPanning: boolean;
  37433. /** @hidden */
  37434. _panningMouseButton: number;
  37435. /**
  37436. * Defines the input associated to the camera.
  37437. */
  37438. inputs: ArcRotateCameraInputsManager;
  37439. /** @hidden */
  37440. _reset: () => void;
  37441. /**
  37442. * Defines the allowed panning axis.
  37443. */
  37444. panningAxis: Vector3;
  37445. protected _localDirection: Vector3;
  37446. protected _transformedDirection: Vector3;
  37447. private _bouncingBehavior;
  37448. /**
  37449. * Gets the bouncing behavior of the camera if it has been enabled.
  37450. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37451. */
  37452. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37453. /**
  37454. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37455. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37456. */
  37457. useBouncingBehavior: boolean;
  37458. private _framingBehavior;
  37459. /**
  37460. * Gets the framing behavior of the camera if it has been enabled.
  37461. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37462. */
  37463. readonly framingBehavior: Nullable<FramingBehavior>;
  37464. /**
  37465. * Defines if the framing behavior of the camera is enabled on the camera.
  37466. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37467. */
  37468. useFramingBehavior: boolean;
  37469. private _autoRotationBehavior;
  37470. /**
  37471. * Gets the auto rotation behavior of the camera if it has been enabled.
  37472. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37473. */
  37474. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37475. /**
  37476. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37477. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37478. */
  37479. useAutoRotationBehavior: boolean;
  37480. /**
  37481. * Observable triggered when the mesh target has been changed on the camera.
  37482. */
  37483. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37484. /**
  37485. * Event raised when the camera is colliding with a mesh.
  37486. */
  37487. onCollide: (collidedMesh: AbstractMesh) => void;
  37488. /**
  37489. * Defines whether the camera should check collision with the objects oh the scene.
  37490. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37491. */
  37492. checkCollisions: boolean;
  37493. /**
  37494. * Defines the collision radius of the camera.
  37495. * This simulates a sphere around the camera.
  37496. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37497. */
  37498. collisionRadius: Vector3;
  37499. protected _collider: Collider;
  37500. protected _previousPosition: Vector3;
  37501. protected _collisionVelocity: Vector3;
  37502. protected _newPosition: Vector3;
  37503. protected _previousAlpha: number;
  37504. protected _previousBeta: number;
  37505. protected _previousRadius: number;
  37506. protected _collisionTriggered: boolean;
  37507. protected _targetBoundingCenter: Nullable<Vector3>;
  37508. private _computationVector;
  37509. /**
  37510. * Instantiates a new ArcRotateCamera in a given scene
  37511. * @param name Defines the name of the camera
  37512. * @param alpha Defines the camera rotation along the logitudinal axis
  37513. * @param beta Defines the camera rotation along the latitudinal axis
  37514. * @param radius Defines the camera distance from its target
  37515. * @param target Defines the camera target
  37516. * @param scene Defines the scene the camera belongs to
  37517. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37518. */
  37519. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37520. /** @hidden */
  37521. _initCache(): void;
  37522. /** @hidden */
  37523. _updateCache(ignoreParentClass?: boolean): void;
  37524. protected _getTargetPosition(): Vector3;
  37525. private _storedAlpha;
  37526. private _storedBeta;
  37527. private _storedRadius;
  37528. private _storedTarget;
  37529. private _storedTargetScreenOffset;
  37530. /**
  37531. * Stores the current state of the camera (alpha, beta, radius and target)
  37532. * @returns the camera itself
  37533. */
  37534. storeState(): Camera;
  37535. /**
  37536. * @hidden
  37537. * Restored camera state. You must call storeState() first
  37538. */
  37539. _restoreStateValues(): boolean;
  37540. /** @hidden */
  37541. _isSynchronizedViewMatrix(): boolean;
  37542. /**
  37543. * Attached controls to the current camera.
  37544. * @param element Defines the element the controls should be listened from
  37545. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37546. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37547. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37548. */
  37549. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37550. /**
  37551. * Detach the current controls from the camera.
  37552. * The camera will stop reacting to inputs.
  37553. * @param element Defines the element to stop listening the inputs from
  37554. */
  37555. detachControl(element: HTMLElement): void;
  37556. /** @hidden */
  37557. _checkInputs(): void;
  37558. protected _checkLimits(): void;
  37559. /**
  37560. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37561. */
  37562. rebuildAnglesAndRadius(): void;
  37563. /**
  37564. * Use a position to define the current camera related information like aplha, beta and radius
  37565. * @param position Defines the position to set the camera at
  37566. */
  37567. setPosition(position: Vector3): void;
  37568. /**
  37569. * Defines the target the camera should look at.
  37570. * This will automatically adapt alpha beta and radius to fit within the new target.
  37571. * @param target Defines the new target as a Vector or a mesh
  37572. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37573. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37574. */
  37575. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37576. /** @hidden */
  37577. _getViewMatrix(): Matrix;
  37578. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37579. /**
  37580. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37581. * @param meshes Defines the mesh to zoom on
  37582. * @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)
  37583. */
  37584. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37585. /**
  37586. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37587. * The target will be changed but the radius
  37588. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37589. * @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)
  37590. */
  37591. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37592. min: Vector3;
  37593. max: Vector3;
  37594. distance: number;
  37595. }, doNotUpdateMaxZ?: boolean): void;
  37596. /**
  37597. * @override
  37598. * Override Camera.createRigCamera
  37599. */
  37600. createRigCamera(name: string, cameraIndex: number): Camera;
  37601. /**
  37602. * @hidden
  37603. * @override
  37604. * Override Camera._updateRigCameras
  37605. */
  37606. _updateRigCameras(): void;
  37607. /**
  37608. * Destroy the camera and release the current resources hold by it.
  37609. */
  37610. dispose(): void;
  37611. /**
  37612. * Gets the current object class name.
  37613. * @return the class name
  37614. */
  37615. getClassName(): string;
  37616. }
  37617. }
  37618. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37619. import { Behavior } from "babylonjs/Behaviors/behavior";
  37620. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37621. /**
  37622. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37623. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37624. */
  37625. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37626. /**
  37627. * Gets the name of the behavior.
  37628. */
  37629. readonly name: string;
  37630. private _zoomStopsAnimation;
  37631. private _idleRotationSpeed;
  37632. private _idleRotationWaitTime;
  37633. private _idleRotationSpinupTime;
  37634. /**
  37635. * Sets the flag that indicates if user zooming should stop animation.
  37636. */
  37637. /**
  37638. * Gets the flag that indicates if user zooming should stop animation.
  37639. */
  37640. zoomStopsAnimation: boolean;
  37641. /**
  37642. * Sets the default speed at which the camera rotates around the model.
  37643. */
  37644. /**
  37645. * Gets the default speed at which the camera rotates around the model.
  37646. */
  37647. idleRotationSpeed: number;
  37648. /**
  37649. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37650. */
  37651. /**
  37652. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37653. */
  37654. idleRotationWaitTime: number;
  37655. /**
  37656. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37657. */
  37658. /**
  37659. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37660. */
  37661. idleRotationSpinupTime: number;
  37662. /**
  37663. * Gets a value indicating if the camera is currently rotating because of this behavior
  37664. */
  37665. readonly rotationInProgress: boolean;
  37666. private _onPrePointerObservableObserver;
  37667. private _onAfterCheckInputsObserver;
  37668. private _attachedCamera;
  37669. private _isPointerDown;
  37670. private _lastFrameTime;
  37671. private _lastInteractionTime;
  37672. private _cameraRotationSpeed;
  37673. /**
  37674. * Initializes the behavior.
  37675. */
  37676. init(): void;
  37677. /**
  37678. * Attaches the behavior to its arc rotate camera.
  37679. * @param camera Defines the camera to attach the behavior to
  37680. */
  37681. attach(camera: ArcRotateCamera): void;
  37682. /**
  37683. * Detaches the behavior from its current arc rotate camera.
  37684. */
  37685. detach(): void;
  37686. /**
  37687. * Returns true if user is scrolling.
  37688. * @return true if user is scrolling.
  37689. */
  37690. private _userIsZooming;
  37691. private _lastFrameRadius;
  37692. private _shouldAnimationStopForInteraction;
  37693. /**
  37694. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37695. */
  37696. private _applyUserInteraction;
  37697. private _userIsMoving;
  37698. }
  37699. }
  37700. declare module "babylonjs/Behaviors/Cameras/index" {
  37701. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37702. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37703. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37704. }
  37705. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37706. import { Mesh } from "babylonjs/Meshes/mesh";
  37707. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37708. import { Behavior } from "babylonjs/Behaviors/behavior";
  37709. /**
  37710. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37711. */
  37712. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37713. private ui;
  37714. /**
  37715. * The name of the behavior
  37716. */
  37717. name: string;
  37718. /**
  37719. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37720. */
  37721. distanceAwayFromFace: number;
  37722. /**
  37723. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37724. */
  37725. distanceAwayFromBottomOfFace: number;
  37726. private _faceVectors;
  37727. private _target;
  37728. private _scene;
  37729. private _onRenderObserver;
  37730. private _tmpMatrix;
  37731. private _tmpVector;
  37732. /**
  37733. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37734. * @param ui The transform node that should be attched to the mesh
  37735. */
  37736. constructor(ui: TransformNode);
  37737. /**
  37738. * Initializes the behavior
  37739. */
  37740. init(): void;
  37741. private _closestFace;
  37742. private _zeroVector;
  37743. private _lookAtTmpMatrix;
  37744. private _lookAtToRef;
  37745. /**
  37746. * Attaches the AttachToBoxBehavior to the passed in mesh
  37747. * @param target The mesh that the specified node will be attached to
  37748. */
  37749. attach(target: Mesh): void;
  37750. /**
  37751. * Detaches the behavior from the mesh
  37752. */
  37753. detach(): void;
  37754. }
  37755. }
  37756. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37757. import { Behavior } from "babylonjs/Behaviors/behavior";
  37758. import { Mesh } from "babylonjs/Meshes/mesh";
  37759. /**
  37760. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37761. */
  37762. export class FadeInOutBehavior implements Behavior<Mesh> {
  37763. /**
  37764. * Time in milliseconds to delay before fading in (Default: 0)
  37765. */
  37766. delay: number;
  37767. /**
  37768. * Time in milliseconds for the mesh to fade in (Default: 300)
  37769. */
  37770. fadeInTime: number;
  37771. private _millisecondsPerFrame;
  37772. private _hovered;
  37773. private _hoverValue;
  37774. private _ownerNode;
  37775. /**
  37776. * Instatiates the FadeInOutBehavior
  37777. */
  37778. constructor();
  37779. /**
  37780. * The name of the behavior
  37781. */
  37782. readonly name: string;
  37783. /**
  37784. * Initializes the behavior
  37785. */
  37786. init(): void;
  37787. /**
  37788. * Attaches the fade behavior on the passed in mesh
  37789. * @param ownerNode The mesh that will be faded in/out once attached
  37790. */
  37791. attach(ownerNode: Mesh): void;
  37792. /**
  37793. * Detaches the behavior from the mesh
  37794. */
  37795. detach(): void;
  37796. /**
  37797. * Triggers the mesh to begin fading in or out
  37798. * @param value if the object should fade in or out (true to fade in)
  37799. */
  37800. fadeIn(value: boolean): void;
  37801. private _update;
  37802. private _setAllVisibility;
  37803. }
  37804. }
  37805. declare module "babylonjs/Misc/pivotTools" {
  37806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37807. /**
  37808. * Class containing a set of static utilities functions for managing Pivots
  37809. * @hidden
  37810. */
  37811. export class PivotTools {
  37812. private static _PivotCached;
  37813. private static _OldPivotPoint;
  37814. private static _PivotTranslation;
  37815. private static _PivotTmpVector;
  37816. /** @hidden */
  37817. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37818. /** @hidden */
  37819. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37820. }
  37821. }
  37822. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37823. import { Scene } from "babylonjs/scene";
  37824. import { Vector4 } from "babylonjs/Maths/math.vector";
  37825. import { Mesh } from "babylonjs/Meshes/mesh";
  37826. import { Nullable } from "babylonjs/types";
  37827. import { Plane } from "babylonjs/Maths/math.plane";
  37828. /**
  37829. * Class containing static functions to help procedurally build meshes
  37830. */
  37831. export class PlaneBuilder {
  37832. /**
  37833. * Creates a plane mesh
  37834. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37835. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37836. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37840. * @param name defines the name of the mesh
  37841. * @param options defines the options used to create the mesh
  37842. * @param scene defines the hosting scene
  37843. * @returns the plane mesh
  37844. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37845. */
  37846. static CreatePlane(name: string, options: {
  37847. size?: number;
  37848. width?: number;
  37849. height?: number;
  37850. sideOrientation?: number;
  37851. frontUVs?: Vector4;
  37852. backUVs?: Vector4;
  37853. updatable?: boolean;
  37854. sourcePlane?: Plane;
  37855. }, scene?: Nullable<Scene>): Mesh;
  37856. }
  37857. }
  37858. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37859. import { Behavior } from "babylonjs/Behaviors/behavior";
  37860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37861. import { Observable } from "babylonjs/Misc/observable";
  37862. import { Vector3 } from "babylonjs/Maths/math.vector";
  37863. import { Ray } from "babylonjs/Culling/ray";
  37864. import "babylonjs/Meshes/Builders/planeBuilder";
  37865. /**
  37866. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37867. */
  37868. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37869. private static _AnyMouseID;
  37870. /**
  37871. * Abstract mesh the behavior is set on
  37872. */
  37873. attachedNode: AbstractMesh;
  37874. private _dragPlane;
  37875. private _scene;
  37876. private _pointerObserver;
  37877. private _beforeRenderObserver;
  37878. private static _planeScene;
  37879. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37880. /**
  37881. * 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)
  37882. */
  37883. maxDragAngle: number;
  37884. /**
  37885. * @hidden
  37886. */
  37887. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37888. /**
  37889. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37890. */
  37891. currentDraggingPointerID: number;
  37892. /**
  37893. * The last position where the pointer hit the drag plane in world space
  37894. */
  37895. lastDragPosition: Vector3;
  37896. /**
  37897. * If the behavior is currently in a dragging state
  37898. */
  37899. dragging: boolean;
  37900. /**
  37901. * 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)
  37902. */
  37903. dragDeltaRatio: number;
  37904. /**
  37905. * If the drag plane orientation should be updated during the dragging (Default: true)
  37906. */
  37907. updateDragPlane: boolean;
  37908. private _debugMode;
  37909. private _moving;
  37910. /**
  37911. * Fires each time the attached mesh is dragged with the pointer
  37912. * * delta between last drag position and current drag position in world space
  37913. * * dragDistance along the drag axis
  37914. * * dragPlaneNormal normal of the current drag plane used during the drag
  37915. * * dragPlanePoint in world space where the drag intersects the drag plane
  37916. */
  37917. onDragObservable: Observable<{
  37918. delta: Vector3;
  37919. dragPlanePoint: Vector3;
  37920. dragPlaneNormal: Vector3;
  37921. dragDistance: number;
  37922. pointerId: number;
  37923. }>;
  37924. /**
  37925. * Fires each time a drag begins (eg. mouse down on mesh)
  37926. */
  37927. onDragStartObservable: Observable<{
  37928. dragPlanePoint: Vector3;
  37929. pointerId: number;
  37930. }>;
  37931. /**
  37932. * Fires each time a drag ends (eg. mouse release after drag)
  37933. */
  37934. onDragEndObservable: Observable<{
  37935. dragPlanePoint: Vector3;
  37936. pointerId: number;
  37937. }>;
  37938. /**
  37939. * If the attached mesh should be moved when dragged
  37940. */
  37941. moveAttached: boolean;
  37942. /**
  37943. * If the drag behavior will react to drag events (Default: true)
  37944. */
  37945. enabled: boolean;
  37946. /**
  37947. * If pointer events should start and release the drag (Default: true)
  37948. */
  37949. startAndReleaseDragOnPointerEvents: boolean;
  37950. /**
  37951. * If camera controls should be detached during the drag
  37952. */
  37953. detachCameraControls: boolean;
  37954. /**
  37955. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37956. */
  37957. useObjectOrienationForDragging: boolean;
  37958. private _options;
  37959. /**
  37960. * Creates a pointer drag behavior that can be attached to a mesh
  37961. * @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)
  37962. */
  37963. constructor(options?: {
  37964. dragAxis?: Vector3;
  37965. dragPlaneNormal?: Vector3;
  37966. });
  37967. /**
  37968. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37969. */
  37970. validateDrag: (targetPosition: Vector3) => boolean;
  37971. /**
  37972. * The name of the behavior
  37973. */
  37974. readonly name: string;
  37975. /**
  37976. * Initializes the behavior
  37977. */
  37978. init(): void;
  37979. private _tmpVector;
  37980. private _alternatePickedPoint;
  37981. private _worldDragAxis;
  37982. private _targetPosition;
  37983. private _attachedElement;
  37984. /**
  37985. * Attaches the drag behavior the passed in mesh
  37986. * @param ownerNode The mesh that will be dragged around once attached
  37987. * @param predicate Predicate to use for pick filtering
  37988. */
  37989. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  37990. /**
  37991. * Force relase the drag action by code.
  37992. */
  37993. releaseDrag(): void;
  37994. private _startDragRay;
  37995. private _lastPointerRay;
  37996. /**
  37997. * Simulates the start of a pointer drag event on the behavior
  37998. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37999. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38000. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38001. */
  38002. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38003. private _startDrag;
  38004. private _dragDelta;
  38005. private _moveDrag;
  38006. private _pickWithRayOnDragPlane;
  38007. private _pointA;
  38008. private _pointB;
  38009. private _pointC;
  38010. private _lineA;
  38011. private _lineB;
  38012. private _localAxis;
  38013. private _lookAt;
  38014. private _updateDragPlanePosition;
  38015. /**
  38016. * Detaches the behavior from the mesh
  38017. */
  38018. detach(): void;
  38019. }
  38020. }
  38021. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38022. import { Mesh } from "babylonjs/Meshes/mesh";
  38023. import { Behavior } from "babylonjs/Behaviors/behavior";
  38024. /**
  38025. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38026. */
  38027. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38028. private _dragBehaviorA;
  38029. private _dragBehaviorB;
  38030. private _startDistance;
  38031. private _initialScale;
  38032. private _targetScale;
  38033. private _ownerNode;
  38034. private _sceneRenderObserver;
  38035. /**
  38036. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38037. */
  38038. constructor();
  38039. /**
  38040. * The name of the behavior
  38041. */
  38042. readonly name: string;
  38043. /**
  38044. * Initializes the behavior
  38045. */
  38046. init(): void;
  38047. private _getCurrentDistance;
  38048. /**
  38049. * Attaches the scale behavior the passed in mesh
  38050. * @param ownerNode The mesh that will be scaled around once attached
  38051. */
  38052. attach(ownerNode: Mesh): void;
  38053. /**
  38054. * Detaches the behavior from the mesh
  38055. */
  38056. detach(): void;
  38057. }
  38058. }
  38059. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38060. import { Behavior } from "babylonjs/Behaviors/behavior";
  38061. import { Mesh } from "babylonjs/Meshes/mesh";
  38062. import { Observable } from "babylonjs/Misc/observable";
  38063. /**
  38064. * 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
  38065. */
  38066. export class SixDofDragBehavior implements Behavior<Mesh> {
  38067. private static _virtualScene;
  38068. private _ownerNode;
  38069. private _sceneRenderObserver;
  38070. private _scene;
  38071. private _targetPosition;
  38072. private _virtualOriginMesh;
  38073. private _virtualDragMesh;
  38074. private _pointerObserver;
  38075. private _moving;
  38076. private _startingOrientation;
  38077. /**
  38078. * 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)
  38079. */
  38080. private zDragFactor;
  38081. /**
  38082. * If the object should rotate to face the drag origin
  38083. */
  38084. rotateDraggedObject: boolean;
  38085. /**
  38086. * If the behavior is currently in a dragging state
  38087. */
  38088. dragging: boolean;
  38089. /**
  38090. * 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)
  38091. */
  38092. dragDeltaRatio: number;
  38093. /**
  38094. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38095. */
  38096. currentDraggingPointerID: number;
  38097. /**
  38098. * If camera controls should be detached during the drag
  38099. */
  38100. detachCameraControls: boolean;
  38101. /**
  38102. * Fires each time a drag starts
  38103. */
  38104. onDragStartObservable: Observable<{}>;
  38105. /**
  38106. * Fires each time a drag ends (eg. mouse release after drag)
  38107. */
  38108. onDragEndObservable: Observable<{}>;
  38109. /**
  38110. * 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
  38111. */
  38112. constructor();
  38113. /**
  38114. * The name of the behavior
  38115. */
  38116. readonly name: string;
  38117. /**
  38118. * Initializes the behavior
  38119. */
  38120. init(): void;
  38121. /**
  38122. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38123. */
  38124. private readonly _pointerCamera;
  38125. /**
  38126. * Attaches the scale behavior the passed in mesh
  38127. * @param ownerNode The mesh that will be scaled around once attached
  38128. */
  38129. attach(ownerNode: Mesh): void;
  38130. /**
  38131. * Detaches the behavior from the mesh
  38132. */
  38133. detach(): void;
  38134. }
  38135. }
  38136. declare module "babylonjs/Behaviors/Meshes/index" {
  38137. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38138. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38139. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38140. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38141. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38142. }
  38143. declare module "babylonjs/Behaviors/index" {
  38144. export * from "babylonjs/Behaviors/behavior";
  38145. export * from "babylonjs/Behaviors/Cameras/index";
  38146. export * from "babylonjs/Behaviors/Meshes/index";
  38147. }
  38148. declare module "babylonjs/Bones/boneIKController" {
  38149. import { Bone } from "babylonjs/Bones/bone";
  38150. import { Vector3 } from "babylonjs/Maths/math.vector";
  38151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38152. import { Nullable } from "babylonjs/types";
  38153. /**
  38154. * Class used to apply inverse kinematics to bones
  38155. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38156. */
  38157. export class BoneIKController {
  38158. private static _tmpVecs;
  38159. private static _tmpQuat;
  38160. private static _tmpMats;
  38161. /**
  38162. * Gets or sets the target mesh
  38163. */
  38164. targetMesh: AbstractMesh;
  38165. /** Gets or sets the mesh used as pole */
  38166. poleTargetMesh: AbstractMesh;
  38167. /**
  38168. * Gets or sets the bone used as pole
  38169. */
  38170. poleTargetBone: Nullable<Bone>;
  38171. /**
  38172. * Gets or sets the target position
  38173. */
  38174. targetPosition: Vector3;
  38175. /**
  38176. * Gets or sets the pole target position
  38177. */
  38178. poleTargetPosition: Vector3;
  38179. /**
  38180. * Gets or sets the pole target local offset
  38181. */
  38182. poleTargetLocalOffset: Vector3;
  38183. /**
  38184. * Gets or sets the pole angle
  38185. */
  38186. poleAngle: number;
  38187. /**
  38188. * Gets or sets the mesh associated with the controller
  38189. */
  38190. mesh: AbstractMesh;
  38191. /**
  38192. * 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)
  38193. */
  38194. slerpAmount: number;
  38195. private _bone1Quat;
  38196. private _bone1Mat;
  38197. private _bone2Ang;
  38198. private _bone1;
  38199. private _bone2;
  38200. private _bone1Length;
  38201. private _bone2Length;
  38202. private _maxAngle;
  38203. private _maxReach;
  38204. private _rightHandedSystem;
  38205. private _bendAxis;
  38206. private _slerping;
  38207. private _adjustRoll;
  38208. /**
  38209. * Gets or sets maximum allowed angle
  38210. */
  38211. maxAngle: number;
  38212. /**
  38213. * Creates a new BoneIKController
  38214. * @param mesh defines the mesh to control
  38215. * @param bone defines the bone to control
  38216. * @param options defines options to set up the controller
  38217. */
  38218. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38219. targetMesh?: AbstractMesh;
  38220. poleTargetMesh?: AbstractMesh;
  38221. poleTargetBone?: Bone;
  38222. poleTargetLocalOffset?: Vector3;
  38223. poleAngle?: number;
  38224. bendAxis?: Vector3;
  38225. maxAngle?: number;
  38226. slerpAmount?: number;
  38227. });
  38228. private _setMaxAngle;
  38229. /**
  38230. * Force the controller to update the bones
  38231. */
  38232. update(): void;
  38233. }
  38234. }
  38235. declare module "babylonjs/Bones/boneLookController" {
  38236. import { Vector3 } from "babylonjs/Maths/math.vector";
  38237. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38238. import { Bone } from "babylonjs/Bones/bone";
  38239. import { Space } from "babylonjs/Maths/math.axis";
  38240. /**
  38241. * Class used to make a bone look toward a point in space
  38242. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38243. */
  38244. export class BoneLookController {
  38245. private static _tmpVecs;
  38246. private static _tmpQuat;
  38247. private static _tmpMats;
  38248. /**
  38249. * The target Vector3 that the bone will look at
  38250. */
  38251. target: Vector3;
  38252. /**
  38253. * The mesh that the bone is attached to
  38254. */
  38255. mesh: AbstractMesh;
  38256. /**
  38257. * The bone that will be looking to the target
  38258. */
  38259. bone: Bone;
  38260. /**
  38261. * The up axis of the coordinate system that is used when the bone is rotated
  38262. */
  38263. upAxis: Vector3;
  38264. /**
  38265. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38266. */
  38267. upAxisSpace: Space;
  38268. /**
  38269. * Used to make an adjustment to the yaw of the bone
  38270. */
  38271. adjustYaw: number;
  38272. /**
  38273. * Used to make an adjustment to the pitch of the bone
  38274. */
  38275. adjustPitch: number;
  38276. /**
  38277. * Used to make an adjustment to the roll of the bone
  38278. */
  38279. adjustRoll: number;
  38280. /**
  38281. * 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)
  38282. */
  38283. slerpAmount: number;
  38284. private _minYaw;
  38285. private _maxYaw;
  38286. private _minPitch;
  38287. private _maxPitch;
  38288. private _minYawSin;
  38289. private _minYawCos;
  38290. private _maxYawSin;
  38291. private _maxYawCos;
  38292. private _midYawConstraint;
  38293. private _minPitchTan;
  38294. private _maxPitchTan;
  38295. private _boneQuat;
  38296. private _slerping;
  38297. private _transformYawPitch;
  38298. private _transformYawPitchInv;
  38299. private _firstFrameSkipped;
  38300. private _yawRange;
  38301. private _fowardAxis;
  38302. /**
  38303. * Gets or sets the minimum yaw angle that the bone can look to
  38304. */
  38305. minYaw: number;
  38306. /**
  38307. * Gets or sets the maximum yaw angle that the bone can look to
  38308. */
  38309. maxYaw: number;
  38310. /**
  38311. * Gets or sets the minimum pitch angle that the bone can look to
  38312. */
  38313. minPitch: number;
  38314. /**
  38315. * Gets or sets the maximum pitch angle that the bone can look to
  38316. */
  38317. maxPitch: number;
  38318. /**
  38319. * Create a BoneLookController
  38320. * @param mesh the mesh that the bone belongs to
  38321. * @param bone the bone that will be looking to the target
  38322. * @param target the target Vector3 to look at
  38323. * @param options optional settings:
  38324. * * maxYaw: the maximum angle the bone will yaw to
  38325. * * minYaw: the minimum angle the bone will yaw to
  38326. * * maxPitch: the maximum angle the bone will pitch to
  38327. * * minPitch: the minimum angle the bone will yaw to
  38328. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38329. * * upAxis: the up axis of the coordinate system
  38330. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38331. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38332. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38333. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38334. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38335. * * adjustRoll: used to make an adjustment to the roll of the bone
  38336. **/
  38337. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38338. maxYaw?: number;
  38339. minYaw?: number;
  38340. maxPitch?: number;
  38341. minPitch?: number;
  38342. slerpAmount?: number;
  38343. upAxis?: Vector3;
  38344. upAxisSpace?: Space;
  38345. yawAxis?: Vector3;
  38346. pitchAxis?: Vector3;
  38347. adjustYaw?: number;
  38348. adjustPitch?: number;
  38349. adjustRoll?: number;
  38350. });
  38351. /**
  38352. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38353. */
  38354. update(): void;
  38355. private _getAngleDiff;
  38356. private _getAngleBetween;
  38357. private _isAngleBetween;
  38358. }
  38359. }
  38360. declare module "babylonjs/Bones/index" {
  38361. export * from "babylonjs/Bones/bone";
  38362. export * from "babylonjs/Bones/boneIKController";
  38363. export * from "babylonjs/Bones/boneLookController";
  38364. export * from "babylonjs/Bones/skeleton";
  38365. }
  38366. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38367. import { Nullable } from "babylonjs/types";
  38368. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38369. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38370. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38371. /**
  38372. * Manage the gamepad inputs to control an arc rotate camera.
  38373. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38374. */
  38375. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38376. /**
  38377. * Defines the camera the input is attached to.
  38378. */
  38379. camera: ArcRotateCamera;
  38380. /**
  38381. * Defines the gamepad the input is gathering event from.
  38382. */
  38383. gamepad: Nullable<Gamepad>;
  38384. /**
  38385. * Defines the gamepad rotation sensiblity.
  38386. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38387. */
  38388. gamepadRotationSensibility: number;
  38389. /**
  38390. * Defines the gamepad move sensiblity.
  38391. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38392. */
  38393. gamepadMoveSensibility: number;
  38394. private _onGamepadConnectedObserver;
  38395. private _onGamepadDisconnectedObserver;
  38396. /**
  38397. * Attach the input controls to a specific dom element to get the input from.
  38398. * @param element Defines the element the controls should be listened from
  38399. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38400. */
  38401. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38402. /**
  38403. * Detach the current controls from the specified dom element.
  38404. * @param element Defines the element to stop listening the inputs from
  38405. */
  38406. detachControl(element: Nullable<HTMLElement>): void;
  38407. /**
  38408. * Update the current camera state depending on the inputs that have been used this frame.
  38409. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38410. */
  38411. checkInputs(): void;
  38412. /**
  38413. * Gets the class name of the current intput.
  38414. * @returns the class name
  38415. */
  38416. getClassName(): string;
  38417. /**
  38418. * Get the friendly name associated with the input class.
  38419. * @returns the input friendly name
  38420. */
  38421. getSimpleName(): string;
  38422. }
  38423. }
  38424. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38425. import { Nullable } from "babylonjs/types";
  38426. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38427. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38428. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38429. interface ArcRotateCameraInputsManager {
  38430. /**
  38431. * Add orientation input support to the input manager.
  38432. * @returns the current input manager
  38433. */
  38434. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38435. }
  38436. }
  38437. /**
  38438. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38439. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38440. */
  38441. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38442. /**
  38443. * Defines the camera the input is attached to.
  38444. */
  38445. camera: ArcRotateCamera;
  38446. /**
  38447. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38448. */
  38449. alphaCorrection: number;
  38450. /**
  38451. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38452. */
  38453. gammaCorrection: number;
  38454. private _alpha;
  38455. private _gamma;
  38456. private _dirty;
  38457. private _deviceOrientationHandler;
  38458. /**
  38459. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38460. */
  38461. constructor();
  38462. /**
  38463. * Attach the input controls to a specific dom element to get the input from.
  38464. * @param element Defines the element the controls should be listened from
  38465. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38466. */
  38467. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38468. /** @hidden */
  38469. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38470. /**
  38471. * Update the current camera state depending on the inputs that have been used this frame.
  38472. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38473. */
  38474. checkInputs(): void;
  38475. /**
  38476. * Detach the current controls from the specified dom element.
  38477. * @param element Defines the element to stop listening the inputs from
  38478. */
  38479. detachControl(element: Nullable<HTMLElement>): void;
  38480. /**
  38481. * Gets the class name of the current intput.
  38482. * @returns the class name
  38483. */
  38484. getClassName(): string;
  38485. /**
  38486. * Get the friendly name associated with the input class.
  38487. * @returns the input friendly name
  38488. */
  38489. getSimpleName(): string;
  38490. }
  38491. }
  38492. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38493. import { Nullable } from "babylonjs/types";
  38494. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38495. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38496. /**
  38497. * Listen to mouse events to control the camera.
  38498. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38499. */
  38500. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38501. /**
  38502. * Defines the camera the input is attached to.
  38503. */
  38504. camera: FlyCamera;
  38505. /**
  38506. * Defines if touch is enabled. (Default is true.)
  38507. */
  38508. touchEnabled: boolean;
  38509. /**
  38510. * Defines the buttons associated with the input to handle camera rotation.
  38511. */
  38512. buttons: number[];
  38513. /**
  38514. * Assign buttons for Yaw control.
  38515. */
  38516. buttonsYaw: number[];
  38517. /**
  38518. * Assign buttons for Pitch control.
  38519. */
  38520. buttonsPitch: number[];
  38521. /**
  38522. * Assign buttons for Roll control.
  38523. */
  38524. buttonsRoll: number[];
  38525. /**
  38526. * Detect if any button is being pressed while mouse is moved.
  38527. * -1 = Mouse locked.
  38528. * 0 = Left button.
  38529. * 1 = Middle Button.
  38530. * 2 = Right Button.
  38531. */
  38532. activeButton: number;
  38533. /**
  38534. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38535. * Higher values reduce its sensitivity.
  38536. */
  38537. angularSensibility: number;
  38538. private _mousemoveCallback;
  38539. private _observer;
  38540. private _rollObserver;
  38541. private previousPosition;
  38542. private noPreventDefault;
  38543. private element;
  38544. /**
  38545. * Listen to mouse events to control the camera.
  38546. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38547. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38548. */
  38549. constructor(touchEnabled?: boolean);
  38550. /**
  38551. * Attach the mouse control to the HTML DOM element.
  38552. * @param element Defines the element that listens to the input events.
  38553. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38554. */
  38555. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38556. /**
  38557. * Detach the current controls from the specified dom element.
  38558. * @param element Defines the element to stop listening the inputs from
  38559. */
  38560. detachControl(element: Nullable<HTMLElement>): void;
  38561. /**
  38562. * Gets the class name of the current input.
  38563. * @returns the class name.
  38564. */
  38565. getClassName(): string;
  38566. /**
  38567. * Get the friendly name associated with the input class.
  38568. * @returns the input's friendly name.
  38569. */
  38570. getSimpleName(): string;
  38571. private _pointerInput;
  38572. private _onMouseMove;
  38573. /**
  38574. * Rotate camera by mouse offset.
  38575. */
  38576. private rotateCamera;
  38577. }
  38578. }
  38579. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38580. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38581. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38582. /**
  38583. * Default Inputs manager for the FlyCamera.
  38584. * It groups all the default supported inputs for ease of use.
  38585. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38586. */
  38587. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38588. /**
  38589. * Instantiates a new FlyCameraInputsManager.
  38590. * @param camera Defines the camera the inputs belong to.
  38591. */
  38592. constructor(camera: FlyCamera);
  38593. /**
  38594. * Add keyboard input support to the input manager.
  38595. * @returns the new FlyCameraKeyboardMoveInput().
  38596. */
  38597. addKeyboard(): FlyCameraInputsManager;
  38598. /**
  38599. * Add mouse input support to the input manager.
  38600. * @param touchEnabled Enable touch screen support.
  38601. * @returns the new FlyCameraMouseInput().
  38602. */
  38603. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38604. }
  38605. }
  38606. declare module "babylonjs/Cameras/flyCamera" {
  38607. import { Scene } from "babylonjs/scene";
  38608. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38609. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38610. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38611. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38612. /**
  38613. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38614. * such as in a 3D Space Shooter or a Flight Simulator.
  38615. */
  38616. export class FlyCamera extends TargetCamera {
  38617. /**
  38618. * Define the collision ellipsoid of the camera.
  38619. * This is helpful for simulating a camera body, like a player's body.
  38620. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38621. */
  38622. ellipsoid: Vector3;
  38623. /**
  38624. * Define an offset for the position of the ellipsoid around the camera.
  38625. * This can be helpful if the camera is attached away from the player's body center,
  38626. * such as at its head.
  38627. */
  38628. ellipsoidOffset: Vector3;
  38629. /**
  38630. * Enable or disable collisions of the camera with the rest of the scene objects.
  38631. */
  38632. checkCollisions: boolean;
  38633. /**
  38634. * Enable or disable gravity on the camera.
  38635. */
  38636. applyGravity: boolean;
  38637. /**
  38638. * Define the current direction the camera is moving to.
  38639. */
  38640. cameraDirection: Vector3;
  38641. /**
  38642. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38643. * This overrides and empties cameraRotation.
  38644. */
  38645. rotationQuaternion: Quaternion;
  38646. /**
  38647. * Track Roll to maintain the wanted Rolling when looking around.
  38648. */
  38649. _trackRoll: number;
  38650. /**
  38651. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38652. */
  38653. rollCorrect: number;
  38654. /**
  38655. * Mimic a banked turn, Rolling the camera when Yawing.
  38656. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38657. */
  38658. bankedTurn: boolean;
  38659. /**
  38660. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38661. */
  38662. bankedTurnLimit: number;
  38663. /**
  38664. * Value of 0 disables the banked Roll.
  38665. * Value of 1 is equal to the Yaw angle in radians.
  38666. */
  38667. bankedTurnMultiplier: number;
  38668. /**
  38669. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38670. */
  38671. inputs: FlyCameraInputsManager;
  38672. /**
  38673. * Gets the input sensibility for mouse input.
  38674. * Higher values reduce sensitivity.
  38675. */
  38676. /**
  38677. * Sets the input sensibility for a mouse input.
  38678. * Higher values reduce sensitivity.
  38679. */
  38680. angularSensibility: number;
  38681. /**
  38682. * Get the keys for camera movement forward.
  38683. */
  38684. /**
  38685. * Set the keys for camera movement forward.
  38686. */
  38687. keysForward: number[];
  38688. /**
  38689. * Get the keys for camera movement backward.
  38690. */
  38691. keysBackward: number[];
  38692. /**
  38693. * Get the keys for camera movement up.
  38694. */
  38695. /**
  38696. * Set the keys for camera movement up.
  38697. */
  38698. keysUp: number[];
  38699. /**
  38700. * Get the keys for camera movement down.
  38701. */
  38702. /**
  38703. * Set the keys for camera movement down.
  38704. */
  38705. keysDown: number[];
  38706. /**
  38707. * Get the keys for camera movement left.
  38708. */
  38709. /**
  38710. * Set the keys for camera movement left.
  38711. */
  38712. keysLeft: number[];
  38713. /**
  38714. * Set the keys for camera movement right.
  38715. */
  38716. /**
  38717. * Set the keys for camera movement right.
  38718. */
  38719. keysRight: number[];
  38720. /**
  38721. * Event raised when the camera collides with a mesh in the scene.
  38722. */
  38723. onCollide: (collidedMesh: AbstractMesh) => void;
  38724. private _collider;
  38725. private _needMoveForGravity;
  38726. private _oldPosition;
  38727. private _diffPosition;
  38728. private _newPosition;
  38729. /** @hidden */
  38730. _localDirection: Vector3;
  38731. /** @hidden */
  38732. _transformedDirection: Vector3;
  38733. /**
  38734. * Instantiates a FlyCamera.
  38735. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38736. * such as in a 3D Space Shooter or a Flight Simulator.
  38737. * @param name Define the name of the camera in the scene.
  38738. * @param position Define the starting position of the camera in the scene.
  38739. * @param scene Define the scene the camera belongs to.
  38740. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38741. */
  38742. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38743. /**
  38744. * Attach a control to the HTML DOM element.
  38745. * @param element Defines the element that listens to the input events.
  38746. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38747. */
  38748. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38749. /**
  38750. * Detach a control from the HTML DOM element.
  38751. * The camera will stop reacting to that input.
  38752. * @param element Defines the element that listens to the input events.
  38753. */
  38754. detachControl(element: HTMLElement): void;
  38755. private _collisionMask;
  38756. /**
  38757. * Get the mask that the camera ignores in collision events.
  38758. */
  38759. /**
  38760. * Set the mask that the camera ignores in collision events.
  38761. */
  38762. collisionMask: number;
  38763. /** @hidden */
  38764. _collideWithWorld(displacement: Vector3): void;
  38765. /** @hidden */
  38766. private _onCollisionPositionChange;
  38767. /** @hidden */
  38768. _checkInputs(): void;
  38769. /** @hidden */
  38770. _decideIfNeedsToMove(): boolean;
  38771. /** @hidden */
  38772. _updatePosition(): void;
  38773. /**
  38774. * Restore the Roll to its target value at the rate specified.
  38775. * @param rate - Higher means slower restoring.
  38776. * @hidden
  38777. */
  38778. restoreRoll(rate: number): void;
  38779. /**
  38780. * Destroy the camera and release the current resources held by it.
  38781. */
  38782. dispose(): void;
  38783. /**
  38784. * Get the current object class name.
  38785. * @returns the class name.
  38786. */
  38787. getClassName(): string;
  38788. }
  38789. }
  38790. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38791. import { Nullable } from "babylonjs/types";
  38792. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38793. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38794. /**
  38795. * Listen to keyboard events to control the camera.
  38796. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38797. */
  38798. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38799. /**
  38800. * Defines the camera the input is attached to.
  38801. */
  38802. camera: FlyCamera;
  38803. /**
  38804. * The list of keyboard keys used to control the forward move of the camera.
  38805. */
  38806. keysForward: number[];
  38807. /**
  38808. * The list of keyboard keys used to control the backward move of the camera.
  38809. */
  38810. keysBackward: number[];
  38811. /**
  38812. * The list of keyboard keys used to control the forward move of the camera.
  38813. */
  38814. keysUp: number[];
  38815. /**
  38816. * The list of keyboard keys used to control the backward move of the camera.
  38817. */
  38818. keysDown: number[];
  38819. /**
  38820. * The list of keyboard keys used to control the right strafe move of the camera.
  38821. */
  38822. keysRight: number[];
  38823. /**
  38824. * The list of keyboard keys used to control the left strafe move of the camera.
  38825. */
  38826. keysLeft: number[];
  38827. private _keys;
  38828. private _onCanvasBlurObserver;
  38829. private _onKeyboardObserver;
  38830. private _engine;
  38831. private _scene;
  38832. /**
  38833. * Attach the input controls to a specific dom element to get the input from.
  38834. * @param element Defines the element the controls should be listened from
  38835. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38836. */
  38837. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38838. /**
  38839. * Detach the current controls from the specified dom element.
  38840. * @param element Defines the element to stop listening the inputs from
  38841. */
  38842. detachControl(element: Nullable<HTMLElement>): void;
  38843. /**
  38844. * Gets the class name of the current intput.
  38845. * @returns the class name
  38846. */
  38847. getClassName(): string;
  38848. /** @hidden */
  38849. _onLostFocus(e: FocusEvent): void;
  38850. /**
  38851. * Get the friendly name associated with the input class.
  38852. * @returns the input friendly name
  38853. */
  38854. getSimpleName(): string;
  38855. /**
  38856. * Update the current camera state depending on the inputs that have been used this frame.
  38857. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38858. */
  38859. checkInputs(): void;
  38860. }
  38861. }
  38862. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38863. import { Nullable } from "babylonjs/types";
  38864. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38865. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38866. /**
  38867. * Manage the mouse wheel inputs to control a follow camera.
  38868. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38869. */
  38870. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38871. /**
  38872. * Defines the camera the input is attached to.
  38873. */
  38874. camera: FollowCamera;
  38875. /**
  38876. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38877. */
  38878. axisControlRadius: boolean;
  38879. /**
  38880. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38881. */
  38882. axisControlHeight: boolean;
  38883. /**
  38884. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38885. */
  38886. axisControlRotation: boolean;
  38887. /**
  38888. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38889. * relation to mouseWheel events.
  38890. */
  38891. wheelPrecision: number;
  38892. /**
  38893. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38894. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38895. */
  38896. wheelDeltaPercentage: number;
  38897. private _wheel;
  38898. private _observer;
  38899. /**
  38900. * Attach the input controls to a specific dom element to get the input from.
  38901. * @param element Defines the element the controls should be listened from
  38902. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38903. */
  38904. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38905. /**
  38906. * Detach the current controls from the specified dom element.
  38907. * @param element Defines the element to stop listening the inputs from
  38908. */
  38909. detachControl(element: Nullable<HTMLElement>): void;
  38910. /**
  38911. * Gets the class name of the current intput.
  38912. * @returns the class name
  38913. */
  38914. getClassName(): string;
  38915. /**
  38916. * Get the friendly name associated with the input class.
  38917. * @returns the input friendly name
  38918. */
  38919. getSimpleName(): string;
  38920. }
  38921. }
  38922. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38923. import { Nullable } from "babylonjs/types";
  38924. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38925. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38926. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38927. /**
  38928. * Manage the pointers inputs to control an follow camera.
  38929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38930. */
  38931. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38932. /**
  38933. * Defines the camera the input is attached to.
  38934. */
  38935. camera: FollowCamera;
  38936. /**
  38937. * Gets the class name of the current input.
  38938. * @returns the class name
  38939. */
  38940. getClassName(): string;
  38941. /**
  38942. * Defines the pointer angular sensibility along the X axis or how fast is
  38943. * the camera rotating.
  38944. * A negative number will reverse the axis direction.
  38945. */
  38946. angularSensibilityX: number;
  38947. /**
  38948. * Defines the pointer angular sensibility along the Y axis or how fast is
  38949. * the camera rotating.
  38950. * A negative number will reverse the axis direction.
  38951. */
  38952. angularSensibilityY: number;
  38953. /**
  38954. * Defines the pointer pinch precision or how fast is the camera zooming.
  38955. * A negative number will reverse the axis direction.
  38956. */
  38957. pinchPrecision: number;
  38958. /**
  38959. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38960. * from 0.
  38961. * It defines the percentage of current camera.radius to use as delta when
  38962. * pinch zoom is used.
  38963. */
  38964. pinchDeltaPercentage: number;
  38965. /**
  38966. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38967. */
  38968. axisXControlRadius: boolean;
  38969. /**
  38970. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38971. */
  38972. axisXControlHeight: boolean;
  38973. /**
  38974. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38975. */
  38976. axisXControlRotation: boolean;
  38977. /**
  38978. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38979. */
  38980. axisYControlRadius: boolean;
  38981. /**
  38982. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38983. */
  38984. axisYControlHeight: boolean;
  38985. /**
  38986. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38987. */
  38988. axisYControlRotation: boolean;
  38989. /**
  38990. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38991. */
  38992. axisPinchControlRadius: boolean;
  38993. /**
  38994. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38995. */
  38996. axisPinchControlHeight: boolean;
  38997. /**
  38998. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38999. */
  39000. axisPinchControlRotation: boolean;
  39001. /**
  39002. * Log error messages if basic misconfiguration has occurred.
  39003. */
  39004. warningEnable: boolean;
  39005. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39006. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39007. private _warningCounter;
  39008. private _warning;
  39009. }
  39010. }
  39011. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39012. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39013. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39014. /**
  39015. * Default Inputs manager for the FollowCamera.
  39016. * It groups all the default supported inputs for ease of use.
  39017. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39018. */
  39019. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39020. /**
  39021. * Instantiates a new FollowCameraInputsManager.
  39022. * @param camera Defines the camera the inputs belong to
  39023. */
  39024. constructor(camera: FollowCamera);
  39025. /**
  39026. * Add keyboard input support to the input manager.
  39027. * @returns the current input manager
  39028. */
  39029. addKeyboard(): FollowCameraInputsManager;
  39030. /**
  39031. * Add mouse wheel input support to the input manager.
  39032. * @returns the current input manager
  39033. */
  39034. addMouseWheel(): FollowCameraInputsManager;
  39035. /**
  39036. * Add pointers input support to the input manager.
  39037. * @returns the current input manager
  39038. */
  39039. addPointers(): FollowCameraInputsManager;
  39040. /**
  39041. * Add orientation input support to the input manager.
  39042. * @returns the current input manager
  39043. */
  39044. addVRDeviceOrientation(): FollowCameraInputsManager;
  39045. }
  39046. }
  39047. declare module "babylonjs/Cameras/followCamera" {
  39048. import { Nullable } from "babylonjs/types";
  39049. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39050. import { Scene } from "babylonjs/scene";
  39051. import { Vector3 } from "babylonjs/Maths/math.vector";
  39052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39053. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39054. /**
  39055. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39056. * an arc rotate version arcFollowCamera are available.
  39057. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39058. */
  39059. export class FollowCamera extends TargetCamera {
  39060. /**
  39061. * Distance the follow camera should follow an object at
  39062. */
  39063. radius: number;
  39064. /**
  39065. * Minimum allowed distance of the camera to the axis of rotation
  39066. * (The camera can not get closer).
  39067. * This can help limiting how the Camera is able to move in the scene.
  39068. */
  39069. lowerRadiusLimit: Nullable<number>;
  39070. /**
  39071. * Maximum allowed distance of the camera to the axis of rotation
  39072. * (The camera can not get further).
  39073. * This can help limiting how the Camera is able to move in the scene.
  39074. */
  39075. upperRadiusLimit: Nullable<number>;
  39076. /**
  39077. * Define a rotation offset between the camera and the object it follows
  39078. */
  39079. rotationOffset: number;
  39080. /**
  39081. * Minimum allowed angle to camera position relative to target object.
  39082. * This can help limiting how the Camera is able to move in the scene.
  39083. */
  39084. lowerRotationOffsetLimit: Nullable<number>;
  39085. /**
  39086. * Maximum allowed angle to camera position relative to target object.
  39087. * This can help limiting how the Camera is able to move in the scene.
  39088. */
  39089. upperRotationOffsetLimit: Nullable<number>;
  39090. /**
  39091. * Define a height offset between the camera and the object it follows.
  39092. * It can help following an object from the top (like a car chaing a plane)
  39093. */
  39094. heightOffset: number;
  39095. /**
  39096. * Minimum allowed height of camera position relative to target object.
  39097. * This can help limiting how the Camera is able to move in the scene.
  39098. */
  39099. lowerHeightOffsetLimit: Nullable<number>;
  39100. /**
  39101. * Maximum allowed height of camera position relative to target object.
  39102. * This can help limiting how the Camera is able to move in the scene.
  39103. */
  39104. upperHeightOffsetLimit: Nullable<number>;
  39105. /**
  39106. * Define how fast the camera can accelerate to follow it s target.
  39107. */
  39108. cameraAcceleration: number;
  39109. /**
  39110. * Define the speed limit of the camera following an object.
  39111. */
  39112. maxCameraSpeed: number;
  39113. /**
  39114. * Define the target of the camera.
  39115. */
  39116. lockedTarget: Nullable<AbstractMesh>;
  39117. /**
  39118. * Defines the input associated with the camera.
  39119. */
  39120. inputs: FollowCameraInputsManager;
  39121. /**
  39122. * Instantiates the follow camera.
  39123. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39124. * @param name Define the name of the camera in the scene
  39125. * @param position Define the position of the camera
  39126. * @param scene Define the scene the camera belong to
  39127. * @param lockedTarget Define the target of the camera
  39128. */
  39129. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39130. private _follow;
  39131. /**
  39132. * Attached controls to the current camera.
  39133. * @param element Defines the element the controls should be listened from
  39134. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39135. */
  39136. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39137. /**
  39138. * Detach the current controls from the camera.
  39139. * The camera will stop reacting to inputs.
  39140. * @param element Defines the element to stop listening the inputs from
  39141. */
  39142. detachControl(element: HTMLElement): void;
  39143. /** @hidden */
  39144. _checkInputs(): void;
  39145. private _checkLimits;
  39146. /**
  39147. * Gets the camera class name.
  39148. * @returns the class name
  39149. */
  39150. getClassName(): string;
  39151. }
  39152. /**
  39153. * Arc Rotate version of the follow camera.
  39154. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39155. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39156. */
  39157. export class ArcFollowCamera extends TargetCamera {
  39158. /** The longitudinal angle of the camera */
  39159. alpha: number;
  39160. /** The latitudinal angle of the camera */
  39161. beta: number;
  39162. /** The radius of the camera from its target */
  39163. radius: number;
  39164. /** Define the camera target (the messh it should follow) */
  39165. target: Nullable<AbstractMesh>;
  39166. private _cartesianCoordinates;
  39167. /**
  39168. * Instantiates a new ArcFollowCamera
  39169. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39170. * @param name Define the name of the camera
  39171. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39172. * @param beta Define the rotation angle of the camera around the elevation axis
  39173. * @param radius Define the radius of the camera from its target point
  39174. * @param target Define the target of the camera
  39175. * @param scene Define the scene the camera belongs to
  39176. */
  39177. constructor(name: string,
  39178. /** The longitudinal angle of the camera */
  39179. alpha: number,
  39180. /** The latitudinal angle of the camera */
  39181. beta: number,
  39182. /** The radius of the camera from its target */
  39183. radius: number,
  39184. /** Define the camera target (the messh it should follow) */
  39185. target: Nullable<AbstractMesh>, scene: Scene);
  39186. private _follow;
  39187. /** @hidden */
  39188. _checkInputs(): void;
  39189. /**
  39190. * Returns the class name of the object.
  39191. * It is mostly used internally for serialization purposes.
  39192. */
  39193. getClassName(): string;
  39194. }
  39195. }
  39196. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39197. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39198. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39199. import { Nullable } from "babylonjs/types";
  39200. /**
  39201. * Manage the keyboard inputs to control the movement of a follow camera.
  39202. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39203. */
  39204. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39205. /**
  39206. * Defines the camera the input is attached to.
  39207. */
  39208. camera: FollowCamera;
  39209. /**
  39210. * Defines the list of key codes associated with the up action (increase heightOffset)
  39211. */
  39212. keysHeightOffsetIncr: number[];
  39213. /**
  39214. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39215. */
  39216. keysHeightOffsetDecr: number[];
  39217. /**
  39218. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39219. */
  39220. keysHeightOffsetModifierAlt: boolean;
  39221. /**
  39222. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39223. */
  39224. keysHeightOffsetModifierCtrl: boolean;
  39225. /**
  39226. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39227. */
  39228. keysHeightOffsetModifierShift: boolean;
  39229. /**
  39230. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39231. */
  39232. keysRotationOffsetIncr: number[];
  39233. /**
  39234. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39235. */
  39236. keysRotationOffsetDecr: number[];
  39237. /**
  39238. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39239. */
  39240. keysRotationOffsetModifierAlt: boolean;
  39241. /**
  39242. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39243. */
  39244. keysRotationOffsetModifierCtrl: boolean;
  39245. /**
  39246. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39247. */
  39248. keysRotationOffsetModifierShift: boolean;
  39249. /**
  39250. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39251. */
  39252. keysRadiusIncr: number[];
  39253. /**
  39254. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39255. */
  39256. keysRadiusDecr: number[];
  39257. /**
  39258. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39259. */
  39260. keysRadiusModifierAlt: boolean;
  39261. /**
  39262. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39263. */
  39264. keysRadiusModifierCtrl: boolean;
  39265. /**
  39266. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39267. */
  39268. keysRadiusModifierShift: boolean;
  39269. /**
  39270. * Defines the rate of change of heightOffset.
  39271. */
  39272. heightSensibility: number;
  39273. /**
  39274. * Defines the rate of change of rotationOffset.
  39275. */
  39276. rotationSensibility: number;
  39277. /**
  39278. * Defines the rate of change of radius.
  39279. */
  39280. radiusSensibility: number;
  39281. private _keys;
  39282. private _ctrlPressed;
  39283. private _altPressed;
  39284. private _shiftPressed;
  39285. private _onCanvasBlurObserver;
  39286. private _onKeyboardObserver;
  39287. private _engine;
  39288. private _scene;
  39289. /**
  39290. * Attach the input controls to a specific dom element to get the input from.
  39291. * @param element Defines the element the controls should be listened from
  39292. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39293. */
  39294. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39295. /**
  39296. * Detach the current controls from the specified dom element.
  39297. * @param element Defines the element to stop listening the inputs from
  39298. */
  39299. detachControl(element: Nullable<HTMLElement>): void;
  39300. /**
  39301. * Update the current camera state depending on the inputs that have been used this frame.
  39302. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39303. */
  39304. checkInputs(): void;
  39305. /**
  39306. * Gets the class name of the current input.
  39307. * @returns the class name
  39308. */
  39309. getClassName(): string;
  39310. /**
  39311. * Get the friendly name associated with the input class.
  39312. * @returns the input friendly name
  39313. */
  39314. getSimpleName(): string;
  39315. /**
  39316. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39317. * allow modification of the heightOffset value.
  39318. */
  39319. private _modifierHeightOffset;
  39320. /**
  39321. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39322. * allow modification of the rotationOffset value.
  39323. */
  39324. private _modifierRotationOffset;
  39325. /**
  39326. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39327. * allow modification of the radius value.
  39328. */
  39329. private _modifierRadius;
  39330. }
  39331. }
  39332. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39333. import { Nullable } from "babylonjs/types";
  39334. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39335. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39336. import { Observable } from "babylonjs/Misc/observable";
  39337. module "babylonjs/Cameras/freeCameraInputsManager" {
  39338. interface FreeCameraInputsManager {
  39339. /**
  39340. * @hidden
  39341. */
  39342. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39343. /**
  39344. * Add orientation input support to the input manager.
  39345. * @returns the current input manager
  39346. */
  39347. addDeviceOrientation(): FreeCameraInputsManager;
  39348. }
  39349. }
  39350. /**
  39351. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39352. * Screen rotation is taken into account.
  39353. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39354. */
  39355. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39356. private _camera;
  39357. private _screenOrientationAngle;
  39358. private _constantTranform;
  39359. private _screenQuaternion;
  39360. private _alpha;
  39361. private _beta;
  39362. private _gamma;
  39363. /**
  39364. * Can be used to detect if a device orientation sensor is availible on a device
  39365. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39366. * @returns a promise that will resolve on orientation change
  39367. */
  39368. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39369. /**
  39370. * @hidden
  39371. */
  39372. _onDeviceOrientationChangedObservable: Observable<void>;
  39373. /**
  39374. * Instantiates a new input
  39375. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39376. */
  39377. constructor();
  39378. /**
  39379. * Define the camera controlled by the input.
  39380. */
  39381. camera: FreeCamera;
  39382. /**
  39383. * Attach the input controls to a specific dom element to get the input from.
  39384. * @param element Defines the element the controls should be listened from
  39385. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39386. */
  39387. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39388. private _orientationChanged;
  39389. private _deviceOrientation;
  39390. /**
  39391. * Detach the current controls from the specified dom element.
  39392. * @param element Defines the element to stop listening the inputs from
  39393. */
  39394. detachControl(element: Nullable<HTMLElement>): void;
  39395. /**
  39396. * Update the current camera state depending on the inputs that have been used this frame.
  39397. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39398. */
  39399. checkInputs(): void;
  39400. /**
  39401. * Gets the class name of the current intput.
  39402. * @returns the class name
  39403. */
  39404. getClassName(): string;
  39405. /**
  39406. * Get the friendly name associated with the input class.
  39407. * @returns the input friendly name
  39408. */
  39409. getSimpleName(): string;
  39410. }
  39411. }
  39412. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39413. import { Nullable } from "babylonjs/types";
  39414. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39415. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39416. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39417. /**
  39418. * Manage the gamepad inputs to control a free camera.
  39419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39420. */
  39421. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39422. /**
  39423. * Define the camera the input is attached to.
  39424. */
  39425. camera: FreeCamera;
  39426. /**
  39427. * Define the Gamepad controlling the input
  39428. */
  39429. gamepad: Nullable<Gamepad>;
  39430. /**
  39431. * Defines the gamepad rotation sensiblity.
  39432. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39433. */
  39434. gamepadAngularSensibility: number;
  39435. /**
  39436. * Defines the gamepad move sensiblity.
  39437. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39438. */
  39439. gamepadMoveSensibility: number;
  39440. private _onGamepadConnectedObserver;
  39441. private _onGamepadDisconnectedObserver;
  39442. private _cameraTransform;
  39443. private _deltaTransform;
  39444. private _vector3;
  39445. private _vector2;
  39446. /**
  39447. * Attach the input controls to a specific dom element to get the input from.
  39448. * @param element Defines the element the controls should be listened from
  39449. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39450. */
  39451. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39452. /**
  39453. * Detach the current controls from the specified dom element.
  39454. * @param element Defines the element to stop listening the inputs from
  39455. */
  39456. detachControl(element: Nullable<HTMLElement>): void;
  39457. /**
  39458. * Update the current camera state depending on the inputs that have been used this frame.
  39459. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39460. */
  39461. checkInputs(): void;
  39462. /**
  39463. * Gets the class name of the current intput.
  39464. * @returns the class name
  39465. */
  39466. getClassName(): string;
  39467. /**
  39468. * Get the friendly name associated with the input class.
  39469. * @returns the input friendly name
  39470. */
  39471. getSimpleName(): string;
  39472. }
  39473. }
  39474. declare module "babylonjs/Misc/virtualJoystick" {
  39475. import { Nullable } from "babylonjs/types";
  39476. import { Vector3 } from "babylonjs/Maths/math.vector";
  39477. /**
  39478. * Defines the potential axis of a Joystick
  39479. */
  39480. export enum JoystickAxis {
  39481. /** X axis */
  39482. X = 0,
  39483. /** Y axis */
  39484. Y = 1,
  39485. /** Z axis */
  39486. Z = 2
  39487. }
  39488. /**
  39489. * Class used to define virtual joystick (used in touch mode)
  39490. */
  39491. export class VirtualJoystick {
  39492. /**
  39493. * Gets or sets a boolean indicating that left and right values must be inverted
  39494. */
  39495. reverseLeftRight: boolean;
  39496. /**
  39497. * Gets or sets a boolean indicating that up and down values must be inverted
  39498. */
  39499. reverseUpDown: boolean;
  39500. /**
  39501. * Gets the offset value for the position (ie. the change of the position value)
  39502. */
  39503. deltaPosition: Vector3;
  39504. /**
  39505. * Gets a boolean indicating if the virtual joystick was pressed
  39506. */
  39507. pressed: boolean;
  39508. /**
  39509. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39510. */
  39511. static Canvas: Nullable<HTMLCanvasElement>;
  39512. private static _globalJoystickIndex;
  39513. private static vjCanvasContext;
  39514. private static vjCanvasWidth;
  39515. private static vjCanvasHeight;
  39516. private static halfWidth;
  39517. private _action;
  39518. private _axisTargetedByLeftAndRight;
  39519. private _axisTargetedByUpAndDown;
  39520. private _joystickSensibility;
  39521. private _inversedSensibility;
  39522. private _joystickPointerID;
  39523. private _joystickColor;
  39524. private _joystickPointerPos;
  39525. private _joystickPreviousPointerPos;
  39526. private _joystickPointerStartPos;
  39527. private _deltaJoystickVector;
  39528. private _leftJoystick;
  39529. private _touches;
  39530. private _onPointerDownHandlerRef;
  39531. private _onPointerMoveHandlerRef;
  39532. private _onPointerUpHandlerRef;
  39533. private _onResize;
  39534. /**
  39535. * Creates a new virtual joystick
  39536. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39537. */
  39538. constructor(leftJoystick?: boolean);
  39539. /**
  39540. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39541. * @param newJoystickSensibility defines the new sensibility
  39542. */
  39543. setJoystickSensibility(newJoystickSensibility: number): void;
  39544. private _onPointerDown;
  39545. private _onPointerMove;
  39546. private _onPointerUp;
  39547. /**
  39548. * Change the color of the virtual joystick
  39549. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39550. */
  39551. setJoystickColor(newColor: string): void;
  39552. /**
  39553. * Defines a callback to call when the joystick is touched
  39554. * @param action defines the callback
  39555. */
  39556. setActionOnTouch(action: () => any): void;
  39557. /**
  39558. * Defines which axis you'd like to control for left & right
  39559. * @param axis defines the axis to use
  39560. */
  39561. setAxisForLeftRight(axis: JoystickAxis): void;
  39562. /**
  39563. * Defines which axis you'd like to control for up & down
  39564. * @param axis defines the axis to use
  39565. */
  39566. setAxisForUpDown(axis: JoystickAxis): void;
  39567. private _drawVirtualJoystick;
  39568. /**
  39569. * Release internal HTML canvas
  39570. */
  39571. releaseCanvas(): void;
  39572. }
  39573. }
  39574. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39575. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39576. import { Nullable } from "babylonjs/types";
  39577. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39578. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39579. module "babylonjs/Cameras/freeCameraInputsManager" {
  39580. interface FreeCameraInputsManager {
  39581. /**
  39582. * Add virtual joystick input support to the input manager.
  39583. * @returns the current input manager
  39584. */
  39585. addVirtualJoystick(): FreeCameraInputsManager;
  39586. }
  39587. }
  39588. /**
  39589. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39590. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39591. */
  39592. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39593. /**
  39594. * Defines the camera the input is attached to.
  39595. */
  39596. camera: FreeCamera;
  39597. private _leftjoystick;
  39598. private _rightjoystick;
  39599. /**
  39600. * Gets the left stick of the virtual joystick.
  39601. * @returns The virtual Joystick
  39602. */
  39603. getLeftJoystick(): VirtualJoystick;
  39604. /**
  39605. * Gets the right stick of the virtual joystick.
  39606. * @returns The virtual Joystick
  39607. */
  39608. getRightJoystick(): VirtualJoystick;
  39609. /**
  39610. * Update the current camera state depending on the inputs that have been used this frame.
  39611. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39612. */
  39613. checkInputs(): void;
  39614. /**
  39615. * Attach the input controls to a specific dom element to get the input from.
  39616. * @param element Defines the element the controls should be listened from
  39617. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39618. */
  39619. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39620. /**
  39621. * Detach the current controls from the specified dom element.
  39622. * @param element Defines the element to stop listening the inputs from
  39623. */
  39624. detachControl(element: Nullable<HTMLElement>): void;
  39625. /**
  39626. * Gets the class name of the current intput.
  39627. * @returns the class name
  39628. */
  39629. getClassName(): string;
  39630. /**
  39631. * Get the friendly name associated with the input class.
  39632. * @returns the input friendly name
  39633. */
  39634. getSimpleName(): string;
  39635. }
  39636. }
  39637. declare module "babylonjs/Cameras/Inputs/index" {
  39638. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39639. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39640. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39641. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39642. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39643. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39644. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39645. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39646. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39647. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39648. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39649. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39650. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39651. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39652. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39653. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39654. }
  39655. declare module "babylonjs/Cameras/touchCamera" {
  39656. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39657. import { Scene } from "babylonjs/scene";
  39658. import { Vector3 } from "babylonjs/Maths/math.vector";
  39659. /**
  39660. * This represents a FPS type of camera controlled by touch.
  39661. * This is like a universal camera minus the Gamepad controls.
  39662. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39663. */
  39664. export class TouchCamera extends FreeCamera {
  39665. /**
  39666. * Defines the touch sensibility for rotation.
  39667. * The higher the faster.
  39668. */
  39669. touchAngularSensibility: number;
  39670. /**
  39671. * Defines the touch sensibility for move.
  39672. * The higher the faster.
  39673. */
  39674. touchMoveSensibility: number;
  39675. /**
  39676. * Instantiates a new touch camera.
  39677. * This represents a FPS type of camera controlled by touch.
  39678. * This is like a universal camera minus the Gamepad controls.
  39679. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39680. * @param name Define the name of the camera in the scene
  39681. * @param position Define the start position of the camera in the scene
  39682. * @param scene Define the scene the camera belongs to
  39683. */
  39684. constructor(name: string, position: Vector3, scene: Scene);
  39685. /**
  39686. * Gets the current object class name.
  39687. * @return the class name
  39688. */
  39689. getClassName(): string;
  39690. /** @hidden */
  39691. _setupInputs(): void;
  39692. }
  39693. }
  39694. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39695. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39696. import { Scene } from "babylonjs/scene";
  39697. import { Vector3 } from "babylonjs/Maths/math.vector";
  39698. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39699. import { Axis } from "babylonjs/Maths/math.axis";
  39700. /**
  39701. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39702. * being tilted forward or back and left or right.
  39703. */
  39704. export class DeviceOrientationCamera extends FreeCamera {
  39705. private _initialQuaternion;
  39706. private _quaternionCache;
  39707. private _tmpDragQuaternion;
  39708. private _disablePointerInputWhenUsingDeviceOrientation;
  39709. /**
  39710. * Creates a new device orientation camera
  39711. * @param name The name of the camera
  39712. * @param position The start position camera
  39713. * @param scene The scene the camera belongs to
  39714. */
  39715. constructor(name: string, position: Vector3, scene: Scene);
  39716. /**
  39717. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39718. */
  39719. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39720. private _dragFactor;
  39721. /**
  39722. * Enabled turning on the y axis when the orientation sensor is active
  39723. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39724. */
  39725. enableHorizontalDragging(dragFactor?: number): void;
  39726. /**
  39727. * Gets the current instance class name ("DeviceOrientationCamera").
  39728. * This helps avoiding instanceof at run time.
  39729. * @returns the class name
  39730. */
  39731. getClassName(): string;
  39732. /**
  39733. * @hidden
  39734. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39735. */
  39736. _checkInputs(): void;
  39737. /**
  39738. * Reset the camera to its default orientation on the specified axis only.
  39739. * @param axis The axis to reset
  39740. */
  39741. resetToCurrentRotation(axis?: Axis): void;
  39742. }
  39743. }
  39744. declare module "babylonjs/Gamepads/xboxGamepad" {
  39745. import { Observable } from "babylonjs/Misc/observable";
  39746. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39747. /**
  39748. * Defines supported buttons for XBox360 compatible gamepads
  39749. */
  39750. export enum Xbox360Button {
  39751. /** A */
  39752. A = 0,
  39753. /** B */
  39754. B = 1,
  39755. /** X */
  39756. X = 2,
  39757. /** Y */
  39758. Y = 3,
  39759. /** Start */
  39760. Start = 4,
  39761. /** Back */
  39762. Back = 5,
  39763. /** Left button */
  39764. LB = 6,
  39765. /** Right button */
  39766. RB = 7,
  39767. /** Left stick */
  39768. LeftStick = 8,
  39769. /** Right stick */
  39770. RightStick = 9
  39771. }
  39772. /** Defines values for XBox360 DPad */
  39773. export enum Xbox360Dpad {
  39774. /** Up */
  39775. Up = 0,
  39776. /** Down */
  39777. Down = 1,
  39778. /** Left */
  39779. Left = 2,
  39780. /** Right */
  39781. Right = 3
  39782. }
  39783. /**
  39784. * Defines a XBox360 gamepad
  39785. */
  39786. export class Xbox360Pad extends Gamepad {
  39787. private _leftTrigger;
  39788. private _rightTrigger;
  39789. private _onlefttriggerchanged;
  39790. private _onrighttriggerchanged;
  39791. private _onbuttondown;
  39792. private _onbuttonup;
  39793. private _ondpaddown;
  39794. private _ondpadup;
  39795. /** Observable raised when a button is pressed */
  39796. onButtonDownObservable: Observable<Xbox360Button>;
  39797. /** Observable raised when a button is released */
  39798. onButtonUpObservable: Observable<Xbox360Button>;
  39799. /** Observable raised when a pad is pressed */
  39800. onPadDownObservable: Observable<Xbox360Dpad>;
  39801. /** Observable raised when a pad is released */
  39802. onPadUpObservable: Observable<Xbox360Dpad>;
  39803. private _buttonA;
  39804. private _buttonB;
  39805. private _buttonX;
  39806. private _buttonY;
  39807. private _buttonBack;
  39808. private _buttonStart;
  39809. private _buttonLB;
  39810. private _buttonRB;
  39811. private _buttonLeftStick;
  39812. private _buttonRightStick;
  39813. private _dPadUp;
  39814. private _dPadDown;
  39815. private _dPadLeft;
  39816. private _dPadRight;
  39817. private _isXboxOnePad;
  39818. /**
  39819. * Creates a new XBox360 gamepad object
  39820. * @param id defines the id of this gamepad
  39821. * @param index defines its index
  39822. * @param gamepad defines the internal HTML gamepad object
  39823. * @param xboxOne defines if it is a XBox One gamepad
  39824. */
  39825. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39826. /**
  39827. * Defines the callback to call when left trigger is pressed
  39828. * @param callback defines the callback to use
  39829. */
  39830. onlefttriggerchanged(callback: (value: number) => void): void;
  39831. /**
  39832. * Defines the callback to call when right trigger is pressed
  39833. * @param callback defines the callback to use
  39834. */
  39835. onrighttriggerchanged(callback: (value: number) => void): void;
  39836. /**
  39837. * Gets the left trigger value
  39838. */
  39839. /**
  39840. * Sets the left trigger value
  39841. */
  39842. leftTrigger: number;
  39843. /**
  39844. * Gets the right trigger value
  39845. */
  39846. /**
  39847. * Sets the right trigger value
  39848. */
  39849. rightTrigger: number;
  39850. /**
  39851. * Defines the callback to call when a button is pressed
  39852. * @param callback defines the callback to use
  39853. */
  39854. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39855. /**
  39856. * Defines the callback to call when a button is released
  39857. * @param callback defines the callback to use
  39858. */
  39859. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39860. /**
  39861. * Defines the callback to call when a pad is pressed
  39862. * @param callback defines the callback to use
  39863. */
  39864. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39865. /**
  39866. * Defines the callback to call when a pad is released
  39867. * @param callback defines the callback to use
  39868. */
  39869. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39870. private _setButtonValue;
  39871. private _setDPadValue;
  39872. /**
  39873. * Gets the value of the `A` button
  39874. */
  39875. /**
  39876. * Sets the value of the `A` button
  39877. */
  39878. buttonA: number;
  39879. /**
  39880. * Gets the value of the `B` button
  39881. */
  39882. /**
  39883. * Sets the value of the `B` button
  39884. */
  39885. buttonB: number;
  39886. /**
  39887. * Gets the value of the `X` button
  39888. */
  39889. /**
  39890. * Sets the value of the `X` button
  39891. */
  39892. buttonX: number;
  39893. /**
  39894. * Gets the value of the `Y` button
  39895. */
  39896. /**
  39897. * Sets the value of the `Y` button
  39898. */
  39899. buttonY: number;
  39900. /**
  39901. * Gets the value of the `Start` button
  39902. */
  39903. /**
  39904. * Sets the value of the `Start` button
  39905. */
  39906. buttonStart: number;
  39907. /**
  39908. * Gets the value of the `Back` button
  39909. */
  39910. /**
  39911. * Sets the value of the `Back` button
  39912. */
  39913. buttonBack: number;
  39914. /**
  39915. * Gets the value of the `Left` button
  39916. */
  39917. /**
  39918. * Sets the value of the `Left` button
  39919. */
  39920. buttonLB: number;
  39921. /**
  39922. * Gets the value of the `Right` button
  39923. */
  39924. /**
  39925. * Sets the value of the `Right` button
  39926. */
  39927. buttonRB: number;
  39928. /**
  39929. * Gets the value of the Left joystick
  39930. */
  39931. /**
  39932. * Sets the value of the Left joystick
  39933. */
  39934. buttonLeftStick: number;
  39935. /**
  39936. * Gets the value of the Right joystick
  39937. */
  39938. /**
  39939. * Sets the value of the Right joystick
  39940. */
  39941. buttonRightStick: number;
  39942. /**
  39943. * Gets the value of D-pad up
  39944. */
  39945. /**
  39946. * Sets the value of D-pad up
  39947. */
  39948. dPadUp: number;
  39949. /**
  39950. * Gets the value of D-pad down
  39951. */
  39952. /**
  39953. * Sets the value of D-pad down
  39954. */
  39955. dPadDown: number;
  39956. /**
  39957. * Gets the value of D-pad left
  39958. */
  39959. /**
  39960. * Sets the value of D-pad left
  39961. */
  39962. dPadLeft: number;
  39963. /**
  39964. * Gets the value of D-pad right
  39965. */
  39966. /**
  39967. * Sets the value of D-pad right
  39968. */
  39969. dPadRight: number;
  39970. /**
  39971. * Force the gamepad to synchronize with device values
  39972. */
  39973. update(): void;
  39974. /**
  39975. * Disposes the gamepad
  39976. */
  39977. dispose(): void;
  39978. }
  39979. }
  39980. declare module "babylonjs/Gamepads/dualShockGamepad" {
  39981. import { Observable } from "babylonjs/Misc/observable";
  39982. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39983. /**
  39984. * Defines supported buttons for DualShock compatible gamepads
  39985. */
  39986. export enum DualShockButton {
  39987. /** Cross */
  39988. Cross = 0,
  39989. /** Circle */
  39990. Circle = 1,
  39991. /** Square */
  39992. Square = 2,
  39993. /** Triangle */
  39994. Triangle = 3,
  39995. /** Options */
  39996. Options = 4,
  39997. /** Share */
  39998. Share = 5,
  39999. /** L1 */
  40000. L1 = 6,
  40001. /** R1 */
  40002. R1 = 7,
  40003. /** Left stick */
  40004. LeftStick = 8,
  40005. /** Right stick */
  40006. RightStick = 9
  40007. }
  40008. /** Defines values for DualShock DPad */
  40009. export enum DualShockDpad {
  40010. /** Up */
  40011. Up = 0,
  40012. /** Down */
  40013. Down = 1,
  40014. /** Left */
  40015. Left = 2,
  40016. /** Right */
  40017. Right = 3
  40018. }
  40019. /**
  40020. * Defines a DualShock gamepad
  40021. */
  40022. export class DualShockPad extends Gamepad {
  40023. private _leftTrigger;
  40024. private _rightTrigger;
  40025. private _onlefttriggerchanged;
  40026. private _onrighttriggerchanged;
  40027. private _onbuttondown;
  40028. private _onbuttonup;
  40029. private _ondpaddown;
  40030. private _ondpadup;
  40031. /** Observable raised when a button is pressed */
  40032. onButtonDownObservable: Observable<DualShockButton>;
  40033. /** Observable raised when a button is released */
  40034. onButtonUpObservable: Observable<DualShockButton>;
  40035. /** Observable raised when a pad is pressed */
  40036. onPadDownObservable: Observable<DualShockDpad>;
  40037. /** Observable raised when a pad is released */
  40038. onPadUpObservable: Observable<DualShockDpad>;
  40039. private _buttonCross;
  40040. private _buttonCircle;
  40041. private _buttonSquare;
  40042. private _buttonTriangle;
  40043. private _buttonShare;
  40044. private _buttonOptions;
  40045. private _buttonL1;
  40046. private _buttonR1;
  40047. private _buttonLeftStick;
  40048. private _buttonRightStick;
  40049. private _dPadUp;
  40050. private _dPadDown;
  40051. private _dPadLeft;
  40052. private _dPadRight;
  40053. /**
  40054. * Creates a new DualShock gamepad object
  40055. * @param id defines the id of this gamepad
  40056. * @param index defines its index
  40057. * @param gamepad defines the internal HTML gamepad object
  40058. */
  40059. constructor(id: string, index: number, gamepad: any);
  40060. /**
  40061. * Defines the callback to call when left trigger is pressed
  40062. * @param callback defines the callback to use
  40063. */
  40064. onlefttriggerchanged(callback: (value: number) => void): void;
  40065. /**
  40066. * Defines the callback to call when right trigger is pressed
  40067. * @param callback defines the callback to use
  40068. */
  40069. onrighttriggerchanged(callback: (value: number) => void): void;
  40070. /**
  40071. * Gets the left trigger value
  40072. */
  40073. /**
  40074. * Sets the left trigger value
  40075. */
  40076. leftTrigger: number;
  40077. /**
  40078. * Gets the right trigger value
  40079. */
  40080. /**
  40081. * Sets the right trigger value
  40082. */
  40083. rightTrigger: number;
  40084. /**
  40085. * Defines the callback to call when a button is pressed
  40086. * @param callback defines the callback to use
  40087. */
  40088. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40089. /**
  40090. * Defines the callback to call when a button is released
  40091. * @param callback defines the callback to use
  40092. */
  40093. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40094. /**
  40095. * Defines the callback to call when a pad is pressed
  40096. * @param callback defines the callback to use
  40097. */
  40098. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40099. /**
  40100. * Defines the callback to call when a pad is released
  40101. * @param callback defines the callback to use
  40102. */
  40103. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40104. private _setButtonValue;
  40105. private _setDPadValue;
  40106. /**
  40107. * Gets the value of the `Cross` button
  40108. */
  40109. /**
  40110. * Sets the value of the `Cross` button
  40111. */
  40112. buttonCross: number;
  40113. /**
  40114. * Gets the value of the `Circle` button
  40115. */
  40116. /**
  40117. * Sets the value of the `Circle` button
  40118. */
  40119. buttonCircle: number;
  40120. /**
  40121. * Gets the value of the `Square` button
  40122. */
  40123. /**
  40124. * Sets the value of the `Square` button
  40125. */
  40126. buttonSquare: number;
  40127. /**
  40128. * Gets the value of the `Triangle` button
  40129. */
  40130. /**
  40131. * Sets the value of the `Triangle` button
  40132. */
  40133. buttonTriangle: number;
  40134. /**
  40135. * Gets the value of the `Options` button
  40136. */
  40137. /**
  40138. * Sets the value of the `Options` button
  40139. */
  40140. buttonOptions: number;
  40141. /**
  40142. * Gets the value of the `Share` button
  40143. */
  40144. /**
  40145. * Sets the value of the `Share` button
  40146. */
  40147. buttonShare: number;
  40148. /**
  40149. * Gets the value of the `L1` button
  40150. */
  40151. /**
  40152. * Sets the value of the `L1` button
  40153. */
  40154. buttonL1: number;
  40155. /**
  40156. * Gets the value of the `R1` button
  40157. */
  40158. /**
  40159. * Sets the value of the `R1` button
  40160. */
  40161. buttonR1: number;
  40162. /**
  40163. * Gets the value of the Left joystick
  40164. */
  40165. /**
  40166. * Sets the value of the Left joystick
  40167. */
  40168. buttonLeftStick: number;
  40169. /**
  40170. * Gets the value of the Right joystick
  40171. */
  40172. /**
  40173. * Sets the value of the Right joystick
  40174. */
  40175. buttonRightStick: number;
  40176. /**
  40177. * Gets the value of D-pad up
  40178. */
  40179. /**
  40180. * Sets the value of D-pad up
  40181. */
  40182. dPadUp: number;
  40183. /**
  40184. * Gets the value of D-pad down
  40185. */
  40186. /**
  40187. * Sets the value of D-pad down
  40188. */
  40189. dPadDown: number;
  40190. /**
  40191. * Gets the value of D-pad left
  40192. */
  40193. /**
  40194. * Sets the value of D-pad left
  40195. */
  40196. dPadLeft: number;
  40197. /**
  40198. * Gets the value of D-pad right
  40199. */
  40200. /**
  40201. * Sets the value of D-pad right
  40202. */
  40203. dPadRight: number;
  40204. /**
  40205. * Force the gamepad to synchronize with device values
  40206. */
  40207. update(): void;
  40208. /**
  40209. * Disposes the gamepad
  40210. */
  40211. dispose(): void;
  40212. }
  40213. }
  40214. declare module "babylonjs/Gamepads/gamepadManager" {
  40215. import { Observable } from "babylonjs/Misc/observable";
  40216. import { Nullable } from "babylonjs/types";
  40217. import { Scene } from "babylonjs/scene";
  40218. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40219. /**
  40220. * Manager for handling gamepads
  40221. */
  40222. export class GamepadManager {
  40223. private _scene?;
  40224. private _babylonGamepads;
  40225. private _oneGamepadConnected;
  40226. /** @hidden */
  40227. _isMonitoring: boolean;
  40228. private _gamepadEventSupported;
  40229. private _gamepadSupport;
  40230. /**
  40231. * observable to be triggered when the gamepad controller has been connected
  40232. */
  40233. onGamepadConnectedObservable: Observable<Gamepad>;
  40234. /**
  40235. * observable to be triggered when the gamepad controller has been disconnected
  40236. */
  40237. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40238. private _onGamepadConnectedEvent;
  40239. private _onGamepadDisconnectedEvent;
  40240. /**
  40241. * Initializes the gamepad manager
  40242. * @param _scene BabylonJS scene
  40243. */
  40244. constructor(_scene?: Scene | undefined);
  40245. /**
  40246. * The gamepads in the game pad manager
  40247. */
  40248. readonly gamepads: Gamepad[];
  40249. /**
  40250. * Get the gamepad controllers based on type
  40251. * @param type The type of gamepad controller
  40252. * @returns Nullable gamepad
  40253. */
  40254. getGamepadByType(type?: number): Nullable<Gamepad>;
  40255. /**
  40256. * Disposes the gamepad manager
  40257. */
  40258. dispose(): void;
  40259. private _addNewGamepad;
  40260. private _startMonitoringGamepads;
  40261. private _stopMonitoringGamepads;
  40262. /** @hidden */
  40263. _checkGamepadsStatus(): void;
  40264. private _updateGamepadObjects;
  40265. }
  40266. }
  40267. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40268. import { Nullable } from "babylonjs/types";
  40269. import { Scene } from "babylonjs/scene";
  40270. import { ISceneComponent } from "babylonjs/sceneComponent";
  40271. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40272. module "babylonjs/scene" {
  40273. interface Scene {
  40274. /** @hidden */
  40275. _gamepadManager: Nullable<GamepadManager>;
  40276. /**
  40277. * Gets the gamepad manager associated with the scene
  40278. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40279. */
  40280. gamepadManager: GamepadManager;
  40281. }
  40282. }
  40283. module "babylonjs/Cameras/freeCameraInputsManager" {
  40284. /**
  40285. * Interface representing a free camera inputs manager
  40286. */
  40287. interface FreeCameraInputsManager {
  40288. /**
  40289. * Adds gamepad input support to the FreeCameraInputsManager.
  40290. * @returns the FreeCameraInputsManager
  40291. */
  40292. addGamepad(): FreeCameraInputsManager;
  40293. }
  40294. }
  40295. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40296. /**
  40297. * Interface representing an arc rotate camera inputs manager
  40298. */
  40299. interface ArcRotateCameraInputsManager {
  40300. /**
  40301. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40302. * @returns the camera inputs manager
  40303. */
  40304. addGamepad(): ArcRotateCameraInputsManager;
  40305. }
  40306. }
  40307. /**
  40308. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40309. */
  40310. export class GamepadSystemSceneComponent implements ISceneComponent {
  40311. /**
  40312. * The component name helpfull to identify the component in the list of scene components.
  40313. */
  40314. readonly name: string;
  40315. /**
  40316. * The scene the component belongs to.
  40317. */
  40318. scene: Scene;
  40319. /**
  40320. * Creates a new instance of the component for the given scene
  40321. * @param scene Defines the scene to register the component in
  40322. */
  40323. constructor(scene: Scene);
  40324. /**
  40325. * Registers the component in a given scene
  40326. */
  40327. register(): void;
  40328. /**
  40329. * Rebuilds the elements related to this component in case of
  40330. * context lost for instance.
  40331. */
  40332. rebuild(): void;
  40333. /**
  40334. * Disposes the component and the associated ressources
  40335. */
  40336. dispose(): void;
  40337. private _beforeCameraUpdate;
  40338. }
  40339. }
  40340. declare module "babylonjs/Cameras/universalCamera" {
  40341. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40342. import { Scene } from "babylonjs/scene";
  40343. import { Vector3 } from "babylonjs/Maths/math.vector";
  40344. import "babylonjs/Gamepads/gamepadSceneComponent";
  40345. /**
  40346. * 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,
  40347. * which still works and will still be found in many Playgrounds.
  40348. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40349. */
  40350. export class UniversalCamera extends TouchCamera {
  40351. /**
  40352. * Defines the gamepad rotation sensiblity.
  40353. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40354. */
  40355. gamepadAngularSensibility: number;
  40356. /**
  40357. * Defines the gamepad move sensiblity.
  40358. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40359. */
  40360. gamepadMoveSensibility: number;
  40361. /**
  40362. * 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,
  40363. * which still works and will still be found in many Playgrounds.
  40364. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40365. * @param name Define the name of the camera in the scene
  40366. * @param position Define the start position of the camera in the scene
  40367. * @param scene Define the scene the camera belongs to
  40368. */
  40369. constructor(name: string, position: Vector3, scene: Scene);
  40370. /**
  40371. * Gets the current object class name.
  40372. * @return the class name
  40373. */
  40374. getClassName(): string;
  40375. }
  40376. }
  40377. declare module "babylonjs/Cameras/gamepadCamera" {
  40378. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40379. import { Scene } from "babylonjs/scene";
  40380. import { Vector3 } from "babylonjs/Maths/math.vector";
  40381. /**
  40382. * This represents a FPS type of camera. This is only here for back compat purpose.
  40383. * Please use the UniversalCamera instead as both are identical.
  40384. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40385. */
  40386. export class GamepadCamera extends UniversalCamera {
  40387. /**
  40388. * Instantiates a new Gamepad Camera
  40389. * This represents a FPS type of camera. This is only here for back compat purpose.
  40390. * Please use the UniversalCamera instead as both are identical.
  40391. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40392. * @param name Define the name of the camera in the scene
  40393. * @param position Define the start position of the camera in the scene
  40394. * @param scene Define the scene the camera belongs to
  40395. */
  40396. constructor(name: string, position: Vector3, scene: Scene);
  40397. /**
  40398. * Gets the current object class name.
  40399. * @return the class name
  40400. */
  40401. getClassName(): string;
  40402. }
  40403. }
  40404. declare module "babylonjs/Shaders/pass.fragment" {
  40405. /** @hidden */
  40406. export var passPixelShader: {
  40407. name: string;
  40408. shader: string;
  40409. };
  40410. }
  40411. declare module "babylonjs/Shaders/passCube.fragment" {
  40412. /** @hidden */
  40413. export var passCubePixelShader: {
  40414. name: string;
  40415. shader: string;
  40416. };
  40417. }
  40418. declare module "babylonjs/PostProcesses/passPostProcess" {
  40419. import { Nullable } from "babylonjs/types";
  40420. import { Camera } from "babylonjs/Cameras/camera";
  40421. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40422. import { Engine } from "babylonjs/Engines/engine";
  40423. import "babylonjs/Shaders/pass.fragment";
  40424. import "babylonjs/Shaders/passCube.fragment";
  40425. /**
  40426. * PassPostProcess which produces an output the same as it's input
  40427. */
  40428. export class PassPostProcess extends PostProcess {
  40429. /**
  40430. * Creates the PassPostProcess
  40431. * @param name The name of the effect.
  40432. * @param options The required width/height ratio to downsize to before computing the render pass.
  40433. * @param camera The camera to apply the render pass to.
  40434. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40435. * @param engine The engine which the post process will be applied. (default: current engine)
  40436. * @param reusable If the post process can be reused on the same frame. (default: false)
  40437. * @param textureType The type of texture to be used when performing the post processing.
  40438. * @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)
  40439. */
  40440. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40441. }
  40442. /**
  40443. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40444. */
  40445. export class PassCubePostProcess extends PostProcess {
  40446. private _face;
  40447. /**
  40448. * Gets or sets the cube face to display.
  40449. * * 0 is +X
  40450. * * 1 is -X
  40451. * * 2 is +Y
  40452. * * 3 is -Y
  40453. * * 4 is +Z
  40454. * * 5 is -Z
  40455. */
  40456. face: number;
  40457. /**
  40458. * Creates the PassCubePostProcess
  40459. * @param name The name of the effect.
  40460. * @param options The required width/height ratio to downsize to before computing the render pass.
  40461. * @param camera The camera to apply the render pass to.
  40462. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40463. * @param engine The engine which the post process will be applied. (default: current engine)
  40464. * @param reusable If the post process can be reused on the same frame. (default: false)
  40465. * @param textureType The type of texture to be used when performing the post processing.
  40466. * @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)
  40467. */
  40468. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40469. }
  40470. }
  40471. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40472. /** @hidden */
  40473. export var anaglyphPixelShader: {
  40474. name: string;
  40475. shader: string;
  40476. };
  40477. }
  40478. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40479. import { Engine } from "babylonjs/Engines/engine";
  40480. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40481. import { Camera } from "babylonjs/Cameras/camera";
  40482. import "babylonjs/Shaders/anaglyph.fragment";
  40483. /**
  40484. * Postprocess used to generate anaglyphic rendering
  40485. */
  40486. export class AnaglyphPostProcess extends PostProcess {
  40487. private _passedProcess;
  40488. /**
  40489. * Creates a new AnaglyphPostProcess
  40490. * @param name defines postprocess name
  40491. * @param options defines creation options or target ratio scale
  40492. * @param rigCameras defines cameras using this postprocess
  40493. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40494. * @param engine defines hosting engine
  40495. * @param reusable defines if the postprocess will be reused multiple times per frame
  40496. */
  40497. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40498. }
  40499. }
  40500. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40501. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40502. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40503. import { Scene } from "babylonjs/scene";
  40504. import { Vector3 } from "babylonjs/Maths/math.vector";
  40505. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40506. /**
  40507. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40508. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40509. */
  40510. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40511. /**
  40512. * Creates a new AnaglyphArcRotateCamera
  40513. * @param name defines camera name
  40514. * @param alpha defines alpha angle (in radians)
  40515. * @param beta defines beta angle (in radians)
  40516. * @param radius defines radius
  40517. * @param target defines camera target
  40518. * @param interaxialDistance defines distance between each color axis
  40519. * @param scene defines the hosting scene
  40520. */
  40521. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40522. /**
  40523. * Gets camera class name
  40524. * @returns AnaglyphArcRotateCamera
  40525. */
  40526. getClassName(): string;
  40527. }
  40528. }
  40529. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40530. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40531. import { Scene } from "babylonjs/scene";
  40532. import { Vector3 } from "babylonjs/Maths/math.vector";
  40533. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40534. /**
  40535. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40536. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40537. */
  40538. export class AnaglyphFreeCamera extends FreeCamera {
  40539. /**
  40540. * Creates a new AnaglyphFreeCamera
  40541. * @param name defines camera name
  40542. * @param position defines initial position
  40543. * @param interaxialDistance defines distance between each color axis
  40544. * @param scene defines the hosting scene
  40545. */
  40546. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40547. /**
  40548. * Gets camera class name
  40549. * @returns AnaglyphFreeCamera
  40550. */
  40551. getClassName(): string;
  40552. }
  40553. }
  40554. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40555. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40556. import { Scene } from "babylonjs/scene";
  40557. import { Vector3 } from "babylonjs/Maths/math.vector";
  40558. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40559. /**
  40560. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40561. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40562. */
  40563. export class AnaglyphGamepadCamera extends GamepadCamera {
  40564. /**
  40565. * Creates a new AnaglyphGamepadCamera
  40566. * @param name defines camera name
  40567. * @param position defines initial position
  40568. * @param interaxialDistance defines distance between each color axis
  40569. * @param scene defines the hosting scene
  40570. */
  40571. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40572. /**
  40573. * Gets camera class name
  40574. * @returns AnaglyphGamepadCamera
  40575. */
  40576. getClassName(): string;
  40577. }
  40578. }
  40579. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40580. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40581. import { Scene } from "babylonjs/scene";
  40582. import { Vector3 } from "babylonjs/Maths/math.vector";
  40583. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40584. /**
  40585. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40586. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40587. */
  40588. export class AnaglyphUniversalCamera extends UniversalCamera {
  40589. /**
  40590. * Creates a new AnaglyphUniversalCamera
  40591. * @param name defines camera name
  40592. * @param position defines initial position
  40593. * @param interaxialDistance defines distance between each color axis
  40594. * @param scene defines the hosting scene
  40595. */
  40596. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40597. /**
  40598. * Gets camera class name
  40599. * @returns AnaglyphUniversalCamera
  40600. */
  40601. getClassName(): string;
  40602. }
  40603. }
  40604. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40605. /** @hidden */
  40606. export var stereoscopicInterlacePixelShader: {
  40607. name: string;
  40608. shader: string;
  40609. };
  40610. }
  40611. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40612. import { Camera } from "babylonjs/Cameras/camera";
  40613. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40614. import { Engine } from "babylonjs/Engines/engine";
  40615. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40616. /**
  40617. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40618. */
  40619. export class StereoscopicInterlacePostProcess extends PostProcess {
  40620. private _stepSize;
  40621. private _passedProcess;
  40622. /**
  40623. * Initializes a StereoscopicInterlacePostProcess
  40624. * @param name The name of the effect.
  40625. * @param rigCameras The rig cameras to be appled to the post process
  40626. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40627. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40628. * @param engine The engine which the post process will be applied. (default: current engine)
  40629. * @param reusable If the post process can be reused on the same frame. (default: false)
  40630. */
  40631. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40632. }
  40633. }
  40634. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40635. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40636. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40637. import { Scene } from "babylonjs/scene";
  40638. import { Vector3 } from "babylonjs/Maths/math.vector";
  40639. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40640. /**
  40641. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40642. * @see http://doc.babylonjs.com/features/cameras
  40643. */
  40644. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40645. /**
  40646. * Creates a new StereoscopicArcRotateCamera
  40647. * @param name defines camera name
  40648. * @param alpha defines alpha angle (in radians)
  40649. * @param beta defines beta angle (in radians)
  40650. * @param radius defines radius
  40651. * @param target defines camera target
  40652. * @param interaxialDistance defines distance between each color axis
  40653. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40654. * @param scene defines the hosting scene
  40655. */
  40656. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40657. /**
  40658. * Gets camera class name
  40659. * @returns StereoscopicArcRotateCamera
  40660. */
  40661. getClassName(): string;
  40662. }
  40663. }
  40664. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40665. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40666. import { Scene } from "babylonjs/scene";
  40667. import { Vector3 } from "babylonjs/Maths/math.vector";
  40668. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40669. /**
  40670. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40671. * @see http://doc.babylonjs.com/features/cameras
  40672. */
  40673. export class StereoscopicFreeCamera extends FreeCamera {
  40674. /**
  40675. * Creates a new StereoscopicFreeCamera
  40676. * @param name defines camera name
  40677. * @param position defines initial position
  40678. * @param interaxialDistance defines distance between each color axis
  40679. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40680. * @param scene defines the hosting scene
  40681. */
  40682. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40683. /**
  40684. * Gets camera class name
  40685. * @returns StereoscopicFreeCamera
  40686. */
  40687. getClassName(): string;
  40688. }
  40689. }
  40690. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40691. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40692. import { Scene } from "babylonjs/scene";
  40693. import { Vector3 } from "babylonjs/Maths/math.vector";
  40694. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40695. /**
  40696. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40697. * @see http://doc.babylonjs.com/features/cameras
  40698. */
  40699. export class StereoscopicGamepadCamera extends GamepadCamera {
  40700. /**
  40701. * Creates a new StereoscopicGamepadCamera
  40702. * @param name defines camera name
  40703. * @param position defines initial position
  40704. * @param interaxialDistance defines distance between each color axis
  40705. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40706. * @param scene defines the hosting scene
  40707. */
  40708. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40709. /**
  40710. * Gets camera class name
  40711. * @returns StereoscopicGamepadCamera
  40712. */
  40713. getClassName(): string;
  40714. }
  40715. }
  40716. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40717. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40718. import { Scene } from "babylonjs/scene";
  40719. import { Vector3 } from "babylonjs/Maths/math.vector";
  40720. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40721. /**
  40722. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40723. * @see http://doc.babylonjs.com/features/cameras
  40724. */
  40725. export class StereoscopicUniversalCamera extends UniversalCamera {
  40726. /**
  40727. * Creates a new StereoscopicUniversalCamera
  40728. * @param name defines camera name
  40729. * @param position defines initial position
  40730. * @param interaxialDistance defines distance between each color axis
  40731. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40732. * @param scene defines the hosting scene
  40733. */
  40734. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40735. /**
  40736. * Gets camera class name
  40737. * @returns StereoscopicUniversalCamera
  40738. */
  40739. getClassName(): string;
  40740. }
  40741. }
  40742. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40743. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40744. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40745. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40746. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40747. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40748. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40749. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40750. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40751. }
  40752. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40753. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40754. import { Scene } from "babylonjs/scene";
  40755. import { Vector3 } from "babylonjs/Maths/math.vector";
  40756. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40757. /**
  40758. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40759. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40760. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40761. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40762. */
  40763. export class VirtualJoysticksCamera extends FreeCamera {
  40764. /**
  40765. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40766. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40767. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40768. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40769. * @param name Define the name of the camera in the scene
  40770. * @param position Define the start position of the camera in the scene
  40771. * @param scene Define the scene the camera belongs to
  40772. */
  40773. constructor(name: string, position: Vector3, scene: Scene);
  40774. /**
  40775. * Gets the current object class name.
  40776. * @return the class name
  40777. */
  40778. getClassName(): string;
  40779. }
  40780. }
  40781. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40782. import { Matrix } from "babylonjs/Maths/math.vector";
  40783. /**
  40784. * This represents all the required metrics to create a VR camera.
  40785. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40786. */
  40787. export class VRCameraMetrics {
  40788. /**
  40789. * Define the horizontal resolution off the screen.
  40790. */
  40791. hResolution: number;
  40792. /**
  40793. * Define the vertical resolution off the screen.
  40794. */
  40795. vResolution: number;
  40796. /**
  40797. * Define the horizontal screen size.
  40798. */
  40799. hScreenSize: number;
  40800. /**
  40801. * Define the vertical screen size.
  40802. */
  40803. vScreenSize: number;
  40804. /**
  40805. * Define the vertical screen center position.
  40806. */
  40807. vScreenCenter: number;
  40808. /**
  40809. * Define the distance of the eyes to the screen.
  40810. */
  40811. eyeToScreenDistance: number;
  40812. /**
  40813. * Define the distance between both lenses
  40814. */
  40815. lensSeparationDistance: number;
  40816. /**
  40817. * Define the distance between both viewer's eyes.
  40818. */
  40819. interpupillaryDistance: number;
  40820. /**
  40821. * Define the distortion factor of the VR postprocess.
  40822. * Please, touch with care.
  40823. */
  40824. distortionK: number[];
  40825. /**
  40826. * Define the chromatic aberration correction factors for the VR post process.
  40827. */
  40828. chromaAbCorrection: number[];
  40829. /**
  40830. * Define the scale factor of the post process.
  40831. * The smaller the better but the slower.
  40832. */
  40833. postProcessScaleFactor: number;
  40834. /**
  40835. * Define an offset for the lens center.
  40836. */
  40837. lensCenterOffset: number;
  40838. /**
  40839. * Define if the current vr camera should compensate the distortion of the lense or not.
  40840. */
  40841. compensateDistortion: boolean;
  40842. /**
  40843. * Defines if multiview should be enabled when rendering (Default: false)
  40844. */
  40845. multiviewEnabled: boolean;
  40846. /**
  40847. * Gets the rendering aspect ratio based on the provided resolutions.
  40848. */
  40849. readonly aspectRatio: number;
  40850. /**
  40851. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40852. */
  40853. readonly aspectRatioFov: number;
  40854. /**
  40855. * @hidden
  40856. */
  40857. readonly leftHMatrix: Matrix;
  40858. /**
  40859. * @hidden
  40860. */
  40861. readonly rightHMatrix: Matrix;
  40862. /**
  40863. * @hidden
  40864. */
  40865. readonly leftPreViewMatrix: Matrix;
  40866. /**
  40867. * @hidden
  40868. */
  40869. readonly rightPreViewMatrix: Matrix;
  40870. /**
  40871. * Get the default VRMetrics based on the most generic setup.
  40872. * @returns the default vr metrics
  40873. */
  40874. static GetDefault(): VRCameraMetrics;
  40875. }
  40876. }
  40877. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40878. /** @hidden */
  40879. export var vrDistortionCorrectionPixelShader: {
  40880. name: string;
  40881. shader: string;
  40882. };
  40883. }
  40884. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40885. import { Camera } from "babylonjs/Cameras/camera";
  40886. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40887. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40888. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40889. /**
  40890. * VRDistortionCorrectionPostProcess used for mobile VR
  40891. */
  40892. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40893. private _isRightEye;
  40894. private _distortionFactors;
  40895. private _postProcessScaleFactor;
  40896. private _lensCenterOffset;
  40897. private _scaleIn;
  40898. private _scaleFactor;
  40899. private _lensCenter;
  40900. /**
  40901. * Initializes the VRDistortionCorrectionPostProcess
  40902. * @param name The name of the effect.
  40903. * @param camera The camera to apply the render pass to.
  40904. * @param isRightEye If this is for the right eye distortion
  40905. * @param vrMetrics All the required metrics for the VR camera
  40906. */
  40907. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40908. }
  40909. }
  40910. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40911. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40912. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40913. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40914. import { Scene } from "babylonjs/scene";
  40915. import { Vector3 } from "babylonjs/Maths/math.vector";
  40916. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40917. import "babylonjs/Cameras/RigModes/vrRigMode";
  40918. /**
  40919. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40920. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40921. */
  40922. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40923. /**
  40924. * Creates a new VRDeviceOrientationArcRotateCamera
  40925. * @param name defines camera name
  40926. * @param alpha defines the camera rotation along the logitudinal axis
  40927. * @param beta defines the camera rotation along the latitudinal axis
  40928. * @param radius defines the camera distance from its target
  40929. * @param target defines the camera target
  40930. * @param scene defines the scene the camera belongs to
  40931. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40932. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40933. */
  40934. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40935. /**
  40936. * Gets camera class name
  40937. * @returns VRDeviceOrientationArcRotateCamera
  40938. */
  40939. getClassName(): string;
  40940. }
  40941. }
  40942. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40943. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40944. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40945. import { Scene } from "babylonjs/scene";
  40946. import { Vector3 } from "babylonjs/Maths/math.vector";
  40947. import "babylonjs/Cameras/RigModes/vrRigMode";
  40948. /**
  40949. * Camera used to simulate VR rendering (based on FreeCamera)
  40950. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40951. */
  40952. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40953. /**
  40954. * Creates a new VRDeviceOrientationFreeCamera
  40955. * @param name defines camera name
  40956. * @param position defines the start position of the camera
  40957. * @param scene defines the scene the camera belongs to
  40958. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40959. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40960. */
  40961. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40962. /**
  40963. * Gets camera class name
  40964. * @returns VRDeviceOrientationFreeCamera
  40965. */
  40966. getClassName(): string;
  40967. }
  40968. }
  40969. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40970. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40971. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40972. import { Scene } from "babylonjs/scene";
  40973. import { Vector3 } from "babylonjs/Maths/math.vector";
  40974. import "babylonjs/Gamepads/gamepadSceneComponent";
  40975. /**
  40976. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40977. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40978. */
  40979. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40980. /**
  40981. * Creates a new VRDeviceOrientationGamepadCamera
  40982. * @param name defines camera name
  40983. * @param position defines the start position of the camera
  40984. * @param scene defines the scene the camera belongs to
  40985. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40986. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40987. */
  40988. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40989. /**
  40990. * Gets camera class name
  40991. * @returns VRDeviceOrientationGamepadCamera
  40992. */
  40993. getClassName(): string;
  40994. }
  40995. }
  40996. declare module "babylonjs/Materials/pushMaterial" {
  40997. import { Nullable } from "babylonjs/types";
  40998. import { Scene } from "babylonjs/scene";
  40999. import { Matrix } from "babylonjs/Maths/math.vector";
  41000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41001. import { Mesh } from "babylonjs/Meshes/mesh";
  41002. import { Material } from "babylonjs/Materials/material";
  41003. import { Effect } from "babylonjs/Materials/effect";
  41004. /**
  41005. * Base class of materials working in push mode in babylon JS
  41006. * @hidden
  41007. */
  41008. export class PushMaterial extends Material {
  41009. protected _activeEffect: Effect;
  41010. protected _normalMatrix: Matrix;
  41011. /**
  41012. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41013. * This means that the material can keep using a previous shader while a new one is being compiled.
  41014. * This is mostly used when shader parallel compilation is supported (true by default)
  41015. */
  41016. allowShaderHotSwapping: boolean;
  41017. constructor(name: string, scene: Scene);
  41018. getEffect(): Effect;
  41019. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41020. /**
  41021. * Binds the given world matrix to the active effect
  41022. *
  41023. * @param world the matrix to bind
  41024. */
  41025. bindOnlyWorldMatrix(world: Matrix): void;
  41026. /**
  41027. * Binds the given normal matrix to the active effect
  41028. *
  41029. * @param normalMatrix the matrix to bind
  41030. */
  41031. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41032. bind(world: Matrix, mesh?: Mesh): void;
  41033. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41034. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41035. }
  41036. }
  41037. declare module "babylonjs/Materials/materialFlags" {
  41038. /**
  41039. * This groups all the flags used to control the materials channel.
  41040. */
  41041. export class MaterialFlags {
  41042. private static _DiffuseTextureEnabled;
  41043. /**
  41044. * Are diffuse textures enabled in the application.
  41045. */
  41046. static DiffuseTextureEnabled: boolean;
  41047. private static _AmbientTextureEnabled;
  41048. /**
  41049. * Are ambient textures enabled in the application.
  41050. */
  41051. static AmbientTextureEnabled: boolean;
  41052. private static _OpacityTextureEnabled;
  41053. /**
  41054. * Are opacity textures enabled in the application.
  41055. */
  41056. static OpacityTextureEnabled: boolean;
  41057. private static _ReflectionTextureEnabled;
  41058. /**
  41059. * Are reflection textures enabled in the application.
  41060. */
  41061. static ReflectionTextureEnabled: boolean;
  41062. private static _EmissiveTextureEnabled;
  41063. /**
  41064. * Are emissive textures enabled in the application.
  41065. */
  41066. static EmissiveTextureEnabled: boolean;
  41067. private static _SpecularTextureEnabled;
  41068. /**
  41069. * Are specular textures enabled in the application.
  41070. */
  41071. static SpecularTextureEnabled: boolean;
  41072. private static _BumpTextureEnabled;
  41073. /**
  41074. * Are bump textures enabled in the application.
  41075. */
  41076. static BumpTextureEnabled: boolean;
  41077. private static _LightmapTextureEnabled;
  41078. /**
  41079. * Are lightmap textures enabled in the application.
  41080. */
  41081. static LightmapTextureEnabled: boolean;
  41082. private static _RefractionTextureEnabled;
  41083. /**
  41084. * Are refraction textures enabled in the application.
  41085. */
  41086. static RefractionTextureEnabled: boolean;
  41087. private static _ColorGradingTextureEnabled;
  41088. /**
  41089. * Are color grading textures enabled in the application.
  41090. */
  41091. static ColorGradingTextureEnabled: boolean;
  41092. private static _FresnelEnabled;
  41093. /**
  41094. * Are fresnels enabled in the application.
  41095. */
  41096. static FresnelEnabled: boolean;
  41097. private static _ClearCoatTextureEnabled;
  41098. /**
  41099. * Are clear coat textures enabled in the application.
  41100. */
  41101. static ClearCoatTextureEnabled: boolean;
  41102. private static _ClearCoatBumpTextureEnabled;
  41103. /**
  41104. * Are clear coat bump textures enabled in the application.
  41105. */
  41106. static ClearCoatBumpTextureEnabled: boolean;
  41107. private static _ClearCoatTintTextureEnabled;
  41108. /**
  41109. * Are clear coat tint textures enabled in the application.
  41110. */
  41111. static ClearCoatTintTextureEnabled: boolean;
  41112. private static _SheenTextureEnabled;
  41113. /**
  41114. * Are sheen textures enabled in the application.
  41115. */
  41116. static SheenTextureEnabled: boolean;
  41117. private static _AnisotropicTextureEnabled;
  41118. /**
  41119. * Are anisotropic textures enabled in the application.
  41120. */
  41121. static AnisotropicTextureEnabled: boolean;
  41122. private static _ThicknessTextureEnabled;
  41123. /**
  41124. * Are thickness textures enabled in the application.
  41125. */
  41126. static ThicknessTextureEnabled: boolean;
  41127. }
  41128. }
  41129. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41130. /** @hidden */
  41131. export var defaultFragmentDeclaration: {
  41132. name: string;
  41133. shader: string;
  41134. };
  41135. }
  41136. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41137. /** @hidden */
  41138. export var defaultUboDeclaration: {
  41139. name: string;
  41140. shader: string;
  41141. };
  41142. }
  41143. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41144. /** @hidden */
  41145. export var lightFragmentDeclaration: {
  41146. name: string;
  41147. shader: string;
  41148. };
  41149. }
  41150. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41151. /** @hidden */
  41152. export var lightUboDeclaration: {
  41153. name: string;
  41154. shader: string;
  41155. };
  41156. }
  41157. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41158. /** @hidden */
  41159. export var lightsFragmentFunctions: {
  41160. name: string;
  41161. shader: string;
  41162. };
  41163. }
  41164. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41165. /** @hidden */
  41166. export var shadowsFragmentFunctions: {
  41167. name: string;
  41168. shader: string;
  41169. };
  41170. }
  41171. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41172. /** @hidden */
  41173. export var fresnelFunction: {
  41174. name: string;
  41175. shader: string;
  41176. };
  41177. }
  41178. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41179. /** @hidden */
  41180. export var reflectionFunction: {
  41181. name: string;
  41182. shader: string;
  41183. };
  41184. }
  41185. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41186. /** @hidden */
  41187. export var bumpFragmentFunctions: {
  41188. name: string;
  41189. shader: string;
  41190. };
  41191. }
  41192. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41193. /** @hidden */
  41194. export var logDepthDeclaration: {
  41195. name: string;
  41196. shader: string;
  41197. };
  41198. }
  41199. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41200. /** @hidden */
  41201. export var bumpFragment: {
  41202. name: string;
  41203. shader: string;
  41204. };
  41205. }
  41206. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41207. /** @hidden */
  41208. export var depthPrePass: {
  41209. name: string;
  41210. shader: string;
  41211. };
  41212. }
  41213. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41214. /** @hidden */
  41215. export var lightFragment: {
  41216. name: string;
  41217. shader: string;
  41218. };
  41219. }
  41220. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41221. /** @hidden */
  41222. export var logDepthFragment: {
  41223. name: string;
  41224. shader: string;
  41225. };
  41226. }
  41227. declare module "babylonjs/Shaders/default.fragment" {
  41228. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41229. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41230. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41231. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41232. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41233. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41234. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41235. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41236. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41237. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41238. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41239. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41240. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41241. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41242. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41243. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41244. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41245. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41246. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41247. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41248. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41249. /** @hidden */
  41250. export var defaultPixelShader: {
  41251. name: string;
  41252. shader: string;
  41253. };
  41254. }
  41255. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41256. /** @hidden */
  41257. export var defaultVertexDeclaration: {
  41258. name: string;
  41259. shader: string;
  41260. };
  41261. }
  41262. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41263. /** @hidden */
  41264. export var bumpVertexDeclaration: {
  41265. name: string;
  41266. shader: string;
  41267. };
  41268. }
  41269. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41270. /** @hidden */
  41271. export var bumpVertex: {
  41272. name: string;
  41273. shader: string;
  41274. };
  41275. }
  41276. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41277. /** @hidden */
  41278. export var fogVertex: {
  41279. name: string;
  41280. shader: string;
  41281. };
  41282. }
  41283. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41284. /** @hidden */
  41285. export var shadowsVertex: {
  41286. name: string;
  41287. shader: string;
  41288. };
  41289. }
  41290. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41291. /** @hidden */
  41292. export var pointCloudVertex: {
  41293. name: string;
  41294. shader: string;
  41295. };
  41296. }
  41297. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41298. /** @hidden */
  41299. export var logDepthVertex: {
  41300. name: string;
  41301. shader: string;
  41302. };
  41303. }
  41304. declare module "babylonjs/Shaders/default.vertex" {
  41305. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41306. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41307. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41308. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41309. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41310. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41311. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41312. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41313. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41314. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41315. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41316. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41317. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41318. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41319. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41320. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41321. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41322. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41323. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41324. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41325. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41326. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41327. /** @hidden */
  41328. export var defaultVertexShader: {
  41329. name: string;
  41330. shader: string;
  41331. };
  41332. }
  41333. declare module "babylonjs/Materials/standardMaterial" {
  41334. import { SmartArray } from "babylonjs/Misc/smartArray";
  41335. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41336. import { Nullable } from "babylonjs/types";
  41337. import { Scene } from "babylonjs/scene";
  41338. import { Matrix } from "babylonjs/Maths/math.vector";
  41339. import { Color3 } from "babylonjs/Maths/math.color";
  41340. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41342. import { Mesh } from "babylonjs/Meshes/mesh";
  41343. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41344. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41345. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41346. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41347. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41348. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41349. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41350. import "babylonjs/Shaders/default.fragment";
  41351. import "babylonjs/Shaders/default.vertex";
  41352. /** @hidden */
  41353. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41354. MAINUV1: boolean;
  41355. MAINUV2: boolean;
  41356. DIFFUSE: boolean;
  41357. DIFFUSEDIRECTUV: number;
  41358. AMBIENT: boolean;
  41359. AMBIENTDIRECTUV: number;
  41360. OPACITY: boolean;
  41361. OPACITYDIRECTUV: number;
  41362. OPACITYRGB: boolean;
  41363. REFLECTION: boolean;
  41364. EMISSIVE: boolean;
  41365. EMISSIVEDIRECTUV: number;
  41366. SPECULAR: boolean;
  41367. SPECULARDIRECTUV: number;
  41368. BUMP: boolean;
  41369. BUMPDIRECTUV: number;
  41370. PARALLAX: boolean;
  41371. PARALLAXOCCLUSION: boolean;
  41372. SPECULAROVERALPHA: boolean;
  41373. CLIPPLANE: boolean;
  41374. CLIPPLANE2: boolean;
  41375. CLIPPLANE3: boolean;
  41376. CLIPPLANE4: boolean;
  41377. ALPHATEST: boolean;
  41378. DEPTHPREPASS: boolean;
  41379. ALPHAFROMDIFFUSE: boolean;
  41380. POINTSIZE: boolean;
  41381. FOG: boolean;
  41382. SPECULARTERM: boolean;
  41383. DIFFUSEFRESNEL: boolean;
  41384. OPACITYFRESNEL: boolean;
  41385. REFLECTIONFRESNEL: boolean;
  41386. REFRACTIONFRESNEL: boolean;
  41387. EMISSIVEFRESNEL: boolean;
  41388. FRESNEL: boolean;
  41389. NORMAL: boolean;
  41390. UV1: boolean;
  41391. UV2: boolean;
  41392. VERTEXCOLOR: boolean;
  41393. VERTEXALPHA: boolean;
  41394. NUM_BONE_INFLUENCERS: number;
  41395. BonesPerMesh: number;
  41396. BONETEXTURE: boolean;
  41397. INSTANCES: boolean;
  41398. GLOSSINESS: boolean;
  41399. ROUGHNESS: boolean;
  41400. EMISSIVEASILLUMINATION: boolean;
  41401. LINKEMISSIVEWITHDIFFUSE: boolean;
  41402. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41403. LIGHTMAP: boolean;
  41404. LIGHTMAPDIRECTUV: number;
  41405. OBJECTSPACE_NORMALMAP: boolean;
  41406. USELIGHTMAPASSHADOWMAP: boolean;
  41407. REFLECTIONMAP_3D: boolean;
  41408. REFLECTIONMAP_SPHERICAL: boolean;
  41409. REFLECTIONMAP_PLANAR: boolean;
  41410. REFLECTIONMAP_CUBIC: boolean;
  41411. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41412. REFLECTIONMAP_PROJECTION: boolean;
  41413. REFLECTIONMAP_SKYBOX: boolean;
  41414. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41415. REFLECTIONMAP_EXPLICIT: boolean;
  41416. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41417. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41418. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41419. INVERTCUBICMAP: boolean;
  41420. LOGARITHMICDEPTH: boolean;
  41421. REFRACTION: boolean;
  41422. REFRACTIONMAP_3D: boolean;
  41423. REFLECTIONOVERALPHA: boolean;
  41424. TWOSIDEDLIGHTING: boolean;
  41425. SHADOWFLOAT: boolean;
  41426. MORPHTARGETS: boolean;
  41427. MORPHTARGETS_NORMAL: boolean;
  41428. MORPHTARGETS_TANGENT: boolean;
  41429. MORPHTARGETS_UV: boolean;
  41430. NUM_MORPH_INFLUENCERS: number;
  41431. NONUNIFORMSCALING: boolean;
  41432. PREMULTIPLYALPHA: boolean;
  41433. IMAGEPROCESSING: boolean;
  41434. VIGNETTE: boolean;
  41435. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41436. VIGNETTEBLENDMODEOPAQUE: boolean;
  41437. TONEMAPPING: boolean;
  41438. TONEMAPPING_ACES: boolean;
  41439. CONTRAST: boolean;
  41440. COLORCURVES: boolean;
  41441. COLORGRADING: boolean;
  41442. COLORGRADING3D: boolean;
  41443. SAMPLER3DGREENDEPTH: boolean;
  41444. SAMPLER3DBGRMAP: boolean;
  41445. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41446. MULTIVIEW: boolean;
  41447. /**
  41448. * If the reflection texture on this material is in linear color space
  41449. * @hidden
  41450. */
  41451. IS_REFLECTION_LINEAR: boolean;
  41452. /**
  41453. * If the refraction texture on this material is in linear color space
  41454. * @hidden
  41455. */
  41456. IS_REFRACTION_LINEAR: boolean;
  41457. EXPOSURE: boolean;
  41458. constructor();
  41459. setReflectionMode(modeToEnable: string): void;
  41460. }
  41461. /**
  41462. * This is the default material used in Babylon. It is the best trade off between quality
  41463. * and performances.
  41464. * @see http://doc.babylonjs.com/babylon101/materials
  41465. */
  41466. export class StandardMaterial extends PushMaterial {
  41467. private _diffuseTexture;
  41468. /**
  41469. * The basic texture of the material as viewed under a light.
  41470. */
  41471. diffuseTexture: Nullable<BaseTexture>;
  41472. private _ambientTexture;
  41473. /**
  41474. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41475. */
  41476. ambientTexture: Nullable<BaseTexture>;
  41477. private _opacityTexture;
  41478. /**
  41479. * Define the transparency of the material from a texture.
  41480. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41481. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41482. */
  41483. opacityTexture: Nullable<BaseTexture>;
  41484. private _reflectionTexture;
  41485. /**
  41486. * Define the texture used to display the reflection.
  41487. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41488. */
  41489. reflectionTexture: Nullable<BaseTexture>;
  41490. private _emissiveTexture;
  41491. /**
  41492. * Define texture of the material as if self lit.
  41493. * This will be mixed in the final result even in the absence of light.
  41494. */
  41495. emissiveTexture: Nullable<BaseTexture>;
  41496. private _specularTexture;
  41497. /**
  41498. * Define how the color and intensity of the highlight given by the light in the material.
  41499. */
  41500. specularTexture: Nullable<BaseTexture>;
  41501. private _bumpTexture;
  41502. /**
  41503. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41504. * 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.
  41505. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41506. */
  41507. bumpTexture: Nullable<BaseTexture>;
  41508. private _lightmapTexture;
  41509. /**
  41510. * Complex lighting can be computationally expensive to compute at runtime.
  41511. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41512. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41513. */
  41514. lightmapTexture: Nullable<BaseTexture>;
  41515. private _refractionTexture;
  41516. /**
  41517. * Define the texture used to display the refraction.
  41518. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41519. */
  41520. refractionTexture: Nullable<BaseTexture>;
  41521. /**
  41522. * The color of the material lit by the environmental background lighting.
  41523. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41524. */
  41525. ambientColor: Color3;
  41526. /**
  41527. * The basic color of the material as viewed under a light.
  41528. */
  41529. diffuseColor: Color3;
  41530. /**
  41531. * Define how the color and intensity of the highlight given by the light in the material.
  41532. */
  41533. specularColor: Color3;
  41534. /**
  41535. * Define the color of the material as if self lit.
  41536. * This will be mixed in the final result even in the absence of light.
  41537. */
  41538. emissiveColor: Color3;
  41539. /**
  41540. * Defines how sharp are the highlights in the material.
  41541. * The bigger the value the sharper giving a more glossy feeling to the result.
  41542. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41543. */
  41544. specularPower: number;
  41545. private _useAlphaFromDiffuseTexture;
  41546. /**
  41547. * Does the transparency come from the diffuse texture alpha channel.
  41548. */
  41549. useAlphaFromDiffuseTexture: boolean;
  41550. private _useEmissiveAsIllumination;
  41551. /**
  41552. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41553. */
  41554. useEmissiveAsIllumination: boolean;
  41555. private _linkEmissiveWithDiffuse;
  41556. /**
  41557. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41558. * the emissive level when the final color is close to one.
  41559. */
  41560. linkEmissiveWithDiffuse: boolean;
  41561. private _useSpecularOverAlpha;
  41562. /**
  41563. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41564. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41565. */
  41566. useSpecularOverAlpha: boolean;
  41567. private _useReflectionOverAlpha;
  41568. /**
  41569. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41570. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41571. */
  41572. useReflectionOverAlpha: boolean;
  41573. private _disableLighting;
  41574. /**
  41575. * Does lights from the scene impacts this material.
  41576. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41577. */
  41578. disableLighting: boolean;
  41579. private _useObjectSpaceNormalMap;
  41580. /**
  41581. * Allows using an object space normal map (instead of tangent space).
  41582. */
  41583. useObjectSpaceNormalMap: boolean;
  41584. private _useParallax;
  41585. /**
  41586. * Is parallax enabled or not.
  41587. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41588. */
  41589. useParallax: boolean;
  41590. private _useParallaxOcclusion;
  41591. /**
  41592. * Is parallax occlusion enabled or not.
  41593. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41594. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41595. */
  41596. useParallaxOcclusion: boolean;
  41597. /**
  41598. * 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.
  41599. */
  41600. parallaxScaleBias: number;
  41601. private _roughness;
  41602. /**
  41603. * Helps to define how blurry the reflections should appears in the material.
  41604. */
  41605. roughness: number;
  41606. /**
  41607. * In case of refraction, define the value of the index of refraction.
  41608. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41609. */
  41610. indexOfRefraction: number;
  41611. /**
  41612. * Invert the refraction texture alongside the y axis.
  41613. * It can be useful with procedural textures or probe for instance.
  41614. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41615. */
  41616. invertRefractionY: boolean;
  41617. /**
  41618. * Defines the alpha limits in alpha test mode.
  41619. */
  41620. alphaCutOff: number;
  41621. private _useLightmapAsShadowmap;
  41622. /**
  41623. * In case of light mapping, define whether the map contains light or shadow informations.
  41624. */
  41625. useLightmapAsShadowmap: boolean;
  41626. private _diffuseFresnelParameters;
  41627. /**
  41628. * Define the diffuse fresnel parameters of the material.
  41629. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41630. */
  41631. diffuseFresnelParameters: FresnelParameters;
  41632. private _opacityFresnelParameters;
  41633. /**
  41634. * Define the opacity fresnel parameters of the material.
  41635. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41636. */
  41637. opacityFresnelParameters: FresnelParameters;
  41638. private _reflectionFresnelParameters;
  41639. /**
  41640. * Define the reflection fresnel parameters of the material.
  41641. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41642. */
  41643. reflectionFresnelParameters: FresnelParameters;
  41644. private _refractionFresnelParameters;
  41645. /**
  41646. * Define the refraction fresnel parameters of the material.
  41647. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41648. */
  41649. refractionFresnelParameters: FresnelParameters;
  41650. private _emissiveFresnelParameters;
  41651. /**
  41652. * Define the emissive fresnel parameters of the material.
  41653. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41654. */
  41655. emissiveFresnelParameters: FresnelParameters;
  41656. private _useReflectionFresnelFromSpecular;
  41657. /**
  41658. * If true automatically deducts the fresnels values from the material specularity.
  41659. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41660. */
  41661. useReflectionFresnelFromSpecular: boolean;
  41662. private _useGlossinessFromSpecularMapAlpha;
  41663. /**
  41664. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41665. */
  41666. useGlossinessFromSpecularMapAlpha: boolean;
  41667. private _maxSimultaneousLights;
  41668. /**
  41669. * Defines the maximum number of lights that can be used in the material
  41670. */
  41671. maxSimultaneousLights: number;
  41672. private _invertNormalMapX;
  41673. /**
  41674. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41675. */
  41676. invertNormalMapX: boolean;
  41677. private _invertNormalMapY;
  41678. /**
  41679. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41680. */
  41681. invertNormalMapY: boolean;
  41682. private _twoSidedLighting;
  41683. /**
  41684. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41685. */
  41686. twoSidedLighting: boolean;
  41687. /**
  41688. * Default configuration related to image processing available in the standard Material.
  41689. */
  41690. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41691. /**
  41692. * Gets the image processing configuration used either in this material.
  41693. */
  41694. /**
  41695. * Sets the Default image processing configuration used either in the this material.
  41696. *
  41697. * If sets to null, the scene one is in use.
  41698. */
  41699. imageProcessingConfiguration: ImageProcessingConfiguration;
  41700. /**
  41701. * Keep track of the image processing observer to allow dispose and replace.
  41702. */
  41703. private _imageProcessingObserver;
  41704. /**
  41705. * Attaches a new image processing configuration to the Standard Material.
  41706. * @param configuration
  41707. */
  41708. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41709. /**
  41710. * Gets wether the color curves effect is enabled.
  41711. */
  41712. /**
  41713. * Sets wether the color curves effect is enabled.
  41714. */
  41715. cameraColorCurvesEnabled: boolean;
  41716. /**
  41717. * Gets wether the color grading effect is enabled.
  41718. */
  41719. /**
  41720. * Gets wether the color grading effect is enabled.
  41721. */
  41722. cameraColorGradingEnabled: boolean;
  41723. /**
  41724. * Gets wether tonemapping is enabled or not.
  41725. */
  41726. /**
  41727. * Sets wether tonemapping is enabled or not
  41728. */
  41729. cameraToneMappingEnabled: boolean;
  41730. /**
  41731. * The camera exposure used on this material.
  41732. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41733. * This corresponds to a photographic exposure.
  41734. */
  41735. /**
  41736. * The camera exposure used on this material.
  41737. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41738. * This corresponds to a photographic exposure.
  41739. */
  41740. cameraExposure: number;
  41741. /**
  41742. * Gets The camera contrast used on this material.
  41743. */
  41744. /**
  41745. * Sets The camera contrast used on this material.
  41746. */
  41747. cameraContrast: number;
  41748. /**
  41749. * Gets the Color Grading 2D Lookup Texture.
  41750. */
  41751. /**
  41752. * Sets the Color Grading 2D Lookup Texture.
  41753. */
  41754. cameraColorGradingTexture: Nullable<BaseTexture>;
  41755. /**
  41756. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41757. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41758. * 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;
  41759. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41760. */
  41761. /**
  41762. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41763. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41764. * 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;
  41765. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41766. */
  41767. cameraColorCurves: Nullable<ColorCurves>;
  41768. /**
  41769. * Custom callback helping to override the default shader used in the material.
  41770. */
  41771. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41772. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41773. protected _worldViewProjectionMatrix: Matrix;
  41774. protected _globalAmbientColor: Color3;
  41775. protected _useLogarithmicDepth: boolean;
  41776. protected _rebuildInParallel: boolean;
  41777. /**
  41778. * Instantiates a new standard material.
  41779. * This is the default material used in Babylon. It is the best trade off between quality
  41780. * and performances.
  41781. * @see http://doc.babylonjs.com/babylon101/materials
  41782. * @param name Define the name of the material in the scene
  41783. * @param scene Define the scene the material belong to
  41784. */
  41785. constructor(name: string, scene: Scene);
  41786. /**
  41787. * Gets a boolean indicating that current material needs to register RTT
  41788. */
  41789. readonly hasRenderTargetTextures: boolean;
  41790. /**
  41791. * Gets the current class name of the material e.g. "StandardMaterial"
  41792. * Mainly use in serialization.
  41793. * @returns the class name
  41794. */
  41795. getClassName(): string;
  41796. /**
  41797. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41798. * You can try switching to logarithmic depth.
  41799. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41800. */
  41801. useLogarithmicDepth: boolean;
  41802. /**
  41803. * Specifies if the material will require alpha blending
  41804. * @returns a boolean specifying if alpha blending is needed
  41805. */
  41806. needAlphaBlending(): boolean;
  41807. /**
  41808. * Specifies if this material should be rendered in alpha test mode
  41809. * @returns a boolean specifying if an alpha test is needed.
  41810. */
  41811. needAlphaTesting(): boolean;
  41812. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41813. /**
  41814. * Get the texture used for alpha test purpose.
  41815. * @returns the diffuse texture in case of the standard material.
  41816. */
  41817. getAlphaTestTexture(): Nullable<BaseTexture>;
  41818. /**
  41819. * Get if the submesh is ready to be used and all its information available.
  41820. * Child classes can use it to update shaders
  41821. * @param mesh defines the mesh to check
  41822. * @param subMesh defines which submesh to check
  41823. * @param useInstances specifies that instances should be used
  41824. * @returns a boolean indicating that the submesh is ready or not
  41825. */
  41826. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41827. /**
  41828. * Builds the material UBO layouts.
  41829. * Used internally during the effect preparation.
  41830. */
  41831. buildUniformLayout(): void;
  41832. /**
  41833. * Unbinds the material from the mesh
  41834. */
  41835. unbind(): void;
  41836. /**
  41837. * Binds the submesh to this material by preparing the effect and shader to draw
  41838. * @param world defines the world transformation matrix
  41839. * @param mesh defines the mesh containing the submesh
  41840. * @param subMesh defines the submesh to bind the material to
  41841. */
  41842. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41843. /**
  41844. * Get the list of animatables in the material.
  41845. * @returns the list of animatables object used in the material
  41846. */
  41847. getAnimatables(): IAnimatable[];
  41848. /**
  41849. * Gets the active textures from the material
  41850. * @returns an array of textures
  41851. */
  41852. getActiveTextures(): BaseTexture[];
  41853. /**
  41854. * Specifies if the material uses a texture
  41855. * @param texture defines the texture to check against the material
  41856. * @returns a boolean specifying if the material uses the texture
  41857. */
  41858. hasTexture(texture: BaseTexture): boolean;
  41859. /**
  41860. * Disposes the material
  41861. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41862. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41863. */
  41864. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41865. /**
  41866. * Makes a duplicate of the material, and gives it a new name
  41867. * @param name defines the new name for the duplicated material
  41868. * @returns the cloned material
  41869. */
  41870. clone(name: string): StandardMaterial;
  41871. /**
  41872. * Serializes this material in a JSON representation
  41873. * @returns the serialized material object
  41874. */
  41875. serialize(): any;
  41876. /**
  41877. * Creates a standard material from parsed material data
  41878. * @param source defines the JSON representation of the material
  41879. * @param scene defines the hosting scene
  41880. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41881. * @returns a new standard material
  41882. */
  41883. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41884. /**
  41885. * Are diffuse textures enabled in the application.
  41886. */
  41887. static DiffuseTextureEnabled: boolean;
  41888. /**
  41889. * Are ambient textures enabled in the application.
  41890. */
  41891. static AmbientTextureEnabled: boolean;
  41892. /**
  41893. * Are opacity textures enabled in the application.
  41894. */
  41895. static OpacityTextureEnabled: boolean;
  41896. /**
  41897. * Are reflection textures enabled in the application.
  41898. */
  41899. static ReflectionTextureEnabled: boolean;
  41900. /**
  41901. * Are emissive textures enabled in the application.
  41902. */
  41903. static EmissiveTextureEnabled: boolean;
  41904. /**
  41905. * Are specular textures enabled in the application.
  41906. */
  41907. static SpecularTextureEnabled: boolean;
  41908. /**
  41909. * Are bump textures enabled in the application.
  41910. */
  41911. static BumpTextureEnabled: boolean;
  41912. /**
  41913. * Are lightmap textures enabled in the application.
  41914. */
  41915. static LightmapTextureEnabled: boolean;
  41916. /**
  41917. * Are refraction textures enabled in the application.
  41918. */
  41919. static RefractionTextureEnabled: boolean;
  41920. /**
  41921. * Are color grading textures enabled in the application.
  41922. */
  41923. static ColorGradingTextureEnabled: boolean;
  41924. /**
  41925. * Are fresnels enabled in the application.
  41926. */
  41927. static FresnelEnabled: boolean;
  41928. }
  41929. }
  41930. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41931. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41932. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41933. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41934. /** @hidden */
  41935. export var imageProcessingPixelShader: {
  41936. name: string;
  41937. shader: string;
  41938. };
  41939. }
  41940. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41941. import { Nullable } from "babylonjs/types";
  41942. import { Color4 } from "babylonjs/Maths/math.color";
  41943. import { Camera } from "babylonjs/Cameras/camera";
  41944. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41945. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41946. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41947. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41948. import { Engine } from "babylonjs/Engines/engine";
  41949. import "babylonjs/Shaders/imageProcessing.fragment";
  41950. import "babylonjs/Shaders/postprocess.vertex";
  41951. /**
  41952. * ImageProcessingPostProcess
  41953. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41954. */
  41955. export class ImageProcessingPostProcess extends PostProcess {
  41956. /**
  41957. * Default configuration related to image processing available in the PBR Material.
  41958. */
  41959. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41960. /**
  41961. * Gets the image processing configuration used either in this material.
  41962. */
  41963. /**
  41964. * Sets the Default image processing configuration used either in the this material.
  41965. *
  41966. * If sets to null, the scene one is in use.
  41967. */
  41968. imageProcessingConfiguration: ImageProcessingConfiguration;
  41969. /**
  41970. * Keep track of the image processing observer to allow dispose and replace.
  41971. */
  41972. private _imageProcessingObserver;
  41973. /**
  41974. * Attaches a new image processing configuration to the PBR Material.
  41975. * @param configuration
  41976. */
  41977. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41978. /**
  41979. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41980. */
  41981. /**
  41982. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41983. */
  41984. colorCurves: Nullable<ColorCurves>;
  41985. /**
  41986. * Gets wether the color curves effect is enabled.
  41987. */
  41988. /**
  41989. * Sets wether the color curves effect is enabled.
  41990. */
  41991. colorCurvesEnabled: boolean;
  41992. /**
  41993. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41994. */
  41995. /**
  41996. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41997. */
  41998. colorGradingTexture: Nullable<BaseTexture>;
  41999. /**
  42000. * Gets wether the color grading effect is enabled.
  42001. */
  42002. /**
  42003. * Gets wether the color grading effect is enabled.
  42004. */
  42005. colorGradingEnabled: boolean;
  42006. /**
  42007. * Gets exposure used in the effect.
  42008. */
  42009. /**
  42010. * Sets exposure used in the effect.
  42011. */
  42012. exposure: number;
  42013. /**
  42014. * Gets wether tonemapping is enabled or not.
  42015. */
  42016. /**
  42017. * Sets wether tonemapping is enabled or not
  42018. */
  42019. toneMappingEnabled: boolean;
  42020. /**
  42021. * Gets the type of tone mapping effect.
  42022. */
  42023. /**
  42024. * Sets the type of tone mapping effect.
  42025. */
  42026. toneMappingType: number;
  42027. /**
  42028. * Gets contrast used in the effect.
  42029. */
  42030. /**
  42031. * Sets contrast used in the effect.
  42032. */
  42033. contrast: number;
  42034. /**
  42035. * Gets Vignette stretch size.
  42036. */
  42037. /**
  42038. * Sets Vignette stretch size.
  42039. */
  42040. vignetteStretch: number;
  42041. /**
  42042. * Gets Vignette centre X Offset.
  42043. */
  42044. /**
  42045. * Sets Vignette centre X Offset.
  42046. */
  42047. vignetteCentreX: number;
  42048. /**
  42049. * Gets Vignette centre Y Offset.
  42050. */
  42051. /**
  42052. * Sets Vignette centre Y Offset.
  42053. */
  42054. vignetteCentreY: number;
  42055. /**
  42056. * Gets Vignette weight or intensity of the vignette effect.
  42057. */
  42058. /**
  42059. * Sets Vignette weight or intensity of the vignette effect.
  42060. */
  42061. vignetteWeight: number;
  42062. /**
  42063. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42064. * if vignetteEnabled is set to true.
  42065. */
  42066. /**
  42067. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42068. * if vignetteEnabled is set to true.
  42069. */
  42070. vignetteColor: Color4;
  42071. /**
  42072. * Gets Camera field of view used by the Vignette effect.
  42073. */
  42074. /**
  42075. * Sets Camera field of view used by the Vignette effect.
  42076. */
  42077. vignetteCameraFov: number;
  42078. /**
  42079. * Gets the vignette blend mode allowing different kind of effect.
  42080. */
  42081. /**
  42082. * Sets the vignette blend mode allowing different kind of effect.
  42083. */
  42084. vignetteBlendMode: number;
  42085. /**
  42086. * Gets wether the vignette effect is enabled.
  42087. */
  42088. /**
  42089. * Sets wether the vignette effect is enabled.
  42090. */
  42091. vignetteEnabled: boolean;
  42092. private _fromLinearSpace;
  42093. /**
  42094. * Gets wether the input of the processing is in Gamma or Linear Space.
  42095. */
  42096. /**
  42097. * Sets wether the input of the processing is in Gamma or Linear Space.
  42098. */
  42099. fromLinearSpace: boolean;
  42100. /**
  42101. * Defines cache preventing GC.
  42102. */
  42103. private _defines;
  42104. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42105. /**
  42106. * "ImageProcessingPostProcess"
  42107. * @returns "ImageProcessingPostProcess"
  42108. */
  42109. getClassName(): string;
  42110. protected _updateParameters(): void;
  42111. dispose(camera?: Camera): void;
  42112. }
  42113. }
  42114. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42115. import { Scene } from "babylonjs/scene";
  42116. import { Color3 } from "babylonjs/Maths/math.color";
  42117. import { Mesh } from "babylonjs/Meshes/mesh";
  42118. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42119. import { Nullable } from "babylonjs/types";
  42120. /**
  42121. * Class containing static functions to help procedurally build meshes
  42122. */
  42123. export class GroundBuilder {
  42124. /**
  42125. * Creates a ground mesh
  42126. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42127. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42129. * @param name defines the name of the mesh
  42130. * @param options defines the options used to create the mesh
  42131. * @param scene defines the hosting scene
  42132. * @returns the ground mesh
  42133. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42134. */
  42135. static CreateGround(name: string, options: {
  42136. width?: number;
  42137. height?: number;
  42138. subdivisions?: number;
  42139. subdivisionsX?: number;
  42140. subdivisionsY?: number;
  42141. updatable?: boolean;
  42142. }, scene: any): Mesh;
  42143. /**
  42144. * Creates a tiled ground mesh
  42145. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42146. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42147. * * 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
  42148. * * 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
  42149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42150. * @param name defines the name of the mesh
  42151. * @param options defines the options used to create the mesh
  42152. * @param scene defines the hosting scene
  42153. * @returns the tiled ground mesh
  42154. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42155. */
  42156. static CreateTiledGround(name: string, options: {
  42157. xmin: number;
  42158. zmin: number;
  42159. xmax: number;
  42160. zmax: number;
  42161. subdivisions?: {
  42162. w: number;
  42163. h: number;
  42164. };
  42165. precision?: {
  42166. w: number;
  42167. h: number;
  42168. };
  42169. updatable?: boolean;
  42170. }, scene?: Nullable<Scene>): Mesh;
  42171. /**
  42172. * Creates a ground mesh from a height map
  42173. * * The parameter `url` sets the URL of the height map image resource.
  42174. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42175. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42176. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42177. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42178. * * 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.
  42179. * * 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).
  42180. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42182. * @param name defines the name of the mesh
  42183. * @param url defines the url to the height map
  42184. * @param options defines the options used to create the mesh
  42185. * @param scene defines the hosting scene
  42186. * @returns the ground mesh
  42187. * @see https://doc.babylonjs.com/babylon101/height_map
  42188. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42189. */
  42190. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42191. width?: number;
  42192. height?: number;
  42193. subdivisions?: number;
  42194. minHeight?: number;
  42195. maxHeight?: number;
  42196. colorFilter?: Color3;
  42197. alphaFilter?: number;
  42198. updatable?: boolean;
  42199. onReady?: (mesh: GroundMesh) => void;
  42200. }, scene?: Nullable<Scene>): GroundMesh;
  42201. }
  42202. }
  42203. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42204. import { Vector4 } from "babylonjs/Maths/math.vector";
  42205. import { Mesh } from "babylonjs/Meshes/mesh";
  42206. /**
  42207. * Class containing static functions to help procedurally build meshes
  42208. */
  42209. export class TorusBuilder {
  42210. /**
  42211. * Creates a torus mesh
  42212. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42213. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42214. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42216. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42218. * @param name defines the name of the mesh
  42219. * @param options defines the options used to create the mesh
  42220. * @param scene defines the hosting scene
  42221. * @returns the torus mesh
  42222. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42223. */
  42224. static CreateTorus(name: string, options: {
  42225. diameter?: number;
  42226. thickness?: number;
  42227. tessellation?: number;
  42228. updatable?: boolean;
  42229. sideOrientation?: number;
  42230. frontUVs?: Vector4;
  42231. backUVs?: Vector4;
  42232. }, scene: any): Mesh;
  42233. }
  42234. }
  42235. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42236. import { Vector4 } from "babylonjs/Maths/math.vector";
  42237. import { Color4 } from "babylonjs/Maths/math.color";
  42238. import { Mesh } from "babylonjs/Meshes/mesh";
  42239. /**
  42240. * Class containing static functions to help procedurally build meshes
  42241. */
  42242. export class CylinderBuilder {
  42243. /**
  42244. * Creates a cylinder or a cone mesh
  42245. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42246. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42247. * * 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.
  42248. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42249. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42250. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42251. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42252. * * 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).
  42253. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42254. * * 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).
  42255. * * 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
  42256. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42257. * * 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
  42258. * * 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.
  42259. * * If `enclose` is false, a ring surface is one element.
  42260. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42261. * * 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
  42262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42265. * @param name defines the name of the mesh
  42266. * @param options defines the options used to create the mesh
  42267. * @param scene defines the hosting scene
  42268. * @returns the cylinder mesh
  42269. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42270. */
  42271. static CreateCylinder(name: string, options: {
  42272. height?: number;
  42273. diameterTop?: number;
  42274. diameterBottom?: number;
  42275. diameter?: number;
  42276. tessellation?: number;
  42277. subdivisions?: number;
  42278. arc?: number;
  42279. faceColors?: Color4[];
  42280. faceUV?: Vector4[];
  42281. updatable?: boolean;
  42282. hasRings?: boolean;
  42283. enclose?: boolean;
  42284. cap?: number;
  42285. sideOrientation?: number;
  42286. frontUVs?: Vector4;
  42287. backUVs?: Vector4;
  42288. }, scene: any): Mesh;
  42289. }
  42290. }
  42291. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42292. import { Observable } from "babylonjs/Misc/observable";
  42293. import { Nullable } from "babylonjs/types";
  42294. import { Camera } from "babylonjs/Cameras/camera";
  42295. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42296. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42297. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42298. import { Scene } from "babylonjs/scene";
  42299. import { Vector3 } from "babylonjs/Maths/math.vector";
  42300. import { Color3 } from "babylonjs/Maths/math.color";
  42301. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42302. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42303. import { Mesh } from "babylonjs/Meshes/mesh";
  42304. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42305. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42306. import "babylonjs/Meshes/Builders/groundBuilder";
  42307. import "babylonjs/Meshes/Builders/torusBuilder";
  42308. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42309. import "babylonjs/Gamepads/gamepadSceneComponent";
  42310. import "babylonjs/Animations/animatable";
  42311. /**
  42312. * Options to modify the vr teleportation behavior.
  42313. */
  42314. export interface VRTeleportationOptions {
  42315. /**
  42316. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42317. */
  42318. floorMeshName?: string;
  42319. /**
  42320. * A list of meshes to be used as the teleportation floor. (default: empty)
  42321. */
  42322. floorMeshes?: Mesh[];
  42323. }
  42324. /**
  42325. * Options to modify the vr experience helper's behavior.
  42326. */
  42327. export interface VRExperienceHelperOptions extends WebVROptions {
  42328. /**
  42329. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42330. */
  42331. createDeviceOrientationCamera?: boolean;
  42332. /**
  42333. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42334. */
  42335. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42336. /**
  42337. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42338. */
  42339. laserToggle?: boolean;
  42340. /**
  42341. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42342. */
  42343. floorMeshes?: Mesh[];
  42344. /**
  42345. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42346. */
  42347. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42348. }
  42349. /**
  42350. * Event containing information after VR has been entered
  42351. */
  42352. export class OnAfterEnteringVRObservableEvent {
  42353. /**
  42354. * If entering vr was successful
  42355. */
  42356. success: boolean;
  42357. }
  42358. /**
  42359. * Helps to quickly add VR support to an existing scene.
  42360. * See http://doc.babylonjs.com/how_to/webvr_helper
  42361. */
  42362. export class VRExperienceHelper {
  42363. /** Options to modify the vr experience helper's behavior. */
  42364. webVROptions: VRExperienceHelperOptions;
  42365. private _scene;
  42366. private _position;
  42367. private _btnVR;
  42368. private _btnVRDisplayed;
  42369. private _webVRsupported;
  42370. private _webVRready;
  42371. private _webVRrequesting;
  42372. private _webVRpresenting;
  42373. private _hasEnteredVR;
  42374. private _fullscreenVRpresenting;
  42375. private _canvas;
  42376. private _webVRCamera;
  42377. private _vrDeviceOrientationCamera;
  42378. private _deviceOrientationCamera;
  42379. private _existingCamera;
  42380. private _onKeyDown;
  42381. private _onVrDisplayPresentChange;
  42382. private _onVRDisplayChanged;
  42383. private _onVRRequestPresentStart;
  42384. private _onVRRequestPresentComplete;
  42385. /**
  42386. * 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)
  42387. */
  42388. enableGazeEvenWhenNoPointerLock: boolean;
  42389. /**
  42390. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42391. */
  42392. exitVROnDoubleTap: boolean;
  42393. /**
  42394. * Observable raised right before entering VR.
  42395. */
  42396. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42397. /**
  42398. * Observable raised when entering VR has completed.
  42399. */
  42400. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42401. /**
  42402. * Observable raised when exiting VR.
  42403. */
  42404. onExitingVRObservable: Observable<VRExperienceHelper>;
  42405. /**
  42406. * Observable raised when controller mesh is loaded.
  42407. */
  42408. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42409. /** Return this.onEnteringVRObservable
  42410. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42411. */
  42412. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42413. /** Return this.onExitingVRObservable
  42414. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42415. */
  42416. readonly onExitingVR: Observable<VRExperienceHelper>;
  42417. /** Return this.onControllerMeshLoadedObservable
  42418. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42419. */
  42420. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42421. private _rayLength;
  42422. private _useCustomVRButton;
  42423. private _teleportationRequested;
  42424. private _teleportActive;
  42425. private _floorMeshName;
  42426. private _floorMeshesCollection;
  42427. private _rotationAllowed;
  42428. private _teleportBackwardsVector;
  42429. private _teleportationTarget;
  42430. private _isDefaultTeleportationTarget;
  42431. private _postProcessMove;
  42432. private _teleportationFillColor;
  42433. private _teleportationBorderColor;
  42434. private _rotationAngle;
  42435. private _haloCenter;
  42436. private _cameraGazer;
  42437. private _padSensibilityUp;
  42438. private _padSensibilityDown;
  42439. private _leftController;
  42440. private _rightController;
  42441. /**
  42442. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42443. */
  42444. onNewMeshSelected: Observable<AbstractMesh>;
  42445. /**
  42446. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42447. * This observable will provide the mesh and the controller used to select the mesh
  42448. */
  42449. onMeshSelectedWithController: Observable<{
  42450. mesh: AbstractMesh;
  42451. controller: WebVRController;
  42452. }>;
  42453. /**
  42454. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42455. */
  42456. onNewMeshPicked: Observable<PickingInfo>;
  42457. private _circleEase;
  42458. /**
  42459. * Observable raised before camera teleportation
  42460. */
  42461. onBeforeCameraTeleport: Observable<Vector3>;
  42462. /**
  42463. * Observable raised after camera teleportation
  42464. */
  42465. onAfterCameraTeleport: Observable<Vector3>;
  42466. /**
  42467. * Observable raised when current selected mesh gets unselected
  42468. */
  42469. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42470. private _raySelectionPredicate;
  42471. /**
  42472. * To be optionaly changed by user to define custom ray selection
  42473. */
  42474. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42475. /**
  42476. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42477. */
  42478. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42479. /**
  42480. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42481. */
  42482. teleportationEnabled: boolean;
  42483. private _defaultHeight;
  42484. private _teleportationInitialized;
  42485. private _interactionsEnabled;
  42486. private _interactionsRequested;
  42487. private _displayGaze;
  42488. private _displayLaserPointer;
  42489. /**
  42490. * The mesh used to display where the user is going to teleport.
  42491. */
  42492. /**
  42493. * Sets the mesh to be used to display where the user is going to teleport.
  42494. */
  42495. teleportationTarget: Mesh;
  42496. /**
  42497. * 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
  42498. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42499. * See http://doc.babylonjs.com/resources/baking_transformations
  42500. */
  42501. gazeTrackerMesh: Mesh;
  42502. /**
  42503. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42504. */
  42505. updateGazeTrackerScale: boolean;
  42506. /**
  42507. * If the gaze trackers color should be updated when selecting meshes
  42508. */
  42509. updateGazeTrackerColor: boolean;
  42510. /**
  42511. * If the controller laser color should be updated when selecting meshes
  42512. */
  42513. updateControllerLaserColor: boolean;
  42514. /**
  42515. * The gaze tracking mesh corresponding to the left controller
  42516. */
  42517. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42518. /**
  42519. * The gaze tracking mesh corresponding to the right controller
  42520. */
  42521. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42522. /**
  42523. * If the ray of the gaze should be displayed.
  42524. */
  42525. /**
  42526. * Sets if the ray of the gaze should be displayed.
  42527. */
  42528. displayGaze: boolean;
  42529. /**
  42530. * If the ray of the LaserPointer should be displayed.
  42531. */
  42532. /**
  42533. * Sets if the ray of the LaserPointer should be displayed.
  42534. */
  42535. displayLaserPointer: boolean;
  42536. /**
  42537. * The deviceOrientationCamera used as the camera when not in VR.
  42538. */
  42539. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42540. /**
  42541. * Based on the current WebVR support, returns the current VR camera used.
  42542. */
  42543. readonly currentVRCamera: Nullable<Camera>;
  42544. /**
  42545. * The webVRCamera which is used when in VR.
  42546. */
  42547. readonly webVRCamera: WebVRFreeCamera;
  42548. /**
  42549. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42550. */
  42551. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42552. /**
  42553. * The html button that is used to trigger entering into VR.
  42554. */
  42555. readonly vrButton: Nullable<HTMLButtonElement>;
  42556. private readonly _teleportationRequestInitiated;
  42557. /**
  42558. * Defines wether or not Pointer lock should be requested when switching to
  42559. * full screen.
  42560. */
  42561. requestPointerLockOnFullScreen: boolean;
  42562. /**
  42563. * Instantiates a VRExperienceHelper.
  42564. * Helps to quickly add VR support to an existing scene.
  42565. * @param scene The scene the VRExperienceHelper belongs to.
  42566. * @param webVROptions Options to modify the vr experience helper's behavior.
  42567. */
  42568. constructor(scene: Scene,
  42569. /** Options to modify the vr experience helper's behavior. */
  42570. webVROptions?: VRExperienceHelperOptions);
  42571. private _onDefaultMeshLoaded;
  42572. private _onResize;
  42573. private _onFullscreenChange;
  42574. /**
  42575. * Gets a value indicating if we are currently in VR mode.
  42576. */
  42577. readonly isInVRMode: boolean;
  42578. private onVrDisplayPresentChange;
  42579. private onVRDisplayChanged;
  42580. private moveButtonToBottomRight;
  42581. private displayVRButton;
  42582. private updateButtonVisibility;
  42583. private _cachedAngularSensibility;
  42584. /**
  42585. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42586. * Otherwise, will use the fullscreen API.
  42587. */
  42588. enterVR(): void;
  42589. /**
  42590. * Attempt to exit VR, or fullscreen.
  42591. */
  42592. exitVR(): void;
  42593. /**
  42594. * The position of the vr experience helper.
  42595. */
  42596. /**
  42597. * Sets the position of the vr experience helper.
  42598. */
  42599. position: Vector3;
  42600. /**
  42601. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42602. */
  42603. enableInteractions(): void;
  42604. private readonly _noControllerIsActive;
  42605. private beforeRender;
  42606. private _isTeleportationFloor;
  42607. /**
  42608. * Adds a floor mesh to be used for teleportation.
  42609. * @param floorMesh the mesh to be used for teleportation.
  42610. */
  42611. addFloorMesh(floorMesh: Mesh): void;
  42612. /**
  42613. * Removes a floor mesh from being used for teleportation.
  42614. * @param floorMesh the mesh to be removed.
  42615. */
  42616. removeFloorMesh(floorMesh: Mesh): void;
  42617. /**
  42618. * Enables interactions and teleportation using the VR controllers and gaze.
  42619. * @param vrTeleportationOptions options to modify teleportation behavior.
  42620. */
  42621. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42622. private _onNewGamepadConnected;
  42623. private _tryEnableInteractionOnController;
  42624. private _onNewGamepadDisconnected;
  42625. private _enableInteractionOnController;
  42626. private _checkTeleportWithRay;
  42627. private _checkRotate;
  42628. private _checkTeleportBackwards;
  42629. private _enableTeleportationOnController;
  42630. private _createTeleportationCircles;
  42631. private _displayTeleportationTarget;
  42632. private _hideTeleportationTarget;
  42633. private _rotateCamera;
  42634. private _moveTeleportationSelectorTo;
  42635. private _workingVector;
  42636. private _workingQuaternion;
  42637. private _workingMatrix;
  42638. /**
  42639. * Teleports the users feet to the desired location
  42640. * @param location The location where the user's feet should be placed
  42641. */
  42642. teleportCamera(location: Vector3): void;
  42643. private _convertNormalToDirectionOfRay;
  42644. private _castRayAndSelectObject;
  42645. private _notifySelectedMeshUnselected;
  42646. /**
  42647. * Sets the color of the laser ray from the vr controllers.
  42648. * @param color new color for the ray.
  42649. */
  42650. changeLaserColor(color: Color3): void;
  42651. /**
  42652. * Sets the color of the ray from the vr headsets gaze.
  42653. * @param color new color for the ray.
  42654. */
  42655. changeGazeColor(color: Color3): void;
  42656. /**
  42657. * Exits VR and disposes of the vr experience helper
  42658. */
  42659. dispose(): void;
  42660. /**
  42661. * Gets the name of the VRExperienceHelper class
  42662. * @returns "VRExperienceHelper"
  42663. */
  42664. getClassName(): string;
  42665. }
  42666. }
  42667. declare module "babylonjs/Cameras/VR/index" {
  42668. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42669. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42670. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42671. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42672. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42673. export * from "babylonjs/Cameras/VR/webVRCamera";
  42674. }
  42675. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42676. import { Observable } from "babylonjs/Misc/observable";
  42677. import { Nullable } from "babylonjs/types";
  42678. import { IDisposable, Scene } from "babylonjs/scene";
  42679. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42680. /**
  42681. * Manages an XRSession to work with Babylon's engine
  42682. * @see https://doc.babylonjs.com/how_to/webxr
  42683. */
  42684. export class WebXRSessionManager implements IDisposable {
  42685. private scene;
  42686. /**
  42687. * Fires every time a new xrFrame arrives which can be used to update the camera
  42688. */
  42689. onXRFrameObservable: Observable<any>;
  42690. /**
  42691. * Fires when the xr session is ended either by the device or manually done
  42692. */
  42693. onXRSessionEnded: Observable<any>;
  42694. /**
  42695. * Underlying xr session
  42696. */
  42697. session: XRSession;
  42698. /**
  42699. * Type of reference space used when creating the session
  42700. */
  42701. referenceSpace: XRReferenceSpace;
  42702. /** @hidden */
  42703. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42704. /**
  42705. * Current XR frame
  42706. */
  42707. currentFrame: Nullable<XRFrame>;
  42708. private _xrNavigator;
  42709. private baseLayer;
  42710. /**
  42711. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42712. * @param scene The scene which the session should be created for
  42713. */
  42714. constructor(scene: Scene);
  42715. /**
  42716. * Initializes the manager
  42717. * After initialization enterXR can be called to start an XR session
  42718. * @returns Promise which resolves after it is initialized
  42719. */
  42720. initializeAsync(): Promise<void>;
  42721. /**
  42722. * Initializes an xr session
  42723. * @param xrSessionMode mode to initialize
  42724. * @returns a promise which will resolve once the session has been initialized
  42725. */
  42726. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42727. /**
  42728. * Sets the reference space on the xr session
  42729. * @param referenceSpace space to set
  42730. * @returns a promise that will resolve once the reference space has been set
  42731. */
  42732. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42733. /**
  42734. * Updates the render state of the session
  42735. * @param state state to set
  42736. * @returns a promise that resolves once the render state has been updated
  42737. */
  42738. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42739. /**
  42740. * Starts rendering to the xr layer
  42741. * @returns a promise that will resolve once rendering has started
  42742. */
  42743. startRenderingToXRAsync(): Promise<void>;
  42744. /**
  42745. * Stops the xrSession and restores the renderloop
  42746. * @returns Promise which resolves after it exits XR
  42747. */
  42748. exitXRAsync(): Promise<unknown>;
  42749. /**
  42750. * Checks if a session would be supported for the creation options specified
  42751. * @param sessionMode session mode to check if supported eg. immersive-vr
  42752. * @returns true if supported
  42753. */
  42754. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42755. /**
  42756. * @hidden
  42757. * Converts the render layer of xrSession to a render target
  42758. * @param session session to create render target for
  42759. * @param scene scene the new render target should be created for
  42760. */
  42761. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42762. /**
  42763. * Disposes of the session manager
  42764. */
  42765. dispose(): void;
  42766. }
  42767. }
  42768. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42769. import { Scene } from "babylonjs/scene";
  42770. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42771. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42772. /**
  42773. * WebXR Camera which holds the views for the xrSession
  42774. * @see https://doc.babylonjs.com/how_to/webxr
  42775. */
  42776. export class WebXRCamera extends FreeCamera {
  42777. private static _TmpMatrix;
  42778. /**
  42779. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42780. * @param name the name of the camera
  42781. * @param scene the scene to add the camera to
  42782. */
  42783. constructor(name: string, scene: Scene);
  42784. private _updateNumberOfRigCameras;
  42785. /** @hidden */
  42786. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42787. /**
  42788. * Updates the cameras position from the current pose information of the XR session
  42789. * @param xrSessionManager the session containing pose information
  42790. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42791. */
  42792. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42793. }
  42794. }
  42795. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42796. import { Nullable } from "babylonjs/types";
  42797. import { IDisposable } from "babylonjs/scene";
  42798. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42799. /**
  42800. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42801. */
  42802. export class WebXRManagedOutputCanvas implements IDisposable {
  42803. private helper;
  42804. private _canvas;
  42805. /**
  42806. * xrpresent context of the canvas which can be used to display/mirror xr content
  42807. */
  42808. canvasContext: WebGLRenderingContext;
  42809. /**
  42810. * xr layer for the canvas
  42811. */
  42812. xrLayer: Nullable<XRWebGLLayer>;
  42813. /**
  42814. * Initializes the xr layer for the session
  42815. * @param xrSession xr session
  42816. * @returns a promise that will resolve once the XR Layer has been created
  42817. */
  42818. initializeXRLayerAsync(xrSession: any): any;
  42819. /**
  42820. * Initializes the canvas to be added/removed upon entering/exiting xr
  42821. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42822. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42823. */
  42824. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42825. /**
  42826. * Disposes of the object
  42827. */
  42828. dispose(): void;
  42829. private _setManagedOutputCanvas;
  42830. private _addCanvas;
  42831. private _removeCanvas;
  42832. }
  42833. }
  42834. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42835. import { Observable } from "babylonjs/Misc/observable";
  42836. import { IDisposable, Scene } from "babylonjs/scene";
  42837. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42839. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42840. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42841. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42842. /**
  42843. * States of the webXR experience
  42844. */
  42845. export enum WebXRState {
  42846. /**
  42847. * Transitioning to being in XR mode
  42848. */
  42849. ENTERING_XR = 0,
  42850. /**
  42851. * Transitioning to non XR mode
  42852. */
  42853. EXITING_XR = 1,
  42854. /**
  42855. * In XR mode and presenting
  42856. */
  42857. IN_XR = 2,
  42858. /**
  42859. * Not entered XR mode
  42860. */
  42861. NOT_IN_XR = 3
  42862. }
  42863. /**
  42864. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42865. * @see https://doc.babylonjs.com/how_to/webxr
  42866. */
  42867. export class WebXRExperienceHelper implements IDisposable {
  42868. private scene;
  42869. /**
  42870. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  42871. */
  42872. container: AbstractMesh;
  42873. /**
  42874. * Camera used to render xr content
  42875. */
  42876. camera: WebXRCamera;
  42877. /**
  42878. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42879. */
  42880. state: WebXRState;
  42881. private _setState;
  42882. private static _TmpVector;
  42883. /**
  42884. * Fires when the state of the experience helper has changed
  42885. */
  42886. onStateChangedObservable: Observable<WebXRState>;
  42887. /** Session manager used to keep track of xr session */
  42888. sessionManager: WebXRSessionManager;
  42889. private _nonVRCamera;
  42890. private _originalSceneAutoClear;
  42891. private _supported;
  42892. /**
  42893. * Creates the experience helper
  42894. * @param scene the scene to attach the experience helper to
  42895. * @returns a promise for the experience helper
  42896. */
  42897. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42898. /**
  42899. * Creates a WebXRExperienceHelper
  42900. * @param scene The scene the helper should be created in
  42901. */
  42902. private constructor();
  42903. /**
  42904. * Exits XR mode and returns the scene to its original state
  42905. * @returns promise that resolves after xr mode has exited
  42906. */
  42907. exitXRAsync(): Promise<unknown>;
  42908. /**
  42909. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42910. * @param sessionCreationOptions options for the XR session
  42911. * @param referenceSpaceType frame of reference of the XR session
  42912. * @param outputCanvas the output canvas that will be used to enter XR mode
  42913. * @returns promise that resolves after xr mode has entered
  42914. */
  42915. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42916. /**
  42917. * Updates the global position of the camera by moving the camera's container
  42918. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42919. * @param position The desired global position of the camera
  42920. */
  42921. setPositionOfCameraUsingContainer(position: Vector3): void;
  42922. /**
  42923. * Rotates the xr camera by rotating the camera's container around the camera's position
  42924. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42925. * @param rotation the desired quaternion rotation to apply to the camera
  42926. */
  42927. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42928. /**
  42929. * Disposes of the experience helper
  42930. */
  42931. dispose(): void;
  42932. }
  42933. }
  42934. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42935. import { Nullable } from "babylonjs/types";
  42936. import { Observable } from "babylonjs/Misc/observable";
  42937. import { IDisposable, Scene } from "babylonjs/scene";
  42938. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42939. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42940. /**
  42941. * Button which can be used to enter a different mode of XR
  42942. */
  42943. export class WebXREnterExitUIButton {
  42944. /** button element */
  42945. element: HTMLElement;
  42946. /** XR initialization options for the button */
  42947. sessionMode: XRSessionMode;
  42948. /** Reference space type */
  42949. referenceSpaceType: XRReferenceSpaceType;
  42950. /**
  42951. * Creates a WebXREnterExitUIButton
  42952. * @param element button element
  42953. * @param sessionMode XR initialization session mode
  42954. * @param referenceSpaceType the type of reference space to be used
  42955. */
  42956. constructor(
  42957. /** button element */
  42958. element: HTMLElement,
  42959. /** XR initialization options for the button */
  42960. sessionMode: XRSessionMode,
  42961. /** Reference space type */
  42962. referenceSpaceType: XRReferenceSpaceType);
  42963. /**
  42964. * Overwritable function which can be used to update the button's visuals when the state changes
  42965. * @param activeButton the current active button in the UI
  42966. */
  42967. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42968. }
  42969. /**
  42970. * Options to create the webXR UI
  42971. */
  42972. export class WebXREnterExitUIOptions {
  42973. /**
  42974. * Context to enter xr with
  42975. */
  42976. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42977. /**
  42978. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42979. */
  42980. customButtons?: Array<WebXREnterExitUIButton>;
  42981. }
  42982. /**
  42983. * UI to allow the user to enter/exit XR mode
  42984. */
  42985. export class WebXREnterExitUI implements IDisposable {
  42986. private scene;
  42987. private _overlay;
  42988. private _buttons;
  42989. private _activeButton;
  42990. /**
  42991. * Fired every time the active button is changed.
  42992. *
  42993. * When xr is entered via a button that launches xr that button will be the callback parameter
  42994. *
  42995. * When exiting xr the callback parameter will be null)
  42996. */
  42997. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42998. /**
  42999. * Creates UI to allow the user to enter/exit XR mode
  43000. * @param scene the scene to add the ui to
  43001. * @param helper the xr experience helper to enter/exit xr with
  43002. * @param options options to configure the UI
  43003. * @returns the created ui
  43004. */
  43005. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43006. private constructor();
  43007. private _updateButtons;
  43008. /**
  43009. * Disposes of the object
  43010. */
  43011. dispose(): void;
  43012. }
  43013. }
  43014. declare module "babylonjs/Cameras/XR/webXRController" {
  43015. import { Nullable } from "babylonjs/types";
  43016. import { Observable } from "babylonjs/Misc/observable";
  43017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43018. import { Ray } from "babylonjs/Culling/ray";
  43019. import { Scene } from "babylonjs/scene";
  43020. /**
  43021. * Represents an XR input
  43022. */
  43023. export class WebXRController {
  43024. private scene;
  43025. /** The underlying input source for the controller */
  43026. inputSource: XRInputSource;
  43027. private parentContainer;
  43028. /**
  43029. * 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
  43030. */
  43031. grip?: AbstractMesh;
  43032. /**
  43033. * Pointer which can be used to select objects or attach a visible laser to
  43034. */
  43035. pointer: AbstractMesh;
  43036. /**
  43037. * Event that fires when the controller is removed/disposed
  43038. */
  43039. onDisposeObservable: Observable<{}>;
  43040. private _tmpMatrix;
  43041. private _tmpQuaternion;
  43042. private _tmpVector;
  43043. /**
  43044. * Creates the controller
  43045. * @see https://doc.babylonjs.com/how_to/webxr
  43046. * @param scene the scene which the controller should be associated to
  43047. * @param inputSource the underlying input source for the controller
  43048. * @param parentContainer parent that the controller meshes should be children of
  43049. */
  43050. constructor(scene: Scene,
  43051. /** The underlying input source for the controller */
  43052. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43053. /**
  43054. * Updates the controller pose based on the given XRFrame
  43055. * @param xrFrame xr frame to update the pose with
  43056. * @param referenceSpace reference space to use
  43057. */
  43058. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43059. /**
  43060. * Gets a world space ray coming from the controller
  43061. * @param result the resulting ray
  43062. */
  43063. getWorldPointerRayToRef(result: Ray): void;
  43064. /**
  43065. * Disposes of the object
  43066. */
  43067. dispose(): void;
  43068. }
  43069. }
  43070. declare module "babylonjs/Cameras/XR/webXRInput" {
  43071. import { Observable } from "babylonjs/Misc/observable";
  43072. import { IDisposable } from "babylonjs/scene";
  43073. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43074. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43075. /**
  43076. * XR input used to track XR inputs such as controllers/rays
  43077. */
  43078. export class WebXRInput implements IDisposable {
  43079. /**
  43080. * Base experience the input listens to
  43081. */
  43082. baseExperience: WebXRExperienceHelper;
  43083. /**
  43084. * XR controllers being tracked
  43085. */
  43086. controllers: Array<WebXRController>;
  43087. private _frameObserver;
  43088. private _stateObserver;
  43089. /**
  43090. * Event when a controller has been connected/added
  43091. */
  43092. onControllerAddedObservable: Observable<WebXRController>;
  43093. /**
  43094. * Event when a controller has been removed/disconnected
  43095. */
  43096. onControllerRemovedObservable: Observable<WebXRController>;
  43097. /**
  43098. * Initializes the WebXRInput
  43099. * @param baseExperience experience helper which the input should be created for
  43100. */
  43101. constructor(
  43102. /**
  43103. * Base experience the input listens to
  43104. */
  43105. baseExperience: WebXRExperienceHelper);
  43106. private _onInputSourcesChange;
  43107. private _addAndRemoveControllers;
  43108. /**
  43109. * Disposes of the object
  43110. */
  43111. dispose(): void;
  43112. }
  43113. }
  43114. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43116. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43117. /**
  43118. * Enables teleportation
  43119. */
  43120. export class WebXRControllerTeleportation {
  43121. private _teleportationFillColor;
  43122. private _teleportationBorderColor;
  43123. private _tmpRay;
  43124. private _tmpVector;
  43125. /**
  43126. * Creates a WebXRControllerTeleportation
  43127. * @param input input manager to add teleportation to
  43128. * @param floorMeshes floormeshes which can be teleported to
  43129. */
  43130. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43131. }
  43132. }
  43133. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43134. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43135. /**
  43136. * Handles pointer input automatically for the pointer of XR controllers
  43137. */
  43138. export class WebXRControllerPointerSelection {
  43139. private static _idCounter;
  43140. private _tmpRay;
  43141. /**
  43142. * Creates a WebXRControllerPointerSelection
  43143. * @param input input manager to setup pointer selection
  43144. */
  43145. constructor(input: WebXRInput);
  43146. private _convertNormalToDirectionOfRay;
  43147. private _updatePointerDistance;
  43148. }
  43149. }
  43150. declare module "babylonjs/Loading/sceneLoader" {
  43151. import { Observable } from "babylonjs/Misc/observable";
  43152. import { Nullable } from "babylonjs/types";
  43153. import { Scene } from "babylonjs/scene";
  43154. import { Engine } from "babylonjs/Engines/engine";
  43155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43156. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43157. import { AssetContainer } from "babylonjs/assetContainer";
  43158. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43159. import { Skeleton } from "babylonjs/Bones/skeleton";
  43160. /**
  43161. * Class used to represent data loading progression
  43162. */
  43163. export class SceneLoaderProgressEvent {
  43164. /** defines if data length to load can be evaluated */
  43165. readonly lengthComputable: boolean;
  43166. /** defines the loaded data length */
  43167. readonly loaded: number;
  43168. /** defines the data length to load */
  43169. readonly total: number;
  43170. /**
  43171. * Create a new progress event
  43172. * @param lengthComputable defines if data length to load can be evaluated
  43173. * @param loaded defines the loaded data length
  43174. * @param total defines the data length to load
  43175. */
  43176. constructor(
  43177. /** defines if data length to load can be evaluated */
  43178. lengthComputable: boolean,
  43179. /** defines the loaded data length */
  43180. loaded: number,
  43181. /** defines the data length to load */
  43182. total: number);
  43183. /**
  43184. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43185. * @param event defines the source event
  43186. * @returns a new SceneLoaderProgressEvent
  43187. */
  43188. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43189. }
  43190. /**
  43191. * Interface used by SceneLoader plugins to define supported file extensions
  43192. */
  43193. export interface ISceneLoaderPluginExtensions {
  43194. /**
  43195. * Defines the list of supported extensions
  43196. */
  43197. [extension: string]: {
  43198. isBinary: boolean;
  43199. };
  43200. }
  43201. /**
  43202. * Interface used by SceneLoader plugin factory
  43203. */
  43204. export interface ISceneLoaderPluginFactory {
  43205. /**
  43206. * Defines the name of the factory
  43207. */
  43208. name: string;
  43209. /**
  43210. * Function called to create a new plugin
  43211. * @return the new plugin
  43212. */
  43213. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43214. /**
  43215. * Boolean indicating if the plugin can direct load specific data
  43216. */
  43217. canDirectLoad?: (data: string) => boolean;
  43218. }
  43219. /**
  43220. * Interface used to define a SceneLoader plugin
  43221. */
  43222. export interface ISceneLoaderPlugin {
  43223. /**
  43224. * The friendly name of this plugin.
  43225. */
  43226. name: string;
  43227. /**
  43228. * The file extensions supported by this plugin.
  43229. */
  43230. extensions: string | ISceneLoaderPluginExtensions;
  43231. /**
  43232. * Import meshes into a scene.
  43233. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43234. * @param scene The scene to import into
  43235. * @param data The data to import
  43236. * @param rootUrl The root url for scene and resources
  43237. * @param meshes The meshes array to import into
  43238. * @param particleSystems The particle systems array to import into
  43239. * @param skeletons The skeletons array to import into
  43240. * @param onError The callback when import fails
  43241. * @returns True if successful or false otherwise
  43242. */
  43243. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43244. /**
  43245. * Load into a scene.
  43246. * @param scene The scene to load into
  43247. * @param data The data to import
  43248. * @param rootUrl The root url for scene and resources
  43249. * @param onError The callback when import fails
  43250. * @returns true if successful or false otherwise
  43251. */
  43252. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43253. /**
  43254. * The callback that returns true if the data can be directly loaded.
  43255. */
  43256. canDirectLoad?: (data: string) => boolean;
  43257. /**
  43258. * The callback that allows custom handling of the root url based on the response url.
  43259. */
  43260. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43261. /**
  43262. * Load into an asset container.
  43263. * @param scene The scene to load into
  43264. * @param data The data to import
  43265. * @param rootUrl The root url for scene and resources
  43266. * @param onError The callback when import fails
  43267. * @returns The loaded asset container
  43268. */
  43269. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43270. }
  43271. /**
  43272. * Interface used to define an async SceneLoader plugin
  43273. */
  43274. export interface ISceneLoaderPluginAsync {
  43275. /**
  43276. * The friendly name of this plugin.
  43277. */
  43278. name: string;
  43279. /**
  43280. * The file extensions supported by this plugin.
  43281. */
  43282. extensions: string | ISceneLoaderPluginExtensions;
  43283. /**
  43284. * Import meshes into a scene.
  43285. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43286. * @param scene The scene to import into
  43287. * @param data The data to import
  43288. * @param rootUrl The root url for scene and resources
  43289. * @param onProgress The callback when the load progresses
  43290. * @param fileName Defines the name of the file to load
  43291. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43292. */
  43293. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43294. meshes: AbstractMesh[];
  43295. particleSystems: IParticleSystem[];
  43296. skeletons: Skeleton[];
  43297. animationGroups: AnimationGroup[];
  43298. }>;
  43299. /**
  43300. * Load into a scene.
  43301. * @param scene The scene to load into
  43302. * @param data The data to import
  43303. * @param rootUrl The root url for scene and resources
  43304. * @param onProgress The callback when the load progresses
  43305. * @param fileName Defines the name of the file to load
  43306. * @returns Nothing
  43307. */
  43308. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43309. /**
  43310. * The callback that returns true if the data can be directly loaded.
  43311. */
  43312. canDirectLoad?: (data: string) => boolean;
  43313. /**
  43314. * The callback that allows custom handling of the root url based on the response url.
  43315. */
  43316. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43317. /**
  43318. * Load into an asset container.
  43319. * @param scene The scene to load into
  43320. * @param data The data to import
  43321. * @param rootUrl The root url for scene and resources
  43322. * @param onProgress The callback when the load progresses
  43323. * @param fileName Defines the name of the file to load
  43324. * @returns The loaded asset container
  43325. */
  43326. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43327. }
  43328. /**
  43329. * Class used to load scene from various file formats using registered plugins
  43330. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43331. */
  43332. export class SceneLoader {
  43333. /**
  43334. * No logging while loading
  43335. */
  43336. static readonly NO_LOGGING: number;
  43337. /**
  43338. * Minimal logging while loading
  43339. */
  43340. static readonly MINIMAL_LOGGING: number;
  43341. /**
  43342. * Summary logging while loading
  43343. */
  43344. static readonly SUMMARY_LOGGING: number;
  43345. /**
  43346. * Detailled logging while loading
  43347. */
  43348. static readonly DETAILED_LOGGING: number;
  43349. /**
  43350. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43351. */
  43352. static ForceFullSceneLoadingForIncremental: boolean;
  43353. /**
  43354. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43355. */
  43356. static ShowLoadingScreen: boolean;
  43357. /**
  43358. * Defines the current logging level (while loading the scene)
  43359. * @ignorenaming
  43360. */
  43361. static loggingLevel: number;
  43362. /**
  43363. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43364. */
  43365. static CleanBoneMatrixWeights: boolean;
  43366. /**
  43367. * Event raised when a plugin is used to load a scene
  43368. */
  43369. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43370. private static _registeredPlugins;
  43371. private static _getDefaultPlugin;
  43372. private static _getPluginForExtension;
  43373. private static _getPluginForDirectLoad;
  43374. private static _getPluginForFilename;
  43375. private static _getDirectLoad;
  43376. private static _loadData;
  43377. private static _getFileInfo;
  43378. /**
  43379. * Gets a plugin that can load the given extension
  43380. * @param extension defines the extension to load
  43381. * @returns a plugin or null if none works
  43382. */
  43383. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43384. /**
  43385. * Gets a boolean indicating that the given extension can be loaded
  43386. * @param extension defines the extension to load
  43387. * @returns true if the extension is supported
  43388. */
  43389. static IsPluginForExtensionAvailable(extension: string): boolean;
  43390. /**
  43391. * Adds a new plugin to the list of registered plugins
  43392. * @param plugin defines the plugin to add
  43393. */
  43394. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43395. /**
  43396. * Import meshes into a scene
  43397. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43398. * @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)
  43399. * @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)
  43400. * @param scene the instance of BABYLON.Scene to append to
  43401. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43402. * @param onProgress a callback with a progress event for each file being loaded
  43403. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43404. * @param pluginExtension the extension used to determine the plugin
  43405. * @returns The loaded plugin
  43406. */
  43407. 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>;
  43408. /**
  43409. * Import meshes into a scene
  43410. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43411. * @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)
  43412. * @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)
  43413. * @param scene the instance of BABYLON.Scene to append to
  43414. * @param onProgress a callback with a progress event for each file being loaded
  43415. * @param pluginExtension the extension used to determine the plugin
  43416. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43417. */
  43418. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43419. meshes: AbstractMesh[];
  43420. particleSystems: IParticleSystem[];
  43421. skeletons: Skeleton[];
  43422. animationGroups: AnimationGroup[];
  43423. }>;
  43424. /**
  43425. * Load a scene
  43426. * @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)
  43427. * @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)
  43428. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43429. * @param onSuccess a callback with the scene when import succeeds
  43430. * @param onProgress a callback with a progress event for each file being loaded
  43431. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43432. * @param pluginExtension the extension used to determine the plugin
  43433. * @returns The loaded plugin
  43434. */
  43435. 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>;
  43436. /**
  43437. * Load a scene
  43438. * @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)
  43439. * @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)
  43440. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43441. * @param onProgress a callback with a progress event for each file being loaded
  43442. * @param pluginExtension the extension used to determine the plugin
  43443. * @returns The loaded scene
  43444. */
  43445. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43446. /**
  43447. * Append a scene
  43448. * @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)
  43449. * @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)
  43450. * @param scene is the instance of BABYLON.Scene to append to
  43451. * @param onSuccess a callback with the scene when import succeeds
  43452. * @param onProgress a callback with a progress event for each file being loaded
  43453. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43454. * @param pluginExtension the extension used to determine the plugin
  43455. * @returns The loaded plugin
  43456. */
  43457. 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>;
  43458. /**
  43459. * Append a scene
  43460. * @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)
  43461. * @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)
  43462. * @param scene is the instance of BABYLON.Scene to append to
  43463. * @param onProgress a callback with a progress event for each file being loaded
  43464. * @param pluginExtension the extension used to determine the plugin
  43465. * @returns The given scene
  43466. */
  43467. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43468. /**
  43469. * Load a scene into an asset container
  43470. * @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)
  43471. * @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)
  43472. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43473. * @param onSuccess a callback with the scene when import succeeds
  43474. * @param onProgress a callback with a progress event for each file being loaded
  43475. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43476. * @param pluginExtension the extension used to determine the plugin
  43477. * @returns The loaded plugin
  43478. */
  43479. 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>;
  43480. /**
  43481. * Load a scene into an asset container
  43482. * @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)
  43483. * @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)
  43484. * @param scene is the instance of Scene to append to
  43485. * @param onProgress a callback with a progress event for each file being loaded
  43486. * @param pluginExtension the extension used to determine the plugin
  43487. * @returns The loaded asset container
  43488. */
  43489. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43490. }
  43491. }
  43492. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43493. import { Scene } from "babylonjs/scene";
  43494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43495. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43496. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43497. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43498. /**
  43499. * Generic Controller
  43500. */
  43501. export class GenericController extends WebVRController {
  43502. /**
  43503. * Base Url for the controller model.
  43504. */
  43505. static readonly MODEL_BASE_URL: string;
  43506. /**
  43507. * File name for the controller model.
  43508. */
  43509. static readonly MODEL_FILENAME: string;
  43510. /**
  43511. * Creates a new GenericController from a gamepad
  43512. * @param vrGamepad the gamepad that the controller should be created from
  43513. */
  43514. constructor(vrGamepad: any);
  43515. /**
  43516. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43517. * @param scene scene in which to add meshes
  43518. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43519. */
  43520. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43521. /**
  43522. * Called once for each button that changed state since the last frame
  43523. * @param buttonIdx Which button index changed
  43524. * @param state New state of the button
  43525. * @param changes Which properties on the state changed since last frame
  43526. */
  43527. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43528. }
  43529. }
  43530. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43531. import { Observable } from "babylonjs/Misc/observable";
  43532. import { Scene } from "babylonjs/scene";
  43533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43534. import { Ray } from "babylonjs/Culling/ray";
  43535. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43536. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43537. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43538. /**
  43539. * Defines the WindowsMotionController object that the state of the windows motion controller
  43540. */
  43541. export class WindowsMotionController extends WebVRController {
  43542. /**
  43543. * The base url used to load the left and right controller models
  43544. */
  43545. static MODEL_BASE_URL: string;
  43546. /**
  43547. * The name of the left controller model file
  43548. */
  43549. static MODEL_LEFT_FILENAME: string;
  43550. /**
  43551. * The name of the right controller model file
  43552. */
  43553. static MODEL_RIGHT_FILENAME: string;
  43554. /**
  43555. * The controller name prefix for this controller type
  43556. */
  43557. static readonly GAMEPAD_ID_PREFIX: string;
  43558. /**
  43559. * The controller id pattern for this controller type
  43560. */
  43561. private static readonly GAMEPAD_ID_PATTERN;
  43562. private _loadedMeshInfo;
  43563. private readonly _mapping;
  43564. /**
  43565. * Fired when the trackpad on this controller is clicked
  43566. */
  43567. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43568. /**
  43569. * Fired when the trackpad on this controller is modified
  43570. */
  43571. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43572. /**
  43573. * The current x and y values of this controller's trackpad
  43574. */
  43575. trackpad: StickValues;
  43576. /**
  43577. * Creates a new WindowsMotionController from a gamepad
  43578. * @param vrGamepad the gamepad that the controller should be created from
  43579. */
  43580. constructor(vrGamepad: any);
  43581. /**
  43582. * Fired when the trigger on this controller is modified
  43583. */
  43584. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43585. /**
  43586. * Fired when the menu button on this controller is modified
  43587. */
  43588. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43589. /**
  43590. * Fired when the grip button on this controller is modified
  43591. */
  43592. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43593. /**
  43594. * Fired when the thumbstick button on this controller is modified
  43595. */
  43596. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43597. /**
  43598. * Fired when the touchpad button on this controller is modified
  43599. */
  43600. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43601. /**
  43602. * Fired when the touchpad values on this controller are modified
  43603. */
  43604. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43605. private _updateTrackpad;
  43606. /**
  43607. * Called once per frame by the engine.
  43608. */
  43609. update(): void;
  43610. /**
  43611. * Called once for each button that changed state since the last frame
  43612. * @param buttonIdx Which button index changed
  43613. * @param state New state of the button
  43614. * @param changes Which properties on the state changed since last frame
  43615. */
  43616. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43617. /**
  43618. * Moves the buttons on the controller mesh based on their current state
  43619. * @param buttonName the name of the button to move
  43620. * @param buttonValue the value of the button which determines the buttons new position
  43621. */
  43622. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43623. /**
  43624. * Moves the axis on the controller mesh based on its current state
  43625. * @param axis the index of the axis
  43626. * @param axisValue the value of the axis which determines the meshes new position
  43627. * @hidden
  43628. */
  43629. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43630. /**
  43631. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43632. * @param scene scene in which to add meshes
  43633. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43634. */
  43635. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43636. /**
  43637. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43638. * can be transformed by button presses and axes values, based on this._mapping.
  43639. *
  43640. * @param scene scene in which the meshes exist
  43641. * @param meshes list of meshes that make up the controller model to process
  43642. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43643. */
  43644. private processModel;
  43645. private createMeshInfo;
  43646. /**
  43647. * Gets the ray of the controller in the direction the controller is pointing
  43648. * @param length the length the resulting ray should be
  43649. * @returns a ray in the direction the controller is pointing
  43650. */
  43651. getForwardRay(length?: number): Ray;
  43652. /**
  43653. * Disposes of the controller
  43654. */
  43655. dispose(): void;
  43656. }
  43657. }
  43658. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43659. import { Observable } from "babylonjs/Misc/observable";
  43660. import { Scene } from "babylonjs/scene";
  43661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43662. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43663. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43664. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43665. /**
  43666. * Oculus Touch Controller
  43667. */
  43668. export class OculusTouchController extends WebVRController {
  43669. /**
  43670. * Base Url for the controller model.
  43671. */
  43672. static MODEL_BASE_URL: string;
  43673. /**
  43674. * File name for the left controller model.
  43675. */
  43676. static MODEL_LEFT_FILENAME: string;
  43677. /**
  43678. * File name for the right controller model.
  43679. */
  43680. static MODEL_RIGHT_FILENAME: string;
  43681. /**
  43682. * Base Url for the Quest controller model.
  43683. */
  43684. static QUEST_MODEL_BASE_URL: string;
  43685. /**
  43686. * @hidden
  43687. * If the controllers are running on a device that needs the updated Quest controller models
  43688. */
  43689. static _IsQuest: boolean;
  43690. /**
  43691. * Fired when the secondary trigger on this controller is modified
  43692. */
  43693. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43694. /**
  43695. * Fired when the thumb rest on this controller is modified
  43696. */
  43697. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43698. /**
  43699. * Creates a new OculusTouchController from a gamepad
  43700. * @param vrGamepad the gamepad that the controller should be created from
  43701. */
  43702. constructor(vrGamepad: any);
  43703. /**
  43704. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43705. * @param scene scene in which to add meshes
  43706. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43707. */
  43708. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43709. /**
  43710. * Fired when the A button on this controller is modified
  43711. */
  43712. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43713. /**
  43714. * Fired when the B button on this controller is modified
  43715. */
  43716. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43717. /**
  43718. * Fired when the X button on this controller is modified
  43719. */
  43720. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43721. /**
  43722. * Fired when the Y button on this controller is modified
  43723. */
  43724. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43725. /**
  43726. * Called once for each button that changed state since the last frame
  43727. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43728. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43729. * 2) secondary trigger (same)
  43730. * 3) A (right) X (left), touch, pressed = value
  43731. * 4) B / Y
  43732. * 5) thumb rest
  43733. * @param buttonIdx Which button index changed
  43734. * @param state New state of the button
  43735. * @param changes Which properties on the state changed since last frame
  43736. */
  43737. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43738. }
  43739. }
  43740. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43741. import { Scene } from "babylonjs/scene";
  43742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43743. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43744. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43745. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43746. import { Observable } from "babylonjs/Misc/observable";
  43747. /**
  43748. * Vive Controller
  43749. */
  43750. export class ViveController extends WebVRController {
  43751. /**
  43752. * Base Url for the controller model.
  43753. */
  43754. static MODEL_BASE_URL: string;
  43755. /**
  43756. * File name for the controller model.
  43757. */
  43758. static MODEL_FILENAME: string;
  43759. /**
  43760. * Creates a new ViveController from a gamepad
  43761. * @param vrGamepad the gamepad that the controller should be created from
  43762. */
  43763. constructor(vrGamepad: any);
  43764. /**
  43765. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43766. * @param scene scene in which to add meshes
  43767. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43768. */
  43769. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43770. /**
  43771. * Fired when the left button on this controller is modified
  43772. */
  43773. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43774. /**
  43775. * Fired when the right button on this controller is modified
  43776. */
  43777. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43778. /**
  43779. * Fired when the menu button on this controller is modified
  43780. */
  43781. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43782. /**
  43783. * Called once for each button that changed state since the last frame
  43784. * Vive mapping:
  43785. * 0: touchpad
  43786. * 1: trigger
  43787. * 2: left AND right buttons
  43788. * 3: menu button
  43789. * @param buttonIdx Which button index changed
  43790. * @param state New state of the button
  43791. * @param changes Which properties on the state changed since last frame
  43792. */
  43793. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43794. }
  43795. }
  43796. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43797. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43798. /**
  43799. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43800. */
  43801. export class WebXRControllerModelLoader {
  43802. /**
  43803. * Creates the WebXRControllerModelLoader
  43804. * @param input xr input that creates the controllers
  43805. */
  43806. constructor(input: WebXRInput);
  43807. }
  43808. }
  43809. declare module "babylonjs/Cameras/XR/index" {
  43810. export * from "babylonjs/Cameras/XR/webXRCamera";
  43811. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43812. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43813. export * from "babylonjs/Cameras/XR/webXRInput";
  43814. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43815. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43816. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43817. export * from "babylonjs/Cameras/XR/webXRController";
  43818. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43819. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43820. }
  43821. declare module "babylonjs/Cameras/RigModes/index" {
  43822. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43823. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43824. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43825. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43826. }
  43827. declare module "babylonjs/Cameras/index" {
  43828. export * from "babylonjs/Cameras/Inputs/index";
  43829. export * from "babylonjs/Cameras/cameraInputsManager";
  43830. export * from "babylonjs/Cameras/camera";
  43831. export * from "babylonjs/Cameras/targetCamera";
  43832. export * from "babylonjs/Cameras/freeCamera";
  43833. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43834. export * from "babylonjs/Cameras/touchCamera";
  43835. export * from "babylonjs/Cameras/arcRotateCamera";
  43836. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43837. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43838. export * from "babylonjs/Cameras/flyCamera";
  43839. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43840. export * from "babylonjs/Cameras/followCamera";
  43841. export * from "babylonjs/Cameras/followCameraInputsManager";
  43842. export * from "babylonjs/Cameras/gamepadCamera";
  43843. export * from "babylonjs/Cameras/Stereoscopic/index";
  43844. export * from "babylonjs/Cameras/universalCamera";
  43845. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43846. export * from "babylonjs/Cameras/VR/index";
  43847. export * from "babylonjs/Cameras/XR/index";
  43848. export * from "babylonjs/Cameras/RigModes/index";
  43849. }
  43850. declare module "babylonjs/Collisions/index" {
  43851. export * from "babylonjs/Collisions/collider";
  43852. export * from "babylonjs/Collisions/collisionCoordinator";
  43853. export * from "babylonjs/Collisions/pickingInfo";
  43854. export * from "babylonjs/Collisions/intersectionInfo";
  43855. export * from "babylonjs/Collisions/meshCollisionData";
  43856. }
  43857. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43858. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43859. import { Vector3 } from "babylonjs/Maths/math.vector";
  43860. import { Ray } from "babylonjs/Culling/ray";
  43861. import { Plane } from "babylonjs/Maths/math.plane";
  43862. /**
  43863. * Contains an array of blocks representing the octree
  43864. */
  43865. export interface IOctreeContainer<T> {
  43866. /**
  43867. * Blocks within the octree
  43868. */
  43869. blocks: Array<OctreeBlock<T>>;
  43870. }
  43871. /**
  43872. * Class used to store a cell in an octree
  43873. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43874. */
  43875. export class OctreeBlock<T> {
  43876. /**
  43877. * Gets the content of the current block
  43878. */
  43879. entries: T[];
  43880. /**
  43881. * Gets the list of block children
  43882. */
  43883. blocks: Array<OctreeBlock<T>>;
  43884. private _depth;
  43885. private _maxDepth;
  43886. private _capacity;
  43887. private _minPoint;
  43888. private _maxPoint;
  43889. private _boundingVectors;
  43890. private _creationFunc;
  43891. /**
  43892. * Creates a new block
  43893. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43894. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43895. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43896. * @param depth defines the current depth of this block in the octree
  43897. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43898. * @param creationFunc defines a callback to call when an element is added to the block
  43899. */
  43900. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43901. /**
  43902. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43903. */
  43904. readonly capacity: number;
  43905. /**
  43906. * Gets the minimum vector (in world space) of the block's bounding box
  43907. */
  43908. readonly minPoint: Vector3;
  43909. /**
  43910. * Gets the maximum vector (in world space) of the block's bounding box
  43911. */
  43912. readonly maxPoint: Vector3;
  43913. /**
  43914. * Add a new element to this block
  43915. * @param entry defines the element to add
  43916. */
  43917. addEntry(entry: T): void;
  43918. /**
  43919. * Remove an element from this block
  43920. * @param entry defines the element to remove
  43921. */
  43922. removeEntry(entry: T): void;
  43923. /**
  43924. * Add an array of elements to this block
  43925. * @param entries defines the array of elements to add
  43926. */
  43927. addEntries(entries: T[]): void;
  43928. /**
  43929. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43930. * @param frustumPlanes defines the frustum planes to test
  43931. * @param selection defines the array to store current content if selection is positive
  43932. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43933. */
  43934. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43935. /**
  43936. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43937. * @param sphereCenter defines the bounding sphere center
  43938. * @param sphereRadius defines the bounding sphere radius
  43939. * @param selection defines the array to store current content if selection is positive
  43940. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43941. */
  43942. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43943. /**
  43944. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43945. * @param ray defines the ray to test with
  43946. * @param selection defines the array to store current content if selection is positive
  43947. */
  43948. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43949. /**
  43950. * Subdivide the content into child blocks (this block will then be empty)
  43951. */
  43952. createInnerBlocks(): void;
  43953. /**
  43954. * @hidden
  43955. */
  43956. 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;
  43957. }
  43958. }
  43959. declare module "babylonjs/Culling/Octrees/octree" {
  43960. import { SmartArray } from "babylonjs/Misc/smartArray";
  43961. import { Vector3 } from "babylonjs/Maths/math.vector";
  43962. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43964. import { Ray } from "babylonjs/Culling/ray";
  43965. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43966. import { Plane } from "babylonjs/Maths/math.plane";
  43967. /**
  43968. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43969. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43970. */
  43971. export class Octree<T> {
  43972. /** 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.) */
  43973. maxDepth: number;
  43974. /**
  43975. * Blocks within the octree containing objects
  43976. */
  43977. blocks: Array<OctreeBlock<T>>;
  43978. /**
  43979. * Content stored in the octree
  43980. */
  43981. dynamicContent: T[];
  43982. private _maxBlockCapacity;
  43983. private _selectionContent;
  43984. private _creationFunc;
  43985. /**
  43986. * Creates a octree
  43987. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43988. * @param creationFunc function to be used to instatiate the octree
  43989. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43990. * @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.)
  43991. */
  43992. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43993. /** 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.) */
  43994. maxDepth?: number);
  43995. /**
  43996. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43997. * @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);
  43998. * @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);
  43999. * @param entries meshes to be added to the octree blocks
  44000. */
  44001. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44002. /**
  44003. * Adds a mesh to the octree
  44004. * @param entry Mesh to add to the octree
  44005. */
  44006. addMesh(entry: T): void;
  44007. /**
  44008. * Remove an element from the octree
  44009. * @param entry defines the element to remove
  44010. */
  44011. removeMesh(entry: T): void;
  44012. /**
  44013. * Selects an array of meshes within the frustum
  44014. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44015. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44016. * @returns array of meshes within the frustum
  44017. */
  44018. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44019. /**
  44020. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44021. * @param sphereCenter defines the bounding sphere center
  44022. * @param sphereRadius defines the bounding sphere radius
  44023. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44024. * @returns an array of objects that intersect the sphere
  44025. */
  44026. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44027. /**
  44028. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44029. * @param ray defines the ray to test with
  44030. * @returns array of intersected objects
  44031. */
  44032. intersectsRay(ray: Ray): SmartArray<T>;
  44033. /**
  44034. * Adds a mesh into the octree block if it intersects the block
  44035. */
  44036. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44037. /**
  44038. * Adds a submesh into the octree block if it intersects the block
  44039. */
  44040. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44041. }
  44042. }
  44043. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44044. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44045. import { Scene } from "babylonjs/scene";
  44046. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44047. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44048. import { Ray } from "babylonjs/Culling/ray";
  44049. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44050. import { Collider } from "babylonjs/Collisions/collider";
  44051. module "babylonjs/scene" {
  44052. interface Scene {
  44053. /**
  44054. * @hidden
  44055. * Backing Filed
  44056. */
  44057. _selectionOctree: Octree<AbstractMesh>;
  44058. /**
  44059. * Gets the octree used to boost mesh selection (picking)
  44060. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44061. */
  44062. selectionOctree: Octree<AbstractMesh>;
  44063. /**
  44064. * Creates or updates the octree used to boost selection (picking)
  44065. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44066. * @param maxCapacity defines the maximum capacity per leaf
  44067. * @param maxDepth defines the maximum depth of the octree
  44068. * @returns an octree of AbstractMesh
  44069. */
  44070. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44071. }
  44072. }
  44073. module "babylonjs/Meshes/abstractMesh" {
  44074. interface AbstractMesh {
  44075. /**
  44076. * @hidden
  44077. * Backing Field
  44078. */
  44079. _submeshesOctree: Octree<SubMesh>;
  44080. /**
  44081. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44082. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44083. * @param maxCapacity defines the maximum size of each block (64 by default)
  44084. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44085. * @returns the new octree
  44086. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44087. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44088. */
  44089. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44090. }
  44091. }
  44092. /**
  44093. * Defines the octree scene component responsible to manage any octrees
  44094. * in a given scene.
  44095. */
  44096. export class OctreeSceneComponent {
  44097. /**
  44098. * The component name help to identify the component in the list of scene components.
  44099. */
  44100. readonly name: string;
  44101. /**
  44102. * The scene the component belongs to.
  44103. */
  44104. scene: Scene;
  44105. /**
  44106. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44107. */
  44108. readonly checksIsEnabled: boolean;
  44109. /**
  44110. * Creates a new instance of the component for the given scene
  44111. * @param scene Defines the scene to register the component in
  44112. */
  44113. constructor(scene: Scene);
  44114. /**
  44115. * Registers the component in a given scene
  44116. */
  44117. register(): void;
  44118. /**
  44119. * Return the list of active meshes
  44120. * @returns the list of active meshes
  44121. */
  44122. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44123. /**
  44124. * Return the list of active sub meshes
  44125. * @param mesh The mesh to get the candidates sub meshes from
  44126. * @returns the list of active sub meshes
  44127. */
  44128. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44129. private _tempRay;
  44130. /**
  44131. * Return the list of sub meshes intersecting with a given local ray
  44132. * @param mesh defines the mesh to find the submesh for
  44133. * @param localRay defines the ray in local space
  44134. * @returns the list of intersecting sub meshes
  44135. */
  44136. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44137. /**
  44138. * Return the list of sub meshes colliding with a collider
  44139. * @param mesh defines the mesh to find the submesh for
  44140. * @param collider defines the collider to evaluate the collision against
  44141. * @returns the list of colliding sub meshes
  44142. */
  44143. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44144. /**
  44145. * Rebuilds the elements related to this component in case of
  44146. * context lost for instance.
  44147. */
  44148. rebuild(): void;
  44149. /**
  44150. * Disposes the component and the associated ressources.
  44151. */
  44152. dispose(): void;
  44153. }
  44154. }
  44155. declare module "babylonjs/Culling/Octrees/index" {
  44156. export * from "babylonjs/Culling/Octrees/octree";
  44157. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44158. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44159. }
  44160. declare module "babylonjs/Culling/index" {
  44161. export * from "babylonjs/Culling/boundingBox";
  44162. export * from "babylonjs/Culling/boundingInfo";
  44163. export * from "babylonjs/Culling/boundingSphere";
  44164. export * from "babylonjs/Culling/Octrees/index";
  44165. export * from "babylonjs/Culling/ray";
  44166. }
  44167. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44168. import { IDisposable, Scene } from "babylonjs/scene";
  44169. import { Nullable } from "babylonjs/types";
  44170. import { Observable } from "babylonjs/Misc/observable";
  44171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44172. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44173. import { Camera } from "babylonjs/Cameras/camera";
  44174. /**
  44175. * Renders a layer on top of an existing scene
  44176. */
  44177. export class UtilityLayerRenderer implements IDisposable {
  44178. /** the original scene that will be rendered on top of */
  44179. originalScene: Scene;
  44180. private _pointerCaptures;
  44181. private _lastPointerEvents;
  44182. private static _DefaultUtilityLayer;
  44183. private static _DefaultKeepDepthUtilityLayer;
  44184. private _sharedGizmoLight;
  44185. private _renderCamera;
  44186. /**
  44187. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44188. * @returns the camera that is used when rendering the utility layer
  44189. */
  44190. getRenderCamera(): Nullable<Camera>;
  44191. /**
  44192. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44193. * @param cam the camera that should be used when rendering the utility layer
  44194. */
  44195. setRenderCamera(cam: Nullable<Camera>): void;
  44196. /**
  44197. * @hidden
  44198. * Light which used by gizmos to get light shading
  44199. */
  44200. _getSharedGizmoLight(): HemisphericLight;
  44201. /**
  44202. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44203. */
  44204. pickUtilitySceneFirst: boolean;
  44205. /**
  44206. * 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)
  44207. */
  44208. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44209. /**
  44210. * 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)
  44211. */
  44212. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44213. /**
  44214. * The scene that is rendered on top of the original scene
  44215. */
  44216. utilityLayerScene: Scene;
  44217. /**
  44218. * If the utility layer should automatically be rendered on top of existing scene
  44219. */
  44220. shouldRender: boolean;
  44221. /**
  44222. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44223. */
  44224. onlyCheckPointerDownEvents: boolean;
  44225. /**
  44226. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44227. */
  44228. processAllEvents: boolean;
  44229. /**
  44230. * Observable raised when the pointer move from the utility layer scene to the main scene
  44231. */
  44232. onPointerOutObservable: Observable<number>;
  44233. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44234. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44235. private _afterRenderObserver;
  44236. private _sceneDisposeObserver;
  44237. private _originalPointerObserver;
  44238. /**
  44239. * Instantiates a UtilityLayerRenderer
  44240. * @param originalScene the original scene that will be rendered on top of
  44241. * @param handleEvents boolean indicating if the utility layer should handle events
  44242. */
  44243. constructor(
  44244. /** the original scene that will be rendered on top of */
  44245. originalScene: Scene, handleEvents?: boolean);
  44246. private _notifyObservers;
  44247. /**
  44248. * Renders the utility layers scene on top of the original scene
  44249. */
  44250. render(): void;
  44251. /**
  44252. * Disposes of the renderer
  44253. */
  44254. dispose(): void;
  44255. private _updateCamera;
  44256. }
  44257. }
  44258. declare module "babylonjs/Gizmos/gizmo" {
  44259. import { Nullable } from "babylonjs/types";
  44260. import { IDisposable } from "babylonjs/scene";
  44261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44262. import { Mesh } from "babylonjs/Meshes/mesh";
  44263. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44264. /**
  44265. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44266. */
  44267. export class Gizmo implements IDisposable {
  44268. /** The utility layer the gizmo will be added to */
  44269. gizmoLayer: UtilityLayerRenderer;
  44270. /**
  44271. * The root mesh of the gizmo
  44272. */
  44273. _rootMesh: Mesh;
  44274. private _attachedMesh;
  44275. /**
  44276. * Ratio for the scale of the gizmo (Default: 1)
  44277. */
  44278. scaleRatio: number;
  44279. /**
  44280. * If a custom mesh has been set (Default: false)
  44281. */
  44282. protected _customMeshSet: boolean;
  44283. /**
  44284. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44285. * * When set, interactions will be enabled
  44286. */
  44287. attachedMesh: Nullable<AbstractMesh>;
  44288. /**
  44289. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44290. * @param mesh The mesh to replace the default mesh of the gizmo
  44291. */
  44292. setCustomMesh(mesh: Mesh): void;
  44293. /**
  44294. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44295. */
  44296. updateGizmoRotationToMatchAttachedMesh: boolean;
  44297. /**
  44298. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44299. */
  44300. updateGizmoPositionToMatchAttachedMesh: boolean;
  44301. /**
  44302. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44303. */
  44304. updateScale: boolean;
  44305. protected _interactionsEnabled: boolean;
  44306. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44307. private _beforeRenderObserver;
  44308. private _tempVector;
  44309. /**
  44310. * Creates a gizmo
  44311. * @param gizmoLayer The utility layer the gizmo will be added to
  44312. */
  44313. constructor(
  44314. /** The utility layer the gizmo will be added to */
  44315. gizmoLayer?: UtilityLayerRenderer);
  44316. /**
  44317. * Updates the gizmo to match the attached mesh's position/rotation
  44318. */
  44319. protected _update(): void;
  44320. /**
  44321. * Disposes of the gizmo
  44322. */
  44323. dispose(): void;
  44324. }
  44325. }
  44326. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44327. import { Observable } from "babylonjs/Misc/observable";
  44328. import { Nullable } from "babylonjs/types";
  44329. import { Vector3 } from "babylonjs/Maths/math.vector";
  44330. import { Color3 } from "babylonjs/Maths/math.color";
  44331. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44333. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44334. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44335. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44336. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44337. import { Scene } from "babylonjs/scene";
  44338. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44339. /**
  44340. * Single plane drag gizmo
  44341. */
  44342. export class PlaneDragGizmo extends Gizmo {
  44343. /**
  44344. * Drag behavior responsible for the gizmos dragging interactions
  44345. */
  44346. dragBehavior: PointerDragBehavior;
  44347. private _pointerObserver;
  44348. /**
  44349. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44350. */
  44351. snapDistance: number;
  44352. /**
  44353. * Event that fires each time the gizmo snaps to a new location.
  44354. * * snapDistance is the the change in distance
  44355. */
  44356. onSnapObservable: Observable<{
  44357. snapDistance: number;
  44358. }>;
  44359. private _plane;
  44360. private _coloredMaterial;
  44361. private _hoverMaterial;
  44362. private _isEnabled;
  44363. private _parent;
  44364. /** @hidden */
  44365. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44366. /** @hidden */
  44367. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44368. /**
  44369. * Creates a PlaneDragGizmo
  44370. * @param gizmoLayer The utility layer the gizmo will be added to
  44371. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44372. * @param color The color of the gizmo
  44373. */
  44374. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44375. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44376. /**
  44377. * If the gizmo is enabled
  44378. */
  44379. isEnabled: boolean;
  44380. /**
  44381. * Disposes of the gizmo
  44382. */
  44383. dispose(): void;
  44384. }
  44385. }
  44386. declare module "babylonjs/Gizmos/positionGizmo" {
  44387. import { Observable } from "babylonjs/Misc/observable";
  44388. import { Nullable } from "babylonjs/types";
  44389. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44390. import { Mesh } from "babylonjs/Meshes/mesh";
  44391. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44392. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44393. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44394. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44395. /**
  44396. * Gizmo that enables dragging a mesh along 3 axis
  44397. */
  44398. export class PositionGizmo extends Gizmo {
  44399. /**
  44400. * Internal gizmo used for interactions on the x axis
  44401. */
  44402. xGizmo: AxisDragGizmo;
  44403. /**
  44404. * Internal gizmo used for interactions on the y axis
  44405. */
  44406. yGizmo: AxisDragGizmo;
  44407. /**
  44408. * Internal gizmo used for interactions on the z axis
  44409. */
  44410. zGizmo: AxisDragGizmo;
  44411. /**
  44412. * Internal gizmo used for interactions on the yz plane
  44413. */
  44414. xPlaneGizmo: PlaneDragGizmo;
  44415. /**
  44416. * Internal gizmo used for interactions on the xz plane
  44417. */
  44418. yPlaneGizmo: PlaneDragGizmo;
  44419. /**
  44420. * Internal gizmo used for interactions on the xy plane
  44421. */
  44422. zPlaneGizmo: PlaneDragGizmo;
  44423. /**
  44424. * private variables
  44425. */
  44426. private _meshAttached;
  44427. private _updateGizmoRotationToMatchAttachedMesh;
  44428. private _snapDistance;
  44429. private _scaleRatio;
  44430. /** Fires an event when any of it's sub gizmos are dragged */
  44431. onDragStartObservable: Observable<unknown>;
  44432. /** Fires an event when any of it's sub gizmos are released from dragging */
  44433. onDragEndObservable: Observable<unknown>;
  44434. /**
  44435. * If set to true, planar drag is enabled
  44436. */
  44437. private _planarGizmoEnabled;
  44438. attachedMesh: Nullable<AbstractMesh>;
  44439. /**
  44440. * Creates a PositionGizmo
  44441. * @param gizmoLayer The utility layer the gizmo will be added to
  44442. */
  44443. constructor(gizmoLayer?: UtilityLayerRenderer);
  44444. /**
  44445. * If the planar drag gizmo is enabled
  44446. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44447. */
  44448. planarGizmoEnabled: boolean;
  44449. updateGizmoRotationToMatchAttachedMesh: boolean;
  44450. /**
  44451. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44452. */
  44453. snapDistance: number;
  44454. /**
  44455. * Ratio for the scale of the gizmo (Default: 1)
  44456. */
  44457. scaleRatio: number;
  44458. /**
  44459. * Disposes of the gizmo
  44460. */
  44461. dispose(): void;
  44462. /**
  44463. * CustomMeshes are not supported by this gizmo
  44464. * @param mesh The mesh to replace the default mesh of the gizmo
  44465. */
  44466. setCustomMesh(mesh: Mesh): void;
  44467. }
  44468. }
  44469. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44470. import { Observable } from "babylonjs/Misc/observable";
  44471. import { Nullable } from "babylonjs/types";
  44472. import { Vector3 } from "babylonjs/Maths/math.vector";
  44473. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44475. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44476. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44477. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44478. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44479. import { Scene } from "babylonjs/scene";
  44480. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44481. import { Color3 } from "babylonjs/Maths/math.color";
  44482. /**
  44483. * Single axis drag gizmo
  44484. */
  44485. export class AxisDragGizmo extends Gizmo {
  44486. /**
  44487. * Drag behavior responsible for the gizmos dragging interactions
  44488. */
  44489. dragBehavior: PointerDragBehavior;
  44490. private _pointerObserver;
  44491. /**
  44492. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44493. */
  44494. snapDistance: number;
  44495. /**
  44496. * Event that fires each time the gizmo snaps to a new location.
  44497. * * snapDistance is the the change in distance
  44498. */
  44499. onSnapObservable: Observable<{
  44500. snapDistance: number;
  44501. }>;
  44502. private _isEnabled;
  44503. private _parent;
  44504. private _arrow;
  44505. private _coloredMaterial;
  44506. private _hoverMaterial;
  44507. /** @hidden */
  44508. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44509. /** @hidden */
  44510. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44511. /**
  44512. * Creates an AxisDragGizmo
  44513. * @param gizmoLayer The utility layer the gizmo will be added to
  44514. * @param dragAxis The axis which the gizmo will be able to drag on
  44515. * @param color The color of the gizmo
  44516. */
  44517. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44518. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44519. /**
  44520. * If the gizmo is enabled
  44521. */
  44522. isEnabled: boolean;
  44523. /**
  44524. * Disposes of the gizmo
  44525. */
  44526. dispose(): void;
  44527. }
  44528. }
  44529. declare module "babylonjs/Debug/axesViewer" {
  44530. import { Vector3 } from "babylonjs/Maths/math.vector";
  44531. import { Nullable } from "babylonjs/types";
  44532. import { Scene } from "babylonjs/scene";
  44533. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44534. /**
  44535. * The Axes viewer will show 3 axes in a specific point in space
  44536. */
  44537. export class AxesViewer {
  44538. private _xAxis;
  44539. private _yAxis;
  44540. private _zAxis;
  44541. private _scaleLinesFactor;
  44542. private _instanced;
  44543. /**
  44544. * Gets the hosting scene
  44545. */
  44546. scene: Scene;
  44547. /**
  44548. * Gets or sets a number used to scale line length
  44549. */
  44550. scaleLines: number;
  44551. /** Gets the node hierarchy used to render x-axis */
  44552. readonly xAxis: TransformNode;
  44553. /** Gets the node hierarchy used to render y-axis */
  44554. readonly yAxis: TransformNode;
  44555. /** Gets the node hierarchy used to render z-axis */
  44556. readonly zAxis: TransformNode;
  44557. /**
  44558. * Creates a new AxesViewer
  44559. * @param scene defines the hosting scene
  44560. * @param scaleLines defines a number used to scale line length (1 by default)
  44561. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44562. * @param xAxis defines the node hierarchy used to render the x-axis
  44563. * @param yAxis defines the node hierarchy used to render the y-axis
  44564. * @param zAxis defines the node hierarchy used to render the z-axis
  44565. */
  44566. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44567. /**
  44568. * Force the viewer to update
  44569. * @param position defines the position of the viewer
  44570. * @param xaxis defines the x axis of the viewer
  44571. * @param yaxis defines the y axis of the viewer
  44572. * @param zaxis defines the z axis of the viewer
  44573. */
  44574. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44575. /**
  44576. * Creates an instance of this axes viewer.
  44577. * @returns a new axes viewer with instanced meshes
  44578. */
  44579. createInstance(): AxesViewer;
  44580. /** Releases resources */
  44581. dispose(): void;
  44582. private static _SetRenderingGroupId;
  44583. }
  44584. }
  44585. declare module "babylonjs/Debug/boneAxesViewer" {
  44586. import { Nullable } from "babylonjs/types";
  44587. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44588. import { Vector3 } from "babylonjs/Maths/math.vector";
  44589. import { Mesh } from "babylonjs/Meshes/mesh";
  44590. import { Bone } from "babylonjs/Bones/bone";
  44591. import { Scene } from "babylonjs/scene";
  44592. /**
  44593. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44594. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44595. */
  44596. export class BoneAxesViewer extends AxesViewer {
  44597. /**
  44598. * Gets or sets the target mesh where to display the axes viewer
  44599. */
  44600. mesh: Nullable<Mesh>;
  44601. /**
  44602. * Gets or sets the target bone where to display the axes viewer
  44603. */
  44604. bone: Nullable<Bone>;
  44605. /** Gets current position */
  44606. pos: Vector3;
  44607. /** Gets direction of X axis */
  44608. xaxis: Vector3;
  44609. /** Gets direction of Y axis */
  44610. yaxis: Vector3;
  44611. /** Gets direction of Z axis */
  44612. zaxis: Vector3;
  44613. /**
  44614. * Creates a new BoneAxesViewer
  44615. * @param scene defines the hosting scene
  44616. * @param bone defines the target bone
  44617. * @param mesh defines the target mesh
  44618. * @param scaleLines defines a scaling factor for line length (1 by default)
  44619. */
  44620. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44621. /**
  44622. * Force the viewer to update
  44623. */
  44624. update(): void;
  44625. /** Releases resources */
  44626. dispose(): void;
  44627. }
  44628. }
  44629. declare module "babylonjs/Debug/debugLayer" {
  44630. import { Scene } from "babylonjs/scene";
  44631. /**
  44632. * Interface used to define scene explorer extensibility option
  44633. */
  44634. export interface IExplorerExtensibilityOption {
  44635. /**
  44636. * Define the option label
  44637. */
  44638. label: string;
  44639. /**
  44640. * Defines the action to execute on click
  44641. */
  44642. action: (entity: any) => void;
  44643. }
  44644. /**
  44645. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44646. */
  44647. export interface IExplorerExtensibilityGroup {
  44648. /**
  44649. * Defines a predicate to test if a given type mut be extended
  44650. */
  44651. predicate: (entity: any) => boolean;
  44652. /**
  44653. * Gets the list of options added to a type
  44654. */
  44655. entries: IExplorerExtensibilityOption[];
  44656. }
  44657. /**
  44658. * Interface used to define the options to use to create the Inspector
  44659. */
  44660. export interface IInspectorOptions {
  44661. /**
  44662. * Display in overlay mode (default: false)
  44663. */
  44664. overlay?: boolean;
  44665. /**
  44666. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44667. */
  44668. globalRoot?: HTMLElement;
  44669. /**
  44670. * Display the Scene explorer
  44671. */
  44672. showExplorer?: boolean;
  44673. /**
  44674. * Display the property inspector
  44675. */
  44676. showInspector?: boolean;
  44677. /**
  44678. * Display in embed mode (both panes on the right)
  44679. */
  44680. embedMode?: boolean;
  44681. /**
  44682. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44683. */
  44684. handleResize?: boolean;
  44685. /**
  44686. * Allow the panes to popup (default: true)
  44687. */
  44688. enablePopup?: boolean;
  44689. /**
  44690. * Allow the panes to be closed by users (default: true)
  44691. */
  44692. enableClose?: boolean;
  44693. /**
  44694. * Optional list of extensibility entries
  44695. */
  44696. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44697. /**
  44698. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44699. */
  44700. inspectorURL?: string;
  44701. }
  44702. module "babylonjs/scene" {
  44703. interface Scene {
  44704. /**
  44705. * @hidden
  44706. * Backing field
  44707. */
  44708. _debugLayer: DebugLayer;
  44709. /**
  44710. * Gets the debug layer (aka Inspector) associated with the scene
  44711. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44712. */
  44713. debugLayer: DebugLayer;
  44714. }
  44715. }
  44716. /**
  44717. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44718. * what is happening in your scene
  44719. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44720. */
  44721. export class DebugLayer {
  44722. /**
  44723. * Define the url to get the inspector script from.
  44724. * By default it uses the babylonjs CDN.
  44725. * @ignoreNaming
  44726. */
  44727. static InspectorURL: string;
  44728. private _scene;
  44729. private BJSINSPECTOR;
  44730. private _onPropertyChangedObservable?;
  44731. /**
  44732. * Observable triggered when a property is changed through the inspector.
  44733. */
  44734. readonly onPropertyChangedObservable: any;
  44735. /**
  44736. * Instantiates a new debug layer.
  44737. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44738. * what is happening in your scene
  44739. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44740. * @param scene Defines the scene to inspect
  44741. */
  44742. constructor(scene: Scene);
  44743. /** Creates the inspector window. */
  44744. private _createInspector;
  44745. /**
  44746. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44747. * @param entity defines the entity to select
  44748. * @param lineContainerTitle defines the specific block to highlight
  44749. */
  44750. select(entity: any, lineContainerTitle?: string): void;
  44751. /** Get the inspector from bundle or global */
  44752. private _getGlobalInspector;
  44753. /**
  44754. * Get if the inspector is visible or not.
  44755. * @returns true if visible otherwise, false
  44756. */
  44757. isVisible(): boolean;
  44758. /**
  44759. * Hide the inspector and close its window.
  44760. */
  44761. hide(): void;
  44762. /**
  44763. * Launch the debugLayer.
  44764. * @param config Define the configuration of the inspector
  44765. * @return a promise fulfilled when the debug layer is visible
  44766. */
  44767. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44768. }
  44769. }
  44770. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44771. import { Nullable } from "babylonjs/types";
  44772. import { Scene } from "babylonjs/scene";
  44773. import { Vector4 } from "babylonjs/Maths/math.vector";
  44774. import { Color4 } from "babylonjs/Maths/math.color";
  44775. import { Mesh } from "babylonjs/Meshes/mesh";
  44776. /**
  44777. * Class containing static functions to help procedurally build meshes
  44778. */
  44779. export class BoxBuilder {
  44780. /**
  44781. * Creates a box mesh
  44782. * * The parameter `size` sets the size (float) of each box side (default 1)
  44783. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44784. * * 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)
  44785. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44787. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44789. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44790. * @param name defines the name of the mesh
  44791. * @param options defines the options used to create the mesh
  44792. * @param scene defines the hosting scene
  44793. * @returns the box mesh
  44794. */
  44795. static CreateBox(name: string, options: {
  44796. size?: number;
  44797. width?: number;
  44798. height?: number;
  44799. depth?: number;
  44800. faceUV?: Vector4[];
  44801. faceColors?: Color4[];
  44802. sideOrientation?: number;
  44803. frontUVs?: Vector4;
  44804. backUVs?: Vector4;
  44805. wrap?: boolean;
  44806. topBaseAt?: number;
  44807. bottomBaseAt?: number;
  44808. updatable?: boolean;
  44809. }, scene?: Nullable<Scene>): Mesh;
  44810. }
  44811. }
  44812. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44813. import { Vector4 } from "babylonjs/Maths/math.vector";
  44814. import { Mesh } from "babylonjs/Meshes/mesh";
  44815. import { Scene } from "babylonjs/scene";
  44816. import { Nullable } from "babylonjs/types";
  44817. /**
  44818. * Class containing static functions to help procedurally build meshes
  44819. */
  44820. export class SphereBuilder {
  44821. /**
  44822. * Creates a sphere mesh
  44823. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44824. * * 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`)
  44825. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44826. * * 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
  44827. * * 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)
  44828. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44829. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44831. * @param name defines the name of the mesh
  44832. * @param options defines the options used to create the mesh
  44833. * @param scene defines the hosting scene
  44834. * @returns the sphere mesh
  44835. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44836. */
  44837. static CreateSphere(name: string, options: {
  44838. segments?: number;
  44839. diameter?: number;
  44840. diameterX?: number;
  44841. diameterY?: number;
  44842. diameterZ?: number;
  44843. arc?: number;
  44844. slice?: number;
  44845. sideOrientation?: number;
  44846. frontUVs?: Vector4;
  44847. backUVs?: Vector4;
  44848. updatable?: boolean;
  44849. }, scene?: Nullable<Scene>): Mesh;
  44850. }
  44851. }
  44852. declare module "babylonjs/Debug/physicsViewer" {
  44853. import { Nullable } from "babylonjs/types";
  44854. import { Scene } from "babylonjs/scene";
  44855. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44856. import { Mesh } from "babylonjs/Meshes/mesh";
  44857. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44858. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44859. /**
  44860. * Used to show the physics impostor around the specific mesh
  44861. */
  44862. export class PhysicsViewer {
  44863. /** @hidden */
  44864. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44865. /** @hidden */
  44866. protected _meshes: Array<Nullable<AbstractMesh>>;
  44867. /** @hidden */
  44868. protected _scene: Nullable<Scene>;
  44869. /** @hidden */
  44870. protected _numMeshes: number;
  44871. /** @hidden */
  44872. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44873. private _renderFunction;
  44874. private _utilityLayer;
  44875. private _debugBoxMesh;
  44876. private _debugSphereMesh;
  44877. private _debugCylinderMesh;
  44878. private _debugMaterial;
  44879. private _debugMeshMeshes;
  44880. /**
  44881. * Creates a new PhysicsViewer
  44882. * @param scene defines the hosting scene
  44883. */
  44884. constructor(scene: Scene);
  44885. /** @hidden */
  44886. protected _updateDebugMeshes(): void;
  44887. /**
  44888. * Renders a specified physic impostor
  44889. * @param impostor defines the impostor to render
  44890. * @param targetMesh defines the mesh represented by the impostor
  44891. * @returns the new debug mesh used to render the impostor
  44892. */
  44893. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44894. /**
  44895. * Hides a specified physic impostor
  44896. * @param impostor defines the impostor to hide
  44897. */
  44898. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44899. private _getDebugMaterial;
  44900. private _getDebugBoxMesh;
  44901. private _getDebugSphereMesh;
  44902. private _getDebugCylinderMesh;
  44903. private _getDebugMeshMesh;
  44904. private _getDebugMesh;
  44905. /** Releases all resources */
  44906. dispose(): void;
  44907. }
  44908. }
  44909. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44910. import { Vector3 } from "babylonjs/Maths/math.vector";
  44911. import { Color4 } from "babylonjs/Maths/math.color";
  44912. import { Nullable } from "babylonjs/types";
  44913. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44914. import { Scene } from "babylonjs/scene";
  44915. /**
  44916. * Class containing static functions to help procedurally build meshes
  44917. */
  44918. export class LinesBuilder {
  44919. /**
  44920. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44921. * * 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
  44922. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44923. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44924. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44925. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44926. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44927. * * 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
  44928. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44930. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44931. * @param name defines the name of the new line system
  44932. * @param options defines the options used to create the line system
  44933. * @param scene defines the hosting scene
  44934. * @returns a new line system mesh
  44935. */
  44936. static CreateLineSystem(name: string, options: {
  44937. lines: Vector3[][];
  44938. updatable?: boolean;
  44939. instance?: Nullable<LinesMesh>;
  44940. colors?: Nullable<Color4[][]>;
  44941. useVertexAlpha?: boolean;
  44942. }, scene: Nullable<Scene>): LinesMesh;
  44943. /**
  44944. * Creates a line mesh
  44945. * 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
  44946. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44947. * * The parameter `points` is an array successive Vector3
  44948. * * 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
  44949. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44950. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44951. * * When updating an instance, remember that only point positions can change, not the number of points
  44952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44953. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44954. * @param name defines the name of the new line system
  44955. * @param options defines the options used to create the line system
  44956. * @param scene defines the hosting scene
  44957. * @returns a new line mesh
  44958. */
  44959. static CreateLines(name: string, options: {
  44960. points: Vector3[];
  44961. updatable?: boolean;
  44962. instance?: Nullable<LinesMesh>;
  44963. colors?: Color4[];
  44964. useVertexAlpha?: boolean;
  44965. }, scene?: Nullable<Scene>): LinesMesh;
  44966. /**
  44967. * Creates a dashed line mesh
  44968. * * 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
  44969. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44970. * * The parameter `points` is an array successive Vector3
  44971. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44972. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44973. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44974. * * 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
  44975. * * When updating an instance, remember that only point positions can change, not the number of points
  44976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44977. * @param name defines the name of the mesh
  44978. * @param options defines the options used to create the mesh
  44979. * @param scene defines the hosting scene
  44980. * @returns the dashed line mesh
  44981. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44982. */
  44983. static CreateDashedLines(name: string, options: {
  44984. points: Vector3[];
  44985. dashSize?: number;
  44986. gapSize?: number;
  44987. dashNb?: number;
  44988. updatable?: boolean;
  44989. instance?: LinesMesh;
  44990. }, scene?: Nullable<Scene>): LinesMesh;
  44991. }
  44992. }
  44993. declare module "babylonjs/Debug/rayHelper" {
  44994. import { Nullable } from "babylonjs/types";
  44995. import { Ray } from "babylonjs/Culling/ray";
  44996. import { Vector3 } from "babylonjs/Maths/math.vector";
  44997. import { Color3 } from "babylonjs/Maths/math.color";
  44998. import { Scene } from "babylonjs/scene";
  44999. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45000. import "babylonjs/Meshes/Builders/linesBuilder";
  45001. /**
  45002. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45003. * in order to better appreciate the issue one might have.
  45004. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45005. */
  45006. export class RayHelper {
  45007. /**
  45008. * Defines the ray we are currently tryin to visualize.
  45009. */
  45010. ray: Nullable<Ray>;
  45011. private _renderPoints;
  45012. private _renderLine;
  45013. private _renderFunction;
  45014. private _scene;
  45015. private _updateToMeshFunction;
  45016. private _attachedToMesh;
  45017. private _meshSpaceDirection;
  45018. private _meshSpaceOrigin;
  45019. /**
  45020. * Helper function to create a colored helper in a scene in one line.
  45021. * @param ray Defines the ray we are currently tryin to visualize
  45022. * @param scene Defines the scene the ray is used in
  45023. * @param color Defines the color we want to see the ray in
  45024. * @returns The newly created ray helper.
  45025. */
  45026. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45027. /**
  45028. * Instantiate a new ray helper.
  45029. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45030. * in order to better appreciate the issue one might have.
  45031. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45032. * @param ray Defines the ray we are currently tryin to visualize
  45033. */
  45034. constructor(ray: Ray);
  45035. /**
  45036. * Shows the ray we are willing to debug.
  45037. * @param scene Defines the scene the ray needs to be rendered in
  45038. * @param color Defines the color the ray needs to be rendered in
  45039. */
  45040. show(scene: Scene, color?: Color3): void;
  45041. /**
  45042. * Hides the ray we are debugging.
  45043. */
  45044. hide(): void;
  45045. private _render;
  45046. /**
  45047. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45048. * @param mesh Defines the mesh we want the helper attached to
  45049. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45050. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45051. * @param length Defines the length of the ray
  45052. */
  45053. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45054. /**
  45055. * Detach the ray helper from the mesh it has previously been attached to.
  45056. */
  45057. detachFromMesh(): void;
  45058. private _updateToMesh;
  45059. /**
  45060. * Dispose the helper and release its associated resources.
  45061. */
  45062. dispose(): void;
  45063. }
  45064. }
  45065. declare module "babylonjs/Debug/skeletonViewer" {
  45066. import { Color3 } from "babylonjs/Maths/math.color";
  45067. import { Scene } from "babylonjs/scene";
  45068. import { Nullable } from "babylonjs/types";
  45069. import { Skeleton } from "babylonjs/Bones/skeleton";
  45070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45071. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45072. /**
  45073. * Class used to render a debug view of a given skeleton
  45074. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45075. */
  45076. export class SkeletonViewer {
  45077. /** defines the skeleton to render */
  45078. skeleton: Skeleton;
  45079. /** defines the mesh attached to the skeleton */
  45080. mesh: AbstractMesh;
  45081. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45082. autoUpdateBonesMatrices: boolean;
  45083. /** defines the rendering group id to use with the viewer */
  45084. renderingGroupId: number;
  45085. /** Gets or sets the color used to render the skeleton */
  45086. color: Color3;
  45087. private _scene;
  45088. private _debugLines;
  45089. private _debugMesh;
  45090. private _isEnabled;
  45091. private _renderFunction;
  45092. private _utilityLayer;
  45093. /**
  45094. * Returns the mesh used to render the bones
  45095. */
  45096. readonly debugMesh: Nullable<LinesMesh>;
  45097. /**
  45098. * Creates a new SkeletonViewer
  45099. * @param skeleton defines the skeleton to render
  45100. * @param mesh defines the mesh attached to the skeleton
  45101. * @param scene defines the hosting scene
  45102. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45103. * @param renderingGroupId defines the rendering group id to use with the viewer
  45104. */
  45105. constructor(
  45106. /** defines the skeleton to render */
  45107. skeleton: Skeleton,
  45108. /** defines the mesh attached to the skeleton */
  45109. mesh: AbstractMesh, scene: Scene,
  45110. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45111. autoUpdateBonesMatrices?: boolean,
  45112. /** defines the rendering group id to use with the viewer */
  45113. renderingGroupId?: number);
  45114. /** Gets or sets a boolean indicating if the viewer is enabled */
  45115. isEnabled: boolean;
  45116. private _getBonePosition;
  45117. private _getLinesForBonesWithLength;
  45118. private _getLinesForBonesNoLength;
  45119. /** Update the viewer to sync with current skeleton state */
  45120. update(): void;
  45121. /** Release associated resources */
  45122. dispose(): void;
  45123. }
  45124. }
  45125. declare module "babylonjs/Debug/index" {
  45126. export * from "babylonjs/Debug/axesViewer";
  45127. export * from "babylonjs/Debug/boneAxesViewer";
  45128. export * from "babylonjs/Debug/debugLayer";
  45129. export * from "babylonjs/Debug/physicsViewer";
  45130. export * from "babylonjs/Debug/rayHelper";
  45131. export * from "babylonjs/Debug/skeletonViewer";
  45132. }
  45133. declare module "babylonjs/Engines/nullEngine" {
  45134. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45135. import { Scene } from "babylonjs/scene";
  45136. import { Engine } from "babylonjs/Engines/engine";
  45137. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45138. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45139. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45140. import { Effect } from "babylonjs/Materials/effect";
  45141. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45142. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45143. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45144. /**
  45145. * Options to create the null engine
  45146. */
  45147. export class NullEngineOptions {
  45148. /**
  45149. * Render width (Default: 512)
  45150. */
  45151. renderWidth: number;
  45152. /**
  45153. * Render height (Default: 256)
  45154. */
  45155. renderHeight: number;
  45156. /**
  45157. * Texture size (Default: 512)
  45158. */
  45159. textureSize: number;
  45160. /**
  45161. * If delta time between frames should be constant
  45162. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45163. */
  45164. deterministicLockstep: boolean;
  45165. /**
  45166. * Maximum about of steps between frames (Default: 4)
  45167. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45168. */
  45169. lockstepMaxSteps: number;
  45170. }
  45171. /**
  45172. * The null engine class provides support for headless version of babylon.js.
  45173. * This can be used in server side scenario or for testing purposes
  45174. */
  45175. export class NullEngine extends Engine {
  45176. private _options;
  45177. /**
  45178. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45179. */
  45180. isDeterministicLockStep(): boolean;
  45181. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  45182. getLockstepMaxSteps(): number;
  45183. /**
  45184. * Sets hardware scaling, used to save performance if needed
  45185. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  45186. */
  45187. getHardwareScalingLevel(): number;
  45188. constructor(options?: NullEngineOptions);
  45189. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45190. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45191. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45192. getRenderWidth(useScreen?: boolean): number;
  45193. getRenderHeight(useScreen?: boolean): number;
  45194. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45195. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45196. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45197. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45198. bindSamplers(effect: Effect): void;
  45199. enableEffect(effect: Effect): void;
  45200. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45201. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45202. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45203. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45204. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45205. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45206. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45207. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45208. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45209. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45210. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45211. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45212. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45213. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45214. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45215. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45216. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45217. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45218. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45219. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45220. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45221. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45222. bindBuffers(vertexBuffers: {
  45223. [key: string]: VertexBuffer;
  45224. }, indexBuffer: DataBuffer, effect: Effect): void;
  45225. wipeCaches(bruteForce?: boolean): void;
  45226. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45227. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45228. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45229. /** @hidden */
  45230. _createTexture(): WebGLTexture;
  45231. /** @hidden */
  45232. _releaseTexture(texture: InternalTexture): void;
  45233. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  45234. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45235. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45236. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45237. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45238. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45239. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45240. areAllEffectsReady(): boolean;
  45241. /**
  45242. * @hidden
  45243. * Get the current error code of the webGL context
  45244. * @returns the error code
  45245. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45246. */
  45247. getError(): number;
  45248. /** @hidden */
  45249. _getUnpackAlignement(): number;
  45250. /** @hidden */
  45251. _unpackFlipY(value: boolean): void;
  45252. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45253. /**
  45254. * Updates a dynamic vertex buffer.
  45255. * @param vertexBuffer the vertex buffer to update
  45256. * @param data the data used to update the vertex buffer
  45257. * @param byteOffset the byte offset of the data (optional)
  45258. * @param byteLength the byte length of the data (optional)
  45259. */
  45260. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45261. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45262. /** @hidden */
  45263. _bindTexture(channel: number, texture: InternalTexture): void;
  45264. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45265. releaseEffects(): void;
  45266. displayLoadingUI(): void;
  45267. hideLoadingUI(): void;
  45268. /** @hidden */
  45269. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45270. /** @hidden */
  45271. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45272. /** @hidden */
  45273. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45274. /** @hidden */
  45275. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45276. }
  45277. }
  45278. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45279. import { Nullable, int } from "babylonjs/types";
  45280. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45281. /** @hidden */
  45282. export class _OcclusionDataStorage {
  45283. /** @hidden */
  45284. occlusionInternalRetryCounter: number;
  45285. /** @hidden */
  45286. isOcclusionQueryInProgress: boolean;
  45287. /** @hidden */
  45288. isOccluded: boolean;
  45289. /** @hidden */
  45290. occlusionRetryCount: number;
  45291. /** @hidden */
  45292. occlusionType: number;
  45293. /** @hidden */
  45294. occlusionQueryAlgorithmType: number;
  45295. }
  45296. module "babylonjs/Engines/engine" {
  45297. interface Engine {
  45298. /**
  45299. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45300. * @return the new query
  45301. */
  45302. createQuery(): WebGLQuery;
  45303. /**
  45304. * Delete and release a webGL query
  45305. * @param query defines the query to delete
  45306. * @return the current engine
  45307. */
  45308. deleteQuery(query: WebGLQuery): Engine;
  45309. /**
  45310. * Check if a given query has resolved and got its value
  45311. * @param query defines the query to check
  45312. * @returns true if the query got its value
  45313. */
  45314. isQueryResultAvailable(query: WebGLQuery): boolean;
  45315. /**
  45316. * Gets the value of a given query
  45317. * @param query defines the query to check
  45318. * @returns the value of the query
  45319. */
  45320. getQueryResult(query: WebGLQuery): number;
  45321. /**
  45322. * Initiates an occlusion query
  45323. * @param algorithmType defines the algorithm to use
  45324. * @param query defines the query to use
  45325. * @returns the current engine
  45326. * @see http://doc.babylonjs.com/features/occlusionquery
  45327. */
  45328. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45329. /**
  45330. * Ends an occlusion query
  45331. * @see http://doc.babylonjs.com/features/occlusionquery
  45332. * @param algorithmType defines the algorithm to use
  45333. * @returns the current engine
  45334. */
  45335. endOcclusionQuery(algorithmType: number): Engine;
  45336. /**
  45337. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45338. * Please note that only one query can be issued at a time
  45339. * @returns a time token used to track the time span
  45340. */
  45341. startTimeQuery(): Nullable<_TimeToken>;
  45342. /**
  45343. * Ends a time query
  45344. * @param token defines the token used to measure the time span
  45345. * @returns the time spent (in ns)
  45346. */
  45347. endTimeQuery(token: _TimeToken): int;
  45348. /** @hidden */
  45349. _currentNonTimestampToken: Nullable<_TimeToken>;
  45350. /** @hidden */
  45351. _createTimeQuery(): WebGLQuery;
  45352. /** @hidden */
  45353. _deleteTimeQuery(query: WebGLQuery): void;
  45354. /** @hidden */
  45355. _getGlAlgorithmType(algorithmType: number): number;
  45356. /** @hidden */
  45357. _getTimeQueryResult(query: WebGLQuery): any;
  45358. /** @hidden */
  45359. _getTimeQueryAvailability(query: WebGLQuery): any;
  45360. }
  45361. }
  45362. module "babylonjs/Meshes/abstractMesh" {
  45363. interface AbstractMesh {
  45364. /**
  45365. * Backing filed
  45366. * @hidden
  45367. */
  45368. __occlusionDataStorage: _OcclusionDataStorage;
  45369. /**
  45370. * Access property
  45371. * @hidden
  45372. */
  45373. _occlusionDataStorage: _OcclusionDataStorage;
  45374. /**
  45375. * 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.
  45376. * The default value is -1 which means don't break the query and wait till the result
  45377. * @see http://doc.babylonjs.com/features/occlusionquery
  45378. */
  45379. occlusionRetryCount: number;
  45380. /**
  45381. * 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:
  45382. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45383. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45384. * * 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.
  45385. * @see http://doc.babylonjs.com/features/occlusionquery
  45386. */
  45387. occlusionType: number;
  45388. /**
  45389. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45390. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45391. * * 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.
  45392. * @see http://doc.babylonjs.com/features/occlusionquery
  45393. */
  45394. occlusionQueryAlgorithmType: number;
  45395. /**
  45396. * 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
  45397. * @see http://doc.babylonjs.com/features/occlusionquery
  45398. */
  45399. isOccluded: boolean;
  45400. /**
  45401. * Flag to check the progress status of the query
  45402. * @see http://doc.babylonjs.com/features/occlusionquery
  45403. */
  45404. isOcclusionQueryInProgress: boolean;
  45405. }
  45406. }
  45407. }
  45408. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45409. import { Nullable } from "babylonjs/types";
  45410. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45411. /** @hidden */
  45412. export var _forceTransformFeedbackToBundle: boolean;
  45413. module "babylonjs/Engines/engine" {
  45414. interface Engine {
  45415. /**
  45416. * Creates a webGL transform feedback object
  45417. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45418. * @returns the webGL transform feedback object
  45419. */
  45420. createTransformFeedback(): WebGLTransformFeedback;
  45421. /**
  45422. * Delete a webGL transform feedback object
  45423. * @param value defines the webGL transform feedback object to delete
  45424. */
  45425. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45426. /**
  45427. * Bind a webGL transform feedback object to the webgl context
  45428. * @param value defines the webGL transform feedback object to bind
  45429. */
  45430. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45431. /**
  45432. * Begins a transform feedback operation
  45433. * @param usePoints defines if points or triangles must be used
  45434. */
  45435. beginTransformFeedback(usePoints: boolean): void;
  45436. /**
  45437. * Ends a transform feedback operation
  45438. */
  45439. endTransformFeedback(): void;
  45440. /**
  45441. * Specify the varyings to use with transform feedback
  45442. * @param program defines the associated webGL program
  45443. * @param value defines the list of strings representing the varying names
  45444. */
  45445. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45446. /**
  45447. * Bind a webGL buffer for a transform feedback operation
  45448. * @param value defines the webGL buffer to bind
  45449. */
  45450. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45451. }
  45452. }
  45453. }
  45454. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45455. import { Scene } from "babylonjs/scene";
  45456. import { Engine } from "babylonjs/Engines/engine";
  45457. import { Texture } from "babylonjs/Materials/Textures/texture";
  45458. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45459. import "babylonjs/Engines/Extensions/engine.multiRender";
  45460. /**
  45461. * Creation options of the multi render target texture.
  45462. */
  45463. export interface IMultiRenderTargetOptions {
  45464. /**
  45465. * Define if the texture needs to create mip maps after render.
  45466. */
  45467. generateMipMaps?: boolean;
  45468. /**
  45469. * Define the types of all the draw buffers we want to create
  45470. */
  45471. types?: number[];
  45472. /**
  45473. * Define the sampling modes of all the draw buffers we want to create
  45474. */
  45475. samplingModes?: number[];
  45476. /**
  45477. * Define if a depth buffer is required
  45478. */
  45479. generateDepthBuffer?: boolean;
  45480. /**
  45481. * Define if a stencil buffer is required
  45482. */
  45483. generateStencilBuffer?: boolean;
  45484. /**
  45485. * Define if a depth texture is required instead of a depth buffer
  45486. */
  45487. generateDepthTexture?: boolean;
  45488. /**
  45489. * Define the number of desired draw buffers
  45490. */
  45491. textureCount?: number;
  45492. /**
  45493. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45494. */
  45495. doNotChangeAspectRatio?: boolean;
  45496. /**
  45497. * Define the default type of the buffers we are creating
  45498. */
  45499. defaultType?: number;
  45500. }
  45501. /**
  45502. * A multi render target, like a render target provides the ability to render to a texture.
  45503. * Unlike the render target, it can render to several draw buffers in one draw.
  45504. * This is specially interesting in deferred rendering or for any effects requiring more than
  45505. * just one color from a single pass.
  45506. */
  45507. export class MultiRenderTarget extends RenderTargetTexture {
  45508. private _internalTextures;
  45509. private _textures;
  45510. private _multiRenderTargetOptions;
  45511. /**
  45512. * Get if draw buffers are currently supported by the used hardware and browser.
  45513. */
  45514. readonly isSupported: boolean;
  45515. /**
  45516. * Get the list of textures generated by the multi render target.
  45517. */
  45518. readonly textures: Texture[];
  45519. /**
  45520. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45521. */
  45522. readonly depthTexture: Texture;
  45523. /**
  45524. * Set the wrapping mode on U of all the textures we are rendering to.
  45525. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45526. */
  45527. wrapU: number;
  45528. /**
  45529. * Set the wrapping mode on V of all the textures we are rendering to.
  45530. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45531. */
  45532. wrapV: number;
  45533. /**
  45534. * Instantiate a new multi render target texture.
  45535. * A multi render target, like a render target provides the ability to render to a texture.
  45536. * Unlike the render target, it can render to several draw buffers in one draw.
  45537. * This is specially interesting in deferred rendering or for any effects requiring more than
  45538. * just one color from a single pass.
  45539. * @param name Define the name of the texture
  45540. * @param size Define the size of the buffers to render to
  45541. * @param count Define the number of target we are rendering into
  45542. * @param scene Define the scene the texture belongs to
  45543. * @param options Define the options used to create the multi render target
  45544. */
  45545. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45546. /** @hidden */
  45547. _rebuild(): void;
  45548. private _createInternalTextures;
  45549. private _createTextures;
  45550. /**
  45551. * Define the number of samples used if MSAA is enabled.
  45552. */
  45553. samples: number;
  45554. /**
  45555. * Resize all the textures in the multi render target.
  45556. * Be carrefull as it will recreate all the data in the new texture.
  45557. * @param size Define the new size
  45558. */
  45559. resize(size: any): void;
  45560. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45561. /**
  45562. * Dispose the render targets and their associated resources
  45563. */
  45564. dispose(): void;
  45565. /**
  45566. * Release all the underlying texture used as draw buffers.
  45567. */
  45568. releaseInternalTextures(): void;
  45569. }
  45570. }
  45571. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45572. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45573. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45574. import { Nullable } from "babylonjs/types";
  45575. module "babylonjs/Engines/engine" {
  45576. interface Engine {
  45577. /**
  45578. * Unbind a list of render target textures from the webGL context
  45579. * This is used only when drawBuffer extension or webGL2 are active
  45580. * @param textures defines the render target textures to unbind
  45581. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45582. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45583. */
  45584. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45585. /**
  45586. * Create a multi render target texture
  45587. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45588. * @param size defines the size of the texture
  45589. * @param options defines the creation options
  45590. * @returns the cube texture as an InternalTexture
  45591. */
  45592. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45593. /**
  45594. * Update the sample count for a given multiple render target texture
  45595. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45596. * @param textures defines the textures to update
  45597. * @param samples defines the sample count to set
  45598. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45599. */
  45600. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45601. }
  45602. }
  45603. }
  45604. declare module "babylonjs/Engines/Extensions/index" {
  45605. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45606. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45607. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45608. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45609. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45610. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45611. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45612. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45613. }
  45614. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  45615. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45616. /** @hidden */
  45617. export var rgbdEncodePixelShader: {
  45618. name: string;
  45619. shader: string;
  45620. };
  45621. }
  45622. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45623. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45624. /** @hidden */
  45625. export var rgbdDecodePixelShader: {
  45626. name: string;
  45627. shader: string;
  45628. };
  45629. }
  45630. declare module "babylonjs/Misc/environmentTextureTools" {
  45631. import { Nullable } from "babylonjs/types";
  45632. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  45633. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45634. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  45635. import "babylonjs/Engines/Extensions/engine.renderTarget";
  45636. import "babylonjs/Shaders/rgbdEncode.fragment";
  45637. import "babylonjs/Shaders/rgbdDecode.fragment";
  45638. /**
  45639. * Raw texture data and descriptor sufficient for WebGL texture upload
  45640. */
  45641. export interface EnvironmentTextureInfo {
  45642. /**
  45643. * Version of the environment map
  45644. */
  45645. version: number;
  45646. /**
  45647. * Width of image
  45648. */
  45649. width: number;
  45650. /**
  45651. * Irradiance information stored in the file.
  45652. */
  45653. irradiance: any;
  45654. /**
  45655. * Specular information stored in the file.
  45656. */
  45657. specular: any;
  45658. }
  45659. /**
  45660. * Defines One Image in the file. It requires only the position in the file
  45661. * as well as the length.
  45662. */
  45663. interface BufferImageData {
  45664. /**
  45665. * Length of the image data.
  45666. */
  45667. length: number;
  45668. /**
  45669. * Position of the data from the null terminator delimiting the end of the JSON.
  45670. */
  45671. position: number;
  45672. }
  45673. /**
  45674. * Defines the specular data enclosed in the file.
  45675. * This corresponds to the version 1 of the data.
  45676. */
  45677. export interface EnvironmentTextureSpecularInfoV1 {
  45678. /**
  45679. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  45680. */
  45681. specularDataPosition?: number;
  45682. /**
  45683. * This contains all the images data needed to reconstruct the cubemap.
  45684. */
  45685. mipmaps: Array<BufferImageData>;
  45686. /**
  45687. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  45688. */
  45689. lodGenerationScale: number;
  45690. }
  45691. /**
  45692. * Sets of helpers addressing the serialization and deserialization of environment texture
  45693. * stored in a BabylonJS env file.
  45694. * Those files are usually stored as .env files.
  45695. */
  45696. export class EnvironmentTextureTools {
  45697. /**
  45698. * Magic number identifying the env file.
  45699. */
  45700. private static _MagicBytes;
  45701. /**
  45702. * Gets the environment info from an env file.
  45703. * @param data The array buffer containing the .env bytes.
  45704. * @returns the environment file info (the json header) if successfully parsed.
  45705. */
  45706. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45707. /**
  45708. * Creates an environment texture from a loaded cube texture.
  45709. * @param texture defines the cube texture to convert in env file
  45710. * @return a promise containing the environment data if succesfull.
  45711. */
  45712. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45713. /**
  45714. * Creates a JSON representation of the spherical data.
  45715. * @param texture defines the texture containing the polynomials
  45716. * @return the JSON representation of the spherical info
  45717. */
  45718. private static _CreateEnvTextureIrradiance;
  45719. /**
  45720. * Creates the ArrayBufferViews used for initializing environment texture image data.
  45721. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  45722. * @param info parameters that determine what views will be created for accessing the underlying buffer
  45723. * @return the views described by info providing access to the underlying buffer
  45724. */
  45725. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  45726. /**
  45727. * Uploads the texture info contained in the env file to the GPU.
  45728. * @param texture defines the internal texture to upload to
  45729. * @param arrayBuffer defines the buffer cotaining the data to load
  45730. * @param info defines the texture info retrieved through the GetEnvInfo method
  45731. * @returns a promise
  45732. */
  45733. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45734. /**
  45735. * Uploads the levels of image data to the GPU.
  45736. * @param texture defines the internal texture to upload to
  45737. * @param imageData defines the array buffer views of image data [mipmap][face]
  45738. * @returns a promise
  45739. */
  45740. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45741. /**
  45742. * Uploads spherical polynomials information to the texture.
  45743. * @param texture defines the texture we are trying to upload the information to
  45744. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45745. */
  45746. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45747. /** @hidden */
  45748. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45749. }
  45750. }
  45751. declare module "babylonjs/Maths/math.vertexFormat" {
  45752. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  45753. /**
  45754. * Contains position and normal vectors for a vertex
  45755. */
  45756. export class PositionNormalVertex {
  45757. /** the position of the vertex (defaut: 0,0,0) */
  45758. position: Vector3;
  45759. /** the normal of the vertex (defaut: 0,1,0) */
  45760. normal: Vector3;
  45761. /**
  45762. * Creates a PositionNormalVertex
  45763. * @param position the position of the vertex (defaut: 0,0,0)
  45764. * @param normal the normal of the vertex (defaut: 0,1,0)
  45765. */
  45766. constructor(
  45767. /** the position of the vertex (defaut: 0,0,0) */
  45768. position?: Vector3,
  45769. /** the normal of the vertex (defaut: 0,1,0) */
  45770. normal?: Vector3);
  45771. /**
  45772. * Clones the PositionNormalVertex
  45773. * @returns the cloned PositionNormalVertex
  45774. */
  45775. clone(): PositionNormalVertex;
  45776. }
  45777. /**
  45778. * Contains position, normal and uv vectors for a vertex
  45779. */
  45780. export class PositionNormalTextureVertex {
  45781. /** the position of the vertex (defaut: 0,0,0) */
  45782. position: Vector3;
  45783. /** the normal of the vertex (defaut: 0,1,0) */
  45784. normal: Vector3;
  45785. /** the uv of the vertex (default: 0,0) */
  45786. uv: Vector2;
  45787. /**
  45788. * Creates a PositionNormalTextureVertex
  45789. * @param position the position of the vertex (defaut: 0,0,0)
  45790. * @param normal the normal of the vertex (defaut: 0,1,0)
  45791. * @param uv the uv of the vertex (default: 0,0)
  45792. */
  45793. constructor(
  45794. /** the position of the vertex (defaut: 0,0,0) */
  45795. position?: Vector3,
  45796. /** the normal of the vertex (defaut: 0,1,0) */
  45797. normal?: Vector3,
  45798. /** the uv of the vertex (default: 0,0) */
  45799. uv?: Vector2);
  45800. /**
  45801. * Clones the PositionNormalTextureVertex
  45802. * @returns the cloned PositionNormalTextureVertex
  45803. */
  45804. clone(): PositionNormalTextureVertex;
  45805. }
  45806. }
  45807. declare module "babylonjs/Maths/math" {
  45808. export * from "babylonjs/Maths/math.axis";
  45809. export * from "babylonjs/Maths/math.color";
  45810. export * from "babylonjs/Maths/math.constants";
  45811. export * from "babylonjs/Maths/math.frustum";
  45812. export * from "babylonjs/Maths/math.path";
  45813. export * from "babylonjs/Maths/math.plane";
  45814. export * from "babylonjs/Maths/math.size";
  45815. export * from "babylonjs/Maths/math.vector";
  45816. export * from "babylonjs/Maths/math.vertexFormat";
  45817. export * from "babylonjs/Maths/math.viewport";
  45818. }
  45819. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  45820. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45821. /** @hidden */
  45822. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  45823. private _genericAttributeLocation;
  45824. private _varyingLocationCount;
  45825. private _varyingLocationMap;
  45826. private _replacements;
  45827. private _textureCount;
  45828. private _uniforms;
  45829. lineProcessor(line: string): string;
  45830. attributeProcessor(attribute: string): string;
  45831. varyingProcessor(varying: string, isFragment: boolean): string;
  45832. uniformProcessor(uniform: string): string;
  45833. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  45834. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  45835. }
  45836. }
  45837. declare module "babylonjs/Engines/nativeEngine" {
  45838. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  45839. import { Engine } from "babylonjs/Engines/engine";
  45840. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45841. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45842. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45843. import { Effect } from "babylonjs/Materials/effect";
  45844. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45845. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  45846. import { Scene } from "babylonjs/scene";
  45847. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45848. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45849. /**
  45850. * Container for accessors for natively-stored mesh data buffers.
  45851. */
  45852. class NativeDataBuffer extends DataBuffer {
  45853. /**
  45854. * Accessor value used to identify/retrieve a natively-stored index buffer.
  45855. */
  45856. nativeIndexBuffer?: any;
  45857. /**
  45858. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  45859. */
  45860. nativeVertexBuffer?: any;
  45861. }
  45862. /** @hidden */
  45863. export class NativeEngine extends Engine {
  45864. private readonly _native;
  45865. getHardwareScalingLevel(): number;
  45866. constructor();
  45867. /**
  45868. * Can be used to override the current requestAnimationFrame requester.
  45869. * @hidden
  45870. */
  45871. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  45872. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45873. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  45874. createVertexBuffer(data: DataArray): NativeDataBuffer;
  45875. recordVertexArrayObject(vertexBuffers: {
  45876. [key: string]: VertexBuffer;
  45877. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  45878. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45879. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  45880. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45881. /**
  45882. * Draw a list of indexed primitives
  45883. * @param fillMode defines the primitive to use
  45884. * @param indexStart defines the starting index
  45885. * @param indexCount defines the number of index to draw
  45886. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45887. */
  45888. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45889. /**
  45890. * Draw a list of unindexed primitives
  45891. * @param fillMode defines the primitive to use
  45892. * @param verticesStart defines the index of first vertex to draw
  45893. * @param verticesCount defines the count of vertices to draw
  45894. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45895. */
  45896. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45897. createPipelineContext(): IPipelineContext;
  45898. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  45899. /** @hidden */
  45900. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45901. /** @hidden */
  45902. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45903. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45904. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  45905. protected _setProgram(program: WebGLProgram): void;
  45906. _releaseEffect(effect: Effect): void;
  45907. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45908. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  45909. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45910. bindSamplers(effect: Effect): void;
  45911. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  45912. getRenderWidth(useScreen?: boolean): number;
  45913. getRenderHeight(useScreen?: boolean): number;
  45914. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  45915. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45916. /**
  45917. * Set the z offset to apply to current rendering
  45918. * @param value defines the offset to apply
  45919. */
  45920. setZOffset(value: number): void;
  45921. /**
  45922. * Gets the current value of the zOffset
  45923. * @returns the current zOffset state
  45924. */
  45925. getZOffset(): number;
  45926. /**
  45927. * Enable or disable depth buffering
  45928. * @param enable defines the state to set
  45929. */
  45930. setDepthBuffer(enable: boolean): void;
  45931. /**
  45932. * Gets a boolean indicating if depth writing is enabled
  45933. * @returns the current depth writing state
  45934. */
  45935. getDepthWrite(): boolean;
  45936. /**
  45937. * Enable or disable depth writing
  45938. * @param enable defines the state to set
  45939. */
  45940. setDepthWrite(enable: boolean): void;
  45941. /**
  45942. * Enable or disable color writing
  45943. * @param enable defines the state to set
  45944. */
  45945. setColorWrite(enable: boolean): void;
  45946. /**
  45947. * Gets a boolean indicating if color writing is enabled
  45948. * @returns the current color writing state
  45949. */
  45950. getColorWrite(): boolean;
  45951. /**
  45952. * Sets alpha constants used by some alpha blending modes
  45953. * @param r defines the red component
  45954. * @param g defines the green component
  45955. * @param b defines the blue component
  45956. * @param a defines the alpha component
  45957. */
  45958. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  45959. /**
  45960. * Sets the current alpha mode
  45961. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  45962. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45963. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45964. */
  45965. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45966. /**
  45967. * Gets the current alpha mode
  45968. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45969. * @returns the current alpha mode
  45970. */
  45971. getAlphaMode(): number;
  45972. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45973. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45974. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45975. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45976. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45977. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45978. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45979. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45980. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45981. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45982. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45983. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45984. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45985. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45986. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45987. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45988. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45989. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45990. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45991. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45992. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  45993. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  45994. wipeCaches(bruteForce?: boolean): void;
  45995. _createTexture(): WebGLTexture;
  45996. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  45997. /**
  45998. * Usually called from BABYLON.Texture.ts.
  45999. * Passed information to create a WebGLTexture
  46000. * @param urlArg defines a value which contains one of the following:
  46001. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46002. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46003. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46004. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46005. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46006. * @param scene needed for loading to the correct scene
  46007. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46008. * @param onLoad optional callback to be called upon successful completion
  46009. * @param onError optional callback to be called upon failure
  46010. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46011. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46012. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46013. * @param forcedExtension defines the extension to use to pick the right loader
  46014. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46015. */
  46016. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  46017. /**
  46018. * Creates a cube texture
  46019. * @param rootUrl defines the url where the files to load is located
  46020. * @param scene defines the current scene
  46021. * @param files defines the list of files to load (1 per face)
  46022. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46023. * @param onLoad defines an optional callback raised when the texture is loaded
  46024. * @param onError defines an optional callback raised if there is an issue to load the texture
  46025. * @param format defines the format of the data
  46026. * @param forcedExtension defines the extension to use to pick the right loader
  46027. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46028. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46029. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46030. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46031. * @returns the cube texture as an InternalTexture
  46032. */
  46033. 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;
  46034. private _getSamplingFilter;
  46035. private static _GetNativeTextureFormat;
  46036. createRenderTargetTexture(size: number | {
  46037. width: number;
  46038. height: number;
  46039. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46040. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46041. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46042. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46043. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46044. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46045. /**
  46046. * Updates a dynamic vertex buffer.
  46047. * @param vertexBuffer the vertex buffer to update
  46048. * @param data the data used to update the vertex buffer
  46049. * @param byteOffset the byte offset of the data (optional)
  46050. * @param byteLength the byte length of the data (optional)
  46051. */
  46052. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46053. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46054. private _updateAnisotropicLevel;
  46055. private _getAddressMode;
  46056. /** @hidden */
  46057. _bindTexture(channel: number, texture: InternalTexture): void;
  46058. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46059. releaseEffects(): void;
  46060. /** @hidden */
  46061. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46062. /** @hidden */
  46063. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46064. /** @hidden */
  46065. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46066. /** @hidden */
  46067. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46068. }
  46069. }
  46070. declare module "babylonjs/Engines/index" {
  46071. export * from "babylonjs/Engines/constants";
  46072. export * from "babylonjs/Engines/engine";
  46073. export * from "babylonjs/Engines/engineStore";
  46074. export * from "babylonjs/Engines/nullEngine";
  46075. export * from "babylonjs/Engines/Extensions/index";
  46076. export * from "babylonjs/Engines/IPipelineContext";
  46077. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46078. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46079. export * from "babylonjs/Engines/nativeEngine";
  46080. }
  46081. declare module "babylonjs/Events/clipboardEvents" {
  46082. /**
  46083. * Gather the list of clipboard event types as constants.
  46084. */
  46085. export class ClipboardEventTypes {
  46086. /**
  46087. * The clipboard event is fired when a copy command is active (pressed).
  46088. */
  46089. static readonly COPY: number;
  46090. /**
  46091. * The clipboard event is fired when a cut command is active (pressed).
  46092. */
  46093. static readonly CUT: number;
  46094. /**
  46095. * The clipboard event is fired when a paste command is active (pressed).
  46096. */
  46097. static readonly PASTE: number;
  46098. }
  46099. /**
  46100. * This class is used to store clipboard related info for the onClipboardObservable event.
  46101. */
  46102. export class ClipboardInfo {
  46103. /**
  46104. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46105. */
  46106. type: number;
  46107. /**
  46108. * Defines the related dom event
  46109. */
  46110. event: ClipboardEvent;
  46111. /**
  46112. *Creates an instance of ClipboardInfo.
  46113. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46114. * @param event Defines the related dom event
  46115. */
  46116. constructor(
  46117. /**
  46118. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46119. */
  46120. type: number,
  46121. /**
  46122. * Defines the related dom event
  46123. */
  46124. event: ClipboardEvent);
  46125. /**
  46126. * Get the clipboard event's type from the keycode.
  46127. * @param keyCode Defines the keyCode for the current keyboard event.
  46128. * @return {number}
  46129. */
  46130. static GetTypeFromCharacter(keyCode: number): number;
  46131. }
  46132. }
  46133. declare module "babylonjs/Events/index" {
  46134. export * from "babylonjs/Events/keyboardEvents";
  46135. export * from "babylonjs/Events/pointerEvents";
  46136. export * from "babylonjs/Events/clipboardEvents";
  46137. }
  46138. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46139. import { Scene } from "babylonjs/scene";
  46140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46141. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46142. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46143. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46144. /**
  46145. * Google Daydream controller
  46146. */
  46147. export class DaydreamController extends WebVRController {
  46148. /**
  46149. * Base Url for the controller model.
  46150. */
  46151. static MODEL_BASE_URL: string;
  46152. /**
  46153. * File name for the controller model.
  46154. */
  46155. static MODEL_FILENAME: string;
  46156. /**
  46157. * Gamepad Id prefix used to identify Daydream Controller.
  46158. */
  46159. static readonly GAMEPAD_ID_PREFIX: string;
  46160. /**
  46161. * Creates a new DaydreamController from a gamepad
  46162. * @param vrGamepad the gamepad that the controller should be created from
  46163. */
  46164. constructor(vrGamepad: any);
  46165. /**
  46166. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46167. * @param scene scene in which to add meshes
  46168. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46169. */
  46170. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46171. /**
  46172. * Called once for each button that changed state since the last frame
  46173. * @param buttonIdx Which button index changed
  46174. * @param state New state of the button
  46175. * @param changes Which properties on the state changed since last frame
  46176. */
  46177. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46178. }
  46179. }
  46180. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46181. import { Scene } from "babylonjs/scene";
  46182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46183. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46184. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46185. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46186. /**
  46187. * Gear VR Controller
  46188. */
  46189. export class GearVRController extends WebVRController {
  46190. /**
  46191. * Base Url for the controller model.
  46192. */
  46193. static MODEL_BASE_URL: string;
  46194. /**
  46195. * File name for the controller model.
  46196. */
  46197. static MODEL_FILENAME: string;
  46198. /**
  46199. * Gamepad Id prefix used to identify this controller.
  46200. */
  46201. static readonly GAMEPAD_ID_PREFIX: string;
  46202. private readonly _buttonIndexToObservableNameMap;
  46203. /**
  46204. * Creates a new GearVRController from a gamepad
  46205. * @param vrGamepad the gamepad that the controller should be created from
  46206. */
  46207. constructor(vrGamepad: any);
  46208. /**
  46209. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46210. * @param scene scene in which to add meshes
  46211. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46212. */
  46213. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46214. /**
  46215. * Called once for each button that changed state since the last frame
  46216. * @param buttonIdx Which button index changed
  46217. * @param state New state of the button
  46218. * @param changes Which properties on the state changed since last frame
  46219. */
  46220. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46221. }
  46222. }
  46223. declare module "babylonjs/Gamepads/Controllers/index" {
  46224. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46225. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46226. export * from "babylonjs/Gamepads/Controllers/genericController";
  46227. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46228. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46229. export * from "babylonjs/Gamepads/Controllers/viveController";
  46230. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46231. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46232. }
  46233. declare module "babylonjs/Gamepads/index" {
  46234. export * from "babylonjs/Gamepads/Controllers/index";
  46235. export * from "babylonjs/Gamepads/gamepad";
  46236. export * from "babylonjs/Gamepads/gamepadManager";
  46237. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46238. export * from "babylonjs/Gamepads/xboxGamepad";
  46239. export * from "babylonjs/Gamepads/dualShockGamepad";
  46240. }
  46241. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46242. import { Scene } from "babylonjs/scene";
  46243. import { Vector4 } from "babylonjs/Maths/math.vector";
  46244. import { Color4 } from "babylonjs/Maths/math.color";
  46245. import { Mesh } from "babylonjs/Meshes/mesh";
  46246. import { Nullable } from "babylonjs/types";
  46247. /**
  46248. * Class containing static functions to help procedurally build meshes
  46249. */
  46250. export class PolyhedronBuilder {
  46251. /**
  46252. * Creates a polyhedron mesh
  46253. * * 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
  46254. * * The parameter `size` (positive float, default 1) sets the polygon size
  46255. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46256. * * 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`
  46257. * * 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
  46258. * * 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)`)
  46259. * * 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
  46260. * * 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
  46261. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46262. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46264. * @param name defines the name of the mesh
  46265. * @param options defines the options used to create the mesh
  46266. * @param scene defines the hosting scene
  46267. * @returns the polyhedron mesh
  46268. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46269. */
  46270. static CreatePolyhedron(name: string, options: {
  46271. type?: number;
  46272. size?: number;
  46273. sizeX?: number;
  46274. sizeY?: number;
  46275. sizeZ?: number;
  46276. custom?: any;
  46277. faceUV?: Vector4[];
  46278. faceColors?: Color4[];
  46279. flat?: boolean;
  46280. updatable?: boolean;
  46281. sideOrientation?: number;
  46282. frontUVs?: Vector4;
  46283. backUVs?: Vector4;
  46284. }, scene?: Nullable<Scene>): Mesh;
  46285. }
  46286. }
  46287. declare module "babylonjs/Gizmos/scaleGizmo" {
  46288. import { Observable } from "babylonjs/Misc/observable";
  46289. import { Nullable } from "babylonjs/types";
  46290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46291. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46292. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46293. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46294. /**
  46295. * Gizmo that enables scaling a mesh along 3 axis
  46296. */
  46297. export class ScaleGizmo extends Gizmo {
  46298. /**
  46299. * Internal gizmo used for interactions on the x axis
  46300. */
  46301. xGizmo: AxisScaleGizmo;
  46302. /**
  46303. * Internal gizmo used for interactions on the y axis
  46304. */
  46305. yGizmo: AxisScaleGizmo;
  46306. /**
  46307. * Internal gizmo used for interactions on the z axis
  46308. */
  46309. zGizmo: AxisScaleGizmo;
  46310. /**
  46311. * Internal gizmo used to scale all axis equally
  46312. */
  46313. uniformScaleGizmo: AxisScaleGizmo;
  46314. private _meshAttached;
  46315. private _updateGizmoRotationToMatchAttachedMesh;
  46316. private _snapDistance;
  46317. private _scaleRatio;
  46318. private _uniformScalingMesh;
  46319. private _octahedron;
  46320. /** Fires an event when any of it's sub gizmos are dragged */
  46321. onDragStartObservable: Observable<unknown>;
  46322. /** Fires an event when any of it's sub gizmos are released from dragging */
  46323. onDragEndObservable: Observable<unknown>;
  46324. attachedMesh: Nullable<AbstractMesh>;
  46325. /**
  46326. * Creates a ScaleGizmo
  46327. * @param gizmoLayer The utility layer the gizmo will be added to
  46328. */
  46329. constructor(gizmoLayer?: UtilityLayerRenderer);
  46330. updateGizmoRotationToMatchAttachedMesh: boolean;
  46331. /**
  46332. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46333. */
  46334. snapDistance: number;
  46335. /**
  46336. * Ratio for the scale of the gizmo (Default: 1)
  46337. */
  46338. scaleRatio: number;
  46339. /**
  46340. * Disposes of the gizmo
  46341. */
  46342. dispose(): void;
  46343. }
  46344. }
  46345. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46346. import { Observable } from "babylonjs/Misc/observable";
  46347. import { Nullable } from "babylonjs/types";
  46348. import { Vector3 } from "babylonjs/Maths/math.vector";
  46349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46350. import { Mesh } from "babylonjs/Meshes/mesh";
  46351. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46352. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46353. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46354. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46355. import { Color3 } from "babylonjs/Maths/math.color";
  46356. /**
  46357. * Single axis scale gizmo
  46358. */
  46359. export class AxisScaleGizmo extends Gizmo {
  46360. /**
  46361. * Drag behavior responsible for the gizmos dragging interactions
  46362. */
  46363. dragBehavior: PointerDragBehavior;
  46364. private _pointerObserver;
  46365. /**
  46366. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46367. */
  46368. snapDistance: number;
  46369. /**
  46370. * Event that fires each time the gizmo snaps to a new location.
  46371. * * snapDistance is the the change in distance
  46372. */
  46373. onSnapObservable: Observable<{
  46374. snapDistance: number;
  46375. }>;
  46376. /**
  46377. * If the scaling operation should be done on all axis (default: false)
  46378. */
  46379. uniformScaling: boolean;
  46380. private _isEnabled;
  46381. private _parent;
  46382. private _arrow;
  46383. private _coloredMaterial;
  46384. private _hoverMaterial;
  46385. /**
  46386. * Creates an AxisScaleGizmo
  46387. * @param gizmoLayer The utility layer the gizmo will be added to
  46388. * @param dragAxis The axis which the gizmo will be able to scale on
  46389. * @param color The color of the gizmo
  46390. */
  46391. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46392. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46393. /**
  46394. * If the gizmo is enabled
  46395. */
  46396. isEnabled: boolean;
  46397. /**
  46398. * Disposes of the gizmo
  46399. */
  46400. dispose(): void;
  46401. /**
  46402. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46403. * @param mesh The mesh to replace the default mesh of the gizmo
  46404. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46405. */
  46406. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46407. }
  46408. }
  46409. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46410. import { Observable } from "babylonjs/Misc/observable";
  46411. import { Nullable } from "babylonjs/types";
  46412. import { Vector3 } from "babylonjs/Maths/math.vector";
  46413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46414. import { Mesh } from "babylonjs/Meshes/mesh";
  46415. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46416. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46417. import { Color3 } from "babylonjs/Maths/math.color";
  46418. import "babylonjs/Meshes/Builders/boxBuilder";
  46419. /**
  46420. * Bounding box gizmo
  46421. */
  46422. export class BoundingBoxGizmo extends Gizmo {
  46423. private _lineBoundingBox;
  46424. private _rotateSpheresParent;
  46425. private _scaleBoxesParent;
  46426. private _boundingDimensions;
  46427. private _renderObserver;
  46428. private _pointerObserver;
  46429. private _scaleDragSpeed;
  46430. private _tmpQuaternion;
  46431. private _tmpVector;
  46432. private _tmpRotationMatrix;
  46433. /**
  46434. * 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)
  46435. */
  46436. ignoreChildren: boolean;
  46437. /**
  46438. * 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)
  46439. */
  46440. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46441. /**
  46442. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46443. */
  46444. rotationSphereSize: number;
  46445. /**
  46446. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46447. */
  46448. scaleBoxSize: number;
  46449. /**
  46450. * 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)
  46451. */
  46452. fixedDragMeshScreenSize: boolean;
  46453. /**
  46454. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46455. */
  46456. fixedDragMeshScreenSizeDistanceFactor: number;
  46457. /**
  46458. * Fired when a rotation sphere or scale box is dragged
  46459. */
  46460. onDragStartObservable: Observable<{}>;
  46461. /**
  46462. * Fired when a scale box is dragged
  46463. */
  46464. onScaleBoxDragObservable: Observable<{}>;
  46465. /**
  46466. * Fired when a scale box drag is ended
  46467. */
  46468. onScaleBoxDragEndObservable: Observable<{}>;
  46469. /**
  46470. * Fired when a rotation sphere is dragged
  46471. */
  46472. onRotationSphereDragObservable: Observable<{}>;
  46473. /**
  46474. * Fired when a rotation sphere drag is ended
  46475. */
  46476. onRotationSphereDragEndObservable: Observable<{}>;
  46477. /**
  46478. * 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)
  46479. */
  46480. scalePivot: Nullable<Vector3>;
  46481. /**
  46482. * Mesh used as a pivot to rotate the attached mesh
  46483. */
  46484. private _anchorMesh;
  46485. private _existingMeshScale;
  46486. private _dragMesh;
  46487. private pointerDragBehavior;
  46488. private coloredMaterial;
  46489. private hoverColoredMaterial;
  46490. /**
  46491. * Sets the color of the bounding box gizmo
  46492. * @param color the color to set
  46493. */
  46494. setColor(color: Color3): void;
  46495. /**
  46496. * Creates an BoundingBoxGizmo
  46497. * @param gizmoLayer The utility layer the gizmo will be added to
  46498. * @param color The color of the gizmo
  46499. */
  46500. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  46501. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46502. private _selectNode;
  46503. /**
  46504. * Updates the bounding box information for the Gizmo
  46505. */
  46506. updateBoundingBox(): void;
  46507. private _updateRotationSpheres;
  46508. private _updateScaleBoxes;
  46509. /**
  46510. * Enables rotation on the specified axis and disables rotation on the others
  46511. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  46512. */
  46513. setEnabledRotationAxis(axis: string): void;
  46514. /**
  46515. * Enables/disables scaling
  46516. * @param enable if scaling should be enabled
  46517. */
  46518. setEnabledScaling(enable: boolean): void;
  46519. private _updateDummy;
  46520. /**
  46521. * Enables a pointer drag behavior on the bounding box of the gizmo
  46522. */
  46523. enableDragBehavior(): void;
  46524. /**
  46525. * Disposes of the gizmo
  46526. */
  46527. dispose(): void;
  46528. /**
  46529. * 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)
  46530. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  46531. * @returns the bounding box mesh with the passed in mesh as a child
  46532. */
  46533. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  46534. /**
  46535. * CustomMeshes are not supported by this gizmo
  46536. * @param mesh The mesh to replace the default mesh of the gizmo
  46537. */
  46538. setCustomMesh(mesh: Mesh): void;
  46539. }
  46540. }
  46541. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  46542. import { Observable } from "babylonjs/Misc/observable";
  46543. import { Nullable } from "babylonjs/types";
  46544. import { Vector3 } from "babylonjs/Maths/math.vector";
  46545. import { Color3 } from "babylonjs/Maths/math.color";
  46546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46547. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46548. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46549. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46550. import "babylonjs/Meshes/Builders/linesBuilder";
  46551. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46552. /**
  46553. * Single plane rotation gizmo
  46554. */
  46555. export class PlaneRotationGizmo extends Gizmo {
  46556. /**
  46557. * Drag behavior responsible for the gizmos dragging interactions
  46558. */
  46559. dragBehavior: PointerDragBehavior;
  46560. private _pointerObserver;
  46561. /**
  46562. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  46563. */
  46564. snapDistance: number;
  46565. /**
  46566. * Event that fires each time the gizmo snaps to a new location.
  46567. * * snapDistance is the the change in distance
  46568. */
  46569. onSnapObservable: Observable<{
  46570. snapDistance: number;
  46571. }>;
  46572. private _isEnabled;
  46573. private _parent;
  46574. /**
  46575. * Creates a PlaneRotationGizmo
  46576. * @param gizmoLayer The utility layer the gizmo will be added to
  46577. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  46578. * @param color The color of the gizmo
  46579. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46580. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46581. */
  46582. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  46583. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46584. /**
  46585. * If the gizmo is enabled
  46586. */
  46587. isEnabled: boolean;
  46588. /**
  46589. * Disposes of the gizmo
  46590. */
  46591. dispose(): void;
  46592. }
  46593. }
  46594. declare module "babylonjs/Gizmos/rotationGizmo" {
  46595. import { Observable } from "babylonjs/Misc/observable";
  46596. import { Nullable } from "babylonjs/types";
  46597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46598. import { Mesh } from "babylonjs/Meshes/mesh";
  46599. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46600. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  46601. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46602. /**
  46603. * Gizmo that enables rotating a mesh along 3 axis
  46604. */
  46605. export class RotationGizmo extends Gizmo {
  46606. /**
  46607. * Internal gizmo used for interactions on the x axis
  46608. */
  46609. xGizmo: PlaneRotationGizmo;
  46610. /**
  46611. * Internal gizmo used for interactions on the y axis
  46612. */
  46613. yGizmo: PlaneRotationGizmo;
  46614. /**
  46615. * Internal gizmo used for interactions on the z axis
  46616. */
  46617. zGizmo: PlaneRotationGizmo;
  46618. /** Fires an event when any of it's sub gizmos are dragged */
  46619. onDragStartObservable: Observable<unknown>;
  46620. /** Fires an event when any of it's sub gizmos are released from dragging */
  46621. onDragEndObservable: Observable<unknown>;
  46622. private _meshAttached;
  46623. attachedMesh: Nullable<AbstractMesh>;
  46624. /**
  46625. * Creates a RotationGizmo
  46626. * @param gizmoLayer The utility layer the gizmo will be added to
  46627. * @param tessellation Amount of tessellation to be used when creating rotation circles
  46628. * @param useEulerRotation Use and update Euler angle instead of quaternion
  46629. */
  46630. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  46631. updateGizmoRotationToMatchAttachedMesh: boolean;
  46632. /**
  46633. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46634. */
  46635. snapDistance: number;
  46636. /**
  46637. * Ratio for the scale of the gizmo (Default: 1)
  46638. */
  46639. scaleRatio: number;
  46640. /**
  46641. * Disposes of the gizmo
  46642. */
  46643. dispose(): void;
  46644. /**
  46645. * CustomMeshes are not supported by this gizmo
  46646. * @param mesh The mesh to replace the default mesh of the gizmo
  46647. */
  46648. setCustomMesh(mesh: Mesh): void;
  46649. }
  46650. }
  46651. declare module "babylonjs/Gizmos/gizmoManager" {
  46652. import { Observable } from "babylonjs/Misc/observable";
  46653. import { Nullable } from "babylonjs/types";
  46654. import { Scene, IDisposable } from "babylonjs/scene";
  46655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46656. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46657. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  46658. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  46659. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  46660. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46661. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  46662. /**
  46663. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  46664. */
  46665. export class GizmoManager implements IDisposable {
  46666. private scene;
  46667. /**
  46668. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  46669. */
  46670. gizmos: {
  46671. positionGizmo: Nullable<PositionGizmo>;
  46672. rotationGizmo: Nullable<RotationGizmo>;
  46673. scaleGizmo: Nullable<ScaleGizmo>;
  46674. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  46675. };
  46676. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  46677. clearGizmoOnEmptyPointerEvent: boolean;
  46678. /** Fires an event when the manager is attached to a mesh */
  46679. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  46680. private _gizmosEnabled;
  46681. private _pointerObserver;
  46682. private _attachedMesh;
  46683. private _boundingBoxColor;
  46684. private _defaultUtilityLayer;
  46685. private _defaultKeepDepthUtilityLayer;
  46686. /**
  46687. * When bounding box gizmo is enabled, this can be used to track drag/end events
  46688. */
  46689. boundingBoxDragBehavior: SixDofDragBehavior;
  46690. /**
  46691. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  46692. */
  46693. attachableMeshes: Nullable<Array<AbstractMesh>>;
  46694. /**
  46695. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  46696. */
  46697. usePointerToAttachGizmos: boolean;
  46698. /**
  46699. * Utility layer that the bounding box gizmo belongs to
  46700. */
  46701. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  46702. /**
  46703. * Utility layer that all gizmos besides bounding box belong to
  46704. */
  46705. readonly utilityLayer: UtilityLayerRenderer;
  46706. /**
  46707. * Instatiates a gizmo manager
  46708. * @param scene the scene to overlay the gizmos on top of
  46709. */
  46710. constructor(scene: Scene);
  46711. /**
  46712. * Attaches a set of gizmos to the specified mesh
  46713. * @param mesh The mesh the gizmo's should be attached to
  46714. */
  46715. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  46716. /**
  46717. * If the position gizmo is enabled
  46718. */
  46719. positionGizmoEnabled: boolean;
  46720. /**
  46721. * If the rotation gizmo is enabled
  46722. */
  46723. rotationGizmoEnabled: boolean;
  46724. /**
  46725. * If the scale gizmo is enabled
  46726. */
  46727. scaleGizmoEnabled: boolean;
  46728. /**
  46729. * If the boundingBox gizmo is enabled
  46730. */
  46731. boundingBoxGizmoEnabled: boolean;
  46732. /**
  46733. * Disposes of the gizmo manager
  46734. */
  46735. dispose(): void;
  46736. }
  46737. }
  46738. declare module "babylonjs/Lights/directionalLight" {
  46739. import { Camera } from "babylonjs/Cameras/camera";
  46740. import { Scene } from "babylonjs/scene";
  46741. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46742. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46743. import { Light } from "babylonjs/Lights/light";
  46744. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46745. import { Effect } from "babylonjs/Materials/effect";
  46746. /**
  46747. * A directional light is defined by a direction (what a surprise!).
  46748. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46749. * 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.
  46750. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46751. */
  46752. export class DirectionalLight extends ShadowLight {
  46753. private _shadowFrustumSize;
  46754. /**
  46755. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46756. */
  46757. /**
  46758. * Specifies a fix frustum size for the shadow generation.
  46759. */
  46760. shadowFrustumSize: number;
  46761. private _shadowOrthoScale;
  46762. /**
  46763. * Gets the shadow projection scale against the optimal computed one.
  46764. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46765. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46766. */
  46767. /**
  46768. * Sets the shadow projection scale against the optimal computed one.
  46769. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46770. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46771. */
  46772. shadowOrthoScale: number;
  46773. /**
  46774. * Automatically compute the projection matrix to best fit (including all the casters)
  46775. * on each frame.
  46776. */
  46777. autoUpdateExtends: boolean;
  46778. private _orthoLeft;
  46779. private _orthoRight;
  46780. private _orthoTop;
  46781. private _orthoBottom;
  46782. /**
  46783. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46784. * The directional light is emitted from everywhere in the given direction.
  46785. * It can cast shadows.
  46786. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46787. * @param name The friendly name of the light
  46788. * @param direction The direction of the light
  46789. * @param scene The scene the light belongs to
  46790. */
  46791. constructor(name: string, direction: Vector3, scene: Scene);
  46792. /**
  46793. * Returns the string "DirectionalLight".
  46794. * @return The class name
  46795. */
  46796. getClassName(): string;
  46797. /**
  46798. * Returns the integer 1.
  46799. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46800. */
  46801. getTypeID(): number;
  46802. /**
  46803. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46804. * Returns the DirectionalLight Shadow projection matrix.
  46805. */
  46806. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46807. /**
  46808. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46809. * Returns the DirectionalLight Shadow projection matrix.
  46810. */
  46811. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46812. /**
  46813. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46814. * Returns the DirectionalLight Shadow projection matrix.
  46815. */
  46816. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46817. protected _buildUniformLayout(): void;
  46818. /**
  46819. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46820. * @param effect The effect to update
  46821. * @param lightIndex The index of the light in the effect to update
  46822. * @returns The directional light
  46823. */
  46824. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46825. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  46826. /**
  46827. * Gets the minZ used for shadow according to both the scene and the light.
  46828. *
  46829. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46830. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46831. * @param activeCamera The camera we are returning the min for
  46832. * @returns the depth min z
  46833. */
  46834. getDepthMinZ(activeCamera: Camera): number;
  46835. /**
  46836. * Gets the maxZ used for shadow according to both the scene and the light.
  46837. *
  46838. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46839. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46840. * @param activeCamera The camera we are returning the max for
  46841. * @returns the depth max z
  46842. */
  46843. getDepthMaxZ(activeCamera: Camera): number;
  46844. /**
  46845. * Prepares the list of defines specific to the light type.
  46846. * @param defines the list of defines
  46847. * @param lightIndex defines the index of the light for the effect
  46848. */
  46849. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46850. }
  46851. }
  46852. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  46853. import { Mesh } from "babylonjs/Meshes/mesh";
  46854. /**
  46855. * Class containing static functions to help procedurally build meshes
  46856. */
  46857. export class HemisphereBuilder {
  46858. /**
  46859. * Creates a hemisphere mesh
  46860. * @param name defines the name of the mesh
  46861. * @param options defines the options used to create the mesh
  46862. * @param scene defines the hosting scene
  46863. * @returns the hemisphere mesh
  46864. */
  46865. static CreateHemisphere(name: string, options: {
  46866. segments?: number;
  46867. diameter?: number;
  46868. sideOrientation?: number;
  46869. }, scene: any): Mesh;
  46870. }
  46871. }
  46872. declare module "babylonjs/Lights/spotLight" {
  46873. import { Nullable } from "babylonjs/types";
  46874. import { Scene } from "babylonjs/scene";
  46875. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46877. import { Effect } from "babylonjs/Materials/effect";
  46878. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46879. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46880. /**
  46881. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46882. * These values define a cone of light starting from the position, emitting toward the direction.
  46883. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46884. * and the exponent defines the speed of the decay of the light with distance (reach).
  46885. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46886. */
  46887. export class SpotLight extends ShadowLight {
  46888. private _angle;
  46889. private _innerAngle;
  46890. private _cosHalfAngle;
  46891. private _lightAngleScale;
  46892. private _lightAngleOffset;
  46893. /**
  46894. * Gets the cone angle of the spot light in Radians.
  46895. */
  46896. /**
  46897. * Sets the cone angle of the spot light in Radians.
  46898. */
  46899. angle: number;
  46900. /**
  46901. * Only used in gltf falloff mode, this defines the angle where
  46902. * the directional falloff will start before cutting at angle which could be seen
  46903. * as outer angle.
  46904. */
  46905. /**
  46906. * Only used in gltf falloff mode, this defines the angle where
  46907. * the directional falloff will start before cutting at angle which could be seen
  46908. * as outer angle.
  46909. */
  46910. innerAngle: number;
  46911. private _shadowAngleScale;
  46912. /**
  46913. * Allows scaling the angle of the light for shadow generation only.
  46914. */
  46915. /**
  46916. * Allows scaling the angle of the light for shadow generation only.
  46917. */
  46918. shadowAngleScale: number;
  46919. /**
  46920. * The light decay speed with the distance from the emission spot.
  46921. */
  46922. exponent: number;
  46923. private _projectionTextureMatrix;
  46924. /**
  46925. * Allows reading the projecton texture
  46926. */
  46927. readonly projectionTextureMatrix: Matrix;
  46928. protected _projectionTextureLightNear: number;
  46929. /**
  46930. * Gets the near clip of the Spotlight for texture projection.
  46931. */
  46932. /**
  46933. * Sets the near clip of the Spotlight for texture projection.
  46934. */
  46935. projectionTextureLightNear: number;
  46936. protected _projectionTextureLightFar: number;
  46937. /**
  46938. * Gets the far clip of the Spotlight for texture projection.
  46939. */
  46940. /**
  46941. * Sets the far clip of the Spotlight for texture projection.
  46942. */
  46943. projectionTextureLightFar: number;
  46944. protected _projectionTextureUpDirection: Vector3;
  46945. /**
  46946. * Gets the Up vector of the Spotlight for texture projection.
  46947. */
  46948. /**
  46949. * Sets the Up vector of the Spotlight for texture projection.
  46950. */
  46951. projectionTextureUpDirection: Vector3;
  46952. private _projectionTexture;
  46953. /**
  46954. * Gets the projection texture of the light.
  46955. */
  46956. /**
  46957. * Sets the projection texture of the light.
  46958. */
  46959. projectionTexture: Nullable<BaseTexture>;
  46960. private _projectionTextureViewLightDirty;
  46961. private _projectionTextureProjectionLightDirty;
  46962. private _projectionTextureDirty;
  46963. private _projectionTextureViewTargetVector;
  46964. private _projectionTextureViewLightMatrix;
  46965. private _projectionTextureProjectionLightMatrix;
  46966. private _projectionTextureScalingMatrix;
  46967. /**
  46968. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46969. * It can cast shadows.
  46970. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46971. * @param name The light friendly name
  46972. * @param position The position of the spot light in the scene
  46973. * @param direction The direction of the light in the scene
  46974. * @param angle The cone angle of the light in Radians
  46975. * @param exponent The light decay speed with the distance from the emission spot
  46976. * @param scene The scene the lights belongs to
  46977. */
  46978. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46979. /**
  46980. * Returns the string "SpotLight".
  46981. * @returns the class name
  46982. */
  46983. getClassName(): string;
  46984. /**
  46985. * Returns the integer 2.
  46986. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46987. */
  46988. getTypeID(): number;
  46989. /**
  46990. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46991. */
  46992. protected _setDirection(value: Vector3): void;
  46993. /**
  46994. * Overrides the position setter to recompute the projection texture view light Matrix.
  46995. */
  46996. protected _setPosition(value: Vector3): void;
  46997. /**
  46998. * 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.
  46999. * Returns the SpotLight.
  47000. */
  47001. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47002. protected _computeProjectionTextureViewLightMatrix(): void;
  47003. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47004. /**
  47005. * Main function for light texture projection matrix computing.
  47006. */
  47007. protected _computeProjectionTextureMatrix(): void;
  47008. protected _buildUniformLayout(): void;
  47009. private _computeAngleValues;
  47010. /**
  47011. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47012. * @param effect The effect to update
  47013. * @param lightIndex The index of the light in the effect to update
  47014. * @returns The spot light
  47015. */
  47016. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47017. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47018. /**
  47019. * Disposes the light and the associated resources.
  47020. */
  47021. dispose(): void;
  47022. /**
  47023. * Prepares the list of defines specific to the light type.
  47024. * @param defines the list of defines
  47025. * @param lightIndex defines the index of the light for the effect
  47026. */
  47027. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47028. }
  47029. }
  47030. declare module "babylonjs/Gizmos/lightGizmo" {
  47031. import { Nullable } from "babylonjs/types";
  47032. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47033. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47034. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47035. import { Light } from "babylonjs/Lights/light";
  47036. /**
  47037. * Gizmo that enables viewing a light
  47038. */
  47039. export class LightGizmo extends Gizmo {
  47040. private _lightMesh;
  47041. private _material;
  47042. private cachedPosition;
  47043. private cachedForward;
  47044. /**
  47045. * Creates a LightGizmo
  47046. * @param gizmoLayer The utility layer the gizmo will be added to
  47047. */
  47048. constructor(gizmoLayer?: UtilityLayerRenderer);
  47049. private _light;
  47050. /**
  47051. * The light that the gizmo is attached to
  47052. */
  47053. light: Nullable<Light>;
  47054. /**
  47055. * Gets the material used to render the light gizmo
  47056. */
  47057. readonly material: StandardMaterial;
  47058. /**
  47059. * @hidden
  47060. * Updates the gizmo to match the attached mesh's position/rotation
  47061. */
  47062. protected _update(): void;
  47063. private static _Scale;
  47064. /**
  47065. * Creates the lines for a light mesh
  47066. */
  47067. private static _createLightLines;
  47068. /**
  47069. * Disposes of the light gizmo
  47070. */
  47071. dispose(): void;
  47072. private static _CreateHemisphericLightMesh;
  47073. private static _CreatePointLightMesh;
  47074. private static _CreateSpotLightMesh;
  47075. private static _CreateDirectionalLightMesh;
  47076. }
  47077. }
  47078. declare module "babylonjs/Gizmos/index" {
  47079. export * from "babylonjs/Gizmos/axisDragGizmo";
  47080. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47081. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47082. export * from "babylonjs/Gizmos/gizmo";
  47083. export * from "babylonjs/Gizmos/gizmoManager";
  47084. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47085. export * from "babylonjs/Gizmos/positionGizmo";
  47086. export * from "babylonjs/Gizmos/rotationGizmo";
  47087. export * from "babylonjs/Gizmos/scaleGizmo";
  47088. export * from "babylonjs/Gizmos/lightGizmo";
  47089. export * from "babylonjs/Gizmos/planeDragGizmo";
  47090. }
  47091. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47092. /** @hidden */
  47093. export var backgroundFragmentDeclaration: {
  47094. name: string;
  47095. shader: string;
  47096. };
  47097. }
  47098. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47099. /** @hidden */
  47100. export var backgroundUboDeclaration: {
  47101. name: string;
  47102. shader: string;
  47103. };
  47104. }
  47105. declare module "babylonjs/Shaders/background.fragment" {
  47106. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47107. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47108. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47109. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47110. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47111. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47112. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47113. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47114. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47115. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47116. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47117. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47118. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47119. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47120. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47121. /** @hidden */
  47122. export var backgroundPixelShader: {
  47123. name: string;
  47124. shader: string;
  47125. };
  47126. }
  47127. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47128. /** @hidden */
  47129. export var backgroundVertexDeclaration: {
  47130. name: string;
  47131. shader: string;
  47132. };
  47133. }
  47134. declare module "babylonjs/Shaders/background.vertex" {
  47135. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47136. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47137. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47138. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47139. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47140. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47141. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47142. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47143. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47144. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47145. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47146. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47147. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47148. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47149. /** @hidden */
  47150. export var backgroundVertexShader: {
  47151. name: string;
  47152. shader: string;
  47153. };
  47154. }
  47155. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47156. import { Nullable, int, float } from "babylonjs/types";
  47157. import { Scene } from "babylonjs/scene";
  47158. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47159. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47161. import { Mesh } from "babylonjs/Meshes/mesh";
  47162. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47163. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47164. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47165. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47166. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47167. import { Color3 } from "babylonjs/Maths/math.color";
  47168. import "babylonjs/Shaders/background.fragment";
  47169. import "babylonjs/Shaders/background.vertex";
  47170. /**
  47171. * Background material used to create an efficient environement around your scene.
  47172. */
  47173. export class BackgroundMaterial extends PushMaterial {
  47174. /**
  47175. * Standard reflectance value at parallel view angle.
  47176. */
  47177. static StandardReflectance0: number;
  47178. /**
  47179. * Standard reflectance value at grazing angle.
  47180. */
  47181. static StandardReflectance90: number;
  47182. protected _primaryColor: Color3;
  47183. /**
  47184. * Key light Color (multiply against the environement texture)
  47185. */
  47186. primaryColor: Color3;
  47187. protected __perceptualColor: Nullable<Color3>;
  47188. /**
  47189. * Experimental Internal Use Only.
  47190. *
  47191. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47192. * This acts as a helper to set the primary color to a more "human friendly" value.
  47193. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47194. * output color as close as possible from the chosen value.
  47195. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47196. * part of lighting setup.)
  47197. */
  47198. _perceptualColor: Nullable<Color3>;
  47199. protected _primaryColorShadowLevel: float;
  47200. /**
  47201. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47202. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47203. */
  47204. primaryColorShadowLevel: float;
  47205. protected _primaryColorHighlightLevel: float;
  47206. /**
  47207. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47208. * The primary color is used at the level chosen to define what the white area would look.
  47209. */
  47210. primaryColorHighlightLevel: float;
  47211. protected _reflectionTexture: Nullable<BaseTexture>;
  47212. /**
  47213. * Reflection Texture used in the material.
  47214. * Should be author in a specific way for the best result (refer to the documentation).
  47215. */
  47216. reflectionTexture: Nullable<BaseTexture>;
  47217. protected _reflectionBlur: float;
  47218. /**
  47219. * Reflection Texture level of blur.
  47220. *
  47221. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47222. * texture twice.
  47223. */
  47224. reflectionBlur: float;
  47225. protected _diffuseTexture: Nullable<BaseTexture>;
  47226. /**
  47227. * Diffuse Texture used in the material.
  47228. * Should be author in a specific way for the best result (refer to the documentation).
  47229. */
  47230. diffuseTexture: Nullable<BaseTexture>;
  47231. protected _shadowLights: Nullable<IShadowLight[]>;
  47232. /**
  47233. * Specify the list of lights casting shadow on the material.
  47234. * All scene shadow lights will be included if null.
  47235. */
  47236. shadowLights: Nullable<IShadowLight[]>;
  47237. protected _shadowLevel: float;
  47238. /**
  47239. * Helps adjusting the shadow to a softer level if required.
  47240. * 0 means black shadows and 1 means no shadows.
  47241. */
  47242. shadowLevel: float;
  47243. protected _sceneCenter: Vector3;
  47244. /**
  47245. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47246. * It is usually zero but might be interesting to modify according to your setup.
  47247. */
  47248. sceneCenter: Vector3;
  47249. protected _opacityFresnel: boolean;
  47250. /**
  47251. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47252. * This helps ensuring a nice transition when the camera goes under the ground.
  47253. */
  47254. opacityFresnel: boolean;
  47255. protected _reflectionFresnel: boolean;
  47256. /**
  47257. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47258. * This helps adding a mirror texture on the ground.
  47259. */
  47260. reflectionFresnel: boolean;
  47261. protected _reflectionFalloffDistance: number;
  47262. /**
  47263. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47264. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47265. */
  47266. reflectionFalloffDistance: number;
  47267. protected _reflectionAmount: number;
  47268. /**
  47269. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47270. */
  47271. reflectionAmount: number;
  47272. protected _reflectionReflectance0: number;
  47273. /**
  47274. * This specifies the weight of the reflection at grazing angle.
  47275. */
  47276. reflectionReflectance0: number;
  47277. protected _reflectionReflectance90: number;
  47278. /**
  47279. * This specifies the weight of the reflection at a perpendicular point of view.
  47280. */
  47281. reflectionReflectance90: number;
  47282. /**
  47283. * Sets the reflection reflectance fresnel values according to the default standard
  47284. * empirically know to work well :-)
  47285. */
  47286. reflectionStandardFresnelWeight: number;
  47287. protected _useRGBColor: boolean;
  47288. /**
  47289. * Helps to directly use the maps channels instead of their level.
  47290. */
  47291. useRGBColor: boolean;
  47292. protected _enableNoise: boolean;
  47293. /**
  47294. * This helps reducing the banding effect that could occur on the background.
  47295. */
  47296. enableNoise: boolean;
  47297. /**
  47298. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47299. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47300. * Recommended to be keep at 1.0 except for special cases.
  47301. */
  47302. fovMultiplier: number;
  47303. private _fovMultiplier;
  47304. /**
  47305. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47306. */
  47307. useEquirectangularFOV: boolean;
  47308. private _maxSimultaneousLights;
  47309. /**
  47310. * Number of Simultaneous lights allowed on the material.
  47311. */
  47312. maxSimultaneousLights: int;
  47313. /**
  47314. * Default configuration related to image processing available in the Background Material.
  47315. */
  47316. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47317. /**
  47318. * Keep track of the image processing observer to allow dispose and replace.
  47319. */
  47320. private _imageProcessingObserver;
  47321. /**
  47322. * Attaches a new image processing configuration to the PBR Material.
  47323. * @param configuration (if null the scene configuration will be use)
  47324. */
  47325. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47326. /**
  47327. * Gets the image processing configuration used either in this material.
  47328. */
  47329. /**
  47330. * Sets the Default image processing configuration used either in the this material.
  47331. *
  47332. * If sets to null, the scene one is in use.
  47333. */
  47334. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47335. /**
  47336. * Gets wether the color curves effect is enabled.
  47337. */
  47338. /**
  47339. * Sets wether the color curves effect is enabled.
  47340. */
  47341. cameraColorCurvesEnabled: boolean;
  47342. /**
  47343. * Gets wether the color grading effect is enabled.
  47344. */
  47345. /**
  47346. * Gets wether the color grading effect is enabled.
  47347. */
  47348. cameraColorGradingEnabled: boolean;
  47349. /**
  47350. * Gets wether tonemapping is enabled or not.
  47351. */
  47352. /**
  47353. * Sets wether tonemapping is enabled or not
  47354. */
  47355. cameraToneMappingEnabled: boolean;
  47356. /**
  47357. * The camera exposure used on this material.
  47358. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47359. * This corresponds to a photographic exposure.
  47360. */
  47361. /**
  47362. * The camera exposure used on this material.
  47363. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47364. * This corresponds to a photographic exposure.
  47365. */
  47366. cameraExposure: float;
  47367. /**
  47368. * Gets The camera contrast used on this material.
  47369. */
  47370. /**
  47371. * Sets The camera contrast used on this material.
  47372. */
  47373. cameraContrast: float;
  47374. /**
  47375. * Gets the Color Grading 2D Lookup Texture.
  47376. */
  47377. /**
  47378. * Sets the Color Grading 2D Lookup Texture.
  47379. */
  47380. cameraColorGradingTexture: Nullable<BaseTexture>;
  47381. /**
  47382. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47383. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47384. * 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;
  47385. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47386. */
  47387. /**
  47388. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47389. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47390. * 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;
  47391. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47392. */
  47393. cameraColorCurves: Nullable<ColorCurves>;
  47394. /**
  47395. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47396. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47397. */
  47398. switchToBGR: boolean;
  47399. private _renderTargets;
  47400. private _reflectionControls;
  47401. private _white;
  47402. private _primaryShadowColor;
  47403. private _primaryHighlightColor;
  47404. /**
  47405. * Instantiates a Background Material in the given scene
  47406. * @param name The friendly name of the material
  47407. * @param scene The scene to add the material to
  47408. */
  47409. constructor(name: string, scene: Scene);
  47410. /**
  47411. * Gets a boolean indicating that current material needs to register RTT
  47412. */
  47413. readonly hasRenderTargetTextures: boolean;
  47414. /**
  47415. * The entire material has been created in order to prevent overdraw.
  47416. * @returns false
  47417. */
  47418. needAlphaTesting(): boolean;
  47419. /**
  47420. * The entire material has been created in order to prevent overdraw.
  47421. * @returns true if blending is enable
  47422. */
  47423. needAlphaBlending(): boolean;
  47424. /**
  47425. * Checks wether the material is ready to be rendered for a given mesh.
  47426. * @param mesh The mesh to render
  47427. * @param subMesh The submesh to check against
  47428. * @param useInstances Specify wether or not the material is used with instances
  47429. * @returns true if all the dependencies are ready (Textures, Effects...)
  47430. */
  47431. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47432. /**
  47433. * Compute the primary color according to the chosen perceptual color.
  47434. */
  47435. private _computePrimaryColorFromPerceptualColor;
  47436. /**
  47437. * Compute the highlights and shadow colors according to their chosen levels.
  47438. */
  47439. private _computePrimaryColors;
  47440. /**
  47441. * Build the uniform buffer used in the material.
  47442. */
  47443. buildUniformLayout(): void;
  47444. /**
  47445. * Unbind the material.
  47446. */
  47447. unbind(): void;
  47448. /**
  47449. * Bind only the world matrix to the material.
  47450. * @param world The world matrix to bind.
  47451. */
  47452. bindOnlyWorldMatrix(world: Matrix): void;
  47453. /**
  47454. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47455. * @param world The world matrix to bind.
  47456. * @param subMesh The submesh to bind for.
  47457. */
  47458. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47459. /**
  47460. * Checks to see if a texture is used in the material.
  47461. * @param texture - Base texture to use.
  47462. * @returns - Boolean specifying if a texture is used in the material.
  47463. */
  47464. hasTexture(texture: BaseTexture): boolean;
  47465. /**
  47466. * Dispose the material.
  47467. * @param forceDisposeEffect Force disposal of the associated effect.
  47468. * @param forceDisposeTextures Force disposal of the associated textures.
  47469. */
  47470. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47471. /**
  47472. * Clones the material.
  47473. * @param name The cloned name.
  47474. * @returns The cloned material.
  47475. */
  47476. clone(name: string): BackgroundMaterial;
  47477. /**
  47478. * Serializes the current material to its JSON representation.
  47479. * @returns The JSON representation.
  47480. */
  47481. serialize(): any;
  47482. /**
  47483. * Gets the class name of the material
  47484. * @returns "BackgroundMaterial"
  47485. */
  47486. getClassName(): string;
  47487. /**
  47488. * Parse a JSON input to create back a background material.
  47489. * @param source The JSON data to parse
  47490. * @param scene The scene to create the parsed material in
  47491. * @param rootUrl The root url of the assets the material depends upon
  47492. * @returns the instantiated BackgroundMaterial.
  47493. */
  47494. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47495. }
  47496. }
  47497. declare module "babylonjs/Helpers/environmentHelper" {
  47498. import { Observable } from "babylonjs/Misc/observable";
  47499. import { Nullable } from "babylonjs/types";
  47500. import { Scene } from "babylonjs/scene";
  47501. import { Vector3 } from "babylonjs/Maths/math.vector";
  47502. import { Color3 } from "babylonjs/Maths/math.color";
  47503. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47504. import { Mesh } from "babylonjs/Meshes/mesh";
  47505. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47506. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  47507. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47508. import "babylonjs/Meshes/Builders/planeBuilder";
  47509. import "babylonjs/Meshes/Builders/boxBuilder";
  47510. /**
  47511. * Represents the different options available during the creation of
  47512. * a Environment helper.
  47513. *
  47514. * This can control the default ground, skybox and image processing setup of your scene.
  47515. */
  47516. export interface IEnvironmentHelperOptions {
  47517. /**
  47518. * Specifies wether or not to create a ground.
  47519. * True by default.
  47520. */
  47521. createGround: boolean;
  47522. /**
  47523. * Specifies the ground size.
  47524. * 15 by default.
  47525. */
  47526. groundSize: number;
  47527. /**
  47528. * The texture used on the ground for the main color.
  47529. * Comes from the BabylonJS CDN by default.
  47530. *
  47531. * Remarks: Can be either a texture or a url.
  47532. */
  47533. groundTexture: string | BaseTexture;
  47534. /**
  47535. * The color mixed in the ground texture by default.
  47536. * BabylonJS clearColor by default.
  47537. */
  47538. groundColor: Color3;
  47539. /**
  47540. * Specifies the ground opacity.
  47541. * 1 by default.
  47542. */
  47543. groundOpacity: number;
  47544. /**
  47545. * Enables the ground to receive shadows.
  47546. * True by default.
  47547. */
  47548. enableGroundShadow: boolean;
  47549. /**
  47550. * Helps preventing the shadow to be fully black on the ground.
  47551. * 0.5 by default.
  47552. */
  47553. groundShadowLevel: number;
  47554. /**
  47555. * Creates a mirror texture attach to the ground.
  47556. * false by default.
  47557. */
  47558. enableGroundMirror: boolean;
  47559. /**
  47560. * Specifies the ground mirror size ratio.
  47561. * 0.3 by default as the default kernel is 64.
  47562. */
  47563. groundMirrorSizeRatio: number;
  47564. /**
  47565. * Specifies the ground mirror blur kernel size.
  47566. * 64 by default.
  47567. */
  47568. groundMirrorBlurKernel: number;
  47569. /**
  47570. * Specifies the ground mirror visibility amount.
  47571. * 1 by default
  47572. */
  47573. groundMirrorAmount: number;
  47574. /**
  47575. * Specifies the ground mirror reflectance weight.
  47576. * This uses the standard weight of the background material to setup the fresnel effect
  47577. * of the mirror.
  47578. * 1 by default.
  47579. */
  47580. groundMirrorFresnelWeight: number;
  47581. /**
  47582. * Specifies the ground mirror Falloff distance.
  47583. * This can helps reducing the size of the reflection.
  47584. * 0 by Default.
  47585. */
  47586. groundMirrorFallOffDistance: number;
  47587. /**
  47588. * Specifies the ground mirror texture type.
  47589. * Unsigned Int by Default.
  47590. */
  47591. groundMirrorTextureType: number;
  47592. /**
  47593. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  47594. * the shown objects.
  47595. */
  47596. groundYBias: number;
  47597. /**
  47598. * Specifies wether or not to create a skybox.
  47599. * True by default.
  47600. */
  47601. createSkybox: boolean;
  47602. /**
  47603. * Specifies the skybox size.
  47604. * 20 by default.
  47605. */
  47606. skyboxSize: number;
  47607. /**
  47608. * The texture used on the skybox for the main color.
  47609. * Comes from the BabylonJS CDN by default.
  47610. *
  47611. * Remarks: Can be either a texture or a url.
  47612. */
  47613. skyboxTexture: string | BaseTexture;
  47614. /**
  47615. * The color mixed in the skybox texture by default.
  47616. * BabylonJS clearColor by default.
  47617. */
  47618. skyboxColor: Color3;
  47619. /**
  47620. * The background rotation around the Y axis of the scene.
  47621. * This helps aligning the key lights of your scene with the background.
  47622. * 0 by default.
  47623. */
  47624. backgroundYRotation: number;
  47625. /**
  47626. * Compute automatically the size of the elements to best fit with the scene.
  47627. */
  47628. sizeAuto: boolean;
  47629. /**
  47630. * Default position of the rootMesh if autoSize is not true.
  47631. */
  47632. rootPosition: Vector3;
  47633. /**
  47634. * Sets up the image processing in the scene.
  47635. * true by default.
  47636. */
  47637. setupImageProcessing: boolean;
  47638. /**
  47639. * The texture used as your environment texture in the scene.
  47640. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  47641. *
  47642. * Remarks: Can be either a texture or a url.
  47643. */
  47644. environmentTexture: string | BaseTexture;
  47645. /**
  47646. * The value of the exposure to apply to the scene.
  47647. * 0.6 by default if setupImageProcessing is true.
  47648. */
  47649. cameraExposure: number;
  47650. /**
  47651. * The value of the contrast to apply to the scene.
  47652. * 1.6 by default if setupImageProcessing is true.
  47653. */
  47654. cameraContrast: number;
  47655. /**
  47656. * Specifies wether or not tonemapping should be enabled in the scene.
  47657. * true by default if setupImageProcessing is true.
  47658. */
  47659. toneMappingEnabled: boolean;
  47660. }
  47661. /**
  47662. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  47663. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  47664. * It also helps with the default setup of your imageProcessing configuration.
  47665. */
  47666. export class EnvironmentHelper {
  47667. /**
  47668. * Default ground texture URL.
  47669. */
  47670. private static _groundTextureCDNUrl;
  47671. /**
  47672. * Default skybox texture URL.
  47673. */
  47674. private static _skyboxTextureCDNUrl;
  47675. /**
  47676. * Default environment texture URL.
  47677. */
  47678. private static _environmentTextureCDNUrl;
  47679. /**
  47680. * Creates the default options for the helper.
  47681. */
  47682. private static _getDefaultOptions;
  47683. private _rootMesh;
  47684. /**
  47685. * Gets the root mesh created by the helper.
  47686. */
  47687. readonly rootMesh: Mesh;
  47688. private _skybox;
  47689. /**
  47690. * Gets the skybox created by the helper.
  47691. */
  47692. readonly skybox: Nullable<Mesh>;
  47693. private _skyboxTexture;
  47694. /**
  47695. * Gets the skybox texture created by the helper.
  47696. */
  47697. readonly skyboxTexture: Nullable<BaseTexture>;
  47698. private _skyboxMaterial;
  47699. /**
  47700. * Gets the skybox material created by the helper.
  47701. */
  47702. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  47703. private _ground;
  47704. /**
  47705. * Gets the ground mesh created by the helper.
  47706. */
  47707. readonly ground: Nullable<Mesh>;
  47708. private _groundTexture;
  47709. /**
  47710. * Gets the ground texture created by the helper.
  47711. */
  47712. readonly groundTexture: Nullable<BaseTexture>;
  47713. private _groundMirror;
  47714. /**
  47715. * Gets the ground mirror created by the helper.
  47716. */
  47717. readonly groundMirror: Nullable<MirrorTexture>;
  47718. /**
  47719. * Gets the ground mirror render list to helps pushing the meshes
  47720. * you wish in the ground reflection.
  47721. */
  47722. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  47723. private _groundMaterial;
  47724. /**
  47725. * Gets the ground material created by the helper.
  47726. */
  47727. readonly groundMaterial: Nullable<BackgroundMaterial>;
  47728. /**
  47729. * Stores the creation options.
  47730. */
  47731. private readonly _scene;
  47732. private _options;
  47733. /**
  47734. * This observable will be notified with any error during the creation of the environment,
  47735. * mainly texture creation errors.
  47736. */
  47737. onErrorObservable: Observable<{
  47738. message?: string;
  47739. exception?: any;
  47740. }>;
  47741. /**
  47742. * constructor
  47743. * @param options Defines the options we want to customize the helper
  47744. * @param scene The scene to add the material to
  47745. */
  47746. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  47747. /**
  47748. * Updates the background according to the new options
  47749. * @param options
  47750. */
  47751. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  47752. /**
  47753. * Sets the primary color of all the available elements.
  47754. * @param color the main color to affect to the ground and the background
  47755. */
  47756. setMainColor(color: Color3): void;
  47757. /**
  47758. * Setup the image processing according to the specified options.
  47759. */
  47760. private _setupImageProcessing;
  47761. /**
  47762. * Setup the environment texture according to the specified options.
  47763. */
  47764. private _setupEnvironmentTexture;
  47765. /**
  47766. * Setup the background according to the specified options.
  47767. */
  47768. private _setupBackground;
  47769. /**
  47770. * Get the scene sizes according to the setup.
  47771. */
  47772. private _getSceneSize;
  47773. /**
  47774. * Setup the ground according to the specified options.
  47775. */
  47776. private _setupGround;
  47777. /**
  47778. * Setup the ground material according to the specified options.
  47779. */
  47780. private _setupGroundMaterial;
  47781. /**
  47782. * Setup the ground diffuse texture according to the specified options.
  47783. */
  47784. private _setupGroundDiffuseTexture;
  47785. /**
  47786. * Setup the ground mirror texture according to the specified options.
  47787. */
  47788. private _setupGroundMirrorTexture;
  47789. /**
  47790. * Setup the ground to receive the mirror texture.
  47791. */
  47792. private _setupMirrorInGroundMaterial;
  47793. /**
  47794. * Setup the skybox according to the specified options.
  47795. */
  47796. private _setupSkybox;
  47797. /**
  47798. * Setup the skybox material according to the specified options.
  47799. */
  47800. private _setupSkyboxMaterial;
  47801. /**
  47802. * Setup the skybox reflection texture according to the specified options.
  47803. */
  47804. private _setupSkyboxReflectionTexture;
  47805. private _errorHandler;
  47806. /**
  47807. * Dispose all the elements created by the Helper.
  47808. */
  47809. dispose(): void;
  47810. }
  47811. }
  47812. declare module "babylonjs/Helpers/photoDome" {
  47813. import { Observable } from "babylonjs/Misc/observable";
  47814. import { Nullable } from "babylonjs/types";
  47815. import { Scene } from "babylonjs/scene";
  47816. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47817. import { Mesh } from "babylonjs/Meshes/mesh";
  47818. import { Texture } from "babylonjs/Materials/Textures/texture";
  47819. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47820. import "babylonjs/Meshes/Builders/sphereBuilder";
  47821. /**
  47822. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  47823. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  47824. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  47825. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47826. */
  47827. export class PhotoDome extends TransformNode {
  47828. /**
  47829. * Define the image as a Monoscopic panoramic 360 image.
  47830. */
  47831. static readonly MODE_MONOSCOPIC: number;
  47832. /**
  47833. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47834. */
  47835. static readonly MODE_TOPBOTTOM: number;
  47836. /**
  47837. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47838. */
  47839. static readonly MODE_SIDEBYSIDE: number;
  47840. private _useDirectMapping;
  47841. /**
  47842. * The texture being displayed on the sphere
  47843. */
  47844. protected _photoTexture: Texture;
  47845. /**
  47846. * Gets or sets the texture being displayed on the sphere
  47847. */
  47848. photoTexture: Texture;
  47849. /**
  47850. * Observable raised when an error occured while loading the 360 image
  47851. */
  47852. onLoadErrorObservable: Observable<string>;
  47853. /**
  47854. * The skybox material
  47855. */
  47856. protected _material: BackgroundMaterial;
  47857. /**
  47858. * The surface used for the skybox
  47859. */
  47860. protected _mesh: Mesh;
  47861. /**
  47862. * Gets the mesh used for the skybox.
  47863. */
  47864. readonly mesh: Mesh;
  47865. /**
  47866. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47867. * Also see the options.resolution property.
  47868. */
  47869. fovMultiplier: number;
  47870. private _imageMode;
  47871. /**
  47872. * Gets or set the current video mode for the video. It can be:
  47873. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  47874. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  47875. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  47876. */
  47877. imageMode: number;
  47878. /**
  47879. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  47880. * @param name Element's name, child elements will append suffixes for their own names.
  47881. * @param urlsOfPhoto defines the url of the photo to display
  47882. * @param options defines an object containing optional or exposed sub element properties
  47883. * @param onError defines a callback called when an error occured while loading the texture
  47884. */
  47885. constructor(name: string, urlOfPhoto: string, options: {
  47886. resolution?: number;
  47887. size?: number;
  47888. useDirectMapping?: boolean;
  47889. faceForward?: boolean;
  47890. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  47891. private _onBeforeCameraRenderObserver;
  47892. private _changeImageMode;
  47893. /**
  47894. * Releases resources associated with this node.
  47895. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47896. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47897. */
  47898. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47899. }
  47900. }
  47901. declare module "babylonjs/Misc/rgbdTextureTools" {
  47902. import "babylonjs/Shaders/rgbdDecode.fragment";
  47903. import { Texture } from "babylonjs/Materials/Textures/texture";
  47904. /**
  47905. * Class used to host RGBD texture specific utilities
  47906. */
  47907. export class RGBDTextureTools {
  47908. /**
  47909. * Expand the RGBD Texture from RGBD to Half Float if possible.
  47910. * @param texture the texture to expand.
  47911. */
  47912. static ExpandRGBDTexture(texture: Texture): void;
  47913. }
  47914. }
  47915. declare module "babylonjs/Misc/brdfTextureTools" {
  47916. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47917. import { Scene } from "babylonjs/scene";
  47918. /**
  47919. * Class used to host texture specific utilities
  47920. */
  47921. export class BRDFTextureTools {
  47922. /**
  47923. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  47924. * @param scene defines the hosting scene
  47925. * @returns the environment BRDF texture
  47926. */
  47927. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  47928. private static _environmentBRDFBase64Texture;
  47929. }
  47930. }
  47931. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  47932. import { Nullable } from "babylonjs/types";
  47933. import { Color3 } from "babylonjs/Maths/math.color";
  47934. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47935. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47936. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47937. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47938. import { Engine } from "babylonjs/Engines/engine";
  47939. import { Scene } from "babylonjs/scene";
  47940. /**
  47941. * @hidden
  47942. */
  47943. export interface IMaterialClearCoatDefines {
  47944. CLEARCOAT: boolean;
  47945. CLEARCOAT_DEFAULTIOR: boolean;
  47946. CLEARCOAT_TEXTURE: boolean;
  47947. CLEARCOAT_TEXTUREDIRECTUV: number;
  47948. CLEARCOAT_BUMP: boolean;
  47949. CLEARCOAT_BUMPDIRECTUV: number;
  47950. CLEARCOAT_TINT: boolean;
  47951. CLEARCOAT_TINT_TEXTURE: boolean;
  47952. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47953. /** @hidden */
  47954. _areTexturesDirty: boolean;
  47955. }
  47956. /**
  47957. * Define the code related to the clear coat parameters of the pbr material.
  47958. */
  47959. export class PBRClearCoatConfiguration {
  47960. /**
  47961. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47962. * The default fits with a polyurethane material.
  47963. */
  47964. private static readonly _DefaultIndexOfRefraction;
  47965. private _isEnabled;
  47966. /**
  47967. * Defines if the clear coat is enabled in the material.
  47968. */
  47969. isEnabled: boolean;
  47970. /**
  47971. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  47972. */
  47973. intensity: number;
  47974. /**
  47975. * Defines the clear coat layer roughness.
  47976. */
  47977. roughness: number;
  47978. private _indexOfRefraction;
  47979. /**
  47980. * Defines the index of refraction of the clear coat.
  47981. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  47982. * The default fits with a polyurethane material.
  47983. * Changing the default value is more performance intensive.
  47984. */
  47985. indexOfRefraction: number;
  47986. private _texture;
  47987. /**
  47988. * Stores the clear coat values in a texture.
  47989. */
  47990. texture: Nullable<BaseTexture>;
  47991. private _bumpTexture;
  47992. /**
  47993. * Define the clear coat specific bump texture.
  47994. */
  47995. bumpTexture: Nullable<BaseTexture>;
  47996. private _isTintEnabled;
  47997. /**
  47998. * Defines if the clear coat tint is enabled in the material.
  47999. */
  48000. isTintEnabled: boolean;
  48001. /**
  48002. * Defines the clear coat tint of the material.
  48003. * This is only use if tint is enabled
  48004. */
  48005. tintColor: Color3;
  48006. /**
  48007. * Defines the distance at which the tint color should be found in the
  48008. * clear coat media.
  48009. * This is only use if tint is enabled
  48010. */
  48011. tintColorAtDistance: number;
  48012. /**
  48013. * Defines the clear coat layer thickness.
  48014. * This is only use if tint is enabled
  48015. */
  48016. tintThickness: number;
  48017. private _tintTexture;
  48018. /**
  48019. * Stores the clear tint values in a texture.
  48020. * rgb is tint
  48021. * a is a thickness factor
  48022. */
  48023. tintTexture: Nullable<BaseTexture>;
  48024. /** @hidden */
  48025. private _internalMarkAllSubMeshesAsTexturesDirty;
  48026. /** @hidden */
  48027. _markAllSubMeshesAsTexturesDirty(): void;
  48028. /**
  48029. * Instantiate a new istance of clear coat configuration.
  48030. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48031. */
  48032. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48033. /**
  48034. * Gets wehter the submesh is ready to be used or not.
  48035. * @param defines the list of "defines" to update.
  48036. * @param scene defines the scene the material belongs to.
  48037. * @param engine defines the engine the material belongs to.
  48038. * @param disableBumpMap defines wether the material disables bump or not.
  48039. * @returns - boolean indicating that the submesh is ready or not.
  48040. */
  48041. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48042. /**
  48043. * Checks to see if a texture is used in the material.
  48044. * @param defines the list of "defines" to update.
  48045. * @param scene defines the scene to the material belongs to.
  48046. */
  48047. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48048. /**
  48049. * Binds the material data.
  48050. * @param uniformBuffer defines the Uniform buffer to fill in.
  48051. * @param scene defines the scene the material belongs to.
  48052. * @param engine defines the engine the material belongs to.
  48053. * @param disableBumpMap defines wether the material disables bump or not.
  48054. * @param isFrozen defines wether the material is frozen or not.
  48055. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48056. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48057. */
  48058. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48059. /**
  48060. * Checks to see if a texture is used in the material.
  48061. * @param texture - Base texture to use.
  48062. * @returns - Boolean specifying if a texture is used in the material.
  48063. */
  48064. hasTexture(texture: BaseTexture): boolean;
  48065. /**
  48066. * Returns an array of the actively used textures.
  48067. * @param activeTextures Array of BaseTextures
  48068. */
  48069. getActiveTextures(activeTextures: BaseTexture[]): void;
  48070. /**
  48071. * Returns the animatable textures.
  48072. * @param animatables Array of animatable textures.
  48073. */
  48074. getAnimatables(animatables: IAnimatable[]): void;
  48075. /**
  48076. * Disposes the resources of the material.
  48077. * @param forceDisposeTextures - Forces the disposal of all textures.
  48078. */
  48079. dispose(forceDisposeTextures?: boolean): void;
  48080. /**
  48081. * Get the current class name of the texture useful for serialization or dynamic coding.
  48082. * @returns "PBRClearCoatConfiguration"
  48083. */
  48084. getClassName(): string;
  48085. /**
  48086. * Add fallbacks to the effect fallbacks list.
  48087. * @param defines defines the Base texture to use.
  48088. * @param fallbacks defines the current fallback list.
  48089. * @param currentRank defines the current fallback rank.
  48090. * @returns the new fallback rank.
  48091. */
  48092. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48093. /**
  48094. * Add the required uniforms to the current list.
  48095. * @param uniforms defines the current uniform list.
  48096. */
  48097. static AddUniforms(uniforms: string[]): void;
  48098. /**
  48099. * Add the required samplers to the current list.
  48100. * @param samplers defines the current sampler list.
  48101. */
  48102. static AddSamplers(samplers: string[]): void;
  48103. /**
  48104. * Add the required uniforms to the current buffer.
  48105. * @param uniformBuffer defines the current uniform buffer.
  48106. */
  48107. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48108. /**
  48109. * Makes a duplicate of the current configuration into another one.
  48110. * @param clearCoatConfiguration define the config where to copy the info
  48111. */
  48112. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48113. /**
  48114. * Serializes this clear coat configuration.
  48115. * @returns - An object with the serialized config.
  48116. */
  48117. serialize(): any;
  48118. /**
  48119. * Parses a anisotropy Configuration from a serialized object.
  48120. * @param source - Serialized object.
  48121. * @param scene Defines the scene we are parsing for
  48122. * @param rootUrl Defines the rootUrl to load from
  48123. */
  48124. parse(source: any, scene: Scene, rootUrl: string): void;
  48125. }
  48126. }
  48127. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48128. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48129. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48131. import { Vector2 } from "babylonjs/Maths/math.vector";
  48132. import { Scene } from "babylonjs/scene";
  48133. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48134. import { Nullable } from "babylonjs/types";
  48135. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48136. /**
  48137. * @hidden
  48138. */
  48139. export interface IMaterialAnisotropicDefines {
  48140. ANISOTROPIC: boolean;
  48141. ANISOTROPIC_TEXTURE: boolean;
  48142. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48143. MAINUV1: boolean;
  48144. _areTexturesDirty: boolean;
  48145. _needUVs: boolean;
  48146. }
  48147. /**
  48148. * Define the code related to the anisotropic parameters of the pbr material.
  48149. */
  48150. export class PBRAnisotropicConfiguration {
  48151. private _isEnabled;
  48152. /**
  48153. * Defines if the anisotropy is enabled in the material.
  48154. */
  48155. isEnabled: boolean;
  48156. /**
  48157. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48158. */
  48159. intensity: number;
  48160. /**
  48161. * Defines if the effect is along the tangents, bitangents or in between.
  48162. * By default, the effect is "strectching" the highlights along the tangents.
  48163. */
  48164. direction: Vector2;
  48165. private _texture;
  48166. /**
  48167. * Stores the anisotropy values in a texture.
  48168. * rg is direction (like normal from -1 to 1)
  48169. * b is a intensity
  48170. */
  48171. texture: Nullable<BaseTexture>;
  48172. /** @hidden */
  48173. private _internalMarkAllSubMeshesAsTexturesDirty;
  48174. /** @hidden */
  48175. _markAllSubMeshesAsTexturesDirty(): void;
  48176. /**
  48177. * Instantiate a new istance of anisotropy configuration.
  48178. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48179. */
  48180. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48181. /**
  48182. * Specifies that the submesh is ready to be used.
  48183. * @param defines the list of "defines" to update.
  48184. * @param scene defines the scene the material belongs to.
  48185. * @returns - boolean indicating that the submesh is ready or not.
  48186. */
  48187. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48188. /**
  48189. * Checks to see if a texture is used in the material.
  48190. * @param defines the list of "defines" to update.
  48191. * @param mesh the mesh we are preparing the defines for.
  48192. * @param scene defines the scene the material belongs to.
  48193. */
  48194. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48195. /**
  48196. * Binds the material data.
  48197. * @param uniformBuffer defines the Uniform buffer to fill in.
  48198. * @param scene defines the scene the material belongs to.
  48199. * @param isFrozen defines wether the material is frozen or not.
  48200. */
  48201. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48202. /**
  48203. * Checks to see if a texture is used in the material.
  48204. * @param texture - Base texture to use.
  48205. * @returns - Boolean specifying if a texture is used in the material.
  48206. */
  48207. hasTexture(texture: BaseTexture): boolean;
  48208. /**
  48209. * Returns an array of the actively used textures.
  48210. * @param activeTextures Array of BaseTextures
  48211. */
  48212. getActiveTextures(activeTextures: BaseTexture[]): void;
  48213. /**
  48214. * Returns the animatable textures.
  48215. * @param animatables Array of animatable textures.
  48216. */
  48217. getAnimatables(animatables: IAnimatable[]): void;
  48218. /**
  48219. * Disposes the resources of the material.
  48220. * @param forceDisposeTextures - Forces the disposal of all textures.
  48221. */
  48222. dispose(forceDisposeTextures?: boolean): void;
  48223. /**
  48224. * Get the current class name of the texture useful for serialization or dynamic coding.
  48225. * @returns "PBRAnisotropicConfiguration"
  48226. */
  48227. getClassName(): string;
  48228. /**
  48229. * Add fallbacks to the effect fallbacks list.
  48230. * @param defines defines the Base texture to use.
  48231. * @param fallbacks defines the current fallback list.
  48232. * @param currentRank defines the current fallback rank.
  48233. * @returns the new fallback rank.
  48234. */
  48235. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48236. /**
  48237. * Add the required uniforms to the current list.
  48238. * @param uniforms defines the current uniform list.
  48239. */
  48240. static AddUniforms(uniforms: string[]): void;
  48241. /**
  48242. * Add the required uniforms to the current buffer.
  48243. * @param uniformBuffer defines the current uniform buffer.
  48244. */
  48245. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48246. /**
  48247. * Add the required samplers to the current list.
  48248. * @param samplers defines the current sampler list.
  48249. */
  48250. static AddSamplers(samplers: string[]): void;
  48251. /**
  48252. * Makes a duplicate of the current configuration into another one.
  48253. * @param anisotropicConfiguration define the config where to copy the info
  48254. */
  48255. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48256. /**
  48257. * Serializes this anisotropy configuration.
  48258. * @returns - An object with the serialized config.
  48259. */
  48260. serialize(): any;
  48261. /**
  48262. * Parses a anisotropy Configuration from a serialized object.
  48263. * @param source - Serialized object.
  48264. * @param scene Defines the scene we are parsing for
  48265. * @param rootUrl Defines the rootUrl to load from
  48266. */
  48267. parse(source: any, scene: Scene, rootUrl: string): void;
  48268. }
  48269. }
  48270. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48271. import { Scene } from "babylonjs/scene";
  48272. /**
  48273. * @hidden
  48274. */
  48275. export interface IMaterialBRDFDefines {
  48276. BRDF_V_HEIGHT_CORRELATED: boolean;
  48277. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48278. SPHERICAL_HARMONICS: boolean;
  48279. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48280. /** @hidden */
  48281. _areMiscDirty: boolean;
  48282. }
  48283. /**
  48284. * Define the code related to the BRDF parameters of the pbr material.
  48285. */
  48286. export class PBRBRDFConfiguration {
  48287. /**
  48288. * Default value used for the energy conservation.
  48289. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48290. */
  48291. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48292. /**
  48293. * Default value used for the Smith Visibility Height Correlated mode.
  48294. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48295. */
  48296. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48297. /**
  48298. * Default value used for the IBL diffuse part.
  48299. * This can help switching back to the polynomials mode globally which is a tiny bit
  48300. * less GPU intensive at the drawback of a lower quality.
  48301. */
  48302. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48303. /**
  48304. * Default value used for activating energy conservation for the specular workflow.
  48305. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48306. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48307. */
  48308. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48309. private _useEnergyConservation;
  48310. /**
  48311. * Defines if the material uses energy conservation.
  48312. */
  48313. useEnergyConservation: boolean;
  48314. private _useSmithVisibilityHeightCorrelated;
  48315. /**
  48316. * LEGACY Mode set to false
  48317. * Defines if the material uses height smith correlated visibility term.
  48318. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48319. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48320. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48321. * Not relying on height correlated will also disable energy conservation.
  48322. */
  48323. useSmithVisibilityHeightCorrelated: boolean;
  48324. private _useSphericalHarmonics;
  48325. /**
  48326. * LEGACY Mode set to false
  48327. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48328. * diffuse part of the IBL.
  48329. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48330. * to the ground truth.
  48331. */
  48332. useSphericalHarmonics: boolean;
  48333. private _useSpecularGlossinessInputEnergyConservation;
  48334. /**
  48335. * Defines if the material uses energy conservation, when the specular workflow is active.
  48336. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48337. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48338. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48339. */
  48340. useSpecularGlossinessInputEnergyConservation: boolean;
  48341. /** @hidden */
  48342. private _internalMarkAllSubMeshesAsMiscDirty;
  48343. /** @hidden */
  48344. _markAllSubMeshesAsMiscDirty(): void;
  48345. /**
  48346. * Instantiate a new istance of clear coat configuration.
  48347. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48348. */
  48349. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48350. /**
  48351. * Checks to see if a texture is used in the material.
  48352. * @param defines the list of "defines" to update.
  48353. */
  48354. prepareDefines(defines: IMaterialBRDFDefines): void;
  48355. /**
  48356. * Get the current class name of the texture useful for serialization or dynamic coding.
  48357. * @returns "PBRClearCoatConfiguration"
  48358. */
  48359. getClassName(): string;
  48360. /**
  48361. * Makes a duplicate of the current configuration into another one.
  48362. * @param brdfConfiguration define the config where to copy the info
  48363. */
  48364. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48365. /**
  48366. * Serializes this BRDF configuration.
  48367. * @returns - An object with the serialized config.
  48368. */
  48369. serialize(): any;
  48370. /**
  48371. * Parses a anisotropy Configuration from a serialized object.
  48372. * @param source - Serialized object.
  48373. * @param scene Defines the scene we are parsing for
  48374. * @param rootUrl Defines the rootUrl to load from
  48375. */
  48376. parse(source: any, scene: Scene, rootUrl: string): void;
  48377. }
  48378. }
  48379. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48380. import { EffectFallbacks } from "babylonjs/Materials/effect";
  48381. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48382. import { Color3 } from "babylonjs/Maths/math.color";
  48383. import { Scene } from "babylonjs/scene";
  48384. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48385. import { Nullable } from "babylonjs/types";
  48386. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48387. /**
  48388. * @hidden
  48389. */
  48390. export interface IMaterialSheenDefines {
  48391. SHEEN: boolean;
  48392. SHEEN_TEXTURE: boolean;
  48393. SHEEN_TEXTUREDIRECTUV: number;
  48394. SHEEN_LINKWITHALBEDO: boolean;
  48395. /** @hidden */
  48396. _areTexturesDirty: boolean;
  48397. }
  48398. /**
  48399. * Define the code related to the Sheen parameters of the pbr material.
  48400. */
  48401. export class PBRSheenConfiguration {
  48402. private _isEnabled;
  48403. /**
  48404. * Defines if the material uses sheen.
  48405. */
  48406. isEnabled: boolean;
  48407. private _linkSheenWithAlbedo;
  48408. /**
  48409. * Defines if the sheen is linked to the sheen color.
  48410. */
  48411. linkSheenWithAlbedo: boolean;
  48412. /**
  48413. * Defines the sheen intensity.
  48414. */
  48415. intensity: number;
  48416. /**
  48417. * Defines the sheen color.
  48418. */
  48419. color: Color3;
  48420. private _texture;
  48421. /**
  48422. * Stores the sheen tint values in a texture.
  48423. * rgb is tint
  48424. * a is a intensity
  48425. */
  48426. texture: Nullable<BaseTexture>;
  48427. /** @hidden */
  48428. private _internalMarkAllSubMeshesAsTexturesDirty;
  48429. /** @hidden */
  48430. _markAllSubMeshesAsTexturesDirty(): void;
  48431. /**
  48432. * Instantiate a new istance of clear coat configuration.
  48433. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48434. */
  48435. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48436. /**
  48437. * Specifies that the submesh is ready to be used.
  48438. * @param defines the list of "defines" to update.
  48439. * @param scene defines the scene the material belongs to.
  48440. * @returns - boolean indicating that the submesh is ready or not.
  48441. */
  48442. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48443. /**
  48444. * Checks to see if a texture is used in the material.
  48445. * @param defines the list of "defines" to update.
  48446. * @param scene defines the scene the material belongs to.
  48447. */
  48448. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48449. /**
  48450. * Binds the material data.
  48451. * @param uniformBuffer defines the Uniform buffer to fill in.
  48452. * @param scene defines the scene the material belongs to.
  48453. * @param isFrozen defines wether the material is frozen or not.
  48454. */
  48455. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48456. /**
  48457. * Checks to see if a texture is used in the material.
  48458. * @param texture - Base texture to use.
  48459. * @returns - Boolean specifying if a texture is used in the material.
  48460. */
  48461. hasTexture(texture: BaseTexture): boolean;
  48462. /**
  48463. * Returns an array of the actively used textures.
  48464. * @param activeTextures Array of BaseTextures
  48465. */
  48466. getActiveTextures(activeTextures: BaseTexture[]): void;
  48467. /**
  48468. * Returns the animatable textures.
  48469. * @param animatables Array of animatable textures.
  48470. */
  48471. getAnimatables(animatables: IAnimatable[]): void;
  48472. /**
  48473. * Disposes the resources of the material.
  48474. * @param forceDisposeTextures - Forces the disposal of all textures.
  48475. */
  48476. dispose(forceDisposeTextures?: boolean): void;
  48477. /**
  48478. * Get the current class name of the texture useful for serialization or dynamic coding.
  48479. * @returns "PBRSheenConfiguration"
  48480. */
  48481. getClassName(): string;
  48482. /**
  48483. * Add fallbacks to the effect fallbacks list.
  48484. * @param defines defines the Base texture to use.
  48485. * @param fallbacks defines the current fallback list.
  48486. * @param currentRank defines the current fallback rank.
  48487. * @returns the new fallback rank.
  48488. */
  48489. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48490. /**
  48491. * Add the required uniforms to the current list.
  48492. * @param uniforms defines the current uniform list.
  48493. */
  48494. static AddUniforms(uniforms: string[]): void;
  48495. /**
  48496. * Add the required uniforms to the current buffer.
  48497. * @param uniformBuffer defines the current uniform buffer.
  48498. */
  48499. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48500. /**
  48501. * Add the required samplers to the current list.
  48502. * @param samplers defines the current sampler list.
  48503. */
  48504. static AddSamplers(samplers: string[]): void;
  48505. /**
  48506. * Makes a duplicate of the current configuration into another one.
  48507. * @param sheenConfiguration define the config where to copy the info
  48508. */
  48509. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  48510. /**
  48511. * Serializes this BRDF configuration.
  48512. * @returns - An object with the serialized config.
  48513. */
  48514. serialize(): any;
  48515. /**
  48516. * Parses a anisotropy Configuration from a serialized object.
  48517. * @param source - Serialized object.
  48518. * @param scene Defines the scene we are parsing for
  48519. * @param rootUrl Defines the rootUrl to load from
  48520. */
  48521. parse(source: any, scene: Scene, rootUrl: string): void;
  48522. }
  48523. }
  48524. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  48525. import { Nullable } from "babylonjs/types";
  48526. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48527. import { Color3 } from "babylonjs/Maths/math.color";
  48528. import { SmartArray } from "babylonjs/Misc/smartArray";
  48529. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48530. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48531. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  48532. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48533. import { Engine } from "babylonjs/Engines/engine";
  48534. import { Scene } from "babylonjs/scene";
  48535. /**
  48536. * @hidden
  48537. */
  48538. export interface IMaterialSubSurfaceDefines {
  48539. SUBSURFACE: boolean;
  48540. SS_REFRACTION: boolean;
  48541. SS_TRANSLUCENCY: boolean;
  48542. SS_SCATERRING: boolean;
  48543. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48544. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48545. SS_REFRACTIONMAP_3D: boolean;
  48546. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48547. SS_LODINREFRACTIONALPHA: boolean;
  48548. SS_GAMMAREFRACTION: boolean;
  48549. SS_RGBDREFRACTION: boolean;
  48550. SS_LINEARSPECULARREFRACTION: boolean;
  48551. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48552. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48553. /** @hidden */
  48554. _areTexturesDirty: boolean;
  48555. }
  48556. /**
  48557. * Define the code related to the sub surface parameters of the pbr material.
  48558. */
  48559. export class PBRSubSurfaceConfiguration {
  48560. private _isRefractionEnabled;
  48561. /**
  48562. * Defines if the refraction is enabled in the material.
  48563. */
  48564. isRefractionEnabled: boolean;
  48565. private _isTranslucencyEnabled;
  48566. /**
  48567. * Defines if the translucency is enabled in the material.
  48568. */
  48569. isTranslucencyEnabled: boolean;
  48570. private _isScatteringEnabled;
  48571. /**
  48572. * Defines the refraction intensity of the material.
  48573. * The refraction when enabled replaces the Diffuse part of the material.
  48574. * The intensity helps transitionning between diffuse and refraction.
  48575. */
  48576. refractionIntensity: number;
  48577. /**
  48578. * Defines the translucency intensity of the material.
  48579. * When translucency has been enabled, this defines how much of the "translucency"
  48580. * is addded to the diffuse part of the material.
  48581. */
  48582. translucencyIntensity: number;
  48583. /**
  48584. * Defines the scattering intensity of the material.
  48585. * When scattering has been enabled, this defines how much of the "scattered light"
  48586. * is addded to the diffuse part of the material.
  48587. */
  48588. scatteringIntensity: number;
  48589. private _thicknessTexture;
  48590. /**
  48591. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  48592. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  48593. * 0 would mean minimumThickness
  48594. * 1 would mean maximumThickness
  48595. * The other channels might be use as a mask to vary the different effects intensity.
  48596. */
  48597. thicknessTexture: Nullable<BaseTexture>;
  48598. private _refractionTexture;
  48599. /**
  48600. * Defines the texture to use for refraction.
  48601. */
  48602. refractionTexture: Nullable<BaseTexture>;
  48603. private _indexOfRefraction;
  48604. /**
  48605. * Defines the index of refraction used in the material.
  48606. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  48607. */
  48608. indexOfRefraction: number;
  48609. private _invertRefractionY;
  48610. /**
  48611. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48612. */
  48613. invertRefractionY: boolean;
  48614. private _linkRefractionWithTransparency;
  48615. /**
  48616. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48617. * Materials half opaque for instance using refraction could benefit from this control.
  48618. */
  48619. linkRefractionWithTransparency: boolean;
  48620. /**
  48621. * Defines the minimum thickness stored in the thickness map.
  48622. * If no thickness map is defined, this value will be used to simulate thickness.
  48623. */
  48624. minimumThickness: number;
  48625. /**
  48626. * Defines the maximum thickness stored in the thickness map.
  48627. */
  48628. maximumThickness: number;
  48629. /**
  48630. * Defines the volume tint of the material.
  48631. * This is used for both translucency and scattering.
  48632. */
  48633. tintColor: Color3;
  48634. /**
  48635. * Defines the distance at which the tint color should be found in the media.
  48636. * This is used for refraction only.
  48637. */
  48638. tintColorAtDistance: number;
  48639. /**
  48640. * Defines how far each channel transmit through the media.
  48641. * It is defined as a color to simplify it selection.
  48642. */
  48643. diffusionDistance: Color3;
  48644. private _useMaskFromThicknessTexture;
  48645. /**
  48646. * Stores the intensity of the different subsurface effects in the thickness texture.
  48647. * * the green channel is the translucency intensity.
  48648. * * the blue channel is the scattering intensity.
  48649. * * the alpha channel is the refraction intensity.
  48650. */
  48651. useMaskFromThicknessTexture: boolean;
  48652. /** @hidden */
  48653. private _internalMarkAllSubMeshesAsTexturesDirty;
  48654. /** @hidden */
  48655. _markAllSubMeshesAsTexturesDirty(): void;
  48656. /**
  48657. * Instantiate a new istance of sub surface configuration.
  48658. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48659. */
  48660. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48661. /**
  48662. * Gets wehter the submesh is ready to be used or not.
  48663. * @param defines the list of "defines" to update.
  48664. * @param scene defines the scene the material belongs to.
  48665. * @returns - boolean indicating that the submesh is ready or not.
  48666. */
  48667. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  48668. /**
  48669. * Checks to see if a texture is used in the material.
  48670. * @param defines the list of "defines" to update.
  48671. * @param scene defines the scene to the material belongs to.
  48672. */
  48673. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  48674. /**
  48675. * Binds the material data.
  48676. * @param uniformBuffer defines the Uniform buffer to fill in.
  48677. * @param scene defines the scene the material belongs to.
  48678. * @param engine defines the engine the material belongs to.
  48679. * @param isFrozen defines wether the material is frozen or not.
  48680. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  48681. */
  48682. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  48683. /**
  48684. * Unbinds the material from the mesh.
  48685. * @param activeEffect defines the effect that should be unbound from.
  48686. * @returns true if unbound, otherwise false
  48687. */
  48688. unbind(activeEffect: Effect): boolean;
  48689. /**
  48690. * Returns the texture used for refraction or null if none is used.
  48691. * @param scene defines the scene the material belongs to.
  48692. * @returns - Refraction texture if present. If no refraction texture and refraction
  48693. * is linked with transparency, returns environment texture. Otherwise, returns null.
  48694. */
  48695. private _getRefractionTexture;
  48696. /**
  48697. * Returns true if alpha blending should be disabled.
  48698. */
  48699. readonly disableAlphaBlending: boolean;
  48700. /**
  48701. * Fills the list of render target textures.
  48702. * @param renderTargets the list of render targets to update
  48703. */
  48704. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  48705. /**
  48706. * Checks to see if a texture is used in the material.
  48707. * @param texture - Base texture to use.
  48708. * @returns - Boolean specifying if a texture is used in the material.
  48709. */
  48710. hasTexture(texture: BaseTexture): boolean;
  48711. /**
  48712. * Gets a boolean indicating that current material needs to register RTT
  48713. * @returns true if this uses a render target otherwise false.
  48714. */
  48715. hasRenderTargetTextures(): boolean;
  48716. /**
  48717. * Returns an array of the actively used textures.
  48718. * @param activeTextures Array of BaseTextures
  48719. */
  48720. getActiveTextures(activeTextures: BaseTexture[]): void;
  48721. /**
  48722. * Returns the animatable textures.
  48723. * @param animatables Array of animatable textures.
  48724. */
  48725. getAnimatables(animatables: IAnimatable[]): void;
  48726. /**
  48727. * Disposes the resources of the material.
  48728. * @param forceDisposeTextures - Forces the disposal of all textures.
  48729. */
  48730. dispose(forceDisposeTextures?: boolean): void;
  48731. /**
  48732. * Get the current class name of the texture useful for serialization or dynamic coding.
  48733. * @returns "PBRSubSurfaceConfiguration"
  48734. */
  48735. getClassName(): string;
  48736. /**
  48737. * Add fallbacks to the effect fallbacks list.
  48738. * @param defines defines the Base texture to use.
  48739. * @param fallbacks defines the current fallback list.
  48740. * @param currentRank defines the current fallback rank.
  48741. * @returns the new fallback rank.
  48742. */
  48743. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48744. /**
  48745. * Add the required uniforms to the current list.
  48746. * @param uniforms defines the current uniform list.
  48747. */
  48748. static AddUniforms(uniforms: string[]): void;
  48749. /**
  48750. * Add the required samplers to the current list.
  48751. * @param samplers defines the current sampler list.
  48752. */
  48753. static AddSamplers(samplers: string[]): void;
  48754. /**
  48755. * Add the required uniforms to the current buffer.
  48756. * @param uniformBuffer defines the current uniform buffer.
  48757. */
  48758. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48759. /**
  48760. * Makes a duplicate of the current configuration into another one.
  48761. * @param configuration define the config where to copy the info
  48762. */
  48763. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  48764. /**
  48765. * Serializes this Sub Surface configuration.
  48766. * @returns - An object with the serialized config.
  48767. */
  48768. serialize(): any;
  48769. /**
  48770. * Parses a anisotropy Configuration from a serialized object.
  48771. * @param source - Serialized object.
  48772. * @param scene Defines the scene we are parsing for
  48773. * @param rootUrl Defines the rootUrl to load from
  48774. */
  48775. parse(source: any, scene: Scene, rootUrl: string): void;
  48776. }
  48777. }
  48778. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  48779. /** @hidden */
  48780. export var pbrFragmentDeclaration: {
  48781. name: string;
  48782. shader: string;
  48783. };
  48784. }
  48785. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  48786. /** @hidden */
  48787. export var pbrUboDeclaration: {
  48788. name: string;
  48789. shader: string;
  48790. };
  48791. }
  48792. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  48793. /** @hidden */
  48794. export var pbrFragmentExtraDeclaration: {
  48795. name: string;
  48796. shader: string;
  48797. };
  48798. }
  48799. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  48800. /** @hidden */
  48801. export var pbrFragmentSamplersDeclaration: {
  48802. name: string;
  48803. shader: string;
  48804. };
  48805. }
  48806. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  48807. /** @hidden */
  48808. export var pbrHelperFunctions: {
  48809. name: string;
  48810. shader: string;
  48811. };
  48812. }
  48813. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  48814. /** @hidden */
  48815. export var harmonicsFunctions: {
  48816. name: string;
  48817. shader: string;
  48818. };
  48819. }
  48820. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  48821. /** @hidden */
  48822. export var pbrDirectLightingSetupFunctions: {
  48823. name: string;
  48824. shader: string;
  48825. };
  48826. }
  48827. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  48828. /** @hidden */
  48829. export var pbrDirectLightingFalloffFunctions: {
  48830. name: string;
  48831. shader: string;
  48832. };
  48833. }
  48834. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  48835. /** @hidden */
  48836. export var pbrBRDFFunctions: {
  48837. name: string;
  48838. shader: string;
  48839. };
  48840. }
  48841. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  48842. /** @hidden */
  48843. export var pbrDirectLightingFunctions: {
  48844. name: string;
  48845. shader: string;
  48846. };
  48847. }
  48848. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  48849. /** @hidden */
  48850. export var pbrIBLFunctions: {
  48851. name: string;
  48852. shader: string;
  48853. };
  48854. }
  48855. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  48856. /** @hidden */
  48857. export var pbrDebug: {
  48858. name: string;
  48859. shader: string;
  48860. };
  48861. }
  48862. declare module "babylonjs/Shaders/pbr.fragment" {
  48863. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  48864. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48865. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  48866. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48867. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48868. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  48869. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  48870. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  48871. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48872. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  48873. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48874. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  48875. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  48876. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  48877. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48878. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  48879. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  48880. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  48881. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  48882. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  48883. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  48884. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  48885. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  48886. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  48887. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  48888. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  48889. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  48890. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  48891. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  48892. /** @hidden */
  48893. export var pbrPixelShader: {
  48894. name: string;
  48895. shader: string;
  48896. };
  48897. }
  48898. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  48899. /** @hidden */
  48900. export var pbrVertexDeclaration: {
  48901. name: string;
  48902. shader: string;
  48903. };
  48904. }
  48905. declare module "babylonjs/Shaders/pbr.vertex" {
  48906. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  48907. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  48908. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48909. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48910. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48911. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  48912. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  48913. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  48914. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  48915. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  48916. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  48917. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48918. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48919. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  48920. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48921. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48922. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48923. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  48924. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  48925. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  48926. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  48927. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  48928. /** @hidden */
  48929. export var pbrVertexShader: {
  48930. name: string;
  48931. shader: string;
  48932. };
  48933. }
  48934. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  48935. import { Nullable } from "babylonjs/types";
  48936. import { Scene } from "babylonjs/scene";
  48937. import { Matrix } from "babylonjs/Maths/math.vector";
  48938. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48940. import { Mesh } from "babylonjs/Meshes/mesh";
  48941. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  48942. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  48943. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  48944. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  48945. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  48946. import { Color3 } from "babylonjs/Maths/math.color";
  48947. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  48948. import { Material } from "babylonjs/Materials/material";
  48949. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  48950. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  48951. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48952. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48953. import "babylonjs/Shaders/pbr.fragment";
  48954. import "babylonjs/Shaders/pbr.vertex";
  48955. /**
  48956. * Manages the defines for the PBR Material.
  48957. * @hidden
  48958. */
  48959. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  48960. PBR: boolean;
  48961. MAINUV1: boolean;
  48962. MAINUV2: boolean;
  48963. UV1: boolean;
  48964. UV2: boolean;
  48965. ALBEDO: boolean;
  48966. ALBEDODIRECTUV: number;
  48967. VERTEXCOLOR: boolean;
  48968. AMBIENT: boolean;
  48969. AMBIENTDIRECTUV: number;
  48970. AMBIENTINGRAYSCALE: boolean;
  48971. OPACITY: boolean;
  48972. VERTEXALPHA: boolean;
  48973. OPACITYDIRECTUV: number;
  48974. OPACITYRGB: boolean;
  48975. ALPHATEST: boolean;
  48976. DEPTHPREPASS: boolean;
  48977. ALPHABLEND: boolean;
  48978. ALPHAFROMALBEDO: boolean;
  48979. ALPHATESTVALUE: string;
  48980. SPECULAROVERALPHA: boolean;
  48981. RADIANCEOVERALPHA: boolean;
  48982. ALPHAFRESNEL: boolean;
  48983. LINEARALPHAFRESNEL: boolean;
  48984. PREMULTIPLYALPHA: boolean;
  48985. EMISSIVE: boolean;
  48986. EMISSIVEDIRECTUV: number;
  48987. REFLECTIVITY: boolean;
  48988. REFLECTIVITYDIRECTUV: number;
  48989. SPECULARTERM: boolean;
  48990. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  48991. MICROSURFACEAUTOMATIC: boolean;
  48992. LODBASEDMICROSFURACE: boolean;
  48993. MICROSURFACEMAP: boolean;
  48994. MICROSURFACEMAPDIRECTUV: number;
  48995. METALLICWORKFLOW: boolean;
  48996. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  48997. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  48998. METALLNESSSTOREINMETALMAPBLUE: boolean;
  48999. AOSTOREINMETALMAPRED: boolean;
  49000. ENVIRONMENTBRDF: boolean;
  49001. ENVIRONMENTBRDF_RGBD: boolean;
  49002. NORMAL: boolean;
  49003. TANGENT: boolean;
  49004. BUMP: boolean;
  49005. BUMPDIRECTUV: number;
  49006. OBJECTSPACE_NORMALMAP: boolean;
  49007. PARALLAX: boolean;
  49008. PARALLAXOCCLUSION: boolean;
  49009. NORMALXYSCALE: boolean;
  49010. LIGHTMAP: boolean;
  49011. LIGHTMAPDIRECTUV: number;
  49012. USELIGHTMAPASSHADOWMAP: boolean;
  49013. GAMMALIGHTMAP: boolean;
  49014. RGBDLIGHTMAP: boolean;
  49015. REFLECTION: boolean;
  49016. REFLECTIONMAP_3D: boolean;
  49017. REFLECTIONMAP_SPHERICAL: boolean;
  49018. REFLECTIONMAP_PLANAR: boolean;
  49019. REFLECTIONMAP_CUBIC: boolean;
  49020. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49021. REFLECTIONMAP_PROJECTION: boolean;
  49022. REFLECTIONMAP_SKYBOX: boolean;
  49023. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49024. REFLECTIONMAP_EXPLICIT: boolean;
  49025. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49026. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49027. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49028. INVERTCUBICMAP: boolean;
  49029. USESPHERICALFROMREFLECTIONMAP: boolean;
  49030. USEIRRADIANCEMAP: boolean;
  49031. SPHERICAL_HARMONICS: boolean;
  49032. USESPHERICALINVERTEX: boolean;
  49033. REFLECTIONMAP_OPPOSITEZ: boolean;
  49034. LODINREFLECTIONALPHA: boolean;
  49035. GAMMAREFLECTION: boolean;
  49036. RGBDREFLECTION: boolean;
  49037. LINEARSPECULARREFLECTION: boolean;
  49038. RADIANCEOCCLUSION: boolean;
  49039. HORIZONOCCLUSION: boolean;
  49040. INSTANCES: boolean;
  49041. NUM_BONE_INFLUENCERS: number;
  49042. BonesPerMesh: number;
  49043. BONETEXTURE: boolean;
  49044. NONUNIFORMSCALING: boolean;
  49045. MORPHTARGETS: boolean;
  49046. MORPHTARGETS_NORMAL: boolean;
  49047. MORPHTARGETS_TANGENT: boolean;
  49048. MORPHTARGETS_UV: boolean;
  49049. NUM_MORPH_INFLUENCERS: number;
  49050. IMAGEPROCESSING: boolean;
  49051. VIGNETTE: boolean;
  49052. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49053. VIGNETTEBLENDMODEOPAQUE: boolean;
  49054. TONEMAPPING: boolean;
  49055. TONEMAPPING_ACES: boolean;
  49056. CONTRAST: boolean;
  49057. COLORCURVES: boolean;
  49058. COLORGRADING: boolean;
  49059. COLORGRADING3D: boolean;
  49060. SAMPLER3DGREENDEPTH: boolean;
  49061. SAMPLER3DBGRMAP: boolean;
  49062. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49063. EXPOSURE: boolean;
  49064. MULTIVIEW: boolean;
  49065. USEPHYSICALLIGHTFALLOFF: boolean;
  49066. USEGLTFLIGHTFALLOFF: boolean;
  49067. TWOSIDEDLIGHTING: boolean;
  49068. SHADOWFLOAT: boolean;
  49069. CLIPPLANE: boolean;
  49070. CLIPPLANE2: boolean;
  49071. CLIPPLANE3: boolean;
  49072. CLIPPLANE4: boolean;
  49073. POINTSIZE: boolean;
  49074. FOG: boolean;
  49075. LOGARITHMICDEPTH: boolean;
  49076. FORCENORMALFORWARD: boolean;
  49077. SPECULARAA: boolean;
  49078. CLEARCOAT: boolean;
  49079. CLEARCOAT_DEFAULTIOR: boolean;
  49080. CLEARCOAT_TEXTURE: boolean;
  49081. CLEARCOAT_TEXTUREDIRECTUV: number;
  49082. CLEARCOAT_BUMP: boolean;
  49083. CLEARCOAT_BUMPDIRECTUV: number;
  49084. CLEARCOAT_TINT: boolean;
  49085. CLEARCOAT_TINT_TEXTURE: boolean;
  49086. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49087. ANISOTROPIC: boolean;
  49088. ANISOTROPIC_TEXTURE: boolean;
  49089. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49090. BRDF_V_HEIGHT_CORRELATED: boolean;
  49091. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49092. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49093. SHEEN: boolean;
  49094. SHEEN_TEXTURE: boolean;
  49095. SHEEN_TEXTUREDIRECTUV: number;
  49096. SHEEN_LINKWITHALBEDO: boolean;
  49097. SUBSURFACE: boolean;
  49098. SS_REFRACTION: boolean;
  49099. SS_TRANSLUCENCY: boolean;
  49100. SS_SCATERRING: boolean;
  49101. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49102. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49103. SS_REFRACTIONMAP_3D: boolean;
  49104. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49105. SS_LODINREFRACTIONALPHA: boolean;
  49106. SS_GAMMAREFRACTION: boolean;
  49107. SS_RGBDREFRACTION: boolean;
  49108. SS_LINEARSPECULARREFRACTION: boolean;
  49109. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49110. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49111. UNLIT: boolean;
  49112. DEBUGMODE: number;
  49113. /**
  49114. * Initializes the PBR Material defines.
  49115. */
  49116. constructor();
  49117. /**
  49118. * Resets the PBR Material defines.
  49119. */
  49120. reset(): void;
  49121. }
  49122. /**
  49123. * The Physically based material base class of BJS.
  49124. *
  49125. * This offers the main features of a standard PBR material.
  49126. * For more information, please refer to the documentation :
  49127. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49128. */
  49129. export abstract class PBRBaseMaterial extends PushMaterial {
  49130. /**
  49131. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49132. */
  49133. static readonly PBRMATERIAL_OPAQUE: number;
  49134. /**
  49135. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49136. */
  49137. static readonly PBRMATERIAL_ALPHATEST: number;
  49138. /**
  49139. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49140. */
  49141. static readonly PBRMATERIAL_ALPHABLEND: number;
  49142. /**
  49143. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49144. * They are also discarded below the alpha cutoff threshold to improve performances.
  49145. */
  49146. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49147. /**
  49148. * Defines the default value of how much AO map is occluding the analytical lights
  49149. * (point spot...).
  49150. */
  49151. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49152. /**
  49153. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49154. */
  49155. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49156. /**
  49157. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49158. * to enhance interoperability with other engines.
  49159. */
  49160. static readonly LIGHTFALLOFF_GLTF: number;
  49161. /**
  49162. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49163. * to enhance interoperability with other materials.
  49164. */
  49165. static readonly LIGHTFALLOFF_STANDARD: number;
  49166. /**
  49167. * Intensity of the direct lights e.g. the four lights available in your scene.
  49168. * This impacts both the direct diffuse and specular highlights.
  49169. */
  49170. protected _directIntensity: number;
  49171. /**
  49172. * Intensity of the emissive part of the material.
  49173. * This helps controlling the emissive effect without modifying the emissive color.
  49174. */
  49175. protected _emissiveIntensity: number;
  49176. /**
  49177. * Intensity of the environment e.g. how much the environment will light the object
  49178. * either through harmonics for rough material or through the refelction for shiny ones.
  49179. */
  49180. protected _environmentIntensity: number;
  49181. /**
  49182. * This is a special control allowing the reduction of the specular highlights coming from the
  49183. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49184. */
  49185. protected _specularIntensity: number;
  49186. /**
  49187. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49188. */
  49189. private _lightingInfos;
  49190. /**
  49191. * Debug Control allowing disabling the bump map on this material.
  49192. */
  49193. protected _disableBumpMap: boolean;
  49194. /**
  49195. * AKA Diffuse Texture in standard nomenclature.
  49196. */
  49197. protected _albedoTexture: Nullable<BaseTexture>;
  49198. /**
  49199. * AKA Occlusion Texture in other nomenclature.
  49200. */
  49201. protected _ambientTexture: Nullable<BaseTexture>;
  49202. /**
  49203. * AKA Occlusion Texture Intensity in other nomenclature.
  49204. */
  49205. protected _ambientTextureStrength: number;
  49206. /**
  49207. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49208. * 1 means it completely occludes it
  49209. * 0 mean it has no impact
  49210. */
  49211. protected _ambientTextureImpactOnAnalyticalLights: number;
  49212. /**
  49213. * Stores the alpha values in a texture.
  49214. */
  49215. protected _opacityTexture: Nullable<BaseTexture>;
  49216. /**
  49217. * Stores the reflection values in a texture.
  49218. */
  49219. protected _reflectionTexture: Nullable<BaseTexture>;
  49220. /**
  49221. * Stores the emissive values in a texture.
  49222. */
  49223. protected _emissiveTexture: Nullable<BaseTexture>;
  49224. /**
  49225. * AKA Specular texture in other nomenclature.
  49226. */
  49227. protected _reflectivityTexture: Nullable<BaseTexture>;
  49228. /**
  49229. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49230. */
  49231. protected _metallicTexture: Nullable<BaseTexture>;
  49232. /**
  49233. * Specifies the metallic scalar of the metallic/roughness workflow.
  49234. * Can also be used to scale the metalness values of the metallic texture.
  49235. */
  49236. protected _metallic: Nullable<number>;
  49237. /**
  49238. * Specifies the roughness scalar of the metallic/roughness workflow.
  49239. * Can also be used to scale the roughness values of the metallic texture.
  49240. */
  49241. protected _roughness: Nullable<number>;
  49242. /**
  49243. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49244. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49245. */
  49246. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49247. /**
  49248. * Stores surface normal data used to displace a mesh in a texture.
  49249. */
  49250. protected _bumpTexture: Nullable<BaseTexture>;
  49251. /**
  49252. * Stores the pre-calculated light information of a mesh in a texture.
  49253. */
  49254. protected _lightmapTexture: Nullable<BaseTexture>;
  49255. /**
  49256. * The color of a material in ambient lighting.
  49257. */
  49258. protected _ambientColor: Color3;
  49259. /**
  49260. * AKA Diffuse Color in other nomenclature.
  49261. */
  49262. protected _albedoColor: Color3;
  49263. /**
  49264. * AKA Specular Color in other nomenclature.
  49265. */
  49266. protected _reflectivityColor: Color3;
  49267. /**
  49268. * The color applied when light is reflected from a material.
  49269. */
  49270. protected _reflectionColor: Color3;
  49271. /**
  49272. * The color applied when light is emitted from a material.
  49273. */
  49274. protected _emissiveColor: Color3;
  49275. /**
  49276. * AKA Glossiness in other nomenclature.
  49277. */
  49278. protected _microSurface: number;
  49279. /**
  49280. * Specifies that the material will use the light map as a show map.
  49281. */
  49282. protected _useLightmapAsShadowmap: boolean;
  49283. /**
  49284. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49285. * makes the reflect vector face the model (under horizon).
  49286. */
  49287. protected _useHorizonOcclusion: boolean;
  49288. /**
  49289. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49290. * too much the area relying on ambient texture to define their ambient occlusion.
  49291. */
  49292. protected _useRadianceOcclusion: boolean;
  49293. /**
  49294. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49295. */
  49296. protected _useAlphaFromAlbedoTexture: boolean;
  49297. /**
  49298. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49299. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49300. */
  49301. protected _useSpecularOverAlpha: boolean;
  49302. /**
  49303. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49304. */
  49305. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49306. /**
  49307. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49308. */
  49309. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49310. /**
  49311. * Specifies if the metallic texture contains the roughness information in its green channel.
  49312. */
  49313. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49314. /**
  49315. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49316. */
  49317. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49318. /**
  49319. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49320. */
  49321. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49322. /**
  49323. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49324. */
  49325. protected _useAmbientInGrayScale: boolean;
  49326. /**
  49327. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49328. * The material will try to infer what glossiness each pixel should be.
  49329. */
  49330. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49331. /**
  49332. * Defines the falloff type used in this material.
  49333. * It by default is Physical.
  49334. */
  49335. protected _lightFalloff: number;
  49336. /**
  49337. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49338. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49339. */
  49340. protected _useRadianceOverAlpha: boolean;
  49341. /**
  49342. * Allows using an object space normal map (instead of tangent space).
  49343. */
  49344. protected _useObjectSpaceNormalMap: boolean;
  49345. /**
  49346. * Allows using the bump map in parallax mode.
  49347. */
  49348. protected _useParallax: boolean;
  49349. /**
  49350. * Allows using the bump map in parallax occlusion mode.
  49351. */
  49352. protected _useParallaxOcclusion: boolean;
  49353. /**
  49354. * Controls the scale bias of the parallax mode.
  49355. */
  49356. protected _parallaxScaleBias: number;
  49357. /**
  49358. * If sets to true, disables all the lights affecting the material.
  49359. */
  49360. protected _disableLighting: boolean;
  49361. /**
  49362. * Number of Simultaneous lights allowed on the material.
  49363. */
  49364. protected _maxSimultaneousLights: number;
  49365. /**
  49366. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49367. */
  49368. protected _invertNormalMapX: boolean;
  49369. /**
  49370. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49371. */
  49372. protected _invertNormalMapY: boolean;
  49373. /**
  49374. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49375. */
  49376. protected _twoSidedLighting: boolean;
  49377. /**
  49378. * Defines the alpha limits in alpha test mode.
  49379. */
  49380. protected _alphaCutOff: number;
  49381. /**
  49382. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49383. */
  49384. protected _forceAlphaTest: boolean;
  49385. /**
  49386. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49387. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49388. */
  49389. protected _useAlphaFresnel: boolean;
  49390. /**
  49391. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49392. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49393. */
  49394. protected _useLinearAlphaFresnel: boolean;
  49395. /**
  49396. * The transparency mode of the material.
  49397. */
  49398. protected _transparencyMode: Nullable<number>;
  49399. /**
  49400. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49401. * from cos thetav and roughness:
  49402. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49403. */
  49404. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49405. /**
  49406. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49407. */
  49408. protected _forceIrradianceInFragment: boolean;
  49409. /**
  49410. * Force normal to face away from face.
  49411. */
  49412. protected _forceNormalForward: boolean;
  49413. /**
  49414. * Enables specular anti aliasing in the PBR shader.
  49415. * It will both interacts on the Geometry for analytical and IBL lighting.
  49416. * It also prefilter the roughness map based on the bump values.
  49417. */
  49418. protected _enableSpecularAntiAliasing: boolean;
  49419. /**
  49420. * Default configuration related to image processing available in the PBR Material.
  49421. */
  49422. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49423. /**
  49424. * Keep track of the image processing observer to allow dispose and replace.
  49425. */
  49426. private _imageProcessingObserver;
  49427. /**
  49428. * Attaches a new image processing configuration to the PBR Material.
  49429. * @param configuration
  49430. */
  49431. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49432. /**
  49433. * Stores the available render targets.
  49434. */
  49435. private _renderTargets;
  49436. /**
  49437. * Sets the global ambient color for the material used in lighting calculations.
  49438. */
  49439. private _globalAmbientColor;
  49440. /**
  49441. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49442. */
  49443. private _useLogarithmicDepth;
  49444. /**
  49445. * If set to true, no lighting calculations will be applied.
  49446. */
  49447. private _unlit;
  49448. private _debugMode;
  49449. /**
  49450. * @hidden
  49451. * This is reserved for the inspector.
  49452. * Defines the material debug mode.
  49453. * It helps seeing only some components of the material while troubleshooting.
  49454. */
  49455. debugMode: number;
  49456. /**
  49457. * @hidden
  49458. * This is reserved for the inspector.
  49459. * Specify from where on screen the debug mode should start.
  49460. * The value goes from -1 (full screen) to 1 (not visible)
  49461. * It helps with side by side comparison against the final render
  49462. * This defaults to -1
  49463. */
  49464. private debugLimit;
  49465. /**
  49466. * @hidden
  49467. * This is reserved for the inspector.
  49468. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49469. * You can use the factor to better multiply the final value.
  49470. */
  49471. private debugFactor;
  49472. /**
  49473. * Defines the clear coat layer parameters for the material.
  49474. */
  49475. readonly clearCoat: PBRClearCoatConfiguration;
  49476. /**
  49477. * Defines the anisotropic parameters for the material.
  49478. */
  49479. readonly anisotropy: PBRAnisotropicConfiguration;
  49480. /**
  49481. * Defines the BRDF parameters for the material.
  49482. */
  49483. readonly brdf: PBRBRDFConfiguration;
  49484. /**
  49485. * Defines the Sheen parameters for the material.
  49486. */
  49487. readonly sheen: PBRSheenConfiguration;
  49488. /**
  49489. * Defines the SubSurface parameters for the material.
  49490. */
  49491. readonly subSurface: PBRSubSurfaceConfiguration;
  49492. /**
  49493. * Custom callback helping to override the default shader used in the material.
  49494. */
  49495. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  49496. protected _rebuildInParallel: boolean;
  49497. /**
  49498. * Instantiates a new PBRMaterial instance.
  49499. *
  49500. * @param name The material name
  49501. * @param scene The scene the material will be use in.
  49502. */
  49503. constructor(name: string, scene: Scene);
  49504. /**
  49505. * Gets a boolean indicating that current material needs to register RTT
  49506. */
  49507. readonly hasRenderTargetTextures: boolean;
  49508. /**
  49509. * Gets the name of the material class.
  49510. */
  49511. getClassName(): string;
  49512. /**
  49513. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49514. */
  49515. /**
  49516. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  49517. */
  49518. useLogarithmicDepth: boolean;
  49519. /**
  49520. * Gets the current transparency mode.
  49521. */
  49522. /**
  49523. * Sets the transparency mode of the material.
  49524. *
  49525. * | Value | Type | Description |
  49526. * | ----- | ----------------------------------- | ----------- |
  49527. * | 0 | OPAQUE | |
  49528. * | 1 | ALPHATEST | |
  49529. * | 2 | ALPHABLEND | |
  49530. * | 3 | ALPHATESTANDBLEND | |
  49531. *
  49532. */
  49533. transparencyMode: Nullable<number>;
  49534. /**
  49535. * Returns true if alpha blending should be disabled.
  49536. */
  49537. private readonly _disableAlphaBlending;
  49538. /**
  49539. * Specifies whether or not this material should be rendered in alpha blend mode.
  49540. */
  49541. needAlphaBlending(): boolean;
  49542. /**
  49543. * Specifies if the mesh will require alpha blending.
  49544. * @param mesh - BJS mesh.
  49545. */
  49546. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  49547. /**
  49548. * Specifies whether or not this material should be rendered in alpha test mode.
  49549. */
  49550. needAlphaTesting(): boolean;
  49551. /**
  49552. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  49553. */
  49554. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  49555. /**
  49556. * Gets the texture used for the alpha test.
  49557. */
  49558. getAlphaTestTexture(): Nullable<BaseTexture>;
  49559. /**
  49560. * Specifies that the submesh is ready to be used.
  49561. * @param mesh - BJS mesh.
  49562. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  49563. * @param useInstances - Specifies that instances should be used.
  49564. * @returns - boolean indicating that the submesh is ready or not.
  49565. */
  49566. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49567. /**
  49568. * Specifies if the material uses metallic roughness workflow.
  49569. * @returns boolean specifiying if the material uses metallic roughness workflow.
  49570. */
  49571. isMetallicWorkflow(): boolean;
  49572. private _prepareEffect;
  49573. private _prepareDefines;
  49574. /**
  49575. * Force shader compilation
  49576. */
  49577. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  49578. clipPlane: boolean;
  49579. }>): void;
  49580. /**
  49581. * Initializes the uniform buffer layout for the shader.
  49582. */
  49583. buildUniformLayout(): void;
  49584. /**
  49585. * Unbinds the material from the mesh
  49586. */
  49587. unbind(): void;
  49588. /**
  49589. * Binds the submesh data.
  49590. * @param world - The world matrix.
  49591. * @param mesh - The BJS mesh.
  49592. * @param subMesh - A submesh of the BJS mesh.
  49593. */
  49594. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49595. /**
  49596. * Returns the animatable textures.
  49597. * @returns - Array of animatable textures.
  49598. */
  49599. getAnimatables(): IAnimatable[];
  49600. /**
  49601. * Returns the texture used for reflections.
  49602. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  49603. */
  49604. private _getReflectionTexture;
  49605. /**
  49606. * Returns an array of the actively used textures.
  49607. * @returns - Array of BaseTextures
  49608. */
  49609. getActiveTextures(): BaseTexture[];
  49610. /**
  49611. * Checks to see if a texture is used in the material.
  49612. * @param texture - Base texture to use.
  49613. * @returns - Boolean specifying if a texture is used in the material.
  49614. */
  49615. hasTexture(texture: BaseTexture): boolean;
  49616. /**
  49617. * Disposes the resources of the material.
  49618. * @param forceDisposeEffect - Forces the disposal of effects.
  49619. * @param forceDisposeTextures - Forces the disposal of all textures.
  49620. */
  49621. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49622. }
  49623. }
  49624. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  49625. import { Nullable } from "babylonjs/types";
  49626. import { Scene } from "babylonjs/scene";
  49627. import { Color3 } from "babylonjs/Maths/math.color";
  49628. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  49629. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  49630. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49631. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  49632. /**
  49633. * The Physically based material of BJS.
  49634. *
  49635. * This offers the main features of a standard PBR material.
  49636. * For more information, please refer to the documentation :
  49637. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49638. */
  49639. export class PBRMaterial extends PBRBaseMaterial {
  49640. /**
  49641. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49642. */
  49643. static readonly PBRMATERIAL_OPAQUE: number;
  49644. /**
  49645. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49646. */
  49647. static readonly PBRMATERIAL_ALPHATEST: number;
  49648. /**
  49649. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49650. */
  49651. static readonly PBRMATERIAL_ALPHABLEND: number;
  49652. /**
  49653. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49654. * They are also discarded below the alpha cutoff threshold to improve performances.
  49655. */
  49656. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49657. /**
  49658. * Defines the default value of how much AO map is occluding the analytical lights
  49659. * (point spot...).
  49660. */
  49661. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49662. /**
  49663. * Intensity of the direct lights e.g. the four lights available in your scene.
  49664. * This impacts both the direct diffuse and specular highlights.
  49665. */
  49666. directIntensity: number;
  49667. /**
  49668. * Intensity of the emissive part of the material.
  49669. * This helps controlling the emissive effect without modifying the emissive color.
  49670. */
  49671. emissiveIntensity: number;
  49672. /**
  49673. * Intensity of the environment e.g. how much the environment will light the object
  49674. * either through harmonics for rough material or through the refelction for shiny ones.
  49675. */
  49676. environmentIntensity: number;
  49677. /**
  49678. * This is a special control allowing the reduction of the specular highlights coming from the
  49679. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49680. */
  49681. specularIntensity: number;
  49682. /**
  49683. * Debug Control allowing disabling the bump map on this material.
  49684. */
  49685. disableBumpMap: boolean;
  49686. /**
  49687. * AKA Diffuse Texture in standard nomenclature.
  49688. */
  49689. albedoTexture: BaseTexture;
  49690. /**
  49691. * AKA Occlusion Texture in other nomenclature.
  49692. */
  49693. ambientTexture: BaseTexture;
  49694. /**
  49695. * AKA Occlusion Texture Intensity in other nomenclature.
  49696. */
  49697. ambientTextureStrength: number;
  49698. /**
  49699. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49700. * 1 means it completely occludes it
  49701. * 0 mean it has no impact
  49702. */
  49703. ambientTextureImpactOnAnalyticalLights: number;
  49704. /**
  49705. * Stores the alpha values in a texture.
  49706. */
  49707. opacityTexture: BaseTexture;
  49708. /**
  49709. * Stores the reflection values in a texture.
  49710. */
  49711. reflectionTexture: Nullable<BaseTexture>;
  49712. /**
  49713. * Stores the emissive values in a texture.
  49714. */
  49715. emissiveTexture: BaseTexture;
  49716. /**
  49717. * AKA Specular texture in other nomenclature.
  49718. */
  49719. reflectivityTexture: BaseTexture;
  49720. /**
  49721. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49722. */
  49723. metallicTexture: BaseTexture;
  49724. /**
  49725. * Specifies the metallic scalar of the metallic/roughness workflow.
  49726. * Can also be used to scale the metalness values of the metallic texture.
  49727. */
  49728. metallic: Nullable<number>;
  49729. /**
  49730. * Specifies the roughness scalar of the metallic/roughness workflow.
  49731. * Can also be used to scale the roughness values of the metallic texture.
  49732. */
  49733. roughness: Nullable<number>;
  49734. /**
  49735. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49736. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49737. */
  49738. microSurfaceTexture: BaseTexture;
  49739. /**
  49740. * Stores surface normal data used to displace a mesh in a texture.
  49741. */
  49742. bumpTexture: BaseTexture;
  49743. /**
  49744. * Stores the pre-calculated light information of a mesh in a texture.
  49745. */
  49746. lightmapTexture: BaseTexture;
  49747. /**
  49748. * Stores the refracted light information in a texture.
  49749. */
  49750. refractionTexture: Nullable<BaseTexture>;
  49751. /**
  49752. * The color of a material in ambient lighting.
  49753. */
  49754. ambientColor: Color3;
  49755. /**
  49756. * AKA Diffuse Color in other nomenclature.
  49757. */
  49758. albedoColor: Color3;
  49759. /**
  49760. * AKA Specular Color in other nomenclature.
  49761. */
  49762. reflectivityColor: Color3;
  49763. /**
  49764. * The color reflected from the material.
  49765. */
  49766. reflectionColor: Color3;
  49767. /**
  49768. * The color emitted from the material.
  49769. */
  49770. emissiveColor: Color3;
  49771. /**
  49772. * AKA Glossiness in other nomenclature.
  49773. */
  49774. microSurface: number;
  49775. /**
  49776. * source material index of refraction (IOR)' / 'destination material IOR.
  49777. */
  49778. indexOfRefraction: number;
  49779. /**
  49780. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49781. */
  49782. invertRefractionY: boolean;
  49783. /**
  49784. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49785. * Materials half opaque for instance using refraction could benefit from this control.
  49786. */
  49787. linkRefractionWithTransparency: boolean;
  49788. /**
  49789. * If true, the light map contains occlusion information instead of lighting info.
  49790. */
  49791. useLightmapAsShadowmap: boolean;
  49792. /**
  49793. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49794. */
  49795. useAlphaFromAlbedoTexture: boolean;
  49796. /**
  49797. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49798. */
  49799. forceAlphaTest: boolean;
  49800. /**
  49801. * Defines the alpha limits in alpha test mode.
  49802. */
  49803. alphaCutOff: number;
  49804. /**
  49805. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  49806. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49807. */
  49808. useSpecularOverAlpha: boolean;
  49809. /**
  49810. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49811. */
  49812. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49813. /**
  49814. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49815. */
  49816. useRoughnessFromMetallicTextureAlpha: boolean;
  49817. /**
  49818. * Specifies if the metallic texture contains the roughness information in its green channel.
  49819. */
  49820. useRoughnessFromMetallicTextureGreen: boolean;
  49821. /**
  49822. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49823. */
  49824. useMetallnessFromMetallicTextureBlue: boolean;
  49825. /**
  49826. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49827. */
  49828. useAmbientOcclusionFromMetallicTextureRed: boolean;
  49829. /**
  49830. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49831. */
  49832. useAmbientInGrayScale: boolean;
  49833. /**
  49834. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49835. * The material will try to infer what glossiness each pixel should be.
  49836. */
  49837. useAutoMicroSurfaceFromReflectivityMap: boolean;
  49838. /**
  49839. * BJS is using an harcoded light falloff based on a manually sets up range.
  49840. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49841. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49842. */
  49843. /**
  49844. * BJS is using an harcoded light falloff based on a manually sets up range.
  49845. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  49846. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  49847. */
  49848. usePhysicalLightFalloff: boolean;
  49849. /**
  49850. * In order to support the falloff compatibility with gltf, a special mode has been added
  49851. * to reproduce the gltf light falloff.
  49852. */
  49853. /**
  49854. * In order to support the falloff compatibility with gltf, a special mode has been added
  49855. * to reproduce the gltf light falloff.
  49856. */
  49857. useGLTFLightFalloff: boolean;
  49858. /**
  49859. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49860. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49861. */
  49862. useRadianceOverAlpha: boolean;
  49863. /**
  49864. * Allows using an object space normal map (instead of tangent space).
  49865. */
  49866. useObjectSpaceNormalMap: boolean;
  49867. /**
  49868. * Allows using the bump map in parallax mode.
  49869. */
  49870. useParallax: boolean;
  49871. /**
  49872. * Allows using the bump map in parallax occlusion mode.
  49873. */
  49874. useParallaxOcclusion: boolean;
  49875. /**
  49876. * Controls the scale bias of the parallax mode.
  49877. */
  49878. parallaxScaleBias: number;
  49879. /**
  49880. * If sets to true, disables all the lights affecting the material.
  49881. */
  49882. disableLighting: boolean;
  49883. /**
  49884. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49885. */
  49886. forceIrradianceInFragment: boolean;
  49887. /**
  49888. * Number of Simultaneous lights allowed on the material.
  49889. */
  49890. maxSimultaneousLights: number;
  49891. /**
  49892. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49893. */
  49894. invertNormalMapX: boolean;
  49895. /**
  49896. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49897. */
  49898. invertNormalMapY: boolean;
  49899. /**
  49900. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49901. */
  49902. twoSidedLighting: boolean;
  49903. /**
  49904. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49905. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49906. */
  49907. useAlphaFresnel: boolean;
  49908. /**
  49909. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49910. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49911. */
  49912. useLinearAlphaFresnel: boolean;
  49913. /**
  49914. * Let user defines the brdf lookup texture used for IBL.
  49915. * A default 8bit version is embedded but you could point at :
  49916. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  49917. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  49918. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  49919. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  49920. */
  49921. environmentBRDFTexture: Nullable<BaseTexture>;
  49922. /**
  49923. * Force normal to face away from face.
  49924. */
  49925. forceNormalForward: boolean;
  49926. /**
  49927. * Enables specular anti aliasing in the PBR shader.
  49928. * It will both interacts on the Geometry for analytical and IBL lighting.
  49929. * It also prefilter the roughness map based on the bump values.
  49930. */
  49931. enableSpecularAntiAliasing: boolean;
  49932. /**
  49933. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49934. * makes the reflect vector face the model (under horizon).
  49935. */
  49936. useHorizonOcclusion: boolean;
  49937. /**
  49938. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49939. * too much the area relying on ambient texture to define their ambient occlusion.
  49940. */
  49941. useRadianceOcclusion: boolean;
  49942. /**
  49943. * If set to true, no lighting calculations will be applied.
  49944. */
  49945. unlit: boolean;
  49946. /**
  49947. * Gets the image processing configuration used either in this material.
  49948. */
  49949. /**
  49950. * Sets the Default image processing configuration used either in the this material.
  49951. *
  49952. * If sets to null, the scene one is in use.
  49953. */
  49954. imageProcessingConfiguration: ImageProcessingConfiguration;
  49955. /**
  49956. * Gets wether the color curves effect is enabled.
  49957. */
  49958. /**
  49959. * Sets wether the color curves effect is enabled.
  49960. */
  49961. cameraColorCurvesEnabled: boolean;
  49962. /**
  49963. * Gets wether the color grading effect is enabled.
  49964. */
  49965. /**
  49966. * Gets wether the color grading effect is enabled.
  49967. */
  49968. cameraColorGradingEnabled: boolean;
  49969. /**
  49970. * Gets wether tonemapping is enabled or not.
  49971. */
  49972. /**
  49973. * Sets wether tonemapping is enabled or not
  49974. */
  49975. cameraToneMappingEnabled: boolean;
  49976. /**
  49977. * The camera exposure used on this material.
  49978. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49979. * This corresponds to a photographic exposure.
  49980. */
  49981. /**
  49982. * The camera exposure used on this material.
  49983. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49984. * This corresponds to a photographic exposure.
  49985. */
  49986. cameraExposure: number;
  49987. /**
  49988. * Gets The camera contrast used on this material.
  49989. */
  49990. /**
  49991. * Sets The camera contrast used on this material.
  49992. */
  49993. cameraContrast: number;
  49994. /**
  49995. * Gets the Color Grading 2D Lookup Texture.
  49996. */
  49997. /**
  49998. * Sets the Color Grading 2D Lookup Texture.
  49999. */
  50000. cameraColorGradingTexture: Nullable<BaseTexture>;
  50001. /**
  50002. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50003. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50004. * 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;
  50005. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50006. */
  50007. /**
  50008. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50009. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50010. * 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;
  50011. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50012. */
  50013. cameraColorCurves: Nullable<ColorCurves>;
  50014. /**
  50015. * Instantiates a new PBRMaterial instance.
  50016. *
  50017. * @param name The material name
  50018. * @param scene The scene the material will be use in.
  50019. */
  50020. constructor(name: string, scene: Scene);
  50021. /**
  50022. * Returns the name of this material class.
  50023. */
  50024. getClassName(): string;
  50025. /**
  50026. * Makes a duplicate of the current material.
  50027. * @param name - name to use for the new material.
  50028. */
  50029. clone(name: string): PBRMaterial;
  50030. /**
  50031. * Serializes this PBR Material.
  50032. * @returns - An object with the serialized material.
  50033. */
  50034. serialize(): any;
  50035. /**
  50036. * Parses a PBR Material from a serialized object.
  50037. * @param source - Serialized object.
  50038. * @param scene - BJS scene instance.
  50039. * @param rootUrl - url for the scene object
  50040. * @returns - PBRMaterial
  50041. */
  50042. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50043. }
  50044. }
  50045. declare module "babylonjs/Misc/dds" {
  50046. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50047. import { Engine } from "babylonjs/Engines/engine";
  50048. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50049. import { Nullable } from "babylonjs/types";
  50050. import { Scene } from "babylonjs/scene";
  50051. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50052. /**
  50053. * Direct draw surface info
  50054. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50055. */
  50056. export interface DDSInfo {
  50057. /**
  50058. * Width of the texture
  50059. */
  50060. width: number;
  50061. /**
  50062. * Width of the texture
  50063. */
  50064. height: number;
  50065. /**
  50066. * Number of Mipmaps for the texture
  50067. * @see https://en.wikipedia.org/wiki/Mipmap
  50068. */
  50069. mipmapCount: number;
  50070. /**
  50071. * If the textures format is a known fourCC format
  50072. * @see https://www.fourcc.org/
  50073. */
  50074. isFourCC: boolean;
  50075. /**
  50076. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50077. */
  50078. isRGB: boolean;
  50079. /**
  50080. * If the texture is a lumincance format
  50081. */
  50082. isLuminance: boolean;
  50083. /**
  50084. * If this is a cube texture
  50085. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50086. */
  50087. isCube: boolean;
  50088. /**
  50089. * If the texture is a compressed format eg. FOURCC_DXT1
  50090. */
  50091. isCompressed: boolean;
  50092. /**
  50093. * The dxgiFormat of the texture
  50094. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50095. */
  50096. dxgiFormat: number;
  50097. /**
  50098. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50099. */
  50100. textureType: number;
  50101. /**
  50102. * Sphericle polynomial created for the dds texture
  50103. */
  50104. sphericalPolynomial?: SphericalPolynomial;
  50105. }
  50106. /**
  50107. * Class used to provide DDS decompression tools
  50108. */
  50109. export class DDSTools {
  50110. /**
  50111. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50112. */
  50113. static StoreLODInAlphaChannel: boolean;
  50114. /**
  50115. * Gets DDS information from an array buffer
  50116. * @param arrayBuffer defines the array buffer to read data from
  50117. * @returns the DDS information
  50118. */
  50119. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50120. private static _FloatView;
  50121. private static _Int32View;
  50122. private static _ToHalfFloat;
  50123. private static _FromHalfFloat;
  50124. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50125. private static _GetHalfFloatRGBAArrayBuffer;
  50126. private static _GetFloatRGBAArrayBuffer;
  50127. private static _GetFloatAsUIntRGBAArrayBuffer;
  50128. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50129. private static _GetRGBAArrayBuffer;
  50130. private static _ExtractLongWordOrder;
  50131. private static _GetRGBArrayBuffer;
  50132. private static _GetLuminanceArrayBuffer;
  50133. /**
  50134. * Uploads DDS Levels to a Babylon Texture
  50135. * @hidden
  50136. */
  50137. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50138. }
  50139. module "babylonjs/Engines/engine" {
  50140. interface Engine {
  50141. /**
  50142. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50143. * @param rootUrl defines the url where the file to load is located
  50144. * @param scene defines the current scene
  50145. * @param lodScale defines scale to apply to the mip map selection
  50146. * @param lodOffset defines offset to apply to the mip map selection
  50147. * @param onLoad defines an optional callback raised when the texture is loaded
  50148. * @param onError defines an optional callback raised if there is an issue to load the texture
  50149. * @param format defines the format of the data
  50150. * @param forcedExtension defines the extension to use to pick the right loader
  50151. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50152. * @returns the cube texture as an InternalTexture
  50153. */
  50154. 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;
  50155. }
  50156. }
  50157. }
  50158. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50159. import { Nullable } from "babylonjs/types";
  50160. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50161. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50162. /**
  50163. * Implementation of the DDS Texture Loader.
  50164. * @hidden
  50165. */
  50166. export class _DDSTextureLoader implements IInternalTextureLoader {
  50167. /**
  50168. * Defines wether the loader supports cascade loading the different faces.
  50169. */
  50170. readonly supportCascades: boolean;
  50171. /**
  50172. * This returns if the loader support the current file information.
  50173. * @param extension defines the file extension of the file being loaded
  50174. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50175. * @param fallback defines the fallback internal texture if any
  50176. * @param isBase64 defines whether the texture is encoded as a base64
  50177. * @param isBuffer defines whether the texture data are stored as a buffer
  50178. * @returns true if the loader can load the specified file
  50179. */
  50180. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50181. /**
  50182. * Transform the url before loading if required.
  50183. * @param rootUrl the url of the texture
  50184. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50185. * @returns the transformed texture
  50186. */
  50187. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50188. /**
  50189. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50190. * @param rootUrl the url of the texture
  50191. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50192. * @returns the fallback texture
  50193. */
  50194. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50195. /**
  50196. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50197. * @param data contains the texture data
  50198. * @param texture defines the BabylonJS internal texture
  50199. * @param createPolynomials will be true if polynomials have been requested
  50200. * @param onLoad defines the callback to trigger once the texture is ready
  50201. * @param onError defines the callback to trigger in case of error
  50202. */
  50203. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50204. /**
  50205. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50206. * @param data contains the texture data
  50207. * @param texture defines the BabylonJS internal texture
  50208. * @param callback defines the method to call once ready to upload
  50209. */
  50210. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50211. }
  50212. }
  50213. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50214. import { Nullable } from "babylonjs/types";
  50215. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50216. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50217. /**
  50218. * Implementation of the ENV Texture Loader.
  50219. * @hidden
  50220. */
  50221. export class _ENVTextureLoader implements IInternalTextureLoader {
  50222. /**
  50223. * Defines wether the loader supports cascade loading the different faces.
  50224. */
  50225. readonly supportCascades: boolean;
  50226. /**
  50227. * This returns if the loader support the current file information.
  50228. * @param extension defines the file extension of the file being loaded
  50229. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50230. * @param fallback defines the fallback internal texture if any
  50231. * @param isBase64 defines whether the texture is encoded as a base64
  50232. * @param isBuffer defines whether the texture data are stored as a buffer
  50233. * @returns true if the loader can load the specified file
  50234. */
  50235. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50236. /**
  50237. * Transform the url before loading if required.
  50238. * @param rootUrl the url of the texture
  50239. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50240. * @returns the transformed texture
  50241. */
  50242. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50243. /**
  50244. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50245. * @param rootUrl the url of the texture
  50246. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50247. * @returns the fallback texture
  50248. */
  50249. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50250. /**
  50251. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50252. * @param data contains the texture data
  50253. * @param texture defines the BabylonJS internal texture
  50254. * @param createPolynomials will be true if polynomials have been requested
  50255. * @param onLoad defines the callback to trigger once the texture is ready
  50256. * @param onError defines the callback to trigger in case of error
  50257. */
  50258. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50259. /**
  50260. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50261. * @param data contains the texture data
  50262. * @param texture defines the BabylonJS internal texture
  50263. * @param callback defines the method to call once ready to upload
  50264. */
  50265. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50266. }
  50267. }
  50268. declare module "babylonjs/Misc/khronosTextureContainer" {
  50269. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50270. /**
  50271. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50272. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50273. */
  50274. export class KhronosTextureContainer {
  50275. /** contents of the KTX container file */
  50276. arrayBuffer: any;
  50277. private static HEADER_LEN;
  50278. private static COMPRESSED_2D;
  50279. private static COMPRESSED_3D;
  50280. private static TEX_2D;
  50281. private static TEX_3D;
  50282. /**
  50283. * Gets the openGL type
  50284. */
  50285. glType: number;
  50286. /**
  50287. * Gets the openGL type size
  50288. */
  50289. glTypeSize: number;
  50290. /**
  50291. * Gets the openGL format
  50292. */
  50293. glFormat: number;
  50294. /**
  50295. * Gets the openGL internal format
  50296. */
  50297. glInternalFormat: number;
  50298. /**
  50299. * Gets the base internal format
  50300. */
  50301. glBaseInternalFormat: number;
  50302. /**
  50303. * Gets image width in pixel
  50304. */
  50305. pixelWidth: number;
  50306. /**
  50307. * Gets image height in pixel
  50308. */
  50309. pixelHeight: number;
  50310. /**
  50311. * Gets image depth in pixels
  50312. */
  50313. pixelDepth: number;
  50314. /**
  50315. * Gets the number of array elements
  50316. */
  50317. numberOfArrayElements: number;
  50318. /**
  50319. * Gets the number of faces
  50320. */
  50321. numberOfFaces: number;
  50322. /**
  50323. * Gets the number of mipmap levels
  50324. */
  50325. numberOfMipmapLevels: number;
  50326. /**
  50327. * Gets the bytes of key value data
  50328. */
  50329. bytesOfKeyValueData: number;
  50330. /**
  50331. * Gets the load type
  50332. */
  50333. loadType: number;
  50334. /**
  50335. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50336. */
  50337. isInvalid: boolean;
  50338. /**
  50339. * Creates a new KhronosTextureContainer
  50340. * @param arrayBuffer contents of the KTX container file
  50341. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50342. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50343. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50344. */
  50345. constructor(
  50346. /** contents of the KTX container file */
  50347. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50348. /**
  50349. * Uploads KTX content to a Babylon Texture.
  50350. * It is assumed that the texture has already been created & is currently bound
  50351. * @hidden
  50352. */
  50353. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50354. private _upload2DCompressedLevels;
  50355. }
  50356. }
  50357. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50358. import { Nullable } from "babylonjs/types";
  50359. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50360. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50361. /**
  50362. * Implementation of the KTX Texture Loader.
  50363. * @hidden
  50364. */
  50365. export class _KTXTextureLoader implements IInternalTextureLoader {
  50366. /**
  50367. * Defines wether the loader supports cascade loading the different faces.
  50368. */
  50369. readonly supportCascades: boolean;
  50370. /**
  50371. * This returns if the loader support the current file information.
  50372. * @param extension defines the file extension of the file being loaded
  50373. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50374. * @param fallback defines the fallback internal texture if any
  50375. * @param isBase64 defines whether the texture is encoded as a base64
  50376. * @param isBuffer defines whether the texture data are stored as a buffer
  50377. * @returns true if the loader can load the specified file
  50378. */
  50379. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50380. /**
  50381. * Transform the url before loading if required.
  50382. * @param rootUrl the url of the texture
  50383. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50384. * @returns the transformed texture
  50385. */
  50386. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50387. /**
  50388. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50389. * @param rootUrl the url of the texture
  50390. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50391. * @returns the fallback texture
  50392. */
  50393. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50394. /**
  50395. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50396. * @param data contains the texture data
  50397. * @param texture defines the BabylonJS internal texture
  50398. * @param createPolynomials will be true if polynomials have been requested
  50399. * @param onLoad defines the callback to trigger once the texture is ready
  50400. * @param onError defines the callback to trigger in case of error
  50401. */
  50402. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50403. /**
  50404. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50405. * @param data contains the texture data
  50406. * @param texture defines the BabylonJS internal texture
  50407. * @param callback defines the method to call once ready to upload
  50408. */
  50409. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50410. }
  50411. }
  50412. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50413. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50414. import { Scene } from "babylonjs/scene";
  50415. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50416. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50417. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50418. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50419. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50420. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50422. /**
  50423. * Options for the default xr helper
  50424. */
  50425. export class WebXRDefaultExperienceOptions {
  50426. /**
  50427. * Floor meshes that should be used for teleporting
  50428. */
  50429. floorMeshes: Array<AbstractMesh>;
  50430. }
  50431. /**
  50432. * Default experience which provides a similar setup to the previous webVRExperience
  50433. */
  50434. export class WebXRDefaultExperience {
  50435. /**
  50436. * Base experience
  50437. */
  50438. baseExperience: WebXRExperienceHelper;
  50439. /**
  50440. * Input experience extension
  50441. */
  50442. input: WebXRInput;
  50443. /**
  50444. * Loads the controller models
  50445. */
  50446. controllerModelLoader: WebXRControllerModelLoader;
  50447. /**
  50448. * Enables laser pointer and selection
  50449. */
  50450. pointerSelection: WebXRControllerPointerSelection;
  50451. /**
  50452. * Enables teleportation
  50453. */
  50454. teleportation: WebXRControllerTeleportation;
  50455. /**
  50456. * Enables ui for enetering/exiting xr
  50457. */
  50458. enterExitUI: WebXREnterExitUI;
  50459. /**
  50460. * Default output canvas xr should render to
  50461. */
  50462. outputCanvas: WebXRManagedOutputCanvas;
  50463. /**
  50464. * Creates the default xr experience
  50465. * @param scene scene
  50466. * @param options options for basic configuration
  50467. * @returns resulting WebXRDefaultExperience
  50468. */
  50469. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50470. private constructor();
  50471. /**
  50472. * DIsposes of the experience helper
  50473. */
  50474. dispose(): void;
  50475. }
  50476. }
  50477. declare module "babylonjs/Helpers/sceneHelpers" {
  50478. import { Nullable } from "babylonjs/types";
  50479. import { Mesh } from "babylonjs/Meshes/mesh";
  50480. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50481. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  50482. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  50483. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50484. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50485. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50486. import "babylonjs/Meshes/Builders/boxBuilder";
  50487. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50488. /** @hidden */
  50489. export var _forceSceneHelpersToBundle: boolean;
  50490. module "babylonjs/scene" {
  50491. interface Scene {
  50492. /**
  50493. * Creates a default light for the scene.
  50494. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50495. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  50496. */
  50497. createDefaultLight(replace?: boolean): void;
  50498. /**
  50499. * Creates a default camera for the scene.
  50500. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  50501. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50502. * @param replace has default false, when true replaces the active camera in the scene
  50503. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  50504. */
  50505. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50506. /**
  50507. * Creates a default camera and a default light.
  50508. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  50509. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  50510. * @param replace has the default false, when true replaces the active camera/light in the scene
  50511. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  50512. */
  50513. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  50514. /**
  50515. * Creates a new sky box
  50516. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  50517. * @param environmentTexture defines the texture to use as environment texture
  50518. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  50519. * @param scale defines the overall scale of the skybox
  50520. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  50521. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  50522. * @returns a new mesh holding the sky box
  50523. */
  50524. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  50525. /**
  50526. * Creates a new environment
  50527. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  50528. * @param options defines the options you can use to configure the environment
  50529. * @returns the new EnvironmentHelper
  50530. */
  50531. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  50532. /**
  50533. * Creates a new VREXperienceHelper
  50534. * @see http://doc.babylonjs.com/how_to/webvr_helper
  50535. * @param webVROptions defines the options used to create the new VREXperienceHelper
  50536. * @returns a new VREXperienceHelper
  50537. */
  50538. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  50539. /**
  50540. * Creates a new WebXRDefaultExperience
  50541. * @see http://doc.babylonjs.com/how_to/webxr
  50542. * @param options experience options
  50543. * @returns a promise for a new WebXRDefaultExperience
  50544. */
  50545. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50546. }
  50547. }
  50548. }
  50549. declare module "babylonjs/Helpers/videoDome" {
  50550. import { Scene } from "babylonjs/scene";
  50551. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50552. import { Mesh } from "babylonjs/Meshes/mesh";
  50553. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  50554. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  50555. import "babylonjs/Meshes/Builders/sphereBuilder";
  50556. /**
  50557. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  50558. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  50559. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  50560. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50561. */
  50562. export class VideoDome extends TransformNode {
  50563. /**
  50564. * Define the video source as a Monoscopic panoramic 360 video.
  50565. */
  50566. static readonly MODE_MONOSCOPIC: number;
  50567. /**
  50568. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50569. */
  50570. static readonly MODE_TOPBOTTOM: number;
  50571. /**
  50572. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50573. */
  50574. static readonly MODE_SIDEBYSIDE: number;
  50575. private _halfDome;
  50576. private _useDirectMapping;
  50577. /**
  50578. * The video texture being displayed on the sphere
  50579. */
  50580. protected _videoTexture: VideoTexture;
  50581. /**
  50582. * Gets the video texture being displayed on the sphere
  50583. */
  50584. readonly videoTexture: VideoTexture;
  50585. /**
  50586. * The skybox material
  50587. */
  50588. protected _material: BackgroundMaterial;
  50589. /**
  50590. * The surface used for the skybox
  50591. */
  50592. protected _mesh: Mesh;
  50593. /**
  50594. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  50595. */
  50596. private _halfDomeMask;
  50597. /**
  50598. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50599. * Also see the options.resolution property.
  50600. */
  50601. fovMultiplier: number;
  50602. private _videoMode;
  50603. /**
  50604. * Gets or set the current video mode for the video. It can be:
  50605. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  50606. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  50607. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  50608. */
  50609. videoMode: number;
  50610. /**
  50611. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  50612. *
  50613. */
  50614. /**
  50615. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  50616. */
  50617. halfDome: boolean;
  50618. /**
  50619. * Oberserver used in Stereoscopic VR Mode.
  50620. */
  50621. private _onBeforeCameraRenderObserver;
  50622. /**
  50623. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  50624. * @param name Element's name, child elements will append suffixes for their own names.
  50625. * @param urlsOrVideo defines the url(s) or the video element to use
  50626. * @param options An object containing optional or exposed sub element properties
  50627. */
  50628. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  50629. resolution?: number;
  50630. clickToPlay?: boolean;
  50631. autoPlay?: boolean;
  50632. loop?: boolean;
  50633. size?: number;
  50634. poster?: string;
  50635. faceForward?: boolean;
  50636. useDirectMapping?: boolean;
  50637. halfDomeMode?: boolean;
  50638. }, scene: Scene);
  50639. private _changeVideoMode;
  50640. /**
  50641. * Releases resources associated with this node.
  50642. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50643. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50644. */
  50645. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50646. }
  50647. }
  50648. declare module "babylonjs/Helpers/index" {
  50649. export * from "babylonjs/Helpers/environmentHelper";
  50650. export * from "babylonjs/Helpers/photoDome";
  50651. export * from "babylonjs/Helpers/sceneHelpers";
  50652. export * from "babylonjs/Helpers/videoDome";
  50653. }
  50654. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  50655. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50656. import { IDisposable } from "babylonjs/scene";
  50657. import { Engine } from "babylonjs/Engines/engine";
  50658. /**
  50659. * This class can be used to get instrumentation data from a Babylon engine
  50660. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50661. */
  50662. export class EngineInstrumentation implements IDisposable {
  50663. /**
  50664. * Define the instrumented engine.
  50665. */
  50666. engine: Engine;
  50667. private _captureGPUFrameTime;
  50668. private _gpuFrameTimeToken;
  50669. private _gpuFrameTime;
  50670. private _captureShaderCompilationTime;
  50671. private _shaderCompilationTime;
  50672. private _onBeginFrameObserver;
  50673. private _onEndFrameObserver;
  50674. private _onBeforeShaderCompilationObserver;
  50675. private _onAfterShaderCompilationObserver;
  50676. /**
  50677. * Gets the perf counter used for GPU frame time
  50678. */
  50679. readonly gpuFrameTimeCounter: PerfCounter;
  50680. /**
  50681. * Gets the GPU frame time capture status
  50682. */
  50683. /**
  50684. * Enable or disable the GPU frame time capture
  50685. */
  50686. captureGPUFrameTime: boolean;
  50687. /**
  50688. * Gets the perf counter used for shader compilation time
  50689. */
  50690. readonly shaderCompilationTimeCounter: PerfCounter;
  50691. /**
  50692. * Gets the shader compilation time capture status
  50693. */
  50694. /**
  50695. * Enable or disable the shader compilation time capture
  50696. */
  50697. captureShaderCompilationTime: boolean;
  50698. /**
  50699. * Instantiates a new engine instrumentation.
  50700. * This class can be used to get instrumentation data from a Babylon engine
  50701. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  50702. * @param engine Defines the engine to instrument
  50703. */
  50704. constructor(
  50705. /**
  50706. * Define the instrumented engine.
  50707. */
  50708. engine: Engine);
  50709. /**
  50710. * Dispose and release associated resources.
  50711. */
  50712. dispose(): void;
  50713. }
  50714. }
  50715. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  50716. import { Scene, IDisposable } from "babylonjs/scene";
  50717. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  50718. /**
  50719. * This class can be used to get instrumentation data from a Babylon engine
  50720. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50721. */
  50722. export class SceneInstrumentation implements IDisposable {
  50723. /**
  50724. * Defines the scene to instrument
  50725. */
  50726. scene: Scene;
  50727. private _captureActiveMeshesEvaluationTime;
  50728. private _activeMeshesEvaluationTime;
  50729. private _captureRenderTargetsRenderTime;
  50730. private _renderTargetsRenderTime;
  50731. private _captureFrameTime;
  50732. private _frameTime;
  50733. private _captureRenderTime;
  50734. private _renderTime;
  50735. private _captureInterFrameTime;
  50736. private _interFrameTime;
  50737. private _captureParticlesRenderTime;
  50738. private _particlesRenderTime;
  50739. private _captureSpritesRenderTime;
  50740. private _spritesRenderTime;
  50741. private _capturePhysicsTime;
  50742. private _physicsTime;
  50743. private _captureAnimationsTime;
  50744. private _animationsTime;
  50745. private _captureCameraRenderTime;
  50746. private _cameraRenderTime;
  50747. private _onBeforeActiveMeshesEvaluationObserver;
  50748. private _onAfterActiveMeshesEvaluationObserver;
  50749. private _onBeforeRenderTargetsRenderObserver;
  50750. private _onAfterRenderTargetsRenderObserver;
  50751. private _onAfterRenderObserver;
  50752. private _onBeforeDrawPhaseObserver;
  50753. private _onAfterDrawPhaseObserver;
  50754. private _onBeforeAnimationsObserver;
  50755. private _onBeforeParticlesRenderingObserver;
  50756. private _onAfterParticlesRenderingObserver;
  50757. private _onBeforeSpritesRenderingObserver;
  50758. private _onAfterSpritesRenderingObserver;
  50759. private _onBeforePhysicsObserver;
  50760. private _onAfterPhysicsObserver;
  50761. private _onAfterAnimationsObserver;
  50762. private _onBeforeCameraRenderObserver;
  50763. private _onAfterCameraRenderObserver;
  50764. /**
  50765. * Gets the perf counter used for active meshes evaluation time
  50766. */
  50767. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  50768. /**
  50769. * Gets the active meshes evaluation time capture status
  50770. */
  50771. /**
  50772. * Enable or disable the active meshes evaluation time capture
  50773. */
  50774. captureActiveMeshesEvaluationTime: boolean;
  50775. /**
  50776. * Gets the perf counter used for render targets render time
  50777. */
  50778. readonly renderTargetsRenderTimeCounter: PerfCounter;
  50779. /**
  50780. * Gets the render targets render time capture status
  50781. */
  50782. /**
  50783. * Enable or disable the render targets render time capture
  50784. */
  50785. captureRenderTargetsRenderTime: boolean;
  50786. /**
  50787. * Gets the perf counter used for particles render time
  50788. */
  50789. readonly particlesRenderTimeCounter: PerfCounter;
  50790. /**
  50791. * Gets the particles render time capture status
  50792. */
  50793. /**
  50794. * Enable or disable the particles render time capture
  50795. */
  50796. captureParticlesRenderTime: boolean;
  50797. /**
  50798. * Gets the perf counter used for sprites render time
  50799. */
  50800. readonly spritesRenderTimeCounter: PerfCounter;
  50801. /**
  50802. * Gets the sprites render time capture status
  50803. */
  50804. /**
  50805. * Enable or disable the sprites render time capture
  50806. */
  50807. captureSpritesRenderTime: boolean;
  50808. /**
  50809. * Gets the perf counter used for physics time
  50810. */
  50811. readonly physicsTimeCounter: PerfCounter;
  50812. /**
  50813. * Gets the physics time capture status
  50814. */
  50815. /**
  50816. * Enable or disable the physics time capture
  50817. */
  50818. capturePhysicsTime: boolean;
  50819. /**
  50820. * Gets the perf counter used for animations time
  50821. */
  50822. readonly animationsTimeCounter: PerfCounter;
  50823. /**
  50824. * Gets the animations time capture status
  50825. */
  50826. /**
  50827. * Enable or disable the animations time capture
  50828. */
  50829. captureAnimationsTime: boolean;
  50830. /**
  50831. * Gets the perf counter used for frame time capture
  50832. */
  50833. readonly frameTimeCounter: PerfCounter;
  50834. /**
  50835. * Gets the frame time capture status
  50836. */
  50837. /**
  50838. * Enable or disable the frame time capture
  50839. */
  50840. captureFrameTime: boolean;
  50841. /**
  50842. * Gets the perf counter used for inter-frames time capture
  50843. */
  50844. readonly interFrameTimeCounter: PerfCounter;
  50845. /**
  50846. * Gets the inter-frames time capture status
  50847. */
  50848. /**
  50849. * Enable or disable the inter-frames time capture
  50850. */
  50851. captureInterFrameTime: boolean;
  50852. /**
  50853. * Gets the perf counter used for render time capture
  50854. */
  50855. readonly renderTimeCounter: PerfCounter;
  50856. /**
  50857. * Gets the render time capture status
  50858. */
  50859. /**
  50860. * Enable or disable the render time capture
  50861. */
  50862. captureRenderTime: boolean;
  50863. /**
  50864. * Gets the perf counter used for camera render time capture
  50865. */
  50866. readonly cameraRenderTimeCounter: PerfCounter;
  50867. /**
  50868. * Gets the camera render time capture status
  50869. */
  50870. /**
  50871. * Enable or disable the camera render time capture
  50872. */
  50873. captureCameraRenderTime: boolean;
  50874. /**
  50875. * Gets the perf counter used for draw calls
  50876. */
  50877. readonly drawCallsCounter: PerfCounter;
  50878. /**
  50879. * Instantiates a new scene instrumentation.
  50880. * This class can be used to get instrumentation data from a Babylon engine
  50881. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  50882. * @param scene Defines the scene to instrument
  50883. */
  50884. constructor(
  50885. /**
  50886. * Defines the scene to instrument
  50887. */
  50888. scene: Scene);
  50889. /**
  50890. * Dispose and release associated resources.
  50891. */
  50892. dispose(): void;
  50893. }
  50894. }
  50895. declare module "babylonjs/Instrumentation/index" {
  50896. export * from "babylonjs/Instrumentation/engineInstrumentation";
  50897. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  50898. export * from "babylonjs/Instrumentation/timeToken";
  50899. }
  50900. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  50901. /** @hidden */
  50902. export var glowMapGenerationPixelShader: {
  50903. name: string;
  50904. shader: string;
  50905. };
  50906. }
  50907. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  50908. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50909. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  50910. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  50911. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50912. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  50913. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50914. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50915. /** @hidden */
  50916. export var glowMapGenerationVertexShader: {
  50917. name: string;
  50918. shader: string;
  50919. };
  50920. }
  50921. declare module "babylonjs/Layers/effectLayer" {
  50922. import { Observable } from "babylonjs/Misc/observable";
  50923. import { Nullable } from "babylonjs/types";
  50924. import { Camera } from "babylonjs/Cameras/camera";
  50925. import { Scene } from "babylonjs/scene";
  50926. import { ISize } from "babylonjs/Maths/math.size";
  50927. import { Color4 } from "babylonjs/Maths/math.color";
  50928. import { Engine } from "babylonjs/Engines/engine";
  50929. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50931. import { Mesh } from "babylonjs/Meshes/mesh";
  50932. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  50933. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50934. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50935. import { Effect } from "babylonjs/Materials/effect";
  50936. import { Material } from "babylonjs/Materials/material";
  50937. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50938. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50939. /**
  50940. * Effect layer options. This helps customizing the behaviour
  50941. * of the effect layer.
  50942. */
  50943. export interface IEffectLayerOptions {
  50944. /**
  50945. * Multiplication factor apply to the canvas size to compute the render target size
  50946. * used to generated the objects (the smaller the faster).
  50947. */
  50948. mainTextureRatio: number;
  50949. /**
  50950. * Enforces a fixed size texture to ensure effect stability across devices.
  50951. */
  50952. mainTextureFixedSize?: number;
  50953. /**
  50954. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50955. */
  50956. alphaBlendingMode: number;
  50957. /**
  50958. * The camera attached to the layer.
  50959. */
  50960. camera: Nullable<Camera>;
  50961. /**
  50962. * The rendering group to draw the layer in.
  50963. */
  50964. renderingGroupId: number;
  50965. }
  50966. /**
  50967. * The effect layer Helps adding post process effect blended with the main pass.
  50968. *
  50969. * This can be for instance use to generate glow or higlight effects on the scene.
  50970. *
  50971. * The effect layer class can not be used directly and is intented to inherited from to be
  50972. * customized per effects.
  50973. */
  50974. export abstract class EffectLayer {
  50975. private _vertexBuffers;
  50976. private _indexBuffer;
  50977. private _cachedDefines;
  50978. private _effectLayerMapGenerationEffect;
  50979. private _effectLayerOptions;
  50980. private _mergeEffect;
  50981. protected _scene: Scene;
  50982. protected _engine: Engine;
  50983. protected _maxSize: number;
  50984. protected _mainTextureDesiredSize: ISize;
  50985. protected _mainTexture: RenderTargetTexture;
  50986. protected _shouldRender: boolean;
  50987. protected _postProcesses: PostProcess[];
  50988. protected _textures: BaseTexture[];
  50989. protected _emissiveTextureAndColor: {
  50990. texture: Nullable<BaseTexture>;
  50991. color: Color4;
  50992. };
  50993. /**
  50994. * The name of the layer
  50995. */
  50996. name: string;
  50997. /**
  50998. * The clear color of the texture used to generate the glow map.
  50999. */
  51000. neutralColor: Color4;
  51001. /**
  51002. * Specifies wether the highlight layer is enabled or not.
  51003. */
  51004. isEnabled: boolean;
  51005. /**
  51006. * Gets the camera attached to the layer.
  51007. */
  51008. readonly camera: Nullable<Camera>;
  51009. /**
  51010. * Gets the rendering group id the layer should render in.
  51011. */
  51012. renderingGroupId: number;
  51013. /**
  51014. * An event triggered when the effect layer has been disposed.
  51015. */
  51016. onDisposeObservable: Observable<EffectLayer>;
  51017. /**
  51018. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51019. */
  51020. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51021. /**
  51022. * An event triggered when the generated texture is being merged in the scene.
  51023. */
  51024. onBeforeComposeObservable: Observable<EffectLayer>;
  51025. /**
  51026. * An event triggered when the generated texture has been merged in the scene.
  51027. */
  51028. onAfterComposeObservable: Observable<EffectLayer>;
  51029. /**
  51030. * An event triggered when the efffect layer changes its size.
  51031. */
  51032. onSizeChangedObservable: Observable<EffectLayer>;
  51033. /** @hidden */
  51034. static _SceneComponentInitialization: (scene: Scene) => void;
  51035. /**
  51036. * Instantiates a new effect Layer and references it in the scene.
  51037. * @param name The name of the layer
  51038. * @param scene The scene to use the layer in
  51039. */
  51040. constructor(
  51041. /** The Friendly of the effect in the scene */
  51042. name: string, scene: Scene);
  51043. /**
  51044. * Get the effect name of the layer.
  51045. * @return The effect name
  51046. */
  51047. abstract getEffectName(): string;
  51048. /**
  51049. * Checks for the readiness of the element composing the layer.
  51050. * @param subMesh the mesh to check for
  51051. * @param useInstances specify wether or not to use instances to render the mesh
  51052. * @return true if ready otherwise, false
  51053. */
  51054. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51055. /**
  51056. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51057. * @returns true if the effect requires stencil during the main canvas render pass.
  51058. */
  51059. abstract needStencil(): boolean;
  51060. /**
  51061. * Create the merge effect. This is the shader use to blit the information back
  51062. * to the main canvas at the end of the scene rendering.
  51063. * @returns The effect containing the shader used to merge the effect on the main canvas
  51064. */
  51065. protected abstract _createMergeEffect(): Effect;
  51066. /**
  51067. * Creates the render target textures and post processes used in the effect layer.
  51068. */
  51069. protected abstract _createTextureAndPostProcesses(): void;
  51070. /**
  51071. * Implementation specific of rendering the generating effect on the main canvas.
  51072. * @param effect The effect used to render through
  51073. */
  51074. protected abstract _internalRender(effect: Effect): void;
  51075. /**
  51076. * Sets the required values for both the emissive texture and and the main color.
  51077. */
  51078. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51079. /**
  51080. * Free any resources and references associated to a mesh.
  51081. * Internal use
  51082. * @param mesh The mesh to free.
  51083. */
  51084. abstract _disposeMesh(mesh: Mesh): void;
  51085. /**
  51086. * Serializes this layer (Glow or Highlight for example)
  51087. * @returns a serialized layer object
  51088. */
  51089. abstract serialize?(): any;
  51090. /**
  51091. * Initializes the effect layer with the required options.
  51092. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51093. */
  51094. protected _init(options: Partial<IEffectLayerOptions>): void;
  51095. /**
  51096. * Generates the index buffer of the full screen quad blending to the main canvas.
  51097. */
  51098. private _generateIndexBuffer;
  51099. /**
  51100. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51101. */
  51102. private _generateVertexBuffer;
  51103. /**
  51104. * Sets the main texture desired size which is the closest power of two
  51105. * of the engine canvas size.
  51106. */
  51107. private _setMainTextureSize;
  51108. /**
  51109. * Creates the main texture for the effect layer.
  51110. */
  51111. protected _createMainTexture(): void;
  51112. /**
  51113. * Adds specific effects defines.
  51114. * @param defines The defines to add specifics to.
  51115. */
  51116. protected _addCustomEffectDefines(defines: string[]): void;
  51117. /**
  51118. * Checks for the readiness of the element composing the layer.
  51119. * @param subMesh the mesh to check for
  51120. * @param useInstances specify wether or not to use instances to render the mesh
  51121. * @param emissiveTexture the associated emissive texture used to generate the glow
  51122. * @return true if ready otherwise, false
  51123. */
  51124. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51125. /**
  51126. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51127. */
  51128. render(): void;
  51129. /**
  51130. * Determine if a given mesh will be used in the current effect.
  51131. * @param mesh mesh to test
  51132. * @returns true if the mesh will be used
  51133. */
  51134. hasMesh(mesh: AbstractMesh): boolean;
  51135. /**
  51136. * Returns true if the layer contains information to display, otherwise false.
  51137. * @returns true if the glow layer should be rendered
  51138. */
  51139. shouldRender(): boolean;
  51140. /**
  51141. * Returns true if the mesh should render, otherwise false.
  51142. * @param mesh The mesh to render
  51143. * @returns true if it should render otherwise false
  51144. */
  51145. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51146. /**
  51147. * Returns true if the mesh can be rendered, otherwise false.
  51148. * @param mesh The mesh to render
  51149. * @param material The material used on the mesh
  51150. * @returns true if it can be rendered otherwise false
  51151. */
  51152. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51153. /**
  51154. * Returns true if the mesh should render, otherwise false.
  51155. * @param mesh The mesh to render
  51156. * @returns true if it should render otherwise false
  51157. */
  51158. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51159. /**
  51160. * Renders the submesh passed in parameter to the generation map.
  51161. */
  51162. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51163. /**
  51164. * Rebuild the required buffers.
  51165. * @hidden Internal use only.
  51166. */
  51167. _rebuild(): void;
  51168. /**
  51169. * Dispose only the render target textures and post process.
  51170. */
  51171. private _disposeTextureAndPostProcesses;
  51172. /**
  51173. * Dispose the highlight layer and free resources.
  51174. */
  51175. dispose(): void;
  51176. /**
  51177. * Gets the class name of the effect layer
  51178. * @returns the string with the class name of the effect layer
  51179. */
  51180. getClassName(): string;
  51181. /**
  51182. * Creates an effect layer from parsed effect layer data
  51183. * @param parsedEffectLayer defines effect layer data
  51184. * @param scene defines the current scene
  51185. * @param rootUrl defines the root URL containing the effect layer information
  51186. * @returns a parsed effect Layer
  51187. */
  51188. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51189. }
  51190. }
  51191. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51192. import { Scene } from "babylonjs/scene";
  51193. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51194. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51195. import { AbstractScene } from "babylonjs/abstractScene";
  51196. module "babylonjs/abstractScene" {
  51197. interface AbstractScene {
  51198. /**
  51199. * The list of effect layers (highlights/glow) added to the scene
  51200. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51201. * @see http://doc.babylonjs.com/how_to/glow_layer
  51202. */
  51203. effectLayers: Array<EffectLayer>;
  51204. /**
  51205. * Removes the given effect layer from this scene.
  51206. * @param toRemove defines the effect layer to remove
  51207. * @returns the index of the removed effect layer
  51208. */
  51209. removeEffectLayer(toRemove: EffectLayer): number;
  51210. /**
  51211. * Adds the given effect layer to this scene
  51212. * @param newEffectLayer defines the effect layer to add
  51213. */
  51214. addEffectLayer(newEffectLayer: EffectLayer): void;
  51215. }
  51216. }
  51217. /**
  51218. * Defines the layer scene component responsible to manage any effect layers
  51219. * in a given scene.
  51220. */
  51221. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51222. /**
  51223. * The component name helpfull to identify the component in the list of scene components.
  51224. */
  51225. readonly name: string;
  51226. /**
  51227. * The scene the component belongs to.
  51228. */
  51229. scene: Scene;
  51230. private _engine;
  51231. private _renderEffects;
  51232. private _needStencil;
  51233. private _previousStencilState;
  51234. /**
  51235. * Creates a new instance of the component for the given scene
  51236. * @param scene Defines the scene to register the component in
  51237. */
  51238. constructor(scene: Scene);
  51239. /**
  51240. * Registers the component in a given scene
  51241. */
  51242. register(): void;
  51243. /**
  51244. * Rebuilds the elements related to this component in case of
  51245. * context lost for instance.
  51246. */
  51247. rebuild(): void;
  51248. /**
  51249. * Serializes the component data to the specified json object
  51250. * @param serializationObject The object to serialize to
  51251. */
  51252. serialize(serializationObject: any): void;
  51253. /**
  51254. * Adds all the elements from the container to the scene
  51255. * @param container the container holding the elements
  51256. */
  51257. addFromContainer(container: AbstractScene): void;
  51258. /**
  51259. * Removes all the elements in the container from the scene
  51260. * @param container contains the elements to remove
  51261. * @param dispose if the removed element should be disposed (default: false)
  51262. */
  51263. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51264. /**
  51265. * Disposes the component and the associated ressources.
  51266. */
  51267. dispose(): void;
  51268. private _isReadyForMesh;
  51269. private _renderMainTexture;
  51270. private _setStencil;
  51271. private _setStencilBack;
  51272. private _draw;
  51273. private _drawCamera;
  51274. private _drawRenderingGroup;
  51275. }
  51276. }
  51277. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51278. /** @hidden */
  51279. export var glowMapMergePixelShader: {
  51280. name: string;
  51281. shader: string;
  51282. };
  51283. }
  51284. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51285. /** @hidden */
  51286. export var glowMapMergeVertexShader: {
  51287. name: string;
  51288. shader: string;
  51289. };
  51290. }
  51291. declare module "babylonjs/Layers/glowLayer" {
  51292. import { Nullable } from "babylonjs/types";
  51293. import { Camera } from "babylonjs/Cameras/camera";
  51294. import { Scene } from "babylonjs/scene";
  51295. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51296. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51297. import { Mesh } from "babylonjs/Meshes/mesh";
  51298. import { Texture } from "babylonjs/Materials/Textures/texture";
  51299. import { Effect } from "babylonjs/Materials/effect";
  51300. import { Material } from "babylonjs/Materials/material";
  51301. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51302. import { Color4 } from "babylonjs/Maths/math.color";
  51303. import "babylonjs/Shaders/glowMapMerge.fragment";
  51304. import "babylonjs/Shaders/glowMapMerge.vertex";
  51305. import "babylonjs/Layers/effectLayerSceneComponent";
  51306. module "babylonjs/abstractScene" {
  51307. interface AbstractScene {
  51308. /**
  51309. * Return a the first highlight layer of the scene with a given name.
  51310. * @param name The name of the highlight layer to look for.
  51311. * @return The highlight layer if found otherwise null.
  51312. */
  51313. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51314. }
  51315. }
  51316. /**
  51317. * Glow layer options. This helps customizing the behaviour
  51318. * of the glow layer.
  51319. */
  51320. export interface IGlowLayerOptions {
  51321. /**
  51322. * Multiplication factor apply to the canvas size to compute the render target size
  51323. * used to generated the glowing objects (the smaller the faster).
  51324. */
  51325. mainTextureRatio: number;
  51326. /**
  51327. * Enforces a fixed size texture to ensure resize independant blur.
  51328. */
  51329. mainTextureFixedSize?: number;
  51330. /**
  51331. * How big is the kernel of the blur texture.
  51332. */
  51333. blurKernelSize: number;
  51334. /**
  51335. * The camera attached to the layer.
  51336. */
  51337. camera: Nullable<Camera>;
  51338. /**
  51339. * Enable MSAA by chosing the number of samples.
  51340. */
  51341. mainTextureSamples?: number;
  51342. /**
  51343. * The rendering group to draw the layer in.
  51344. */
  51345. renderingGroupId: number;
  51346. }
  51347. /**
  51348. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51349. *
  51350. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51351. * glowy meshes to your scene.
  51352. *
  51353. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51354. */
  51355. export class GlowLayer extends EffectLayer {
  51356. /**
  51357. * Effect Name of the layer.
  51358. */
  51359. static readonly EffectName: string;
  51360. /**
  51361. * The default blur kernel size used for the glow.
  51362. */
  51363. static DefaultBlurKernelSize: number;
  51364. /**
  51365. * The default texture size ratio used for the glow.
  51366. */
  51367. static DefaultTextureRatio: number;
  51368. /**
  51369. * Sets the kernel size of the blur.
  51370. */
  51371. /**
  51372. * Gets the kernel size of the blur.
  51373. */
  51374. blurKernelSize: number;
  51375. /**
  51376. * Sets the glow intensity.
  51377. */
  51378. /**
  51379. * Gets the glow intensity.
  51380. */
  51381. intensity: number;
  51382. private _options;
  51383. private _intensity;
  51384. private _horizontalBlurPostprocess1;
  51385. private _verticalBlurPostprocess1;
  51386. private _horizontalBlurPostprocess2;
  51387. private _verticalBlurPostprocess2;
  51388. private _blurTexture1;
  51389. private _blurTexture2;
  51390. private _postProcesses1;
  51391. private _postProcesses2;
  51392. private _includedOnlyMeshes;
  51393. private _excludedMeshes;
  51394. /**
  51395. * Callback used to let the user override the color selection on a per mesh basis
  51396. */
  51397. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51398. /**
  51399. * Callback used to let the user override the texture selection on a per mesh basis
  51400. */
  51401. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51402. /**
  51403. * Instantiates a new glow Layer and references it to the scene.
  51404. * @param name The name of the layer
  51405. * @param scene The scene to use the layer in
  51406. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51407. */
  51408. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51409. /**
  51410. * Get the effect name of the layer.
  51411. * @return The effect name
  51412. */
  51413. getEffectName(): string;
  51414. /**
  51415. * Create the merge effect. This is the shader use to blit the information back
  51416. * to the main canvas at the end of the scene rendering.
  51417. */
  51418. protected _createMergeEffect(): Effect;
  51419. /**
  51420. * Creates the render target textures and post processes used in the glow layer.
  51421. */
  51422. protected _createTextureAndPostProcesses(): void;
  51423. /**
  51424. * Checks for the readiness of the element composing the layer.
  51425. * @param subMesh the mesh to check for
  51426. * @param useInstances specify wether or not to use instances to render the mesh
  51427. * @param emissiveTexture the associated emissive texture used to generate the glow
  51428. * @return true if ready otherwise, false
  51429. */
  51430. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51431. /**
  51432. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51433. */
  51434. needStencil(): boolean;
  51435. /**
  51436. * Returns true if the mesh can be rendered, otherwise false.
  51437. * @param mesh The mesh to render
  51438. * @param material The material used on the mesh
  51439. * @returns true if it can be rendered otherwise false
  51440. */
  51441. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51442. /**
  51443. * Implementation specific of rendering the generating effect on the main canvas.
  51444. * @param effect The effect used to render through
  51445. */
  51446. protected _internalRender(effect: Effect): void;
  51447. /**
  51448. * Sets the required values for both the emissive texture and and the main color.
  51449. */
  51450. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51451. /**
  51452. * Returns true if the mesh should render, otherwise false.
  51453. * @param mesh The mesh to render
  51454. * @returns true if it should render otherwise false
  51455. */
  51456. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51457. /**
  51458. * Adds specific effects defines.
  51459. * @param defines The defines to add specifics to.
  51460. */
  51461. protected _addCustomEffectDefines(defines: string[]): void;
  51462. /**
  51463. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51464. * @param mesh The mesh to exclude from the glow layer
  51465. */
  51466. addExcludedMesh(mesh: Mesh): void;
  51467. /**
  51468. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51469. * @param mesh The mesh to remove
  51470. */
  51471. removeExcludedMesh(mesh: Mesh): void;
  51472. /**
  51473. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51474. * @param mesh The mesh to include in the glow layer
  51475. */
  51476. addIncludedOnlyMesh(mesh: Mesh): void;
  51477. /**
  51478. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51479. * @param mesh The mesh to remove
  51480. */
  51481. removeIncludedOnlyMesh(mesh: Mesh): void;
  51482. /**
  51483. * Determine if a given mesh will be used in the glow layer
  51484. * @param mesh The mesh to test
  51485. * @returns true if the mesh will be highlighted by the current glow layer
  51486. */
  51487. hasMesh(mesh: AbstractMesh): boolean;
  51488. /**
  51489. * Free any resources and references associated to a mesh.
  51490. * Internal use
  51491. * @param mesh The mesh to free.
  51492. * @hidden
  51493. */
  51494. _disposeMesh(mesh: Mesh): void;
  51495. /**
  51496. * Gets the class name of the effect layer
  51497. * @returns the string with the class name of the effect layer
  51498. */
  51499. getClassName(): string;
  51500. /**
  51501. * Serializes this glow layer
  51502. * @returns a serialized glow layer object
  51503. */
  51504. serialize(): any;
  51505. /**
  51506. * Creates a Glow Layer from parsed glow layer data
  51507. * @param parsedGlowLayer defines glow layer data
  51508. * @param scene defines the current scene
  51509. * @param rootUrl defines the root URL containing the glow layer information
  51510. * @returns a parsed Glow Layer
  51511. */
  51512. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  51513. }
  51514. }
  51515. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  51516. /** @hidden */
  51517. export var glowBlurPostProcessPixelShader: {
  51518. name: string;
  51519. shader: string;
  51520. };
  51521. }
  51522. declare module "babylonjs/Layers/highlightLayer" {
  51523. import { Observable } from "babylonjs/Misc/observable";
  51524. import { Nullable } from "babylonjs/types";
  51525. import { Camera } from "babylonjs/Cameras/camera";
  51526. import { Scene } from "babylonjs/scene";
  51527. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51528. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51529. import { Mesh } from "babylonjs/Meshes/mesh";
  51530. import { Effect } from "babylonjs/Materials/effect";
  51531. import { Material } from "babylonjs/Materials/material";
  51532. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51533. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  51534. import "babylonjs/Shaders/glowMapMerge.fragment";
  51535. import "babylonjs/Shaders/glowMapMerge.vertex";
  51536. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  51537. module "babylonjs/abstractScene" {
  51538. interface AbstractScene {
  51539. /**
  51540. * Return a the first highlight layer of the scene with a given name.
  51541. * @param name The name of the highlight layer to look for.
  51542. * @return The highlight layer if found otherwise null.
  51543. */
  51544. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  51545. }
  51546. }
  51547. /**
  51548. * Highlight layer options. This helps customizing the behaviour
  51549. * of the highlight layer.
  51550. */
  51551. export interface IHighlightLayerOptions {
  51552. /**
  51553. * Multiplication factor apply to the canvas size to compute the render target size
  51554. * used to generated the glowing objects (the smaller the faster).
  51555. */
  51556. mainTextureRatio: number;
  51557. /**
  51558. * Enforces a fixed size texture to ensure resize independant blur.
  51559. */
  51560. mainTextureFixedSize?: number;
  51561. /**
  51562. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  51563. * of the picture to blur (the smaller the faster).
  51564. */
  51565. blurTextureSizeRatio: number;
  51566. /**
  51567. * How big in texel of the blur texture is the vertical blur.
  51568. */
  51569. blurVerticalSize: number;
  51570. /**
  51571. * How big in texel of the blur texture is the horizontal blur.
  51572. */
  51573. blurHorizontalSize: number;
  51574. /**
  51575. * Alpha blending mode used to apply the blur. Default is combine.
  51576. */
  51577. alphaBlendingMode: number;
  51578. /**
  51579. * The camera attached to the layer.
  51580. */
  51581. camera: Nullable<Camera>;
  51582. /**
  51583. * Should we display highlight as a solid stroke?
  51584. */
  51585. isStroke?: boolean;
  51586. /**
  51587. * The rendering group to draw the layer in.
  51588. */
  51589. renderingGroupId: number;
  51590. }
  51591. /**
  51592. * The highlight layer Helps adding a glow effect around a mesh.
  51593. *
  51594. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51595. * glowy meshes to your scene.
  51596. *
  51597. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  51598. */
  51599. export class HighlightLayer extends EffectLayer {
  51600. name: string;
  51601. /**
  51602. * Effect Name of the highlight layer.
  51603. */
  51604. static readonly EffectName: string;
  51605. /**
  51606. * The neutral color used during the preparation of the glow effect.
  51607. * This is black by default as the blend operation is a blend operation.
  51608. */
  51609. static NeutralColor: Color4;
  51610. /**
  51611. * Stencil value used for glowing meshes.
  51612. */
  51613. static GlowingMeshStencilReference: number;
  51614. /**
  51615. * Stencil value used for the other meshes in the scene.
  51616. */
  51617. static NormalMeshStencilReference: number;
  51618. /**
  51619. * Specifies whether or not the inner glow is ACTIVE in the layer.
  51620. */
  51621. innerGlow: boolean;
  51622. /**
  51623. * Specifies whether or not the outer glow is ACTIVE in the layer.
  51624. */
  51625. outerGlow: boolean;
  51626. /**
  51627. * Specifies the horizontal size of the blur.
  51628. */
  51629. /**
  51630. * Gets the horizontal size of the blur.
  51631. */
  51632. blurHorizontalSize: number;
  51633. /**
  51634. * Specifies the vertical size of the blur.
  51635. */
  51636. /**
  51637. * Gets the vertical size of the blur.
  51638. */
  51639. blurVerticalSize: number;
  51640. /**
  51641. * An event triggered when the highlight layer is being blurred.
  51642. */
  51643. onBeforeBlurObservable: Observable<HighlightLayer>;
  51644. /**
  51645. * An event triggered when the highlight layer has been blurred.
  51646. */
  51647. onAfterBlurObservable: Observable<HighlightLayer>;
  51648. private _instanceGlowingMeshStencilReference;
  51649. private _options;
  51650. private _downSamplePostprocess;
  51651. private _horizontalBlurPostprocess;
  51652. private _verticalBlurPostprocess;
  51653. private _blurTexture;
  51654. private _meshes;
  51655. private _excludedMeshes;
  51656. /**
  51657. * Instantiates a new highlight Layer and references it to the scene..
  51658. * @param name The name of the layer
  51659. * @param scene The scene to use the layer in
  51660. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  51661. */
  51662. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  51663. /**
  51664. * Get the effect name of the layer.
  51665. * @return The effect name
  51666. */
  51667. getEffectName(): string;
  51668. /**
  51669. * Create the merge effect. This is the shader use to blit the information back
  51670. * to the main canvas at the end of the scene rendering.
  51671. */
  51672. protected _createMergeEffect(): Effect;
  51673. /**
  51674. * Creates the render target textures and post processes used in the highlight layer.
  51675. */
  51676. protected _createTextureAndPostProcesses(): void;
  51677. /**
  51678. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51679. */
  51680. needStencil(): boolean;
  51681. /**
  51682. * Checks for the readiness of the element composing the layer.
  51683. * @param subMesh the mesh to check for
  51684. * @param useInstances specify wether or not to use instances to render the mesh
  51685. * @param emissiveTexture the associated emissive texture used to generate the glow
  51686. * @return true if ready otherwise, false
  51687. */
  51688. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51689. /**
  51690. * Implementation specific of rendering the generating effect on the main canvas.
  51691. * @param effect The effect used to render through
  51692. */
  51693. protected _internalRender(effect: Effect): void;
  51694. /**
  51695. * Returns true if the layer contains information to display, otherwise false.
  51696. */
  51697. shouldRender(): boolean;
  51698. /**
  51699. * Returns true if the mesh should render, otherwise false.
  51700. * @param mesh The mesh to render
  51701. * @returns true if it should render otherwise false
  51702. */
  51703. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51704. /**
  51705. * Sets the required values for both the emissive texture and and the main color.
  51706. */
  51707. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51708. /**
  51709. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  51710. * @param mesh The mesh to exclude from the highlight layer
  51711. */
  51712. addExcludedMesh(mesh: Mesh): void;
  51713. /**
  51714. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  51715. * @param mesh The mesh to highlight
  51716. */
  51717. removeExcludedMesh(mesh: Mesh): void;
  51718. /**
  51719. * Determine if a given mesh will be highlighted by the current HighlightLayer
  51720. * @param mesh mesh to test
  51721. * @returns true if the mesh will be highlighted by the current HighlightLayer
  51722. */
  51723. hasMesh(mesh: AbstractMesh): boolean;
  51724. /**
  51725. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  51726. * @param mesh The mesh to highlight
  51727. * @param color The color of the highlight
  51728. * @param glowEmissiveOnly Extract the glow from the emissive texture
  51729. */
  51730. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  51731. /**
  51732. * Remove a mesh from the highlight layer in order to make it stop glowing.
  51733. * @param mesh The mesh to highlight
  51734. */
  51735. removeMesh(mesh: Mesh): void;
  51736. /**
  51737. * Force the stencil to the normal expected value for none glowing parts
  51738. */
  51739. private _defaultStencilReference;
  51740. /**
  51741. * Free any resources and references associated to a mesh.
  51742. * Internal use
  51743. * @param mesh The mesh to free.
  51744. * @hidden
  51745. */
  51746. _disposeMesh(mesh: Mesh): void;
  51747. /**
  51748. * Dispose the highlight layer and free resources.
  51749. */
  51750. dispose(): void;
  51751. /**
  51752. * Gets the class name of the effect layer
  51753. * @returns the string with the class name of the effect layer
  51754. */
  51755. getClassName(): string;
  51756. /**
  51757. * Serializes this Highlight layer
  51758. * @returns a serialized Highlight layer object
  51759. */
  51760. serialize(): any;
  51761. /**
  51762. * Creates a Highlight layer from parsed Highlight layer data
  51763. * @param parsedHightlightLayer defines the Highlight layer data
  51764. * @param scene defines the current scene
  51765. * @param rootUrl defines the root URL containing the Highlight layer information
  51766. * @returns a parsed Highlight layer
  51767. */
  51768. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  51769. }
  51770. }
  51771. declare module "babylonjs/Layers/layerSceneComponent" {
  51772. import { Scene } from "babylonjs/scene";
  51773. import { ISceneComponent } from "babylonjs/sceneComponent";
  51774. import { Layer } from "babylonjs/Layers/layer";
  51775. import { AbstractScene } from "babylonjs/abstractScene";
  51776. module "babylonjs/abstractScene" {
  51777. interface AbstractScene {
  51778. /**
  51779. * The list of layers (background and foreground) of the scene
  51780. */
  51781. layers: Array<Layer>;
  51782. }
  51783. }
  51784. /**
  51785. * Defines the layer scene component responsible to manage any layers
  51786. * in a given scene.
  51787. */
  51788. export class LayerSceneComponent implements ISceneComponent {
  51789. /**
  51790. * The component name helpfull to identify the component in the list of scene components.
  51791. */
  51792. readonly name: string;
  51793. /**
  51794. * The scene the component belongs to.
  51795. */
  51796. scene: Scene;
  51797. private _engine;
  51798. /**
  51799. * Creates a new instance of the component for the given scene
  51800. * @param scene Defines the scene to register the component in
  51801. */
  51802. constructor(scene: Scene);
  51803. /**
  51804. * Registers the component in a given scene
  51805. */
  51806. register(): void;
  51807. /**
  51808. * Rebuilds the elements related to this component in case of
  51809. * context lost for instance.
  51810. */
  51811. rebuild(): void;
  51812. /**
  51813. * Disposes the component and the associated ressources.
  51814. */
  51815. dispose(): void;
  51816. private _draw;
  51817. private _drawCameraPredicate;
  51818. private _drawCameraBackground;
  51819. private _drawCameraForeground;
  51820. private _drawRenderTargetPredicate;
  51821. private _drawRenderTargetBackground;
  51822. private _drawRenderTargetForeground;
  51823. /**
  51824. * Adds all the elements from the container to the scene
  51825. * @param container the container holding the elements
  51826. */
  51827. addFromContainer(container: AbstractScene): void;
  51828. /**
  51829. * Removes all the elements in the container from the scene
  51830. * @param container contains the elements to remove
  51831. * @param dispose if the removed element should be disposed (default: false)
  51832. */
  51833. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51834. }
  51835. }
  51836. declare module "babylonjs/Shaders/layer.fragment" {
  51837. /** @hidden */
  51838. export var layerPixelShader: {
  51839. name: string;
  51840. shader: string;
  51841. };
  51842. }
  51843. declare module "babylonjs/Shaders/layer.vertex" {
  51844. /** @hidden */
  51845. export var layerVertexShader: {
  51846. name: string;
  51847. shader: string;
  51848. };
  51849. }
  51850. declare module "babylonjs/Layers/layer" {
  51851. import { Observable } from "babylonjs/Misc/observable";
  51852. import { Nullable } from "babylonjs/types";
  51853. import { Scene } from "babylonjs/scene";
  51854. import { Vector2 } from "babylonjs/Maths/math.vector";
  51855. import { Color4 } from "babylonjs/Maths/math.color";
  51856. import { Texture } from "babylonjs/Materials/Textures/texture";
  51857. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51858. import "babylonjs/Shaders/layer.fragment";
  51859. import "babylonjs/Shaders/layer.vertex";
  51860. /**
  51861. * This represents a full screen 2d layer.
  51862. * This can be useful to display a picture in the background of your scene for instance.
  51863. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51864. */
  51865. export class Layer {
  51866. /**
  51867. * Define the name of the layer.
  51868. */
  51869. name: string;
  51870. /**
  51871. * Define the texture the layer should display.
  51872. */
  51873. texture: Nullable<Texture>;
  51874. /**
  51875. * Is the layer in background or foreground.
  51876. */
  51877. isBackground: boolean;
  51878. /**
  51879. * Define the color of the layer (instead of texture).
  51880. */
  51881. color: Color4;
  51882. /**
  51883. * Define the scale of the layer in order to zoom in out of the texture.
  51884. */
  51885. scale: Vector2;
  51886. /**
  51887. * Define an offset for the layer in order to shift the texture.
  51888. */
  51889. offset: Vector2;
  51890. /**
  51891. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  51892. */
  51893. alphaBlendingMode: number;
  51894. /**
  51895. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  51896. * Alpha test will not mix with the background color in case of transparency.
  51897. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  51898. */
  51899. alphaTest: boolean;
  51900. /**
  51901. * Define a mask to restrict the layer to only some of the scene cameras.
  51902. */
  51903. layerMask: number;
  51904. /**
  51905. * Define the list of render target the layer is visible into.
  51906. */
  51907. renderTargetTextures: RenderTargetTexture[];
  51908. /**
  51909. * Define if the layer is only used in renderTarget or if it also
  51910. * renders in the main frame buffer of the canvas.
  51911. */
  51912. renderOnlyInRenderTargetTextures: boolean;
  51913. private _scene;
  51914. private _vertexBuffers;
  51915. private _indexBuffer;
  51916. private _effect;
  51917. private _alphaTestEffect;
  51918. /**
  51919. * An event triggered when the layer is disposed.
  51920. */
  51921. onDisposeObservable: Observable<Layer>;
  51922. private _onDisposeObserver;
  51923. /**
  51924. * Back compatibility with callback before the onDisposeObservable existed.
  51925. * The set callback will be triggered when the layer has been disposed.
  51926. */
  51927. onDispose: () => void;
  51928. /**
  51929. * An event triggered before rendering the scene
  51930. */
  51931. onBeforeRenderObservable: Observable<Layer>;
  51932. private _onBeforeRenderObserver;
  51933. /**
  51934. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51935. * The set callback will be triggered just before rendering the layer.
  51936. */
  51937. onBeforeRender: () => void;
  51938. /**
  51939. * An event triggered after rendering the scene
  51940. */
  51941. onAfterRenderObservable: Observable<Layer>;
  51942. private _onAfterRenderObserver;
  51943. /**
  51944. * Back compatibility with callback before the onAfterRenderObservable existed.
  51945. * The set callback will be triggered just after rendering the layer.
  51946. */
  51947. onAfterRender: () => void;
  51948. /**
  51949. * Instantiates a new layer.
  51950. * This represents a full screen 2d layer.
  51951. * This can be useful to display a picture in the background of your scene for instance.
  51952. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51953. * @param name Define the name of the layer in the scene
  51954. * @param imgUrl Define the url of the texture to display in the layer
  51955. * @param scene Define the scene the layer belongs to
  51956. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51957. * @param color Defines a color for the layer
  51958. */
  51959. constructor(
  51960. /**
  51961. * Define the name of the layer.
  51962. */
  51963. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51964. private _createIndexBuffer;
  51965. /** @hidden */
  51966. _rebuild(): void;
  51967. /**
  51968. * Renders the layer in the scene.
  51969. */
  51970. render(): void;
  51971. /**
  51972. * Disposes and releases the associated ressources.
  51973. */
  51974. dispose(): void;
  51975. }
  51976. }
  51977. declare module "babylonjs/Layers/index" {
  51978. export * from "babylonjs/Layers/effectLayer";
  51979. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51980. export * from "babylonjs/Layers/glowLayer";
  51981. export * from "babylonjs/Layers/highlightLayer";
  51982. export * from "babylonjs/Layers/layer";
  51983. export * from "babylonjs/Layers/layerSceneComponent";
  51984. }
  51985. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51986. /** @hidden */
  51987. export var lensFlarePixelShader: {
  51988. name: string;
  51989. shader: string;
  51990. };
  51991. }
  51992. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51993. /** @hidden */
  51994. export var lensFlareVertexShader: {
  51995. name: string;
  51996. shader: string;
  51997. };
  51998. }
  51999. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52000. import { Scene } from "babylonjs/scene";
  52001. import { Vector3 } from "babylonjs/Maths/math.vector";
  52002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52003. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52004. import "babylonjs/Shaders/lensFlare.fragment";
  52005. import "babylonjs/Shaders/lensFlare.vertex";
  52006. import { Viewport } from "babylonjs/Maths/math.viewport";
  52007. /**
  52008. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52009. * It is usually composed of several `lensFlare`.
  52010. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52011. */
  52012. export class LensFlareSystem {
  52013. /**
  52014. * Define the name of the lens flare system
  52015. */
  52016. name: string;
  52017. /**
  52018. * List of lens flares used in this system.
  52019. */
  52020. lensFlares: LensFlare[];
  52021. /**
  52022. * Define a limit from the border the lens flare can be visible.
  52023. */
  52024. borderLimit: number;
  52025. /**
  52026. * Define a viewport border we do not want to see the lens flare in.
  52027. */
  52028. viewportBorder: number;
  52029. /**
  52030. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52031. */
  52032. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52033. /**
  52034. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52035. */
  52036. layerMask: number;
  52037. /**
  52038. * Define the id of the lens flare system in the scene.
  52039. * (equal to name by default)
  52040. */
  52041. id: string;
  52042. private _scene;
  52043. private _emitter;
  52044. private _vertexBuffers;
  52045. private _indexBuffer;
  52046. private _effect;
  52047. private _positionX;
  52048. private _positionY;
  52049. private _isEnabled;
  52050. /** @hidden */
  52051. static _SceneComponentInitialization: (scene: Scene) => void;
  52052. /**
  52053. * Instantiates a lens flare system.
  52054. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52055. * It is usually composed of several `lensFlare`.
  52056. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52057. * @param name Define the name of the lens flare system in the scene
  52058. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52059. * @param scene Define the scene the lens flare system belongs to
  52060. */
  52061. constructor(
  52062. /**
  52063. * Define the name of the lens flare system
  52064. */
  52065. name: string, emitter: any, scene: Scene);
  52066. /**
  52067. * Define if the lens flare system is enabled.
  52068. */
  52069. isEnabled: boolean;
  52070. /**
  52071. * Get the scene the effects belongs to.
  52072. * @returns the scene holding the lens flare system
  52073. */
  52074. getScene(): Scene;
  52075. /**
  52076. * Get the emitter of the lens flare system.
  52077. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52078. * @returns the emitter of the lens flare system
  52079. */
  52080. getEmitter(): any;
  52081. /**
  52082. * Set the emitter of the lens flare system.
  52083. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52084. * @param newEmitter Define the new emitter of the system
  52085. */
  52086. setEmitter(newEmitter: any): void;
  52087. /**
  52088. * Get the lens flare system emitter position.
  52089. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52090. * @returns the position
  52091. */
  52092. getEmitterPosition(): Vector3;
  52093. /**
  52094. * @hidden
  52095. */
  52096. computeEffectivePosition(globalViewport: Viewport): boolean;
  52097. /** @hidden */
  52098. _isVisible(): boolean;
  52099. /**
  52100. * @hidden
  52101. */
  52102. render(): boolean;
  52103. /**
  52104. * Dispose and release the lens flare with its associated resources.
  52105. */
  52106. dispose(): void;
  52107. /**
  52108. * Parse a lens flare system from a JSON repressentation
  52109. * @param parsedLensFlareSystem Define the JSON to parse
  52110. * @param scene Define the scene the parsed system should be instantiated in
  52111. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52112. * @returns the parsed system
  52113. */
  52114. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52115. /**
  52116. * Serialize the current Lens Flare System into a JSON representation.
  52117. * @returns the serialized JSON
  52118. */
  52119. serialize(): any;
  52120. }
  52121. }
  52122. declare module "babylonjs/LensFlares/lensFlare" {
  52123. import { Nullable } from "babylonjs/types";
  52124. import { Color3 } from "babylonjs/Maths/math.color";
  52125. import { Texture } from "babylonjs/Materials/Textures/texture";
  52126. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52127. /**
  52128. * This represents one of the lens effect in a `lensFlareSystem`.
  52129. * It controls one of the indiviual texture used in the effect.
  52130. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52131. */
  52132. export class LensFlare {
  52133. /**
  52134. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52135. */
  52136. size: number;
  52137. /**
  52138. * 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.
  52139. */
  52140. position: number;
  52141. /**
  52142. * Define the lens color.
  52143. */
  52144. color: Color3;
  52145. /**
  52146. * Define the lens texture.
  52147. */
  52148. texture: Nullable<Texture>;
  52149. /**
  52150. * Define the alpha mode to render this particular lens.
  52151. */
  52152. alphaMode: number;
  52153. private _system;
  52154. /**
  52155. * Creates a new Lens Flare.
  52156. * This represents one of the lens effect in a `lensFlareSystem`.
  52157. * It controls one of the indiviual texture used in the effect.
  52158. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52159. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52160. * @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.
  52161. * @param color Define the lens color
  52162. * @param imgUrl Define the lens texture url
  52163. * @param system Define the `lensFlareSystem` this flare is part of
  52164. * @returns The newly created Lens Flare
  52165. */
  52166. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52167. /**
  52168. * Instantiates a new Lens Flare.
  52169. * This represents one of the lens effect in a `lensFlareSystem`.
  52170. * It controls one of the indiviual texture used in the effect.
  52171. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52172. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52173. * @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.
  52174. * @param color Define the lens color
  52175. * @param imgUrl Define the lens texture url
  52176. * @param system Define the `lensFlareSystem` this flare is part of
  52177. */
  52178. constructor(
  52179. /**
  52180. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52181. */
  52182. size: number,
  52183. /**
  52184. * 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.
  52185. */
  52186. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52187. /**
  52188. * Dispose and release the lens flare with its associated resources.
  52189. */
  52190. dispose(): void;
  52191. }
  52192. }
  52193. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52194. import { Nullable } from "babylonjs/types";
  52195. import { Scene } from "babylonjs/scene";
  52196. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52197. import { AbstractScene } from "babylonjs/abstractScene";
  52198. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52199. module "babylonjs/abstractScene" {
  52200. interface AbstractScene {
  52201. /**
  52202. * The list of lens flare system added to the scene
  52203. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52204. */
  52205. lensFlareSystems: Array<LensFlareSystem>;
  52206. /**
  52207. * Removes the given lens flare system from this scene.
  52208. * @param toRemove The lens flare system to remove
  52209. * @returns The index of the removed lens flare system
  52210. */
  52211. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52212. /**
  52213. * Adds the given lens flare system to this scene
  52214. * @param newLensFlareSystem The lens flare system to add
  52215. */
  52216. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52217. /**
  52218. * Gets a lens flare system using its name
  52219. * @param name defines the name to look for
  52220. * @returns the lens flare system or null if not found
  52221. */
  52222. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52223. /**
  52224. * Gets a lens flare system using its id
  52225. * @param id defines the id to look for
  52226. * @returns the lens flare system or null if not found
  52227. */
  52228. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52229. }
  52230. }
  52231. /**
  52232. * Defines the lens flare scene component responsible to manage any lens flares
  52233. * in a given scene.
  52234. */
  52235. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52236. /**
  52237. * The component name helpfull to identify the component in the list of scene components.
  52238. */
  52239. readonly name: string;
  52240. /**
  52241. * The scene the component belongs to.
  52242. */
  52243. scene: Scene;
  52244. /**
  52245. * Creates a new instance of the component for the given scene
  52246. * @param scene Defines the scene to register the component in
  52247. */
  52248. constructor(scene: Scene);
  52249. /**
  52250. * Registers the component in a given scene
  52251. */
  52252. register(): void;
  52253. /**
  52254. * Rebuilds the elements related to this component in case of
  52255. * context lost for instance.
  52256. */
  52257. rebuild(): void;
  52258. /**
  52259. * Adds all the elements from the container to the scene
  52260. * @param container the container holding the elements
  52261. */
  52262. addFromContainer(container: AbstractScene): void;
  52263. /**
  52264. * Removes all the elements in the container from the scene
  52265. * @param container contains the elements to remove
  52266. * @param dispose if the removed element should be disposed (default: false)
  52267. */
  52268. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52269. /**
  52270. * Serializes the component data to the specified json object
  52271. * @param serializationObject The object to serialize to
  52272. */
  52273. serialize(serializationObject: any): void;
  52274. /**
  52275. * Disposes the component and the associated ressources.
  52276. */
  52277. dispose(): void;
  52278. private _draw;
  52279. }
  52280. }
  52281. declare module "babylonjs/LensFlares/index" {
  52282. export * from "babylonjs/LensFlares/lensFlare";
  52283. export * from "babylonjs/LensFlares/lensFlareSystem";
  52284. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52285. }
  52286. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52287. import { Scene } from "babylonjs/scene";
  52288. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52289. import { AbstractScene } from "babylonjs/abstractScene";
  52290. /**
  52291. * Defines the shadow generator component responsible to manage any shadow generators
  52292. * in a given scene.
  52293. */
  52294. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52295. /**
  52296. * The component name helpfull to identify the component in the list of scene components.
  52297. */
  52298. readonly name: string;
  52299. /**
  52300. * The scene the component belongs to.
  52301. */
  52302. scene: Scene;
  52303. /**
  52304. * Creates a new instance of the component for the given scene
  52305. * @param scene Defines the scene to register the component in
  52306. */
  52307. constructor(scene: Scene);
  52308. /**
  52309. * Registers the component in a given scene
  52310. */
  52311. register(): void;
  52312. /**
  52313. * Rebuilds the elements related to this component in case of
  52314. * context lost for instance.
  52315. */
  52316. rebuild(): void;
  52317. /**
  52318. * Serializes the component data to the specified json object
  52319. * @param serializationObject The object to serialize to
  52320. */
  52321. serialize(serializationObject: any): void;
  52322. /**
  52323. * Adds all the elements from the container to the scene
  52324. * @param container the container holding the elements
  52325. */
  52326. addFromContainer(container: AbstractScene): void;
  52327. /**
  52328. * Removes all the elements in the container from the scene
  52329. * @param container contains the elements to remove
  52330. * @param dispose if the removed element should be disposed (default: false)
  52331. */
  52332. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52333. /**
  52334. * Rebuilds the elements related to this component in case of
  52335. * context lost for instance.
  52336. */
  52337. dispose(): void;
  52338. private _gatherRenderTargets;
  52339. }
  52340. }
  52341. declare module "babylonjs/Lights/Shadows/index" {
  52342. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52343. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52344. }
  52345. declare module "babylonjs/Lights/pointLight" {
  52346. import { Scene } from "babylonjs/scene";
  52347. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52349. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52350. import { Effect } from "babylonjs/Materials/effect";
  52351. /**
  52352. * A point light is a light defined by an unique point in world space.
  52353. * The light is emitted in every direction from this point.
  52354. * A good example of a point light is a standard light bulb.
  52355. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52356. */
  52357. export class PointLight extends ShadowLight {
  52358. private _shadowAngle;
  52359. /**
  52360. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52361. * This specifies what angle the shadow will use to be created.
  52362. *
  52363. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52364. */
  52365. /**
  52366. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52367. * This specifies what angle the shadow will use to be created.
  52368. *
  52369. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52370. */
  52371. shadowAngle: number;
  52372. /**
  52373. * Gets the direction if it has been set.
  52374. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52375. */
  52376. /**
  52377. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52378. */
  52379. direction: Vector3;
  52380. /**
  52381. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52382. * A PointLight emits the light in every direction.
  52383. * It can cast shadows.
  52384. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52385. * ```javascript
  52386. * var pointLight = new PointLight("pl", camera.position, scene);
  52387. * ```
  52388. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52389. * @param name The light friendly name
  52390. * @param position The position of the point light in the scene
  52391. * @param scene The scene the lights belongs to
  52392. */
  52393. constructor(name: string, position: Vector3, scene: Scene);
  52394. /**
  52395. * Returns the string "PointLight"
  52396. * @returns the class name
  52397. */
  52398. getClassName(): string;
  52399. /**
  52400. * Returns the integer 0.
  52401. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52402. */
  52403. getTypeID(): number;
  52404. /**
  52405. * Specifies wether or not the shadowmap should be a cube texture.
  52406. * @returns true if the shadowmap needs to be a cube texture.
  52407. */
  52408. needCube(): boolean;
  52409. /**
  52410. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52411. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52412. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52413. */
  52414. getShadowDirection(faceIndex?: number): Vector3;
  52415. /**
  52416. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52417. * - fov = PI / 2
  52418. * - aspect ratio : 1.0
  52419. * - z-near and far equal to the active camera minZ and maxZ.
  52420. * Returns the PointLight.
  52421. */
  52422. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52423. protected _buildUniformLayout(): void;
  52424. /**
  52425. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52426. * @param effect The effect to update
  52427. * @param lightIndex The index of the light in the effect to update
  52428. * @returns The point light
  52429. */
  52430. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52431. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52432. /**
  52433. * Prepares the list of defines specific to the light type.
  52434. * @param defines the list of defines
  52435. * @param lightIndex defines the index of the light for the effect
  52436. */
  52437. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52438. }
  52439. }
  52440. declare module "babylonjs/Lights/index" {
  52441. export * from "babylonjs/Lights/light";
  52442. export * from "babylonjs/Lights/shadowLight";
  52443. export * from "babylonjs/Lights/Shadows/index";
  52444. export * from "babylonjs/Lights/directionalLight";
  52445. export * from "babylonjs/Lights/hemisphericLight";
  52446. export * from "babylonjs/Lights/pointLight";
  52447. export * from "babylonjs/Lights/spotLight";
  52448. }
  52449. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52450. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52451. /**
  52452. * Header information of HDR texture files.
  52453. */
  52454. export interface HDRInfo {
  52455. /**
  52456. * The height of the texture in pixels.
  52457. */
  52458. height: number;
  52459. /**
  52460. * The width of the texture in pixels.
  52461. */
  52462. width: number;
  52463. /**
  52464. * The index of the beginning of the data in the binary file.
  52465. */
  52466. dataPosition: number;
  52467. }
  52468. /**
  52469. * This groups tools to convert HDR texture to native colors array.
  52470. */
  52471. export class HDRTools {
  52472. private static Ldexp;
  52473. private static Rgbe2float;
  52474. private static readStringLine;
  52475. /**
  52476. * Reads header information from an RGBE texture stored in a native array.
  52477. * More information on this format are available here:
  52478. * https://en.wikipedia.org/wiki/RGBE_image_format
  52479. *
  52480. * @param uint8array The binary file stored in native array.
  52481. * @return The header information.
  52482. */
  52483. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52484. /**
  52485. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52486. * This RGBE texture needs to store the information as a panorama.
  52487. *
  52488. * More information on this format are available here:
  52489. * https://en.wikipedia.org/wiki/RGBE_image_format
  52490. *
  52491. * @param buffer The binary file stored in an array buffer.
  52492. * @param size The expected size of the extracted cubemap.
  52493. * @return The Cube Map information.
  52494. */
  52495. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  52496. /**
  52497. * Returns the pixels data extracted from an RGBE texture.
  52498. * This pixels will be stored left to right up to down in the R G B order in one array.
  52499. *
  52500. * More information on this format are available here:
  52501. * https://en.wikipedia.org/wiki/RGBE_image_format
  52502. *
  52503. * @param uint8array The binary file stored in an array buffer.
  52504. * @param hdrInfo The header information of the file.
  52505. * @return The pixels data in RGB right to left up to down order.
  52506. */
  52507. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  52508. private static RGBE_ReadPixels_RLE;
  52509. }
  52510. }
  52511. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  52512. import { Nullable } from "babylonjs/types";
  52513. import { Scene } from "babylonjs/scene";
  52514. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52515. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52516. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52517. /**
  52518. * This represents a texture coming from an HDR input.
  52519. *
  52520. * The only supported format is currently panorama picture stored in RGBE format.
  52521. * Example of such files can be found on HDRLib: http://hdrlib.com/
  52522. */
  52523. export class HDRCubeTexture extends BaseTexture {
  52524. private static _facesMapping;
  52525. private _generateHarmonics;
  52526. private _noMipmap;
  52527. private _textureMatrix;
  52528. private _size;
  52529. private _onLoad;
  52530. private _onError;
  52531. /**
  52532. * The texture URL.
  52533. */
  52534. url: string;
  52535. /**
  52536. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  52537. */
  52538. coordinatesMode: number;
  52539. protected _isBlocking: boolean;
  52540. /**
  52541. * Sets wether or not the texture is blocking during loading.
  52542. */
  52543. /**
  52544. * Gets wether or not the texture is blocking during loading.
  52545. */
  52546. isBlocking: boolean;
  52547. protected _rotationY: number;
  52548. /**
  52549. * Sets texture matrix rotation angle around Y axis in radians.
  52550. */
  52551. /**
  52552. * Gets texture matrix rotation angle around Y axis radians.
  52553. */
  52554. rotationY: number;
  52555. /**
  52556. * Gets or sets the center of the bounding box associated with the cube texture
  52557. * It must define where the camera used to render the texture was set
  52558. */
  52559. boundingBoxPosition: Vector3;
  52560. private _boundingBoxSize;
  52561. /**
  52562. * Gets or sets the size of the bounding box associated with the cube texture
  52563. * When defined, the cubemap will switch to local mode
  52564. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  52565. * @example https://www.babylonjs-playground.com/#RNASML
  52566. */
  52567. boundingBoxSize: Vector3;
  52568. /**
  52569. * Instantiates an HDRTexture from the following parameters.
  52570. *
  52571. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  52572. * @param scene The scene the texture will be used in
  52573. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52574. * @param noMipmap Forces to not generate the mipmap if true
  52575. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  52576. * @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)
  52577. * @param reserved Reserved flag for internal use.
  52578. */
  52579. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52580. /**
  52581. * Get the current class name of the texture useful for serialization or dynamic coding.
  52582. * @returns "HDRCubeTexture"
  52583. */
  52584. getClassName(): string;
  52585. /**
  52586. * Occurs when the file is raw .hdr file.
  52587. */
  52588. private loadTexture;
  52589. clone(): HDRCubeTexture;
  52590. delayLoad(): void;
  52591. /**
  52592. * Get the texture reflection matrix used to rotate/transform the reflection.
  52593. * @returns the reflection matrix
  52594. */
  52595. getReflectionTextureMatrix(): Matrix;
  52596. /**
  52597. * Set the texture reflection matrix used to rotate/transform the reflection.
  52598. * @param value Define the reflection matrix to set
  52599. */
  52600. setReflectionTextureMatrix(value: Matrix): void;
  52601. /**
  52602. * Parses a JSON representation of an HDR Texture in order to create the texture
  52603. * @param parsedTexture Define the JSON representation
  52604. * @param scene Define the scene the texture should be created in
  52605. * @param rootUrl Define the root url in case we need to load relative dependencies
  52606. * @returns the newly created texture after parsing
  52607. */
  52608. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  52609. serialize(): any;
  52610. }
  52611. }
  52612. declare module "babylonjs/Physics/physicsEngine" {
  52613. import { Nullable } from "babylonjs/types";
  52614. import { Vector3 } from "babylonjs/Maths/math.vector";
  52615. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52616. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  52617. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  52618. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52619. /**
  52620. * Class used to control physics engine
  52621. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52622. */
  52623. export class PhysicsEngine implements IPhysicsEngine {
  52624. private _physicsPlugin;
  52625. /**
  52626. * Global value used to control the smallest number supported by the simulation
  52627. */
  52628. static Epsilon: number;
  52629. private _impostors;
  52630. private _joints;
  52631. /**
  52632. * Gets the gravity vector used by the simulation
  52633. */
  52634. gravity: Vector3;
  52635. /**
  52636. * Factory used to create the default physics plugin.
  52637. * @returns The default physics plugin
  52638. */
  52639. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  52640. /**
  52641. * Creates a new Physics Engine
  52642. * @param gravity defines the gravity vector used by the simulation
  52643. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  52644. */
  52645. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  52646. /**
  52647. * Sets the gravity vector used by the simulation
  52648. * @param gravity defines the gravity vector to use
  52649. */
  52650. setGravity(gravity: Vector3): void;
  52651. /**
  52652. * Set the time step of the physics engine.
  52653. * Default is 1/60.
  52654. * To slow it down, enter 1/600 for example.
  52655. * To speed it up, 1/30
  52656. * @param newTimeStep defines the new timestep to apply to this world.
  52657. */
  52658. setTimeStep(newTimeStep?: number): void;
  52659. /**
  52660. * Get the time step of the physics engine.
  52661. * @returns the current time step
  52662. */
  52663. getTimeStep(): number;
  52664. /**
  52665. * Release all resources
  52666. */
  52667. dispose(): void;
  52668. /**
  52669. * Gets the name of the current physics plugin
  52670. * @returns the name of the plugin
  52671. */
  52672. getPhysicsPluginName(): string;
  52673. /**
  52674. * Adding a new impostor for the impostor tracking.
  52675. * This will be done by the impostor itself.
  52676. * @param impostor the impostor to add
  52677. */
  52678. addImpostor(impostor: PhysicsImpostor): void;
  52679. /**
  52680. * Remove an impostor from the engine.
  52681. * This impostor and its mesh will not longer be updated by the physics engine.
  52682. * @param impostor the impostor to remove
  52683. */
  52684. removeImpostor(impostor: PhysicsImpostor): void;
  52685. /**
  52686. * Add a joint to the physics engine
  52687. * @param mainImpostor defines the main impostor to which the joint is added.
  52688. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  52689. * @param joint defines the joint that will connect both impostors.
  52690. */
  52691. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52692. /**
  52693. * Removes a joint from the simulation
  52694. * @param mainImpostor defines the impostor used with the joint
  52695. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  52696. * @param joint defines the joint to remove
  52697. */
  52698. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  52699. /**
  52700. * Called by the scene. No need to call it.
  52701. * @param delta defines the timespam between frames
  52702. */
  52703. _step(delta: number): void;
  52704. /**
  52705. * Gets the current plugin used to run the simulation
  52706. * @returns current plugin
  52707. */
  52708. getPhysicsPlugin(): IPhysicsEnginePlugin;
  52709. /**
  52710. * Gets the list of physic impostors
  52711. * @returns an array of PhysicsImpostor
  52712. */
  52713. getImpostors(): Array<PhysicsImpostor>;
  52714. /**
  52715. * Gets the impostor for a physics enabled object
  52716. * @param object defines the object impersonated by the impostor
  52717. * @returns the PhysicsImpostor or null if not found
  52718. */
  52719. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  52720. /**
  52721. * Gets the impostor for a physics body object
  52722. * @param body defines physics body used by the impostor
  52723. * @returns the PhysicsImpostor or null if not found
  52724. */
  52725. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  52726. /**
  52727. * Does a raycast in the physics world
  52728. * @param from when should the ray start?
  52729. * @param to when should the ray end?
  52730. * @returns PhysicsRaycastResult
  52731. */
  52732. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52733. }
  52734. }
  52735. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  52736. import { Nullable } from "babylonjs/types";
  52737. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52738. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52739. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52740. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52741. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52742. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52743. /** @hidden */
  52744. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  52745. private _useDeltaForWorldStep;
  52746. world: any;
  52747. name: string;
  52748. private _physicsMaterials;
  52749. private _fixedTimeStep;
  52750. private _cannonRaycastResult;
  52751. private _raycastResult;
  52752. private _physicsBodysToRemoveAfterStep;
  52753. BJSCANNON: any;
  52754. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  52755. setGravity(gravity: Vector3): void;
  52756. setTimeStep(timeStep: number): void;
  52757. getTimeStep(): number;
  52758. executeStep(delta: number): void;
  52759. private _removeMarkedPhysicsBodiesFromWorld;
  52760. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52761. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52762. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52763. private _processChildMeshes;
  52764. removePhysicsBody(impostor: PhysicsImpostor): void;
  52765. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52766. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52767. private _addMaterial;
  52768. private _checkWithEpsilon;
  52769. private _createShape;
  52770. private _createHeightmap;
  52771. private _minus90X;
  52772. private _plus90X;
  52773. private _tmpPosition;
  52774. private _tmpDeltaPosition;
  52775. private _tmpUnityRotation;
  52776. private _updatePhysicsBodyTransformation;
  52777. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52778. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52779. isSupported(): boolean;
  52780. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52781. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52782. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52783. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52784. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52785. getBodyMass(impostor: PhysicsImpostor): number;
  52786. getBodyFriction(impostor: PhysicsImpostor): number;
  52787. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52788. getBodyRestitution(impostor: PhysicsImpostor): number;
  52789. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52790. sleepBody(impostor: PhysicsImpostor): void;
  52791. wakeUpBody(impostor: PhysicsImpostor): void;
  52792. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  52793. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52794. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52795. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52796. getRadius(impostor: PhysicsImpostor): number;
  52797. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52798. dispose(): void;
  52799. private _extendNamespace;
  52800. /**
  52801. * Does a raycast in the physics world
  52802. * @param from when should the ray start?
  52803. * @param to when should the ray end?
  52804. * @returns PhysicsRaycastResult
  52805. */
  52806. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52807. }
  52808. }
  52809. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  52810. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52811. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52812. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52814. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  52815. import { Nullable } from "babylonjs/types";
  52816. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52817. /** @hidden */
  52818. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  52819. world: any;
  52820. name: string;
  52821. BJSOIMO: any;
  52822. private _raycastResult;
  52823. constructor(iterations?: number, oimoInjection?: any);
  52824. setGravity(gravity: Vector3): void;
  52825. setTimeStep(timeStep: number): void;
  52826. getTimeStep(): number;
  52827. private _tmpImpostorsArray;
  52828. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52829. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52830. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52831. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52832. private _tmpPositionVector;
  52833. removePhysicsBody(impostor: PhysicsImpostor): void;
  52834. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52835. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52836. isSupported(): boolean;
  52837. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52838. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52839. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52840. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52841. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52842. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52843. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52844. getBodyMass(impostor: PhysicsImpostor): number;
  52845. getBodyFriction(impostor: PhysicsImpostor): number;
  52846. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52847. getBodyRestitution(impostor: PhysicsImpostor): number;
  52848. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52849. sleepBody(impostor: PhysicsImpostor): void;
  52850. wakeUpBody(impostor: PhysicsImpostor): void;
  52851. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52852. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  52853. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  52854. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52855. getRadius(impostor: PhysicsImpostor): number;
  52856. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52857. dispose(): void;
  52858. /**
  52859. * Does a raycast in the physics world
  52860. * @param from when should the ray start?
  52861. * @param to when should the ray end?
  52862. * @returns PhysicsRaycastResult
  52863. */
  52864. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52865. }
  52866. }
  52867. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  52868. import { Nullable } from "babylonjs/types";
  52869. import { Scene } from "babylonjs/scene";
  52870. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  52871. import { Color4 } from "babylonjs/Maths/math.color";
  52872. import { Mesh } from "babylonjs/Meshes/mesh";
  52873. /**
  52874. * Class containing static functions to help procedurally build meshes
  52875. */
  52876. export class RibbonBuilder {
  52877. /**
  52878. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52879. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52880. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52881. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52882. * * 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
  52883. * * 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
  52884. * * 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
  52885. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52886. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52887. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52888. * * 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
  52889. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52890. * * 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
  52891. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52893. * @param name defines the name of the mesh
  52894. * @param options defines the options used to create the mesh
  52895. * @param scene defines the hosting scene
  52896. * @returns the ribbon mesh
  52897. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52898. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52899. */
  52900. static CreateRibbon(name: string, options: {
  52901. pathArray: Vector3[][];
  52902. closeArray?: boolean;
  52903. closePath?: boolean;
  52904. offset?: number;
  52905. updatable?: boolean;
  52906. sideOrientation?: number;
  52907. frontUVs?: Vector4;
  52908. backUVs?: Vector4;
  52909. instance?: Mesh;
  52910. invertUV?: boolean;
  52911. uvs?: Vector2[];
  52912. colors?: Color4[];
  52913. }, scene?: Nullable<Scene>): Mesh;
  52914. }
  52915. }
  52916. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  52917. import { Nullable } from "babylonjs/types";
  52918. import { Scene } from "babylonjs/scene";
  52919. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  52920. import { Mesh } from "babylonjs/Meshes/mesh";
  52921. /**
  52922. * Class containing static functions to help procedurally build meshes
  52923. */
  52924. export class ShapeBuilder {
  52925. /**
  52926. * 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.
  52927. * * 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.
  52928. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52929. * * 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.
  52930. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52931. * * 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
  52932. * * 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
  52933. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52935. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52936. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52938. * @param name defines the name of the mesh
  52939. * @param options defines the options used to create the mesh
  52940. * @param scene defines the hosting scene
  52941. * @returns the extruded shape mesh
  52942. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52943. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52944. */
  52945. static ExtrudeShape(name: string, options: {
  52946. shape: Vector3[];
  52947. path: Vector3[];
  52948. scale?: number;
  52949. rotation?: number;
  52950. cap?: number;
  52951. updatable?: boolean;
  52952. sideOrientation?: number;
  52953. frontUVs?: Vector4;
  52954. backUVs?: Vector4;
  52955. instance?: Mesh;
  52956. invertUV?: boolean;
  52957. }, scene?: Nullable<Scene>): Mesh;
  52958. /**
  52959. * Creates an custom extruded shape mesh.
  52960. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52961. * * 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.
  52962. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52963. * * 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
  52964. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52965. * * 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
  52966. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52967. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52968. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52969. * * 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
  52970. * * 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
  52971. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52974. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52976. * @param name defines the name of the mesh
  52977. * @param options defines the options used to create the mesh
  52978. * @param scene defines the hosting scene
  52979. * @returns the custom extruded shape mesh
  52980. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52981. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52982. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52983. */
  52984. static ExtrudeShapeCustom(name: string, options: {
  52985. shape: Vector3[];
  52986. path: Vector3[];
  52987. scaleFunction?: any;
  52988. rotationFunction?: any;
  52989. ribbonCloseArray?: boolean;
  52990. ribbonClosePath?: boolean;
  52991. cap?: number;
  52992. updatable?: boolean;
  52993. sideOrientation?: number;
  52994. frontUVs?: Vector4;
  52995. backUVs?: Vector4;
  52996. instance?: Mesh;
  52997. invertUV?: boolean;
  52998. }, scene?: Nullable<Scene>): Mesh;
  52999. private static _ExtrudeShapeGeneric;
  53000. }
  53001. }
  53002. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53003. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53004. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53005. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53006. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53007. import { Nullable } from "babylonjs/types";
  53008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53009. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53010. /**
  53011. * AmmoJS Physics plugin
  53012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53013. * @see https://github.com/kripken/ammo.js/
  53014. */
  53015. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53016. private _useDeltaForWorldStep;
  53017. /**
  53018. * Reference to the Ammo library
  53019. */
  53020. bjsAMMO: any;
  53021. /**
  53022. * Created ammoJS world which physics bodies are added to
  53023. */
  53024. world: any;
  53025. /**
  53026. * Name of the plugin
  53027. */
  53028. name: string;
  53029. private _timeStep;
  53030. private _fixedTimeStep;
  53031. private _maxSteps;
  53032. private _tmpQuaternion;
  53033. private _tmpAmmoTransform;
  53034. private _tmpAmmoQuaternion;
  53035. private _tmpAmmoConcreteContactResultCallback;
  53036. private _collisionConfiguration;
  53037. private _dispatcher;
  53038. private _overlappingPairCache;
  53039. private _solver;
  53040. private _softBodySolver;
  53041. private _tmpAmmoVectorA;
  53042. private _tmpAmmoVectorB;
  53043. private _tmpAmmoVectorC;
  53044. private _tmpAmmoVectorD;
  53045. private _tmpContactCallbackResult;
  53046. private _tmpAmmoVectorRCA;
  53047. private _tmpAmmoVectorRCB;
  53048. private _raycastResult;
  53049. private static readonly DISABLE_COLLISION_FLAG;
  53050. private static readonly KINEMATIC_FLAG;
  53051. private static readonly DISABLE_DEACTIVATION_FLAG;
  53052. /**
  53053. * Initializes the ammoJS plugin
  53054. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53055. * @param ammoInjection can be used to inject your own ammo reference
  53056. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53057. */
  53058. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53059. /**
  53060. * Sets the gravity of the physics world (m/(s^2))
  53061. * @param gravity Gravity to set
  53062. */
  53063. setGravity(gravity: Vector3): void;
  53064. /**
  53065. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53066. * @param timeStep timestep to use in seconds
  53067. */
  53068. setTimeStep(timeStep: number): void;
  53069. /**
  53070. * 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)
  53071. * @param fixedTimeStep fixedTimeStep to use in seconds
  53072. */
  53073. setFixedTimeStep(fixedTimeStep: number): void;
  53074. /**
  53075. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53076. * @param maxSteps the maximum number of steps by the physics engine per frame
  53077. */
  53078. setMaxSteps(maxSteps: number): void;
  53079. /**
  53080. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53081. * @returns the current timestep in seconds
  53082. */
  53083. getTimeStep(): number;
  53084. private _isImpostorInContact;
  53085. private _isImpostorPairInContact;
  53086. private _stepSimulation;
  53087. /**
  53088. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53089. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53090. * After the step the babylon meshes are set to the position of the physics imposters
  53091. * @param delta amount of time to step forward
  53092. * @param impostors array of imposters to update before/after the step
  53093. */
  53094. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53095. /**
  53096. * Update babylon mesh to match physics world object
  53097. * @param impostor imposter to match
  53098. */
  53099. private _afterSoftStep;
  53100. /**
  53101. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53102. * @param impostor imposter to match
  53103. */
  53104. private _ropeStep;
  53105. /**
  53106. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53107. * @param impostor imposter to match
  53108. */
  53109. private _softbodyOrClothStep;
  53110. private _tmpVector;
  53111. private _tmpMatrix;
  53112. /**
  53113. * Applies an impulse on the imposter
  53114. * @param impostor imposter to apply impulse to
  53115. * @param force amount of force to be applied to the imposter
  53116. * @param contactPoint the location to apply the impulse on the imposter
  53117. */
  53118. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53119. /**
  53120. * Applies a force on the imposter
  53121. * @param impostor imposter to apply force
  53122. * @param force amount of force to be applied to the imposter
  53123. * @param contactPoint the location to apply the force on the imposter
  53124. */
  53125. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53126. /**
  53127. * Creates a physics body using the plugin
  53128. * @param impostor the imposter to create the physics body on
  53129. */
  53130. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53131. /**
  53132. * Removes the physics body from the imposter and disposes of the body's memory
  53133. * @param impostor imposter to remove the physics body from
  53134. */
  53135. removePhysicsBody(impostor: PhysicsImpostor): void;
  53136. /**
  53137. * Generates a joint
  53138. * @param impostorJoint the imposter joint to create the joint with
  53139. */
  53140. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53141. /**
  53142. * Removes a joint
  53143. * @param impostorJoint the imposter joint to remove the joint from
  53144. */
  53145. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53146. private _addMeshVerts;
  53147. /**
  53148. * Initialise the soft body vertices to match its object's (mesh) vertices
  53149. * Softbody vertices (nodes) are in world space and to match this
  53150. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53151. * @param impostor to create the softbody for
  53152. */
  53153. private _softVertexData;
  53154. /**
  53155. * Create an impostor's soft body
  53156. * @param impostor to create the softbody for
  53157. */
  53158. private _createSoftbody;
  53159. /**
  53160. * Create cloth for an impostor
  53161. * @param impostor to create the softbody for
  53162. */
  53163. private _createCloth;
  53164. /**
  53165. * Create rope for an impostor
  53166. * @param impostor to create the softbody for
  53167. */
  53168. private _createRope;
  53169. private _addHullVerts;
  53170. private _createShape;
  53171. /**
  53172. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53173. * @param impostor imposter containing the physics body and babylon object
  53174. */
  53175. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53176. /**
  53177. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53178. * @param impostor imposter containing the physics body and babylon object
  53179. * @param newPosition new position
  53180. * @param newRotation new rotation
  53181. */
  53182. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53183. /**
  53184. * If this plugin is supported
  53185. * @returns true if its supported
  53186. */
  53187. isSupported(): boolean;
  53188. /**
  53189. * Sets the linear velocity of the physics body
  53190. * @param impostor imposter to set the velocity on
  53191. * @param velocity velocity to set
  53192. */
  53193. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53194. /**
  53195. * Sets the angular velocity of the physics body
  53196. * @param impostor imposter to set the velocity on
  53197. * @param velocity velocity to set
  53198. */
  53199. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53200. /**
  53201. * gets the linear velocity
  53202. * @param impostor imposter to get linear velocity from
  53203. * @returns linear velocity
  53204. */
  53205. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53206. /**
  53207. * gets the angular velocity
  53208. * @param impostor imposter to get angular velocity from
  53209. * @returns angular velocity
  53210. */
  53211. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53212. /**
  53213. * Sets the mass of physics body
  53214. * @param impostor imposter to set the mass on
  53215. * @param mass mass to set
  53216. */
  53217. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53218. /**
  53219. * Gets the mass of the physics body
  53220. * @param impostor imposter to get the mass from
  53221. * @returns mass
  53222. */
  53223. getBodyMass(impostor: PhysicsImpostor): number;
  53224. /**
  53225. * Gets friction of the impostor
  53226. * @param impostor impostor to get friction from
  53227. * @returns friction value
  53228. */
  53229. getBodyFriction(impostor: PhysicsImpostor): number;
  53230. /**
  53231. * Sets friction of the impostor
  53232. * @param impostor impostor to set friction on
  53233. * @param friction friction value
  53234. */
  53235. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53236. /**
  53237. * Gets restitution of the impostor
  53238. * @param impostor impostor to get restitution from
  53239. * @returns restitution value
  53240. */
  53241. getBodyRestitution(impostor: PhysicsImpostor): number;
  53242. /**
  53243. * Sets resitution of the impostor
  53244. * @param impostor impostor to set resitution on
  53245. * @param restitution resitution value
  53246. */
  53247. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53248. /**
  53249. * Gets pressure inside the impostor
  53250. * @param impostor impostor to get pressure from
  53251. * @returns pressure value
  53252. */
  53253. getBodyPressure(impostor: PhysicsImpostor): number;
  53254. /**
  53255. * Sets pressure inside a soft body impostor
  53256. * Cloth and rope must remain 0 pressure
  53257. * @param impostor impostor to set pressure on
  53258. * @param pressure pressure value
  53259. */
  53260. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53261. /**
  53262. * Gets stiffness of the impostor
  53263. * @param impostor impostor to get stiffness from
  53264. * @returns pressure value
  53265. */
  53266. getBodyStiffness(impostor: PhysicsImpostor): number;
  53267. /**
  53268. * Sets stiffness of the impostor
  53269. * @param impostor impostor to set stiffness on
  53270. * @param stiffness stiffness value from 0 to 1
  53271. */
  53272. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53273. /**
  53274. * Gets velocityIterations of the impostor
  53275. * @param impostor impostor to get velocity iterations from
  53276. * @returns velocityIterations value
  53277. */
  53278. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53279. /**
  53280. * Sets velocityIterations of the impostor
  53281. * @param impostor impostor to set velocity iterations on
  53282. * @param velocityIterations velocityIterations value
  53283. */
  53284. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53285. /**
  53286. * Gets positionIterations of the impostor
  53287. * @param impostor impostor to get position iterations from
  53288. * @returns positionIterations value
  53289. */
  53290. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53291. /**
  53292. * Sets positionIterations of the impostor
  53293. * @param impostor impostor to set position on
  53294. * @param positionIterations positionIterations value
  53295. */
  53296. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53297. /**
  53298. * Append an anchor to a cloth object
  53299. * @param impostor is the cloth impostor to add anchor to
  53300. * @param otherImpostor is the rigid impostor to anchor to
  53301. * @param width ratio across width from 0 to 1
  53302. * @param height ratio up height from 0 to 1
  53303. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53304. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53305. */
  53306. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53307. /**
  53308. * Append an hook to a rope object
  53309. * @param impostor is the rope impostor to add hook to
  53310. * @param otherImpostor is the rigid impostor to hook to
  53311. * @param length ratio along the rope from 0 to 1
  53312. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53313. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53314. */
  53315. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53316. /**
  53317. * Sleeps the physics body and stops it from being active
  53318. * @param impostor impostor to sleep
  53319. */
  53320. sleepBody(impostor: PhysicsImpostor): void;
  53321. /**
  53322. * Activates the physics body
  53323. * @param impostor impostor to activate
  53324. */
  53325. wakeUpBody(impostor: PhysicsImpostor): void;
  53326. /**
  53327. * Updates the distance parameters of the joint
  53328. * @param joint joint to update
  53329. * @param maxDistance maximum distance of the joint
  53330. * @param minDistance minimum distance of the joint
  53331. */
  53332. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53333. /**
  53334. * Sets a motor on the joint
  53335. * @param joint joint to set motor on
  53336. * @param speed speed of the motor
  53337. * @param maxForce maximum force of the motor
  53338. * @param motorIndex index of the motor
  53339. */
  53340. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53341. /**
  53342. * Sets the motors limit
  53343. * @param joint joint to set limit on
  53344. * @param upperLimit upper limit
  53345. * @param lowerLimit lower limit
  53346. */
  53347. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53348. /**
  53349. * Syncs the position and rotation of a mesh with the impostor
  53350. * @param mesh mesh to sync
  53351. * @param impostor impostor to update the mesh with
  53352. */
  53353. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53354. /**
  53355. * Gets the radius of the impostor
  53356. * @param impostor impostor to get radius from
  53357. * @returns the radius
  53358. */
  53359. getRadius(impostor: PhysicsImpostor): number;
  53360. /**
  53361. * Gets the box size of the impostor
  53362. * @param impostor impostor to get box size from
  53363. * @param result the resulting box size
  53364. */
  53365. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53366. /**
  53367. * Disposes of the impostor
  53368. */
  53369. dispose(): void;
  53370. /**
  53371. * Does a raycast in the physics world
  53372. * @param from when should the ray start?
  53373. * @param to when should the ray end?
  53374. * @returns PhysicsRaycastResult
  53375. */
  53376. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53377. }
  53378. }
  53379. declare module "babylonjs/Probes/reflectionProbe" {
  53380. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53381. import { Vector3 } from "babylonjs/Maths/math.vector";
  53382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53383. import { Nullable } from "babylonjs/types";
  53384. import { Scene } from "babylonjs/scene";
  53385. module "babylonjs/abstractScene" {
  53386. interface AbstractScene {
  53387. /**
  53388. * The list of reflection probes added to the scene
  53389. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53390. */
  53391. reflectionProbes: Array<ReflectionProbe>;
  53392. /**
  53393. * Removes the given reflection probe from this scene.
  53394. * @param toRemove The reflection probe to remove
  53395. * @returns The index of the removed reflection probe
  53396. */
  53397. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53398. /**
  53399. * Adds the given reflection probe to this scene.
  53400. * @param newReflectionProbe The reflection probe to add
  53401. */
  53402. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53403. }
  53404. }
  53405. /**
  53406. * Class used to generate realtime reflection / refraction cube textures
  53407. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53408. */
  53409. export class ReflectionProbe {
  53410. /** defines the name of the probe */
  53411. name: string;
  53412. private _scene;
  53413. private _renderTargetTexture;
  53414. private _projectionMatrix;
  53415. private _viewMatrix;
  53416. private _target;
  53417. private _add;
  53418. private _attachedMesh;
  53419. private _invertYAxis;
  53420. /** Gets or sets probe position (center of the cube map) */
  53421. position: Vector3;
  53422. /**
  53423. * Creates a new reflection probe
  53424. * @param name defines the name of the probe
  53425. * @param size defines the texture resolution (for each face)
  53426. * @param scene defines the hosting scene
  53427. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53428. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53429. */
  53430. constructor(
  53431. /** defines the name of the probe */
  53432. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53433. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53434. samples: number;
  53435. /** Gets or sets the refresh rate to use (on every frame by default) */
  53436. refreshRate: number;
  53437. /**
  53438. * Gets the hosting scene
  53439. * @returns a Scene
  53440. */
  53441. getScene(): Scene;
  53442. /** Gets the internal CubeTexture used to render to */
  53443. readonly cubeTexture: RenderTargetTexture;
  53444. /** Gets the list of meshes to render */
  53445. readonly renderList: Nullable<AbstractMesh[]>;
  53446. /**
  53447. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53448. * @param mesh defines the mesh to attach to
  53449. */
  53450. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53451. /**
  53452. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53453. * @param renderingGroupId The rendering group id corresponding to its index
  53454. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53455. */
  53456. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53457. /**
  53458. * Clean all associated resources
  53459. */
  53460. dispose(): void;
  53461. /**
  53462. * Converts the reflection probe information to a readable string for debug purpose.
  53463. * @param fullDetails Supports for multiple levels of logging within scene loading
  53464. * @returns the human readable reflection probe info
  53465. */
  53466. toString(fullDetails?: boolean): string;
  53467. /**
  53468. * Get the class name of the relfection probe.
  53469. * @returns "ReflectionProbe"
  53470. */
  53471. getClassName(): string;
  53472. /**
  53473. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53474. * @returns The JSON representation of the texture
  53475. */
  53476. serialize(): any;
  53477. /**
  53478. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53479. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53480. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53481. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53482. * @returns The parsed reflection probe if successful
  53483. */
  53484. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53485. }
  53486. }
  53487. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53488. /** @hidden */
  53489. export var _BabylonLoaderRegistered: boolean;
  53490. }
  53491. declare module "babylonjs/Loading/Plugins/index" {
  53492. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53493. }
  53494. declare module "babylonjs/Loading/index" {
  53495. export * from "babylonjs/Loading/loadingScreen";
  53496. export * from "babylonjs/Loading/Plugins/index";
  53497. export * from "babylonjs/Loading/sceneLoader";
  53498. export * from "babylonjs/Loading/sceneLoaderFlags";
  53499. }
  53500. declare module "babylonjs/Materials/Background/index" {
  53501. export * from "babylonjs/Materials/Background/backgroundMaterial";
  53502. }
  53503. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  53504. import { Scene } from "babylonjs/scene";
  53505. import { Color3 } from "babylonjs/Maths/math.color";
  53506. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53507. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53508. /**
  53509. * The Physically based simple base material of BJS.
  53510. *
  53511. * This enables better naming and convention enforcements on top of the pbrMaterial.
  53512. * It is used as the base class for both the specGloss and metalRough conventions.
  53513. */
  53514. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  53515. /**
  53516. * Number of Simultaneous lights allowed on the material.
  53517. */
  53518. maxSimultaneousLights: number;
  53519. /**
  53520. * If sets to true, disables all the lights affecting the material.
  53521. */
  53522. disableLighting: boolean;
  53523. /**
  53524. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  53525. */
  53526. environmentTexture: BaseTexture;
  53527. /**
  53528. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53529. */
  53530. invertNormalMapX: boolean;
  53531. /**
  53532. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53533. */
  53534. invertNormalMapY: boolean;
  53535. /**
  53536. * Normal map used in the model.
  53537. */
  53538. normalTexture: BaseTexture;
  53539. /**
  53540. * Emissivie color used to self-illuminate the model.
  53541. */
  53542. emissiveColor: Color3;
  53543. /**
  53544. * Emissivie texture used to self-illuminate the model.
  53545. */
  53546. emissiveTexture: BaseTexture;
  53547. /**
  53548. * Occlusion Channel Strenght.
  53549. */
  53550. occlusionStrength: number;
  53551. /**
  53552. * Occlusion Texture of the material (adding extra occlusion effects).
  53553. */
  53554. occlusionTexture: BaseTexture;
  53555. /**
  53556. * Defines the alpha limits in alpha test mode.
  53557. */
  53558. alphaCutOff: number;
  53559. /**
  53560. * Gets the current double sided mode.
  53561. */
  53562. /**
  53563. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53564. */
  53565. doubleSided: boolean;
  53566. /**
  53567. * Stores the pre-calculated light information of a mesh in a texture.
  53568. */
  53569. lightmapTexture: BaseTexture;
  53570. /**
  53571. * If true, the light map contains occlusion information instead of lighting info.
  53572. */
  53573. useLightmapAsShadowmap: boolean;
  53574. /**
  53575. * Instantiates a new PBRMaterial instance.
  53576. *
  53577. * @param name The material name
  53578. * @param scene The scene the material will be use in.
  53579. */
  53580. constructor(name: string, scene: Scene);
  53581. getClassName(): string;
  53582. }
  53583. }
  53584. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  53585. import { Scene } from "babylonjs/scene";
  53586. import { Color3 } from "babylonjs/Maths/math.color";
  53587. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53588. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53589. /**
  53590. * The PBR material of BJS following the metal roughness convention.
  53591. *
  53592. * This fits to the PBR convention in the GLTF definition:
  53593. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53594. */
  53595. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  53596. /**
  53597. * The base color has two different interpretations depending on the value of metalness.
  53598. * When the material is a metal, the base color is the specific measured reflectance value
  53599. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  53600. * of the material.
  53601. */
  53602. baseColor: Color3;
  53603. /**
  53604. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  53605. * well as opacity information in the alpha channel.
  53606. */
  53607. baseTexture: BaseTexture;
  53608. /**
  53609. * Specifies the metallic scalar value of the material.
  53610. * Can also be used to scale the metalness values of the metallic texture.
  53611. */
  53612. metallic: number;
  53613. /**
  53614. * Specifies the roughness scalar value of the material.
  53615. * Can also be used to scale the roughness values of the metallic texture.
  53616. */
  53617. roughness: number;
  53618. /**
  53619. * Texture containing both the metallic value in the B channel and the
  53620. * roughness value in the G channel to keep better precision.
  53621. */
  53622. metallicRoughnessTexture: BaseTexture;
  53623. /**
  53624. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53625. *
  53626. * @param name The material name
  53627. * @param scene The scene the material will be use in.
  53628. */
  53629. constructor(name: string, scene: Scene);
  53630. /**
  53631. * Return the currrent class name of the material.
  53632. */
  53633. getClassName(): string;
  53634. /**
  53635. * Makes a duplicate of the current material.
  53636. * @param name - name to use for the new material.
  53637. */
  53638. clone(name: string): PBRMetallicRoughnessMaterial;
  53639. /**
  53640. * Serialize the material to a parsable JSON object.
  53641. */
  53642. serialize(): any;
  53643. /**
  53644. * Parses a JSON object correponding to the serialize function.
  53645. */
  53646. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  53647. }
  53648. }
  53649. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  53650. import { Scene } from "babylonjs/scene";
  53651. import { Color3 } from "babylonjs/Maths/math.color";
  53652. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53653. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53654. /**
  53655. * The PBR material of BJS following the specular glossiness convention.
  53656. *
  53657. * This fits to the PBR convention in the GLTF definition:
  53658. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53659. */
  53660. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  53661. /**
  53662. * Specifies the diffuse color of the material.
  53663. */
  53664. diffuseColor: Color3;
  53665. /**
  53666. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  53667. * channel.
  53668. */
  53669. diffuseTexture: BaseTexture;
  53670. /**
  53671. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  53672. */
  53673. specularColor: Color3;
  53674. /**
  53675. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  53676. */
  53677. glossiness: number;
  53678. /**
  53679. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  53680. */
  53681. specularGlossinessTexture: BaseTexture;
  53682. /**
  53683. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53684. *
  53685. * @param name The material name
  53686. * @param scene The scene the material will be use in.
  53687. */
  53688. constructor(name: string, scene: Scene);
  53689. /**
  53690. * Return the currrent class name of the material.
  53691. */
  53692. getClassName(): string;
  53693. /**
  53694. * Makes a duplicate of the current material.
  53695. * @param name - name to use for the new material.
  53696. */
  53697. clone(name: string): PBRSpecularGlossinessMaterial;
  53698. /**
  53699. * Serialize the material to a parsable JSON object.
  53700. */
  53701. serialize(): any;
  53702. /**
  53703. * Parses a JSON object correponding to the serialize function.
  53704. */
  53705. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  53706. }
  53707. }
  53708. declare module "babylonjs/Materials/PBR/index" {
  53709. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53710. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  53711. export * from "babylonjs/Materials/PBR/pbrMaterial";
  53712. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  53713. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  53714. }
  53715. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  53716. import { Nullable } from "babylonjs/types";
  53717. import { Scene } from "babylonjs/scene";
  53718. import { Matrix } from "babylonjs/Maths/math.vector";
  53719. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53720. /**
  53721. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  53722. * It can help converting any input color in a desired output one. This can then be used to create effects
  53723. * from sepia, black and white to sixties or futuristic rendering...
  53724. *
  53725. * The only supported format is currently 3dl.
  53726. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  53727. */
  53728. export class ColorGradingTexture extends BaseTexture {
  53729. /**
  53730. * The current texture matrix. (will always be identity in color grading texture)
  53731. */
  53732. private _textureMatrix;
  53733. /**
  53734. * The texture URL.
  53735. */
  53736. url: string;
  53737. /**
  53738. * Empty line regex stored for GC.
  53739. */
  53740. private static _noneEmptyLineRegex;
  53741. private _engine;
  53742. /**
  53743. * Instantiates a ColorGradingTexture from the following parameters.
  53744. *
  53745. * @param url The location of the color gradind data (currently only supporting 3dl)
  53746. * @param scene The scene the texture will be used in
  53747. */
  53748. constructor(url: string, scene: Scene);
  53749. /**
  53750. * Returns the texture matrix used in most of the material.
  53751. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  53752. */
  53753. getTextureMatrix(): Matrix;
  53754. /**
  53755. * Occurs when the file being loaded is a .3dl LUT file.
  53756. */
  53757. private load3dlTexture;
  53758. /**
  53759. * Starts the loading process of the texture.
  53760. */
  53761. private loadTexture;
  53762. /**
  53763. * Clones the color gradind texture.
  53764. */
  53765. clone(): ColorGradingTexture;
  53766. /**
  53767. * Called during delayed load for textures.
  53768. */
  53769. delayLoad(): void;
  53770. /**
  53771. * Parses a color grading texture serialized by Babylon.
  53772. * @param parsedTexture The texture information being parsedTexture
  53773. * @param scene The scene to load the texture in
  53774. * @param rootUrl The root url of the data assets to load
  53775. * @return A color gradind texture
  53776. */
  53777. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  53778. /**
  53779. * Serializes the LUT texture to json format.
  53780. */
  53781. serialize(): any;
  53782. }
  53783. }
  53784. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  53785. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53786. import { Scene } from "babylonjs/scene";
  53787. import { Nullable } from "babylonjs/types";
  53788. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53789. /**
  53790. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  53791. */
  53792. export class EquiRectangularCubeTexture extends BaseTexture {
  53793. /** The six faces of the cube. */
  53794. private static _FacesMapping;
  53795. private _noMipmap;
  53796. private _onLoad;
  53797. private _onError;
  53798. /** The size of the cubemap. */
  53799. private _size;
  53800. /** The buffer of the image. */
  53801. private _buffer;
  53802. /** The width of the input image. */
  53803. private _width;
  53804. /** The height of the input image. */
  53805. private _height;
  53806. /** The URL to the image. */
  53807. url: string;
  53808. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  53809. coordinatesMode: number;
  53810. /**
  53811. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  53812. * @param url The location of the image
  53813. * @param scene The scene the texture will be used in
  53814. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53815. * @param noMipmap Forces to not generate the mipmap if true
  53816. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  53817. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  53818. * @param onLoad — defines a callback called when texture is loaded
  53819. * @param onError — defines a callback called if there is an error
  53820. */
  53821. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  53822. /**
  53823. * Load the image data, by putting the image on a canvas and extracting its buffer.
  53824. */
  53825. private loadImage;
  53826. /**
  53827. * Convert the image buffer into a cubemap and create a CubeTexture.
  53828. */
  53829. private loadTexture;
  53830. /**
  53831. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  53832. * @param buffer The ArrayBuffer that should be converted.
  53833. * @returns The buffer as Float32Array.
  53834. */
  53835. private getFloat32ArrayFromArrayBuffer;
  53836. /**
  53837. * Get the current class name of the texture useful for serialization or dynamic coding.
  53838. * @returns "EquiRectangularCubeTexture"
  53839. */
  53840. getClassName(): string;
  53841. /**
  53842. * Create a clone of the current EquiRectangularCubeTexture and return it.
  53843. * @returns A clone of the current EquiRectangularCubeTexture.
  53844. */
  53845. clone(): EquiRectangularCubeTexture;
  53846. }
  53847. }
  53848. declare module "babylonjs/Misc/tga" {
  53849. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53850. /**
  53851. * Based on jsTGALoader - Javascript loader for TGA file
  53852. * By Vincent Thibault
  53853. * @see http://blog.robrowser.com/javascript-tga-loader.html
  53854. */
  53855. export class TGATools {
  53856. private static _TYPE_INDEXED;
  53857. private static _TYPE_RGB;
  53858. private static _TYPE_GREY;
  53859. private static _TYPE_RLE_INDEXED;
  53860. private static _TYPE_RLE_RGB;
  53861. private static _TYPE_RLE_GREY;
  53862. private static _ORIGIN_MASK;
  53863. private static _ORIGIN_SHIFT;
  53864. private static _ORIGIN_BL;
  53865. private static _ORIGIN_BR;
  53866. private static _ORIGIN_UL;
  53867. private static _ORIGIN_UR;
  53868. /**
  53869. * Gets the header of a TGA file
  53870. * @param data defines the TGA data
  53871. * @returns the header
  53872. */
  53873. static GetTGAHeader(data: Uint8Array): any;
  53874. /**
  53875. * Uploads TGA content to a Babylon Texture
  53876. * @hidden
  53877. */
  53878. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  53879. /** @hidden */
  53880. 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;
  53881. /** @hidden */
  53882. 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;
  53883. /** @hidden */
  53884. 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;
  53885. /** @hidden */
  53886. 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;
  53887. /** @hidden */
  53888. 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;
  53889. /** @hidden */
  53890. 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;
  53891. }
  53892. }
  53893. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  53894. import { Nullable } from "babylonjs/types";
  53895. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53896. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53897. /**
  53898. * Implementation of the TGA Texture Loader.
  53899. * @hidden
  53900. */
  53901. export class _TGATextureLoader implements IInternalTextureLoader {
  53902. /**
  53903. * Defines wether the loader supports cascade loading the different faces.
  53904. */
  53905. readonly supportCascades: boolean;
  53906. /**
  53907. * This returns if the loader support the current file information.
  53908. * @param extension defines the file extension of the file being loaded
  53909. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53910. * @param fallback defines the fallback internal texture if any
  53911. * @param isBase64 defines whether the texture is encoded as a base64
  53912. * @param isBuffer defines whether the texture data are stored as a buffer
  53913. * @returns true if the loader can load the specified file
  53914. */
  53915. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53916. /**
  53917. * Transform the url before loading if required.
  53918. * @param rootUrl the url of the texture
  53919. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53920. * @returns the transformed texture
  53921. */
  53922. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53923. /**
  53924. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53925. * @param rootUrl the url of the texture
  53926. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53927. * @returns the fallback texture
  53928. */
  53929. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53930. /**
  53931. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53932. * @param data contains the texture data
  53933. * @param texture defines the BabylonJS internal texture
  53934. * @param createPolynomials will be true if polynomials have been requested
  53935. * @param onLoad defines the callback to trigger once the texture is ready
  53936. * @param onError defines the callback to trigger in case of error
  53937. */
  53938. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53939. /**
  53940. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53941. * @param data contains the texture data
  53942. * @param texture defines the BabylonJS internal texture
  53943. * @param callback defines the method to call once ready to upload
  53944. */
  53945. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53946. }
  53947. }
  53948. declare module "babylonjs/Misc/basis" {
  53949. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53950. /**
  53951. * Info about the .basis files
  53952. */
  53953. class BasisFileInfo {
  53954. /**
  53955. * If the file has alpha
  53956. */
  53957. hasAlpha: boolean;
  53958. /**
  53959. * Info about each image of the basis file
  53960. */
  53961. images: Array<{
  53962. levels: Array<{
  53963. width: number;
  53964. height: number;
  53965. transcodedPixels: ArrayBufferView;
  53966. }>;
  53967. }>;
  53968. }
  53969. /**
  53970. * Result of transcoding a basis file
  53971. */
  53972. class TranscodeResult {
  53973. /**
  53974. * Info about the .basis file
  53975. */
  53976. fileInfo: BasisFileInfo;
  53977. /**
  53978. * Format to use when loading the file
  53979. */
  53980. format: number;
  53981. }
  53982. /**
  53983. * Configuration options for the Basis transcoder
  53984. */
  53985. export class BasisTranscodeConfiguration {
  53986. /**
  53987. * Supported compression formats used to determine the supported output format of the transcoder
  53988. */
  53989. supportedCompressionFormats?: {
  53990. /**
  53991. * etc1 compression format
  53992. */
  53993. etc1?: boolean;
  53994. /**
  53995. * s3tc compression format
  53996. */
  53997. s3tc?: boolean;
  53998. /**
  53999. * pvrtc compression format
  54000. */
  54001. pvrtc?: boolean;
  54002. /**
  54003. * etc2 compression format
  54004. */
  54005. etc2?: boolean;
  54006. };
  54007. /**
  54008. * If mipmap levels should be loaded for transcoded images (Default: true)
  54009. */
  54010. loadMipmapLevels?: boolean;
  54011. /**
  54012. * Index of a single image to load (Default: all images)
  54013. */
  54014. loadSingleImage?: number;
  54015. }
  54016. /**
  54017. * Used to load .Basis files
  54018. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54019. */
  54020. export class BasisTools {
  54021. private static _IgnoreSupportedFormats;
  54022. /**
  54023. * URL to use when loading the basis transcoder
  54024. */
  54025. static JSModuleURL: string;
  54026. /**
  54027. * URL to use when loading the wasm module for the transcoder
  54028. */
  54029. static WasmModuleURL: string;
  54030. /**
  54031. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54032. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54033. * @returns internal format corresponding to the Basis format
  54034. */
  54035. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54036. private static _WorkerPromise;
  54037. private static _Worker;
  54038. private static _actionId;
  54039. private static _CreateWorkerAsync;
  54040. /**
  54041. * Transcodes a loaded image file to compressed pixel data
  54042. * @param imageData image data to transcode
  54043. * @param config configuration options for the transcoding
  54044. * @returns a promise resulting in the transcoded image
  54045. */
  54046. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54047. /**
  54048. * Loads a texture from the transcode result
  54049. * @param texture texture load to
  54050. * @param transcodeResult the result of transcoding the basis file to load from
  54051. */
  54052. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54053. }
  54054. }
  54055. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54056. import { Nullable } from "babylonjs/types";
  54057. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54058. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54059. /**
  54060. * Loader for .basis file format
  54061. */
  54062. export class _BasisTextureLoader implements IInternalTextureLoader {
  54063. /**
  54064. * Defines whether the loader supports cascade loading the different faces.
  54065. */
  54066. readonly supportCascades: boolean;
  54067. /**
  54068. * This returns if the loader support the current file information.
  54069. * @param extension defines the file extension of the file being loaded
  54070. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54071. * @param fallback defines the fallback internal texture if any
  54072. * @param isBase64 defines whether the texture is encoded as a base64
  54073. * @param isBuffer defines whether the texture data are stored as a buffer
  54074. * @returns true if the loader can load the specified file
  54075. */
  54076. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54077. /**
  54078. * Transform the url before loading if required.
  54079. * @param rootUrl the url of the texture
  54080. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54081. * @returns the transformed texture
  54082. */
  54083. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54084. /**
  54085. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54086. * @param rootUrl the url of the texture
  54087. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54088. * @returns the fallback texture
  54089. */
  54090. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54091. /**
  54092. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54093. * @param data contains the texture data
  54094. * @param texture defines the BabylonJS internal texture
  54095. * @param createPolynomials will be true if polynomials have been requested
  54096. * @param onLoad defines the callback to trigger once the texture is ready
  54097. * @param onError defines the callback to trigger in case of error
  54098. */
  54099. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54100. /**
  54101. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54102. * @param data contains the texture data
  54103. * @param texture defines the BabylonJS internal texture
  54104. * @param callback defines the method to call once ready to upload
  54105. */
  54106. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54107. }
  54108. }
  54109. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54110. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54111. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54112. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54113. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54114. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54115. }
  54116. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54117. import { Scene } from "babylonjs/scene";
  54118. import { Texture } from "babylonjs/Materials/Textures/texture";
  54119. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54120. /**
  54121. * 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.
  54122. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54123. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54124. */
  54125. export class CustomProceduralTexture extends ProceduralTexture {
  54126. private _animate;
  54127. private _time;
  54128. private _config;
  54129. private _texturePath;
  54130. /**
  54131. * Instantiates a new Custom Procedural Texture.
  54132. * 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.
  54133. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54134. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54135. * @param name Define the name of the texture
  54136. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54137. * @param size Define the size of the texture to create
  54138. * @param scene Define the scene the texture belongs to
  54139. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54140. * @param generateMipMaps Define if the texture should creates mip maps or not
  54141. */
  54142. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54143. private _loadJson;
  54144. /**
  54145. * Is the texture ready to be used ? (rendered at least once)
  54146. * @returns true if ready, otherwise, false.
  54147. */
  54148. isReady(): boolean;
  54149. /**
  54150. * Render the texture to its associated render target.
  54151. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54152. */
  54153. render(useCameraPostProcess?: boolean): void;
  54154. /**
  54155. * Update the list of dependant textures samplers in the shader.
  54156. */
  54157. updateTextures(): void;
  54158. /**
  54159. * Update the uniform values of the procedural texture in the shader.
  54160. */
  54161. updateShaderUniforms(): void;
  54162. /**
  54163. * Define if the texture animates or not.
  54164. */
  54165. animate: boolean;
  54166. }
  54167. }
  54168. declare module "babylonjs/Shaders/noise.fragment" {
  54169. /** @hidden */
  54170. export var noisePixelShader: {
  54171. name: string;
  54172. shader: string;
  54173. };
  54174. }
  54175. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54176. import { Nullable } from "babylonjs/types";
  54177. import { Scene } from "babylonjs/scene";
  54178. import { Texture } from "babylonjs/Materials/Textures/texture";
  54179. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54180. import "babylonjs/Shaders/noise.fragment";
  54181. /**
  54182. * Class used to generate noise procedural textures
  54183. */
  54184. export class NoiseProceduralTexture extends ProceduralTexture {
  54185. private _time;
  54186. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54187. brightness: number;
  54188. /** Defines the number of octaves to process */
  54189. octaves: number;
  54190. /** Defines the level of persistence (0.8 by default) */
  54191. persistence: number;
  54192. /** Gets or sets animation speed factor (default is 1) */
  54193. animationSpeedFactor: number;
  54194. /**
  54195. * Creates a new NoiseProceduralTexture
  54196. * @param name defines the name fo the texture
  54197. * @param size defines the size of the texture (default is 256)
  54198. * @param scene defines the hosting scene
  54199. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54200. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54201. */
  54202. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54203. private _updateShaderUniforms;
  54204. protected _getDefines(): string;
  54205. /** Generate the current state of the procedural texture */
  54206. render(useCameraPostProcess?: boolean): void;
  54207. /**
  54208. * Serializes this noise procedural texture
  54209. * @returns a serialized noise procedural texture object
  54210. */
  54211. serialize(): any;
  54212. /**
  54213. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54214. * @param parsedTexture defines parsed texture data
  54215. * @param scene defines the current scene
  54216. * @param rootUrl defines the root URL containing noise procedural texture information
  54217. * @returns a parsed NoiseProceduralTexture
  54218. */
  54219. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54220. }
  54221. }
  54222. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54223. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54224. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54225. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54226. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54227. }
  54228. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54229. import { Nullable } from "babylonjs/types";
  54230. import { Scene } from "babylonjs/scene";
  54231. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54232. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54233. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54234. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54235. /**
  54236. * Raw cube texture where the raw buffers are passed in
  54237. */
  54238. export class RawCubeTexture extends CubeTexture {
  54239. /**
  54240. * Creates a cube texture where the raw buffers are passed in.
  54241. * @param scene defines the scene the texture is attached to
  54242. * @param data defines the array of data to use to create each face
  54243. * @param size defines the size of the textures
  54244. * @param format defines the format of the data
  54245. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54246. * @param generateMipMaps defines if the engine should generate the mip levels
  54247. * @param invertY defines if data must be stored with Y axis inverted
  54248. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54249. * @param compression defines the compression used (null by default)
  54250. */
  54251. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54252. /**
  54253. * Updates the raw cube texture.
  54254. * @param data defines the data to store
  54255. * @param format defines the data format
  54256. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54257. * @param invertY defines if data must be stored with Y axis inverted
  54258. * @param compression defines the compression used (null by default)
  54259. * @param level defines which level of the texture to update
  54260. */
  54261. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54262. /**
  54263. * Updates a raw cube texture with RGBD encoded data.
  54264. * @param data defines the array of data [mipmap][face] to use to create each face
  54265. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54266. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54267. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54268. * @returns a promsie that resolves when the operation is complete
  54269. */
  54270. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54271. /**
  54272. * Clones the raw cube texture.
  54273. * @return a new cube texture
  54274. */
  54275. clone(): CubeTexture;
  54276. /** @hidden */
  54277. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54278. }
  54279. }
  54280. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54281. import { Scene } from "babylonjs/scene";
  54282. import { Texture } from "babylonjs/Materials/Textures/texture";
  54283. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54284. /**
  54285. * Class used to store 3D textures containing user data
  54286. */
  54287. export class RawTexture3D extends Texture {
  54288. /** Gets or sets the texture format to use */
  54289. format: number;
  54290. private _engine;
  54291. /**
  54292. * Create a new RawTexture3D
  54293. * @param data defines the data of the texture
  54294. * @param width defines the width of the texture
  54295. * @param height defines the height of the texture
  54296. * @param depth defines the depth of the texture
  54297. * @param format defines the texture format to use
  54298. * @param scene defines the hosting scene
  54299. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54300. * @param invertY defines if texture must be stored with Y axis inverted
  54301. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54302. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54303. */
  54304. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54305. /** Gets or sets the texture format to use */
  54306. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54307. /**
  54308. * Update the texture with new data
  54309. * @param data defines the data to store in the texture
  54310. */
  54311. update(data: ArrayBufferView): void;
  54312. }
  54313. }
  54314. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54315. import { Scene } from "babylonjs/scene";
  54316. import { Plane } from "babylonjs/Maths/math.plane";
  54317. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54318. /**
  54319. * Creates a refraction texture used by refraction channel of the standard material.
  54320. * It is like a mirror but to see through a material.
  54321. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54322. */
  54323. export class RefractionTexture extends RenderTargetTexture {
  54324. /**
  54325. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54326. * 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.
  54327. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54328. */
  54329. refractionPlane: Plane;
  54330. /**
  54331. * Define how deep under the surface we should see.
  54332. */
  54333. depth: number;
  54334. /**
  54335. * Creates a refraction texture used by refraction channel of the standard material.
  54336. * It is like a mirror but to see through a material.
  54337. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54338. * @param name Define the texture name
  54339. * @param size Define the size of the underlying texture
  54340. * @param scene Define the scene the refraction belongs to
  54341. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54342. */
  54343. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54344. /**
  54345. * Clone the refraction texture.
  54346. * @returns the cloned texture
  54347. */
  54348. clone(): RefractionTexture;
  54349. /**
  54350. * Serialize the texture to a JSON representation you could use in Parse later on
  54351. * @returns the serialized JSON representation
  54352. */
  54353. serialize(): any;
  54354. }
  54355. }
  54356. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54357. import { Nullable } from "babylonjs/types";
  54358. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54359. import { Matrix } from "babylonjs/Maths/math.vector";
  54360. import { Engine } from "babylonjs/Engines/engine";
  54361. import { Scene } from "babylonjs/scene";
  54362. /**
  54363. * Defines the options related to the creation of an HtmlElementTexture
  54364. */
  54365. export interface IHtmlElementTextureOptions {
  54366. /**
  54367. * Defines wether mip maps should be created or not.
  54368. */
  54369. generateMipMaps?: boolean;
  54370. /**
  54371. * Defines the sampling mode of the texture.
  54372. */
  54373. samplingMode?: number;
  54374. /**
  54375. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54376. */
  54377. engine: Nullable<Engine>;
  54378. /**
  54379. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54380. */
  54381. scene: Nullable<Scene>;
  54382. }
  54383. /**
  54384. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54385. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54386. * is automatically managed.
  54387. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54388. * in your application.
  54389. *
  54390. * As the update is not automatic, you need to call them manually.
  54391. */
  54392. export class HtmlElementTexture extends BaseTexture {
  54393. /**
  54394. * The texture URL.
  54395. */
  54396. element: HTMLVideoElement | HTMLCanvasElement;
  54397. private static readonly DefaultOptions;
  54398. private _textureMatrix;
  54399. private _engine;
  54400. private _isVideo;
  54401. private _generateMipMaps;
  54402. private _samplingMode;
  54403. /**
  54404. * Instantiates a HtmlElementTexture from the following parameters.
  54405. *
  54406. * @param name Defines the name of the texture
  54407. * @param element Defines the video or canvas the texture is filled with
  54408. * @param options Defines the other none mandatory texture creation options
  54409. */
  54410. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54411. private _createInternalTexture;
  54412. /**
  54413. * Returns the texture matrix used in most of the material.
  54414. */
  54415. getTextureMatrix(): Matrix;
  54416. /**
  54417. * Updates the content of the texture.
  54418. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54419. */
  54420. update(invertY?: Nullable<boolean>): void;
  54421. }
  54422. }
  54423. declare module "babylonjs/Materials/Textures/index" {
  54424. export * from "babylonjs/Materials/Textures/baseTexture";
  54425. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54426. export * from "babylonjs/Materials/Textures/cubeTexture";
  54427. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54428. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54429. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54430. export * from "babylonjs/Materials/Textures/internalTexture";
  54431. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54432. export * from "babylonjs/Materials/Textures/Loaders/index";
  54433. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54434. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54435. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54436. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54437. export * from "babylonjs/Materials/Textures/rawTexture";
  54438. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54439. export * from "babylonjs/Materials/Textures/refractionTexture";
  54440. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54441. export * from "babylonjs/Materials/Textures/texture";
  54442. export * from "babylonjs/Materials/Textures/videoTexture";
  54443. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54444. }
  54445. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  54446. /**
  54447. * Enum used to define the target of a block
  54448. */
  54449. export enum NodeMaterialBlockTargets {
  54450. /** Vertex shader */
  54451. Vertex = 1,
  54452. /** Fragment shader */
  54453. Fragment = 2,
  54454. /** Neutral */
  54455. Neutral = 4,
  54456. /** Vertex and Fragment */
  54457. VertexAndFragment = 3
  54458. }
  54459. }
  54460. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  54461. /**
  54462. * Defines the kind of connection point for node based material
  54463. */
  54464. export enum NodeMaterialBlockConnectionPointTypes {
  54465. /** Float */
  54466. Float = 1,
  54467. /** Int */
  54468. Int = 2,
  54469. /** Vector2 */
  54470. Vector2 = 4,
  54471. /** Vector3 */
  54472. Vector3 = 8,
  54473. /** Vector4 */
  54474. Vector4 = 16,
  54475. /** Color3 */
  54476. Color3 = 32,
  54477. /** Color4 */
  54478. Color4 = 64,
  54479. /** Matrix */
  54480. Matrix = 128,
  54481. /** Detect type based on connection */
  54482. AutoDetect = 1024,
  54483. /** Output type that will be defined by input type */
  54484. BasedOnInput = 2048
  54485. }
  54486. }
  54487. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  54488. /**
  54489. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54490. */
  54491. export enum NodeMaterialBlockConnectionPointMode {
  54492. /** Value is an uniform */
  54493. Uniform = 0,
  54494. /** Value is a mesh attribute */
  54495. Attribute = 1,
  54496. /** Value is a varying between vertex and fragment shaders */
  54497. Varying = 2,
  54498. /** Mode is undefined */
  54499. Undefined = 3
  54500. }
  54501. }
  54502. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  54503. /**
  54504. * Enum used to define system values e.g. values automatically provided by the system
  54505. */
  54506. export enum NodeMaterialSystemValues {
  54507. /** World */
  54508. World = 1,
  54509. /** View */
  54510. View = 2,
  54511. /** Projection */
  54512. Projection = 3,
  54513. /** ViewProjection */
  54514. ViewProjection = 4,
  54515. /** WorldView */
  54516. WorldView = 5,
  54517. /** WorldViewProjection */
  54518. WorldViewProjection = 6,
  54519. /** CameraPosition */
  54520. CameraPosition = 7,
  54521. /** Fog Color */
  54522. FogColor = 8
  54523. }
  54524. }
  54525. declare module "babylonjs/Materials/Node/Enums/index" {
  54526. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  54527. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  54528. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  54529. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  54530. }
  54531. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  54532. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54533. /**
  54534. * Root class for all node material optimizers
  54535. */
  54536. export class NodeMaterialOptimizer {
  54537. /**
  54538. * Function used to optimize a NodeMaterial graph
  54539. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  54540. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  54541. */
  54542. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  54543. }
  54544. }
  54545. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  54546. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54547. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54548. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54549. import { Scene } from "babylonjs/scene";
  54550. /**
  54551. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  54552. */
  54553. export class TransformBlock extends NodeMaterialBlock {
  54554. /**
  54555. * Defines the value to use to complement W value to transform it to a Vector4
  54556. */
  54557. complementW: number;
  54558. /**
  54559. * Defines the value to use to complement z value to transform it to a Vector4
  54560. */
  54561. complementZ: number;
  54562. /**
  54563. * Creates a new TransformBlock
  54564. * @param name defines the block name
  54565. */
  54566. constructor(name: string);
  54567. /**
  54568. * Gets the current class name
  54569. * @returns the class name
  54570. */
  54571. getClassName(): string;
  54572. /**
  54573. * Gets the vector input
  54574. */
  54575. readonly vector: NodeMaterialConnectionPoint;
  54576. /**
  54577. * Gets the output component
  54578. */
  54579. readonly output: NodeMaterialConnectionPoint;
  54580. /**
  54581. * Gets the matrix transform input
  54582. */
  54583. readonly transform: NodeMaterialConnectionPoint;
  54584. protected _buildBlock(state: NodeMaterialBuildState): this;
  54585. serialize(): any;
  54586. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54587. protected _dumpPropertiesCode(): string;
  54588. }
  54589. }
  54590. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  54591. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54592. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54593. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54594. /**
  54595. * Block used to output the vertex position
  54596. */
  54597. export class VertexOutputBlock extends NodeMaterialBlock {
  54598. /**
  54599. * Creates a new VertexOutputBlock
  54600. * @param name defines the block name
  54601. */
  54602. constructor(name: string);
  54603. /**
  54604. * Gets the current class name
  54605. * @returns the class name
  54606. */
  54607. getClassName(): string;
  54608. /**
  54609. * Gets the vector input component
  54610. */
  54611. readonly vector: NodeMaterialConnectionPoint;
  54612. protected _buildBlock(state: NodeMaterialBuildState): this;
  54613. }
  54614. }
  54615. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  54616. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54617. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54618. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54619. /**
  54620. * Block used to output the final color
  54621. */
  54622. export class FragmentOutputBlock extends NodeMaterialBlock {
  54623. /**
  54624. * Create a new FragmentOutputBlock
  54625. * @param name defines the block name
  54626. */
  54627. constructor(name: string);
  54628. /**
  54629. * Gets the current class name
  54630. * @returns the class name
  54631. */
  54632. getClassName(): string;
  54633. /**
  54634. * Gets the rgba input component
  54635. */
  54636. readonly rgba: NodeMaterialConnectionPoint;
  54637. /**
  54638. * Gets the rgb input component
  54639. */
  54640. readonly rgb: NodeMaterialConnectionPoint;
  54641. /**
  54642. * Gets the a input component
  54643. */
  54644. readonly a: NodeMaterialConnectionPoint;
  54645. protected _buildBlock(state: NodeMaterialBuildState): this;
  54646. }
  54647. }
  54648. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  54649. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54650. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54651. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54652. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54654. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54655. import { Effect } from "babylonjs/Materials/effect";
  54656. import { Mesh } from "babylonjs/Meshes/mesh";
  54657. import { Nullable } from "babylonjs/types";
  54658. import { Scene } from "babylonjs/scene";
  54659. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  54660. /**
  54661. * Block used to read a reflection texture from a sampler
  54662. */
  54663. export class ReflectionTextureBlock extends NodeMaterialBlock {
  54664. private _define3DName;
  54665. private _defineCubicName;
  54666. private _defineExplicitName;
  54667. private _defineProjectionName;
  54668. private _defineLocalCubicName;
  54669. private _defineSphericalName;
  54670. private _definePlanarName;
  54671. private _defineEquirectangularName;
  54672. private _defineMirroredEquirectangularFixedName;
  54673. private _defineEquirectangularFixedName;
  54674. private _defineSkyboxName;
  54675. private _cubeSamplerName;
  54676. private _2DSamplerName;
  54677. private _positionUVWName;
  54678. private _directionWName;
  54679. private _reflectionCoordsName;
  54680. private _reflection2DCoordsName;
  54681. private _reflectionColorName;
  54682. private _reflectionMatrixName;
  54683. /**
  54684. * Gets or sets the texture associated with the node
  54685. */
  54686. texture: Nullable<BaseTexture>;
  54687. /**
  54688. * Create a new TextureBlock
  54689. * @param name defines the block name
  54690. */
  54691. constructor(name: string);
  54692. /**
  54693. * Gets the current class name
  54694. * @returns the class name
  54695. */
  54696. getClassName(): string;
  54697. /**
  54698. * Gets the world position input component
  54699. */
  54700. readonly position: NodeMaterialConnectionPoint;
  54701. /**
  54702. * Gets the world position input component
  54703. */
  54704. readonly worldPosition: NodeMaterialConnectionPoint;
  54705. /**
  54706. * Gets the world normal input component
  54707. */
  54708. readonly worldNormal: NodeMaterialConnectionPoint;
  54709. /**
  54710. * Gets the world input component
  54711. */
  54712. readonly world: NodeMaterialConnectionPoint;
  54713. /**
  54714. * Gets the camera (or eye) position component
  54715. */
  54716. readonly cameraPosition: NodeMaterialConnectionPoint;
  54717. /**
  54718. * Gets the view input component
  54719. */
  54720. readonly view: NodeMaterialConnectionPoint;
  54721. /**
  54722. * Gets the rgb output component
  54723. */
  54724. readonly rgb: NodeMaterialConnectionPoint;
  54725. /**
  54726. * Gets the r output component
  54727. */
  54728. readonly r: NodeMaterialConnectionPoint;
  54729. /**
  54730. * Gets the g output component
  54731. */
  54732. readonly g: NodeMaterialConnectionPoint;
  54733. /**
  54734. * Gets the b output component
  54735. */
  54736. readonly b: NodeMaterialConnectionPoint;
  54737. autoConfigure(material: NodeMaterial): void;
  54738. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54739. isReady(): boolean;
  54740. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54741. private _injectVertexCode;
  54742. private _writeOutput;
  54743. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54744. serialize(): any;
  54745. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54746. }
  54747. }
  54748. declare module "babylonjs/Materials/Node/nodeMaterial" {
  54749. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54750. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  54751. import { Scene } from "babylonjs/scene";
  54752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54753. import { Matrix } from "babylonjs/Maths/math.vector";
  54754. import { Mesh } from "babylonjs/Meshes/mesh";
  54755. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54756. import { Observable } from "babylonjs/Misc/observable";
  54757. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54758. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  54759. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54760. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  54761. import { Nullable } from "babylonjs/types";
  54762. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54763. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54764. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  54765. /**
  54766. * Interface used to configure the node material editor
  54767. */
  54768. export interface INodeMaterialEditorOptions {
  54769. /** Define the URl to load node editor script */
  54770. editorURL?: string;
  54771. }
  54772. /** @hidden */
  54773. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  54774. /** BONES */
  54775. NUM_BONE_INFLUENCERS: number;
  54776. BonesPerMesh: number;
  54777. BONETEXTURE: boolean;
  54778. /** MORPH TARGETS */
  54779. MORPHTARGETS: boolean;
  54780. MORPHTARGETS_NORMAL: boolean;
  54781. MORPHTARGETS_TANGENT: boolean;
  54782. MORPHTARGETS_UV: boolean;
  54783. NUM_MORPH_INFLUENCERS: number;
  54784. /** IMAGE PROCESSING */
  54785. IMAGEPROCESSING: boolean;
  54786. VIGNETTE: boolean;
  54787. VIGNETTEBLENDMODEMULTIPLY: boolean;
  54788. VIGNETTEBLENDMODEOPAQUE: boolean;
  54789. TONEMAPPING: boolean;
  54790. TONEMAPPING_ACES: boolean;
  54791. CONTRAST: boolean;
  54792. EXPOSURE: boolean;
  54793. COLORCURVES: boolean;
  54794. COLORGRADING: boolean;
  54795. COLORGRADING3D: boolean;
  54796. SAMPLER3DGREENDEPTH: boolean;
  54797. SAMPLER3DBGRMAP: boolean;
  54798. IMAGEPROCESSINGPOSTPROCESS: boolean;
  54799. /** MISC. */
  54800. BUMPDIRECTUV: number;
  54801. constructor();
  54802. setValue(name: string, value: boolean): void;
  54803. }
  54804. /**
  54805. * Class used to configure NodeMaterial
  54806. */
  54807. export interface INodeMaterialOptions {
  54808. /**
  54809. * Defines if blocks should emit comments
  54810. */
  54811. emitComments: boolean;
  54812. }
  54813. /**
  54814. * Class used to create a node based material built by assembling shader blocks
  54815. */
  54816. export class NodeMaterial extends PushMaterial {
  54817. private static _BuildIdGenerator;
  54818. private _options;
  54819. private _vertexCompilationState;
  54820. private _fragmentCompilationState;
  54821. private _sharedData;
  54822. private _buildId;
  54823. private _buildWasSuccessful;
  54824. private _cachedWorldViewMatrix;
  54825. private _cachedWorldViewProjectionMatrix;
  54826. private _optimizers;
  54827. private _animationFrame;
  54828. /** Define the URl to load node editor script */
  54829. static EditorURL: string;
  54830. private BJSNODEMATERIALEDITOR;
  54831. /** Get the inspector from bundle or global */
  54832. private _getGlobalNodeMaterialEditor;
  54833. /**
  54834. * 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)
  54835. */
  54836. ignoreAlpha: boolean;
  54837. /**
  54838. * Defines the maximum number of lights that can be used in the material
  54839. */
  54840. maxSimultaneousLights: number;
  54841. /**
  54842. * Observable raised when the material is built
  54843. */
  54844. onBuildObservable: Observable<NodeMaterial>;
  54845. /**
  54846. * Gets or sets the root nodes of the material vertex shader
  54847. */
  54848. _vertexOutputNodes: NodeMaterialBlock[];
  54849. /**
  54850. * Gets or sets the root nodes of the material fragment (pixel) shader
  54851. */
  54852. _fragmentOutputNodes: NodeMaterialBlock[];
  54853. /** Gets or sets options to control the node material overall behavior */
  54854. options: INodeMaterialOptions;
  54855. /**
  54856. * Default configuration related to image processing available in the standard Material.
  54857. */
  54858. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54859. /**
  54860. * Gets the image processing configuration used either in this material.
  54861. */
  54862. /**
  54863. * Sets the Default image processing configuration used either in the this material.
  54864. *
  54865. * If sets to null, the scene one is in use.
  54866. */
  54867. imageProcessingConfiguration: ImageProcessingConfiguration;
  54868. /**
  54869. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  54870. */
  54871. attachedBlocks: NodeMaterialBlock[];
  54872. /**
  54873. * Create a new node based material
  54874. * @param name defines the material name
  54875. * @param scene defines the hosting scene
  54876. * @param options defines creation option
  54877. */
  54878. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  54879. /**
  54880. * Gets the current class name of the material e.g. "NodeMaterial"
  54881. * @returns the class name
  54882. */
  54883. getClassName(): string;
  54884. /**
  54885. * Keep track of the image processing observer to allow dispose and replace.
  54886. */
  54887. private _imageProcessingObserver;
  54888. /**
  54889. * Attaches a new image processing configuration to the Standard Material.
  54890. * @param configuration
  54891. */
  54892. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54893. /**
  54894. * Get a block by its name
  54895. * @param name defines the name of the block to retrieve
  54896. * @returns the required block or null if not found
  54897. */
  54898. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  54899. /**
  54900. * Get a block by its name
  54901. * @param predicate defines the predicate used to find the good candidate
  54902. * @returns the required block or null if not found
  54903. */
  54904. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  54905. /**
  54906. * Get an input block by its name
  54907. * @param predicate defines the predicate used to find the good candidate
  54908. * @returns the required input block or null if not found
  54909. */
  54910. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  54911. /**
  54912. * Gets the list of input blocks attached to this material
  54913. * @returns an array of InputBlocks
  54914. */
  54915. getInputBlocks(): InputBlock[];
  54916. /**
  54917. * Adds a new optimizer to the list of optimizers
  54918. * @param optimizer defines the optimizers to add
  54919. * @returns the current material
  54920. */
  54921. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54922. /**
  54923. * Remove an optimizer from the list of optimizers
  54924. * @param optimizer defines the optimizers to remove
  54925. * @returns the current material
  54926. */
  54927. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  54928. /**
  54929. * Add a new block to the list of output nodes
  54930. * @param node defines the node to add
  54931. * @returns the current material
  54932. */
  54933. addOutputNode(node: NodeMaterialBlock): this;
  54934. /**
  54935. * Remove a block from the list of root nodes
  54936. * @param node defines the node to remove
  54937. * @returns the current material
  54938. */
  54939. removeOutputNode(node: NodeMaterialBlock): this;
  54940. private _addVertexOutputNode;
  54941. private _removeVertexOutputNode;
  54942. private _addFragmentOutputNode;
  54943. private _removeFragmentOutputNode;
  54944. /**
  54945. * Specifies if the material will require alpha blending
  54946. * @returns a boolean specifying if alpha blending is needed
  54947. */
  54948. needAlphaBlending(): boolean;
  54949. /**
  54950. * Specifies if this material should be rendered in alpha test mode
  54951. * @returns a boolean specifying if an alpha test is needed.
  54952. */
  54953. needAlphaTesting(): boolean;
  54954. private _initializeBlock;
  54955. private _resetDualBlocks;
  54956. /**
  54957. * Build the material and generates the inner effect
  54958. * @param verbose defines if the build should log activity
  54959. */
  54960. build(verbose?: boolean): void;
  54961. /**
  54962. * Runs an otpimization phase to try to improve the shader code
  54963. */
  54964. optimize(): void;
  54965. private _prepareDefinesForAttributes;
  54966. /**
  54967. * Get if the submesh is ready to be used and all its information available.
  54968. * Child classes can use it to update shaders
  54969. * @param mesh defines the mesh to check
  54970. * @param subMesh defines which submesh to check
  54971. * @param useInstances specifies that instances should be used
  54972. * @returns a boolean indicating that the submesh is ready or not
  54973. */
  54974. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54975. /**
  54976. * Get a string representing the shaders built by the current node graph
  54977. */
  54978. readonly compiledShaders: string;
  54979. /**
  54980. * Binds the world matrix to the material
  54981. * @param world defines the world transformation matrix
  54982. */
  54983. bindOnlyWorldMatrix(world: Matrix): void;
  54984. /**
  54985. * Binds the submesh to this material by preparing the effect and shader to draw
  54986. * @param world defines the world transformation matrix
  54987. * @param mesh defines the mesh containing the submesh
  54988. * @param subMesh defines the submesh to bind the material to
  54989. */
  54990. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54991. /**
  54992. * Gets the active textures from the material
  54993. * @returns an array of textures
  54994. */
  54995. getActiveTextures(): BaseTexture[];
  54996. /**
  54997. * Gets the list of texture blocks
  54998. * @returns an array of texture blocks
  54999. */
  55000. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55001. /**
  55002. * Specifies if the material uses a texture
  55003. * @param texture defines the texture to check against the material
  55004. * @returns a boolean specifying if the material uses the texture
  55005. */
  55006. hasTexture(texture: BaseTexture): boolean;
  55007. /**
  55008. * Disposes the material
  55009. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55010. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55011. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55012. */
  55013. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55014. /** Creates the node editor window. */
  55015. private _createNodeEditor;
  55016. /**
  55017. * Launch the node material editor
  55018. * @param config Define the configuration of the editor
  55019. * @return a promise fulfilled when the node editor is visible
  55020. */
  55021. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55022. /**
  55023. * Clear the current material
  55024. */
  55025. clear(): void;
  55026. /**
  55027. * Clear the current material and set it to a default state
  55028. */
  55029. setToDefault(): void;
  55030. /**
  55031. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55032. * @param url defines the url to load from
  55033. * @returns a promise that will fullfil when the material is fully loaded
  55034. */
  55035. loadAsync(url: string): Promise<unknown>;
  55036. private _gatherBlocks;
  55037. /**
  55038. * Generate a string containing the code declaration required to create an equivalent of this material
  55039. * @returns a string
  55040. */
  55041. generateCode(): string;
  55042. /**
  55043. * Serializes this material in a JSON representation
  55044. * @returns the serialized material object
  55045. */
  55046. serialize(): any;
  55047. private _restoreConnections;
  55048. /**
  55049. * Clear the current graph and load a new one from a serialization object
  55050. * @param source defines the JSON representation of the material
  55051. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55052. */
  55053. loadFromSerialization(source: any, rootUrl?: string): void;
  55054. /**
  55055. * Creates a node material from parsed material data
  55056. * @param source defines the JSON representation of the material
  55057. * @param scene defines the hosting scene
  55058. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55059. * @returns a new node material
  55060. */
  55061. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55062. /**
  55063. * Creates a new node material set to default basic configuration
  55064. * @param name defines the name of the material
  55065. * @param scene defines the hosting scene
  55066. * @returns a new NodeMaterial
  55067. */
  55068. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55069. }
  55070. }
  55071. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55072. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55073. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55074. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55075. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55077. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55078. import { Effect } from "babylonjs/Materials/effect";
  55079. import { Mesh } from "babylonjs/Meshes/mesh";
  55080. import { Nullable } from "babylonjs/types";
  55081. import { Texture } from "babylonjs/Materials/Textures/texture";
  55082. import { Scene } from "babylonjs/scene";
  55083. /**
  55084. * Block used to read a texture from a sampler
  55085. */
  55086. export class TextureBlock extends NodeMaterialBlock {
  55087. private _defineName;
  55088. private _samplerName;
  55089. private _transformedUVName;
  55090. private _textureTransformName;
  55091. private _textureInfoName;
  55092. private _mainUVName;
  55093. private _mainUVDefineName;
  55094. /**
  55095. * Gets or sets the texture associated with the node
  55096. */
  55097. texture: Nullable<Texture>;
  55098. /**
  55099. * Create a new TextureBlock
  55100. * @param name defines the block name
  55101. */
  55102. constructor(name: string);
  55103. /**
  55104. * Gets the current class name
  55105. * @returns the class name
  55106. */
  55107. getClassName(): string;
  55108. /**
  55109. * Gets the uv input component
  55110. */
  55111. readonly uv: NodeMaterialConnectionPoint;
  55112. /**
  55113. * Gets the rgba output component
  55114. */
  55115. readonly rgba: NodeMaterialConnectionPoint;
  55116. /**
  55117. * Gets the rgb output component
  55118. */
  55119. readonly rgb: NodeMaterialConnectionPoint;
  55120. /**
  55121. * Gets the r output component
  55122. */
  55123. readonly r: NodeMaterialConnectionPoint;
  55124. /**
  55125. * Gets the g output component
  55126. */
  55127. readonly g: NodeMaterialConnectionPoint;
  55128. /**
  55129. * Gets the b output component
  55130. */
  55131. readonly b: NodeMaterialConnectionPoint;
  55132. /**
  55133. * Gets the a output component
  55134. */
  55135. readonly a: NodeMaterialConnectionPoint;
  55136. readonly target: NodeMaterialBlockTargets;
  55137. autoConfigure(material: NodeMaterial): void;
  55138. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55139. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55140. isReady(): boolean;
  55141. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55142. private readonly _isMixed;
  55143. private _injectVertexCode;
  55144. private _writeOutput;
  55145. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55146. protected _dumpPropertiesCode(): string;
  55147. serialize(): any;
  55148. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55149. }
  55150. }
  55151. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55152. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55153. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55154. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55155. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55156. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55157. import { Scene } from "babylonjs/scene";
  55158. /**
  55159. * Class used to store shared data between 2 NodeMaterialBuildState
  55160. */
  55161. export class NodeMaterialBuildStateSharedData {
  55162. /**
  55163. * Gets the list of emitted varyings
  55164. */
  55165. temps: string[];
  55166. /**
  55167. * Gets the list of emitted varyings
  55168. */
  55169. varyings: string[];
  55170. /**
  55171. * Gets the varying declaration string
  55172. */
  55173. varyingDeclaration: string;
  55174. /**
  55175. * Input blocks
  55176. */
  55177. inputBlocks: InputBlock[];
  55178. /**
  55179. * Input blocks
  55180. */
  55181. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55182. /**
  55183. * Bindable blocks (Blocks that need to set data to the effect)
  55184. */
  55185. bindableBlocks: NodeMaterialBlock[];
  55186. /**
  55187. * List of blocks that can provide a compilation fallback
  55188. */
  55189. blocksWithFallbacks: NodeMaterialBlock[];
  55190. /**
  55191. * List of blocks that can provide a define update
  55192. */
  55193. blocksWithDefines: NodeMaterialBlock[];
  55194. /**
  55195. * List of blocks that can provide a repeatable content
  55196. */
  55197. repeatableContentBlocks: NodeMaterialBlock[];
  55198. /**
  55199. * List of blocks that can provide a dynamic list of uniforms
  55200. */
  55201. dynamicUniformBlocks: NodeMaterialBlock[];
  55202. /**
  55203. * List of blocks that can block the isReady function for the material
  55204. */
  55205. blockingBlocks: NodeMaterialBlock[];
  55206. /**
  55207. * Gets the list of animated inputs
  55208. */
  55209. animatedInputs: InputBlock[];
  55210. /**
  55211. * Build Id used to avoid multiple recompilations
  55212. */
  55213. buildId: number;
  55214. /** List of emitted variables */
  55215. variableNames: {
  55216. [key: string]: number;
  55217. };
  55218. /** List of emitted defines */
  55219. defineNames: {
  55220. [key: string]: number;
  55221. };
  55222. /** Should emit comments? */
  55223. emitComments: boolean;
  55224. /** Emit build activity */
  55225. verbose: boolean;
  55226. /** Gets or sets the hosting scene */
  55227. scene: Scene;
  55228. /**
  55229. * Gets the compilation hints emitted at compilation time
  55230. */
  55231. hints: {
  55232. needWorldViewMatrix: boolean;
  55233. needWorldViewProjectionMatrix: boolean;
  55234. needAlphaBlending: boolean;
  55235. needAlphaTesting: boolean;
  55236. };
  55237. /**
  55238. * List of compilation checks
  55239. */
  55240. checks: {
  55241. emitVertex: boolean;
  55242. emitFragment: boolean;
  55243. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55244. };
  55245. /** Creates a new shared data */
  55246. constructor();
  55247. /**
  55248. * Emits console errors and exceptions if there is a failing check
  55249. */
  55250. emitErrors(): void;
  55251. }
  55252. }
  55253. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55254. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55255. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55256. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55257. /**
  55258. * Class used to store node based material build state
  55259. */
  55260. export class NodeMaterialBuildState {
  55261. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55262. supportUniformBuffers: boolean;
  55263. /**
  55264. * Gets the list of emitted attributes
  55265. */
  55266. attributes: string[];
  55267. /**
  55268. * Gets the list of emitted uniforms
  55269. */
  55270. uniforms: string[];
  55271. /**
  55272. * Gets the list of emitted constants
  55273. */
  55274. constants: string[];
  55275. /**
  55276. * Gets the list of emitted uniform buffers
  55277. */
  55278. uniformBuffers: string[];
  55279. /**
  55280. * Gets the list of emitted samplers
  55281. */
  55282. samplers: string[];
  55283. /**
  55284. * Gets the list of emitted functions
  55285. */
  55286. functions: {
  55287. [key: string]: string;
  55288. };
  55289. /**
  55290. * Gets the list of emitted extensions
  55291. */
  55292. extensions: {
  55293. [key: string]: string;
  55294. };
  55295. /**
  55296. * Gets the target of the compilation state
  55297. */
  55298. target: NodeMaterialBlockTargets;
  55299. /**
  55300. * Gets the list of emitted counters
  55301. */
  55302. counters: {
  55303. [key: string]: number;
  55304. };
  55305. /**
  55306. * Shared data between multiple NodeMaterialBuildState instances
  55307. */
  55308. sharedData: NodeMaterialBuildStateSharedData;
  55309. /** @hidden */
  55310. _vertexState: NodeMaterialBuildState;
  55311. /** @hidden */
  55312. _attributeDeclaration: string;
  55313. /** @hidden */
  55314. _uniformDeclaration: string;
  55315. /** @hidden */
  55316. _constantDeclaration: string;
  55317. /** @hidden */
  55318. _samplerDeclaration: string;
  55319. /** @hidden */
  55320. _varyingTransfer: string;
  55321. private _repeatableContentAnchorIndex;
  55322. /** @hidden */
  55323. _builtCompilationString: string;
  55324. /**
  55325. * Gets the emitted compilation strings
  55326. */
  55327. compilationString: string;
  55328. /**
  55329. * Finalize the compilation strings
  55330. * @param state defines the current compilation state
  55331. */
  55332. finalize(state: NodeMaterialBuildState): void;
  55333. /** @hidden */
  55334. readonly _repeatableContentAnchor: string;
  55335. /** @hidden */
  55336. _getFreeVariableName(prefix: string): string;
  55337. /** @hidden */
  55338. _getFreeDefineName(prefix: string): string;
  55339. /** @hidden */
  55340. _excludeVariableName(name: string): void;
  55341. /** @hidden */
  55342. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55343. /** @hidden */
  55344. _emitExtension(name: string, extension: string): void;
  55345. /** @hidden */
  55346. _emitFunction(name: string, code: string, comments: string): void;
  55347. /** @hidden */
  55348. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55349. replaceStrings?: {
  55350. search: RegExp;
  55351. replace: string;
  55352. }[];
  55353. repeatKey?: string;
  55354. }): string;
  55355. /** @hidden */
  55356. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55357. repeatKey?: string;
  55358. removeAttributes?: boolean;
  55359. removeUniforms?: boolean;
  55360. removeVaryings?: boolean;
  55361. removeIfDef?: boolean;
  55362. replaceStrings?: {
  55363. search: RegExp;
  55364. replace: string;
  55365. }[];
  55366. }, storeKey?: string): void;
  55367. /** @hidden */
  55368. _registerTempVariable(name: string): boolean;
  55369. /** @hidden */
  55370. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55371. /** @hidden */
  55372. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55373. }
  55374. }
  55375. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55376. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55377. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55378. import { Nullable } from "babylonjs/types";
  55379. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55380. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55381. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55383. import { Mesh } from "babylonjs/Meshes/mesh";
  55384. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55385. import { Scene } from "babylonjs/scene";
  55386. /**
  55387. * Defines a block that can be used inside a node based material
  55388. */
  55389. export class NodeMaterialBlock {
  55390. private _buildId;
  55391. private _buildTarget;
  55392. private _target;
  55393. private _isFinalMerger;
  55394. private _isInput;
  55395. /** @hidden */
  55396. _codeVariableName: string;
  55397. /** @hidden */
  55398. _inputs: NodeMaterialConnectionPoint[];
  55399. /** @hidden */
  55400. _outputs: NodeMaterialConnectionPoint[];
  55401. /** @hidden */
  55402. _preparationId: number;
  55403. /**
  55404. * Gets or sets the name of the block
  55405. */
  55406. name: string;
  55407. /**
  55408. * Gets or sets the unique id of the node
  55409. */
  55410. uniqueId: number;
  55411. /**
  55412. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55413. */
  55414. readonly isFinalMerger: boolean;
  55415. /**
  55416. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55417. */
  55418. readonly isInput: boolean;
  55419. /**
  55420. * Gets or sets the build Id
  55421. */
  55422. buildId: number;
  55423. /**
  55424. * Gets or sets the target of the block
  55425. */
  55426. target: NodeMaterialBlockTargets;
  55427. /**
  55428. * Gets the list of input points
  55429. */
  55430. readonly inputs: NodeMaterialConnectionPoint[];
  55431. /** Gets the list of output points */
  55432. readonly outputs: NodeMaterialConnectionPoint[];
  55433. /**
  55434. * Find an input by its name
  55435. * @param name defines the name of the input to look for
  55436. * @returns the input or null if not found
  55437. */
  55438. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55439. /**
  55440. * Find an output by its name
  55441. * @param name defines the name of the outputto look for
  55442. * @returns the output or null if not found
  55443. */
  55444. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55445. /**
  55446. * Creates a new NodeMaterialBlock
  55447. * @param name defines the block name
  55448. * @param target defines the target of that block (Vertex by default)
  55449. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55450. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55451. */
  55452. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55453. /**
  55454. * Initialize the block and prepare the context for build
  55455. * @param state defines the state that will be used for the build
  55456. */
  55457. initialize(state: NodeMaterialBuildState): void;
  55458. /**
  55459. * Bind data to effect. Will only be called for blocks with isBindable === true
  55460. * @param effect defines the effect to bind data to
  55461. * @param nodeMaterial defines the hosting NodeMaterial
  55462. * @param mesh defines the mesh that will be rendered
  55463. */
  55464. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55465. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55466. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55467. protected _writeFloat(value: number): string;
  55468. /**
  55469. * Gets the current class name e.g. "NodeMaterialBlock"
  55470. * @returns the class name
  55471. */
  55472. getClassName(): string;
  55473. /**
  55474. * Register a new input. Must be called inside a block constructor
  55475. * @param name defines the connection point name
  55476. * @param type defines the connection point type
  55477. * @param isOptional defines a boolean indicating that this input can be omitted
  55478. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55479. * @returns the current block
  55480. */
  55481. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55482. /**
  55483. * Register a new output. Must be called inside a block constructor
  55484. * @param name defines the connection point name
  55485. * @param type defines the connection point type
  55486. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55487. * @returns the current block
  55488. */
  55489. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  55490. /**
  55491. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  55492. * @param forOutput defines an optional connection point to check compatibility with
  55493. * @returns the first available input or null
  55494. */
  55495. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  55496. /**
  55497. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  55498. * @param forBlock defines an optional block to check compatibility with
  55499. * @returns the first available input or null
  55500. */
  55501. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  55502. /**
  55503. * Gets the sibling of the given output
  55504. * @param current defines the current output
  55505. * @returns the next output in the list or null
  55506. */
  55507. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  55508. /**
  55509. * Connect current block with another block
  55510. * @param other defines the block to connect with
  55511. * @param options define the various options to help pick the right connections
  55512. * @returns the current block
  55513. */
  55514. connectTo(other: NodeMaterialBlock, options?: {
  55515. input?: string;
  55516. output?: string;
  55517. outputSwizzle?: string;
  55518. }): this | undefined;
  55519. protected _buildBlock(state: NodeMaterialBuildState): void;
  55520. /**
  55521. * Add uniforms, samplers and uniform buffers at compilation time
  55522. * @param state defines the state to update
  55523. * @param nodeMaterial defines the node material requesting the update
  55524. * @param defines defines the material defines to update
  55525. */
  55526. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55527. /**
  55528. * Add potential fallbacks if shader compilation fails
  55529. * @param mesh defines the mesh to be rendered
  55530. * @param fallbacks defines the current prioritized list of fallbacks
  55531. */
  55532. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55533. /**
  55534. * Initialize defines for shader compilation
  55535. * @param mesh defines the mesh to be rendered
  55536. * @param nodeMaterial defines the node material requesting the update
  55537. * @param defines defines the material defines to update
  55538. * @param useInstances specifies that instances should be used
  55539. */
  55540. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55541. /**
  55542. * Update defines for shader compilation
  55543. * @param mesh defines the mesh to be rendered
  55544. * @param nodeMaterial defines the node material requesting the update
  55545. * @param defines defines the material defines to update
  55546. * @param useInstances specifies that instances should be used
  55547. */
  55548. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55549. /**
  55550. * Lets the block try to connect some inputs automatically
  55551. * @param material defines the hosting NodeMaterial
  55552. */
  55553. autoConfigure(material: NodeMaterial): void;
  55554. /**
  55555. * Function called when a block is declared as repeatable content generator
  55556. * @param vertexShaderState defines the current compilation state for the vertex shader
  55557. * @param fragmentShaderState defines the current compilation state for the fragment shader
  55558. * @param mesh defines the mesh to be rendered
  55559. * @param defines defines the material defines to update
  55560. */
  55561. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  55562. /**
  55563. * Checks if the block is ready
  55564. * @param mesh defines the mesh to be rendered
  55565. * @param nodeMaterial defines the node material requesting the update
  55566. * @param defines defines the material defines to update
  55567. * @param useInstances specifies that instances should be used
  55568. * @returns true if the block is ready
  55569. */
  55570. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  55571. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  55572. private _processBuild;
  55573. /**
  55574. * Compile the current node and generate the shader code
  55575. * @param state defines the current compilation state (uniforms, samplers, current string)
  55576. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  55577. * @returns true if already built
  55578. */
  55579. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  55580. protected _inputRename(name: string): string;
  55581. protected _outputRename(name: string): string;
  55582. protected _dumpPropertiesCode(): string;
  55583. /** @hidden */
  55584. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  55585. /**
  55586. * Clone the current block to a new identical block
  55587. * @param scene defines the hosting scene
  55588. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55589. * @returns a copy of the current block
  55590. */
  55591. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  55592. /**
  55593. * Serializes this block in a JSON representation
  55594. * @returns the serialized block object
  55595. */
  55596. serialize(): any;
  55597. /** @hidden */
  55598. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55599. }
  55600. }
  55601. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  55602. /**
  55603. * Enum defining the type of animations supported by InputBlock
  55604. */
  55605. export enum AnimatedInputBlockTypes {
  55606. /** No animation */
  55607. None = 0,
  55608. /** Time based animation. Will only work for floats */
  55609. Time = 1
  55610. }
  55611. }
  55612. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  55613. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55614. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55615. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55616. import { Nullable } from "babylonjs/types";
  55617. import { Effect } from "babylonjs/Materials/effect";
  55618. import { Matrix } from "babylonjs/Maths/math.vector";
  55619. import { Scene } from "babylonjs/scene";
  55620. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55621. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55622. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55623. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  55624. /**
  55625. * Block used to expose an input value
  55626. */
  55627. export class InputBlock extends NodeMaterialBlock {
  55628. private _mode;
  55629. private _associatedVariableName;
  55630. private _storedValue;
  55631. private _valueCallback;
  55632. private _type;
  55633. private _animationType;
  55634. /** Gets or set a value used to limit the range of float values */
  55635. min: number;
  55636. /** Gets or set a value used to limit the range of float values */
  55637. max: number;
  55638. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  55639. matrixMode: number;
  55640. /** @hidden */
  55641. _systemValue: Nullable<NodeMaterialSystemValues>;
  55642. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  55643. visibleInInspector: boolean;
  55644. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  55645. isConstant: boolean;
  55646. /**
  55647. * Gets or sets the connection point type (default is float)
  55648. */
  55649. readonly type: NodeMaterialBlockConnectionPointTypes;
  55650. /**
  55651. * Creates a new InputBlock
  55652. * @param name defines the block name
  55653. * @param target defines the target of that block (Vertex by default)
  55654. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  55655. */
  55656. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  55657. /**
  55658. * Gets the output component
  55659. */
  55660. readonly output: NodeMaterialConnectionPoint;
  55661. /**
  55662. * Set the source of this connection point to a vertex attribute
  55663. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  55664. * @returns the current connection point
  55665. */
  55666. setAsAttribute(attributeName?: string): InputBlock;
  55667. /**
  55668. * Set the source of this connection point to a system value
  55669. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  55670. * @returns the current connection point
  55671. */
  55672. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  55673. /**
  55674. * Gets or sets the value of that point.
  55675. * Please note that this value will be ignored if valueCallback is defined
  55676. */
  55677. value: any;
  55678. /**
  55679. * Gets or sets a callback used to get the value of that point.
  55680. * Please note that setting this value will force the connection point to ignore the value property
  55681. */
  55682. valueCallback: () => any;
  55683. /**
  55684. * Gets or sets the associated variable name in the shader
  55685. */
  55686. associatedVariableName: string;
  55687. /** Gets or sets the type of animation applied to the input */
  55688. animationType: AnimatedInputBlockTypes;
  55689. /**
  55690. * Gets a boolean indicating that this connection point not defined yet
  55691. */
  55692. readonly isUndefined: boolean;
  55693. /**
  55694. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  55695. * In this case the connection point name must be the name of the uniform to use.
  55696. * Can only be set on inputs
  55697. */
  55698. isUniform: boolean;
  55699. /**
  55700. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  55701. * In this case the connection point name must be the name of the attribute to use
  55702. * Can only be set on inputs
  55703. */
  55704. isAttribute: boolean;
  55705. /**
  55706. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  55707. * Can only be set on exit points
  55708. */
  55709. isVarying: boolean;
  55710. /**
  55711. * Gets a boolean indicating that the current connection point is a system value
  55712. */
  55713. readonly isSystemValue: boolean;
  55714. /**
  55715. * Gets or sets the current well known value or null if not defined as a system value
  55716. */
  55717. systemValue: Nullable<NodeMaterialSystemValues>;
  55718. /**
  55719. * Gets the current class name
  55720. * @returns the class name
  55721. */
  55722. getClassName(): string;
  55723. /**
  55724. * Animate the input if animationType !== None
  55725. * @param scene defines the rendering scene
  55726. */
  55727. animate(scene: Scene): void;
  55728. private _emitDefine;
  55729. initialize(state: NodeMaterialBuildState): void;
  55730. /**
  55731. * Set the input block to its default value (based on its type)
  55732. */
  55733. setDefaultValue(): void;
  55734. private _emitConstant;
  55735. private _emit;
  55736. /** @hidden */
  55737. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  55738. /** @hidden */
  55739. _transmit(effect: Effect, scene: Scene): void;
  55740. protected _buildBlock(state: NodeMaterialBuildState): void;
  55741. protected _dumpPropertiesCode(): string;
  55742. serialize(): any;
  55743. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55744. }
  55745. }
  55746. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  55747. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55748. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55749. import { Nullable } from "babylonjs/types";
  55750. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55751. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55752. /**
  55753. * Defines a connection point for a block
  55754. */
  55755. export class NodeMaterialConnectionPoint {
  55756. /** @hidden */
  55757. _ownerBlock: NodeMaterialBlock;
  55758. /** @hidden */
  55759. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55760. private _endpoints;
  55761. private _associatedVariableName;
  55762. /** @hidden */
  55763. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55764. /** @hidden */
  55765. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  55766. private _type;
  55767. /** @hidden */
  55768. _enforceAssociatedVariableName: boolean;
  55769. /**
  55770. * Gets or sets the additional types supported by this connection point
  55771. */
  55772. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55773. /**
  55774. * Gets or sets the additional types excluded by this connection point
  55775. */
  55776. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  55777. /**
  55778. * Gets or sets the associated variable name in the shader
  55779. */
  55780. associatedVariableName: string;
  55781. /**
  55782. * Gets or sets the connection point type (default is float)
  55783. */
  55784. type: NodeMaterialBlockConnectionPointTypes;
  55785. /**
  55786. * Gets or sets the connection point name
  55787. */
  55788. name: string;
  55789. /**
  55790. * Gets or sets a boolean indicating that this connection point can be omitted
  55791. */
  55792. isOptional: boolean;
  55793. /**
  55794. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  55795. */
  55796. define: string;
  55797. /** Gets or sets the target of that connection point */
  55798. target: NodeMaterialBlockTargets;
  55799. /**
  55800. * Gets a boolean indicating that the current point is connected
  55801. */
  55802. readonly isConnected: boolean;
  55803. /**
  55804. * Gets a boolean indicating that the current point is connected to an input block
  55805. */
  55806. readonly isConnectedToInputBlock: boolean;
  55807. /**
  55808. * Gets a the connected input block (if any)
  55809. */
  55810. readonly connectInputBlock: Nullable<InputBlock>;
  55811. /** Get the other side of the connection (if any) */
  55812. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  55813. /** Get the block that owns this connection point */
  55814. readonly ownerBlock: NodeMaterialBlock;
  55815. /** Get the block connected on the other side of this connection (if any) */
  55816. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  55817. /** Get the block connected on the endpoints of this connection (if any) */
  55818. readonly connectedBlocks: Array<NodeMaterialBlock>;
  55819. /** Gets the list of connected endpoints */
  55820. readonly endpoints: NodeMaterialConnectionPoint[];
  55821. /** Gets a boolean indicating if that output point is connected to at least one input */
  55822. readonly hasEndpoints: boolean;
  55823. /**
  55824. * Creates a new connection point
  55825. * @param name defines the connection point name
  55826. * @param ownerBlock defines the block hosting this connection point
  55827. */
  55828. constructor(name: string, ownerBlock: NodeMaterialBlock);
  55829. /**
  55830. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  55831. * @returns the class name
  55832. */
  55833. getClassName(): string;
  55834. /**
  55835. * Gets an boolean indicating if the current point can be connected to another point
  55836. * @param connectionPoint defines the other connection point
  55837. * @returns true if the connection is possible
  55838. */
  55839. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  55840. /**
  55841. * Connect this point to another connection point
  55842. * @param connectionPoint defines the other connection point
  55843. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  55844. * @returns the current connection point
  55845. */
  55846. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  55847. /**
  55848. * Disconnect this point from one of his endpoint
  55849. * @param endpoint defines the other connection point
  55850. * @returns the current connection point
  55851. */
  55852. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  55853. /**
  55854. * Serializes this point in a JSON representation
  55855. * @returns the serialized point object
  55856. */
  55857. serialize(): any;
  55858. }
  55859. }
  55860. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  55861. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55862. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55864. import { Mesh } from "babylonjs/Meshes/mesh";
  55865. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  55866. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55867. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55868. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55869. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55870. /**
  55871. * Block used to add support for vertex skinning (bones)
  55872. */
  55873. export class BonesBlock extends NodeMaterialBlock {
  55874. /**
  55875. * Creates a new BonesBlock
  55876. * @param name defines the block name
  55877. */
  55878. constructor(name: string);
  55879. /**
  55880. * Initialize the block and prepare the context for build
  55881. * @param state defines the state that will be used for the build
  55882. */
  55883. initialize(state: NodeMaterialBuildState): void;
  55884. /**
  55885. * Gets the current class name
  55886. * @returns the class name
  55887. */
  55888. getClassName(): string;
  55889. /**
  55890. * Gets the matrix indices input component
  55891. */
  55892. readonly matricesIndices: NodeMaterialConnectionPoint;
  55893. /**
  55894. * Gets the matrix weights input component
  55895. */
  55896. readonly matricesWeights: NodeMaterialConnectionPoint;
  55897. /**
  55898. * Gets the extra matrix indices input component
  55899. */
  55900. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  55901. /**
  55902. * Gets the extra matrix weights input component
  55903. */
  55904. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  55905. /**
  55906. * Gets the world input component
  55907. */
  55908. readonly world: NodeMaterialConnectionPoint;
  55909. /**
  55910. * Gets the output component
  55911. */
  55912. readonly output: NodeMaterialConnectionPoint;
  55913. autoConfigure(material: NodeMaterial): void;
  55914. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  55915. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55916. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55917. protected _buildBlock(state: NodeMaterialBuildState): this;
  55918. }
  55919. }
  55920. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  55921. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55922. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55923. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55925. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55926. /**
  55927. * Block used to add support for instances
  55928. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  55929. */
  55930. export class InstancesBlock extends NodeMaterialBlock {
  55931. /**
  55932. * Creates a new InstancesBlock
  55933. * @param name defines the block name
  55934. */
  55935. constructor(name: string);
  55936. /**
  55937. * Gets the current class name
  55938. * @returns the class name
  55939. */
  55940. getClassName(): string;
  55941. /**
  55942. * Gets the first world row input component
  55943. */
  55944. readonly world0: NodeMaterialConnectionPoint;
  55945. /**
  55946. * Gets the second world row input component
  55947. */
  55948. readonly world1: NodeMaterialConnectionPoint;
  55949. /**
  55950. * Gets the third world row input component
  55951. */
  55952. readonly world2: NodeMaterialConnectionPoint;
  55953. /**
  55954. * Gets the forth world row input component
  55955. */
  55956. readonly world3: NodeMaterialConnectionPoint;
  55957. /**
  55958. * Gets the world input component
  55959. */
  55960. readonly world: NodeMaterialConnectionPoint;
  55961. /**
  55962. * Gets the output component
  55963. */
  55964. readonly output: NodeMaterialConnectionPoint;
  55965. autoConfigure(material: NodeMaterial): void;
  55966. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55967. protected _buildBlock(state: NodeMaterialBuildState): this;
  55968. }
  55969. }
  55970. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  55971. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55972. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55973. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55975. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55976. import { Effect } from "babylonjs/Materials/effect";
  55977. import { Mesh } from "babylonjs/Meshes/mesh";
  55978. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55979. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55980. /**
  55981. * Block used to add morph targets support to vertex shader
  55982. */
  55983. export class MorphTargetsBlock extends NodeMaterialBlock {
  55984. private _repeatableContentAnchor;
  55985. private _repeatebleContentGenerated;
  55986. /**
  55987. * Create a new MorphTargetsBlock
  55988. * @param name defines the block name
  55989. */
  55990. constructor(name: string);
  55991. /**
  55992. * Gets the current class name
  55993. * @returns the class name
  55994. */
  55995. getClassName(): string;
  55996. /**
  55997. * Gets the position input component
  55998. */
  55999. readonly position: NodeMaterialConnectionPoint;
  56000. /**
  56001. * Gets the normal input component
  56002. */
  56003. readonly normal: NodeMaterialConnectionPoint;
  56004. /**
  56005. * Gets the tangent input component
  56006. */
  56007. readonly tangent: NodeMaterialConnectionPoint;
  56008. /**
  56009. * Gets the tangent input component
  56010. */
  56011. readonly uv: NodeMaterialConnectionPoint;
  56012. /**
  56013. * Gets the position output component
  56014. */
  56015. readonly positionOutput: NodeMaterialConnectionPoint;
  56016. /**
  56017. * Gets the normal output component
  56018. */
  56019. readonly normalOutput: NodeMaterialConnectionPoint;
  56020. /**
  56021. * Gets the tangent output component
  56022. */
  56023. readonly tangentOutput: NodeMaterialConnectionPoint;
  56024. /**
  56025. * Gets the tangent output component
  56026. */
  56027. readonly uvOutput: NodeMaterialConnectionPoint;
  56028. initialize(state: NodeMaterialBuildState): void;
  56029. autoConfigure(material: NodeMaterial): void;
  56030. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56031. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56032. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56033. protected _buildBlock(state: NodeMaterialBuildState): this;
  56034. }
  56035. }
  56036. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56037. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56038. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56039. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56040. import { Nullable } from "babylonjs/types";
  56041. import { Scene } from "babylonjs/scene";
  56042. import { Effect } from "babylonjs/Materials/effect";
  56043. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56044. import { Mesh } from "babylonjs/Meshes/mesh";
  56045. import { Light } from "babylonjs/Lights/light";
  56046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56047. /**
  56048. * Block used to get data information from a light
  56049. */
  56050. export class LightInformationBlock extends NodeMaterialBlock {
  56051. private _lightDataUniformName;
  56052. private _lightColorUniformName;
  56053. private _lightTypeDefineName;
  56054. /**
  56055. * Gets or sets the light associated with this block
  56056. */
  56057. light: Nullable<Light>;
  56058. /**
  56059. * Creates a new LightInformationBlock
  56060. * @param name defines the block name
  56061. */
  56062. constructor(name: string);
  56063. /**
  56064. * Gets the current class name
  56065. * @returns the class name
  56066. */
  56067. getClassName(): string;
  56068. /**
  56069. * Gets the world position input component
  56070. */
  56071. readonly worldPosition: NodeMaterialConnectionPoint;
  56072. /**
  56073. * Gets the direction output component
  56074. */
  56075. readonly direction: NodeMaterialConnectionPoint;
  56076. /**
  56077. * Gets the direction output component
  56078. */
  56079. readonly color: NodeMaterialConnectionPoint;
  56080. /**
  56081. * Gets the direction output component
  56082. */
  56083. readonly intensity: NodeMaterialConnectionPoint;
  56084. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56085. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56086. protected _buildBlock(state: NodeMaterialBuildState): this;
  56087. serialize(): any;
  56088. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56089. }
  56090. }
  56091. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56092. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56093. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56094. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56095. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56096. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56097. }
  56098. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56099. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56100. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56101. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56103. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56104. import { Effect } from "babylonjs/Materials/effect";
  56105. import { Mesh } from "babylonjs/Meshes/mesh";
  56106. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56107. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56108. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56109. /**
  56110. * Block used to add image processing support to fragment shader
  56111. */
  56112. export class ImageProcessingBlock extends NodeMaterialBlock {
  56113. /**
  56114. * Create a new ImageProcessingBlock
  56115. * @param name defines the block name
  56116. */
  56117. constructor(name: string);
  56118. /**
  56119. * Gets the current class name
  56120. * @returns the class name
  56121. */
  56122. getClassName(): string;
  56123. /**
  56124. * Gets the color input component
  56125. */
  56126. readonly color: NodeMaterialConnectionPoint;
  56127. /**
  56128. * Gets the output component
  56129. */
  56130. readonly output: NodeMaterialConnectionPoint;
  56131. /**
  56132. * Initialize the block and prepare the context for build
  56133. * @param state defines the state that will be used for the build
  56134. */
  56135. initialize(state: NodeMaterialBuildState): void;
  56136. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56137. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56138. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56139. protected _buildBlock(state: NodeMaterialBuildState): this;
  56140. }
  56141. }
  56142. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56143. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56144. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56145. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56146. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56148. import { Effect } from "babylonjs/Materials/effect";
  56149. import { Mesh } from "babylonjs/Meshes/mesh";
  56150. import { Scene } from "babylonjs/scene";
  56151. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56152. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56153. /**
  56154. * Block used to pertub normals based on a normal map
  56155. */
  56156. export class PerturbNormalBlock extends NodeMaterialBlock {
  56157. private _tangentSpaceParameterName;
  56158. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56159. invertX: boolean;
  56160. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56161. invertY: boolean;
  56162. /**
  56163. * Create a new PerturbNormalBlock
  56164. * @param name defines the block name
  56165. */
  56166. constructor(name: string);
  56167. /**
  56168. * Gets the current class name
  56169. * @returns the class name
  56170. */
  56171. getClassName(): string;
  56172. /**
  56173. * Gets the world position input component
  56174. */
  56175. readonly worldPosition: NodeMaterialConnectionPoint;
  56176. /**
  56177. * Gets the world normal input component
  56178. */
  56179. readonly worldNormal: NodeMaterialConnectionPoint;
  56180. /**
  56181. * Gets the uv input component
  56182. */
  56183. readonly uv: NodeMaterialConnectionPoint;
  56184. /**
  56185. * Gets the normal map color input component
  56186. */
  56187. readonly normalMapColor: NodeMaterialConnectionPoint;
  56188. /**
  56189. * Gets the strength input component
  56190. */
  56191. readonly strength: NodeMaterialConnectionPoint;
  56192. /**
  56193. * Gets the output component
  56194. */
  56195. readonly output: NodeMaterialConnectionPoint;
  56196. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56197. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56198. autoConfigure(material: NodeMaterial): void;
  56199. protected _buildBlock(state: NodeMaterialBuildState): this;
  56200. protected _dumpPropertiesCode(): string;
  56201. serialize(): any;
  56202. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56203. }
  56204. }
  56205. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56206. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56207. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56208. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56209. /**
  56210. * Block used to discard a pixel if a value is smaller than a cutoff
  56211. */
  56212. export class DiscardBlock extends NodeMaterialBlock {
  56213. /**
  56214. * Create a new DiscardBlock
  56215. * @param name defines the block name
  56216. */
  56217. constructor(name: string);
  56218. /**
  56219. * Gets the current class name
  56220. * @returns the class name
  56221. */
  56222. getClassName(): string;
  56223. /**
  56224. * Gets the color input component
  56225. */
  56226. readonly value: NodeMaterialConnectionPoint;
  56227. /**
  56228. * Gets the cutoff input component
  56229. */
  56230. readonly cutoff: NodeMaterialConnectionPoint;
  56231. protected _buildBlock(state: NodeMaterialBuildState): this;
  56232. }
  56233. }
  56234. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56235. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56236. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56237. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56238. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56239. }
  56240. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56241. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56242. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56243. import { Mesh } from "babylonjs/Meshes/mesh";
  56244. import { Effect } from "babylonjs/Materials/effect";
  56245. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56247. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56248. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56249. /**
  56250. * Block used to add support for scene fog
  56251. */
  56252. export class FogBlock extends NodeMaterialBlock {
  56253. private _fogDistanceName;
  56254. private _fogParameters;
  56255. /**
  56256. * Create a new FogBlock
  56257. * @param name defines the block name
  56258. */
  56259. constructor(name: string);
  56260. /**
  56261. * Gets the current class name
  56262. * @returns the class name
  56263. */
  56264. getClassName(): string;
  56265. /**
  56266. * Gets the world position input component
  56267. */
  56268. readonly worldPosition: NodeMaterialConnectionPoint;
  56269. /**
  56270. * Gets the view input component
  56271. */
  56272. readonly view: NodeMaterialConnectionPoint;
  56273. /**
  56274. * Gets the color input component
  56275. */
  56276. readonly input: NodeMaterialConnectionPoint;
  56277. /**
  56278. * Gets the fog color input component
  56279. */
  56280. readonly fogColor: NodeMaterialConnectionPoint;
  56281. /**
  56282. * Gets the output component
  56283. */
  56284. readonly output: NodeMaterialConnectionPoint;
  56285. autoConfigure(material: NodeMaterial): void;
  56286. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56287. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56288. protected _buildBlock(state: NodeMaterialBuildState): this;
  56289. }
  56290. }
  56291. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56292. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56293. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56294. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56296. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56297. import { Effect } from "babylonjs/Materials/effect";
  56298. import { Mesh } from "babylonjs/Meshes/mesh";
  56299. import { Light } from "babylonjs/Lights/light";
  56300. import { Nullable } from "babylonjs/types";
  56301. import { Scene } from "babylonjs/scene";
  56302. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56303. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56304. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56305. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56306. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56307. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56308. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56309. /**
  56310. * Block used to add light in the fragment shader
  56311. */
  56312. export class LightBlock extends NodeMaterialBlock {
  56313. private _lightId;
  56314. /**
  56315. * Gets or sets the light associated with this block
  56316. */
  56317. light: Nullable<Light>;
  56318. /**
  56319. * Create a new LightBlock
  56320. * @param name defines the block name
  56321. */
  56322. constructor(name: string);
  56323. /**
  56324. * Gets the current class name
  56325. * @returns the class name
  56326. */
  56327. getClassName(): string;
  56328. /**
  56329. * Gets the world position input component
  56330. */
  56331. readonly worldPosition: NodeMaterialConnectionPoint;
  56332. /**
  56333. * Gets the world normal input component
  56334. */
  56335. readonly worldNormal: NodeMaterialConnectionPoint;
  56336. /**
  56337. * Gets the camera (or eye) position component
  56338. */
  56339. readonly cameraPosition: NodeMaterialConnectionPoint;
  56340. /**
  56341. * Gets the diffuse output component
  56342. */
  56343. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56344. /**
  56345. * Gets the specular output component
  56346. */
  56347. readonly specularOutput: NodeMaterialConnectionPoint;
  56348. autoConfigure(material: NodeMaterial): void;
  56349. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56350. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56351. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56352. private _injectVertexCode;
  56353. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56354. serialize(): any;
  56355. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56356. }
  56357. }
  56358. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56359. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56360. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56361. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56362. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56363. }
  56364. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56365. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56366. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56367. }
  56368. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56369. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56370. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56371. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56372. /**
  56373. * Block used to multiply 2 values
  56374. */
  56375. export class MultiplyBlock extends NodeMaterialBlock {
  56376. /**
  56377. * Creates a new MultiplyBlock
  56378. * @param name defines the block name
  56379. */
  56380. constructor(name: string);
  56381. /**
  56382. * Gets the current class name
  56383. * @returns the class name
  56384. */
  56385. getClassName(): string;
  56386. /**
  56387. * Gets the left operand input component
  56388. */
  56389. readonly left: NodeMaterialConnectionPoint;
  56390. /**
  56391. * Gets the right operand input component
  56392. */
  56393. readonly right: NodeMaterialConnectionPoint;
  56394. /**
  56395. * Gets the output component
  56396. */
  56397. readonly output: NodeMaterialConnectionPoint;
  56398. protected _buildBlock(state: NodeMaterialBuildState): this;
  56399. }
  56400. }
  56401. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56402. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56403. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56404. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56405. /**
  56406. * Block used to add 2 vectors
  56407. */
  56408. export class AddBlock extends NodeMaterialBlock {
  56409. /**
  56410. * Creates a new AddBlock
  56411. * @param name defines the block name
  56412. */
  56413. constructor(name: string);
  56414. /**
  56415. * Gets the current class name
  56416. * @returns the class name
  56417. */
  56418. getClassName(): string;
  56419. /**
  56420. * Gets the left operand input component
  56421. */
  56422. readonly left: NodeMaterialConnectionPoint;
  56423. /**
  56424. * Gets the right operand input component
  56425. */
  56426. readonly right: NodeMaterialConnectionPoint;
  56427. /**
  56428. * Gets the output component
  56429. */
  56430. readonly output: NodeMaterialConnectionPoint;
  56431. protected _buildBlock(state: NodeMaterialBuildState): this;
  56432. }
  56433. }
  56434. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  56435. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56436. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56437. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56438. /**
  56439. * Block used to scale a vector by a float
  56440. */
  56441. export class ScaleBlock extends NodeMaterialBlock {
  56442. /**
  56443. * Creates a new ScaleBlock
  56444. * @param name defines the block name
  56445. */
  56446. constructor(name: string);
  56447. /**
  56448. * Gets the current class name
  56449. * @returns the class name
  56450. */
  56451. getClassName(): string;
  56452. /**
  56453. * Gets the input component
  56454. */
  56455. readonly input: NodeMaterialConnectionPoint;
  56456. /**
  56457. * Gets the factor input component
  56458. */
  56459. readonly factor: NodeMaterialConnectionPoint;
  56460. /**
  56461. * Gets the output component
  56462. */
  56463. readonly output: NodeMaterialConnectionPoint;
  56464. protected _buildBlock(state: NodeMaterialBuildState): this;
  56465. }
  56466. }
  56467. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  56468. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56469. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56470. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56471. import { Scene } from "babylonjs/scene";
  56472. /**
  56473. * Block used to clamp a float
  56474. */
  56475. export class ClampBlock extends NodeMaterialBlock {
  56476. /** Gets or sets the minimum range */
  56477. minimum: number;
  56478. /** Gets or sets the maximum range */
  56479. maximum: number;
  56480. /**
  56481. * Creates a new ClampBlock
  56482. * @param name defines the block name
  56483. */
  56484. constructor(name: string);
  56485. /**
  56486. * Gets the current class name
  56487. * @returns the class name
  56488. */
  56489. getClassName(): string;
  56490. /**
  56491. * Gets the value input component
  56492. */
  56493. readonly value: NodeMaterialConnectionPoint;
  56494. /**
  56495. * Gets the output component
  56496. */
  56497. readonly output: NodeMaterialConnectionPoint;
  56498. protected _buildBlock(state: NodeMaterialBuildState): this;
  56499. protected _dumpPropertiesCode(): string;
  56500. serialize(): any;
  56501. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56502. }
  56503. }
  56504. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  56505. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56506. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56507. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56508. /**
  56509. * Block used to apply a cross product between 2 vectors
  56510. */
  56511. export class CrossBlock extends NodeMaterialBlock {
  56512. /**
  56513. * Creates a new CrossBlock
  56514. * @param name defines the block name
  56515. */
  56516. constructor(name: string);
  56517. /**
  56518. * Gets the current class name
  56519. * @returns the class name
  56520. */
  56521. getClassName(): string;
  56522. /**
  56523. * Gets the left operand input component
  56524. */
  56525. readonly left: NodeMaterialConnectionPoint;
  56526. /**
  56527. * Gets the right operand input component
  56528. */
  56529. readonly right: NodeMaterialConnectionPoint;
  56530. /**
  56531. * Gets the output component
  56532. */
  56533. readonly output: NodeMaterialConnectionPoint;
  56534. protected _buildBlock(state: NodeMaterialBuildState): this;
  56535. }
  56536. }
  56537. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  56538. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56539. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56540. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56541. /**
  56542. * Block used to apply a dot product between 2 vectors
  56543. */
  56544. export class DotBlock extends NodeMaterialBlock {
  56545. /**
  56546. * Creates a new DotBlock
  56547. * @param name defines the block name
  56548. */
  56549. constructor(name: string);
  56550. /**
  56551. * Gets the current class name
  56552. * @returns the class name
  56553. */
  56554. getClassName(): string;
  56555. /**
  56556. * Gets the left operand input component
  56557. */
  56558. readonly left: NodeMaterialConnectionPoint;
  56559. /**
  56560. * Gets the right operand input component
  56561. */
  56562. readonly right: NodeMaterialConnectionPoint;
  56563. /**
  56564. * Gets the output component
  56565. */
  56566. readonly output: NodeMaterialConnectionPoint;
  56567. protected _buildBlock(state: NodeMaterialBuildState): this;
  56568. }
  56569. }
  56570. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  56571. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56572. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56573. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56574. import { Vector2 } from "babylonjs/Maths/math.vector";
  56575. import { Scene } from "babylonjs/scene";
  56576. /**
  56577. * Block used to remap a float from a range to a new one
  56578. */
  56579. export class RemapBlock extends NodeMaterialBlock {
  56580. /**
  56581. * Gets or sets the source range
  56582. */
  56583. sourceRange: Vector2;
  56584. /**
  56585. * Gets or sets the target range
  56586. */
  56587. targetRange: Vector2;
  56588. /**
  56589. * Creates a new RemapBlock
  56590. * @param name defines the block name
  56591. */
  56592. constructor(name: string);
  56593. /**
  56594. * Gets the current class name
  56595. * @returns the class name
  56596. */
  56597. getClassName(): string;
  56598. /**
  56599. * Gets the input component
  56600. */
  56601. readonly input: NodeMaterialConnectionPoint;
  56602. /**
  56603. * Gets the source min input component
  56604. */
  56605. readonly sourceMin: NodeMaterialConnectionPoint;
  56606. /**
  56607. * Gets the source max input component
  56608. */
  56609. readonly sourceMax: NodeMaterialConnectionPoint;
  56610. /**
  56611. * Gets the target min input component
  56612. */
  56613. readonly targetMin: NodeMaterialConnectionPoint;
  56614. /**
  56615. * Gets the target max input component
  56616. */
  56617. readonly targetMax: NodeMaterialConnectionPoint;
  56618. /**
  56619. * Gets the output component
  56620. */
  56621. readonly output: NodeMaterialConnectionPoint;
  56622. protected _buildBlock(state: NodeMaterialBuildState): this;
  56623. protected _dumpPropertiesCode(): string;
  56624. serialize(): any;
  56625. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56626. }
  56627. }
  56628. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  56629. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56630. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56631. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56632. /**
  56633. * Block used to normalize a vector
  56634. */
  56635. export class NormalizeBlock extends NodeMaterialBlock {
  56636. /**
  56637. * Creates a new NormalizeBlock
  56638. * @param name defines the block name
  56639. */
  56640. constructor(name: string);
  56641. /**
  56642. * Gets the current class name
  56643. * @returns the class name
  56644. */
  56645. getClassName(): string;
  56646. /**
  56647. * Gets the input component
  56648. */
  56649. readonly input: NodeMaterialConnectionPoint;
  56650. /**
  56651. * Gets the output component
  56652. */
  56653. readonly output: NodeMaterialConnectionPoint;
  56654. protected _buildBlock(state: NodeMaterialBuildState): this;
  56655. }
  56656. }
  56657. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  56658. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56659. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56660. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56661. import { Scene } from "babylonjs/scene";
  56662. /**
  56663. * Operations supported by the Trigonometry block
  56664. */
  56665. export enum TrigonometryBlockOperations {
  56666. /** Cos */
  56667. Cos = 0,
  56668. /** Sin */
  56669. Sin = 1,
  56670. /** Abs */
  56671. Abs = 2,
  56672. /** Exp */
  56673. Exp = 3,
  56674. /** Exp2 */
  56675. Exp2 = 4,
  56676. /** Round */
  56677. Round = 5,
  56678. /** Floor */
  56679. Floor = 6,
  56680. /** Ceiling */
  56681. Ceiling = 7,
  56682. /** Square root */
  56683. Sqrt = 8
  56684. }
  56685. /**
  56686. * Block used to apply trigonometry operation to floats
  56687. */
  56688. export class TrigonometryBlock extends NodeMaterialBlock {
  56689. /**
  56690. * Gets or sets the operation applied by the block
  56691. */
  56692. operation: TrigonometryBlockOperations;
  56693. /**
  56694. * Creates a new TrigonometryBlock
  56695. * @param name defines the block name
  56696. */
  56697. constructor(name: string);
  56698. /**
  56699. * Gets the current class name
  56700. * @returns the class name
  56701. */
  56702. getClassName(): string;
  56703. /**
  56704. * Gets the input component
  56705. */
  56706. readonly input: NodeMaterialConnectionPoint;
  56707. /**
  56708. * Gets the output component
  56709. */
  56710. readonly output: NodeMaterialConnectionPoint;
  56711. protected _buildBlock(state: NodeMaterialBuildState): this;
  56712. serialize(): any;
  56713. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56714. }
  56715. }
  56716. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  56717. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56718. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56719. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56720. /**
  56721. * Block used to create a Color3/4 out of individual inputs (one for each component)
  56722. */
  56723. export class ColorMergerBlock extends NodeMaterialBlock {
  56724. /**
  56725. * Create a new ColorMergerBlock
  56726. * @param name defines the block name
  56727. */
  56728. constructor(name: string);
  56729. /**
  56730. * Gets the current class name
  56731. * @returns the class name
  56732. */
  56733. getClassName(): string;
  56734. /**
  56735. * Gets the r component (input)
  56736. */
  56737. readonly r: NodeMaterialConnectionPoint;
  56738. /**
  56739. * Gets the g component (input)
  56740. */
  56741. readonly g: NodeMaterialConnectionPoint;
  56742. /**
  56743. * Gets the b component (input)
  56744. */
  56745. readonly b: NodeMaterialConnectionPoint;
  56746. /**
  56747. * Gets the a component (input)
  56748. */
  56749. readonly a: NodeMaterialConnectionPoint;
  56750. /**
  56751. * Gets the rgba component (output)
  56752. */
  56753. readonly rgba: NodeMaterialConnectionPoint;
  56754. /**
  56755. * Gets the rgb component (output)
  56756. */
  56757. readonly rgb: NodeMaterialConnectionPoint;
  56758. protected _buildBlock(state: NodeMaterialBuildState): this;
  56759. }
  56760. }
  56761. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  56762. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56763. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56764. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56765. /**
  56766. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  56767. */
  56768. export class VectorMergerBlock extends NodeMaterialBlock {
  56769. /**
  56770. * Create a new VectorMergerBlock
  56771. * @param name defines the block name
  56772. */
  56773. constructor(name: string);
  56774. /**
  56775. * Gets the current class name
  56776. * @returns the class name
  56777. */
  56778. getClassName(): string;
  56779. /**
  56780. * Gets the x component (input)
  56781. */
  56782. readonly x: NodeMaterialConnectionPoint;
  56783. /**
  56784. * Gets the y component (input)
  56785. */
  56786. readonly y: NodeMaterialConnectionPoint;
  56787. /**
  56788. * Gets the z component (input)
  56789. */
  56790. readonly z: NodeMaterialConnectionPoint;
  56791. /**
  56792. * Gets the w component (input)
  56793. */
  56794. readonly w: NodeMaterialConnectionPoint;
  56795. /**
  56796. * Gets the xyzw component (output)
  56797. */
  56798. readonly xyzw: NodeMaterialConnectionPoint;
  56799. /**
  56800. * Gets the xyz component (output)
  56801. */
  56802. readonly xyz: NodeMaterialConnectionPoint;
  56803. /**
  56804. * Gets the xy component (output)
  56805. */
  56806. readonly xy: NodeMaterialConnectionPoint;
  56807. protected _buildBlock(state: NodeMaterialBuildState): this;
  56808. }
  56809. }
  56810. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  56811. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56812. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56813. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56814. /**
  56815. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  56816. */
  56817. export class ColorSplitterBlock extends NodeMaterialBlock {
  56818. /**
  56819. * Create a new ColorSplitterBlock
  56820. * @param name defines the block name
  56821. */
  56822. constructor(name: string);
  56823. /**
  56824. * Gets the current class name
  56825. * @returns the class name
  56826. */
  56827. getClassName(): string;
  56828. /**
  56829. * Gets the rgba component (input)
  56830. */
  56831. readonly rgba: NodeMaterialConnectionPoint;
  56832. /**
  56833. * Gets the rgb component (input)
  56834. */
  56835. readonly rgbIn: NodeMaterialConnectionPoint;
  56836. /**
  56837. * Gets the rgb component (output)
  56838. */
  56839. readonly rgbOut: NodeMaterialConnectionPoint;
  56840. /**
  56841. * Gets the r component (output)
  56842. */
  56843. readonly r: NodeMaterialConnectionPoint;
  56844. /**
  56845. * Gets the g component (output)
  56846. */
  56847. readonly g: NodeMaterialConnectionPoint;
  56848. /**
  56849. * Gets the b component (output)
  56850. */
  56851. readonly b: NodeMaterialConnectionPoint;
  56852. /**
  56853. * Gets the a component (output)
  56854. */
  56855. readonly a: NodeMaterialConnectionPoint;
  56856. protected _inputRename(name: string): string;
  56857. protected _outputRename(name: string): string;
  56858. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56859. }
  56860. }
  56861. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  56862. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56863. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56864. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56865. /**
  56866. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  56867. */
  56868. export class VectorSplitterBlock extends NodeMaterialBlock {
  56869. /**
  56870. * Create a new VectorSplitterBlock
  56871. * @param name defines the block name
  56872. */
  56873. constructor(name: string);
  56874. /**
  56875. * Gets the current class name
  56876. * @returns the class name
  56877. */
  56878. getClassName(): string;
  56879. /**
  56880. * Gets the xyzw component (input)
  56881. */
  56882. readonly xyzw: NodeMaterialConnectionPoint;
  56883. /**
  56884. * Gets the xyz component (input)
  56885. */
  56886. readonly xyzIn: NodeMaterialConnectionPoint;
  56887. /**
  56888. * Gets the xy component (input)
  56889. */
  56890. readonly xyIn: NodeMaterialConnectionPoint;
  56891. /**
  56892. * Gets the xyz component (output)
  56893. */
  56894. readonly xyzOut: NodeMaterialConnectionPoint;
  56895. /**
  56896. * Gets the xy component (output)
  56897. */
  56898. readonly xyOut: NodeMaterialConnectionPoint;
  56899. /**
  56900. * Gets the x component (output)
  56901. */
  56902. readonly x: NodeMaterialConnectionPoint;
  56903. /**
  56904. * Gets the y component (output)
  56905. */
  56906. readonly y: NodeMaterialConnectionPoint;
  56907. /**
  56908. * Gets the z component (output)
  56909. */
  56910. readonly z: NodeMaterialConnectionPoint;
  56911. /**
  56912. * Gets the w component (output)
  56913. */
  56914. readonly w: NodeMaterialConnectionPoint;
  56915. protected _inputRename(name: string): string;
  56916. protected _outputRename(name: string): string;
  56917. protected _buildBlock(state: NodeMaterialBuildState): this;
  56918. }
  56919. }
  56920. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  56921. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56922. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56923. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56924. /**
  56925. * Block used to lerp 2 values
  56926. */
  56927. export class LerpBlock extends NodeMaterialBlock {
  56928. /**
  56929. * Creates a new LerpBlock
  56930. * @param name defines the block name
  56931. */
  56932. constructor(name: string);
  56933. /**
  56934. * Gets the current class name
  56935. * @returns the class name
  56936. */
  56937. getClassName(): string;
  56938. /**
  56939. * Gets the left operand input component
  56940. */
  56941. readonly left: NodeMaterialConnectionPoint;
  56942. /**
  56943. * Gets the right operand input component
  56944. */
  56945. readonly right: NodeMaterialConnectionPoint;
  56946. /**
  56947. * Gets the gradient operand input component
  56948. */
  56949. readonly gradient: NodeMaterialConnectionPoint;
  56950. /**
  56951. * Gets the output component
  56952. */
  56953. readonly output: NodeMaterialConnectionPoint;
  56954. protected _buildBlock(state: NodeMaterialBuildState): this;
  56955. }
  56956. }
  56957. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  56958. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56959. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56960. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56961. /**
  56962. * Block used to divide 2 vectors
  56963. */
  56964. export class DivideBlock extends NodeMaterialBlock {
  56965. /**
  56966. * Creates a new DivideBlock
  56967. * @param name defines the block name
  56968. */
  56969. constructor(name: string);
  56970. /**
  56971. * Gets the current class name
  56972. * @returns the class name
  56973. */
  56974. getClassName(): string;
  56975. /**
  56976. * Gets the left operand input component
  56977. */
  56978. readonly left: NodeMaterialConnectionPoint;
  56979. /**
  56980. * Gets the right operand input component
  56981. */
  56982. readonly right: NodeMaterialConnectionPoint;
  56983. /**
  56984. * Gets the output component
  56985. */
  56986. readonly output: NodeMaterialConnectionPoint;
  56987. protected _buildBlock(state: NodeMaterialBuildState): this;
  56988. }
  56989. }
  56990. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  56991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56992. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56993. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56994. /**
  56995. * Block used to subtract 2 vectors
  56996. */
  56997. export class SubtractBlock extends NodeMaterialBlock {
  56998. /**
  56999. * Creates a new SubtractBlock
  57000. * @param name defines the block name
  57001. */
  57002. constructor(name: string);
  57003. /**
  57004. * Gets the current class name
  57005. * @returns the class name
  57006. */
  57007. getClassName(): string;
  57008. /**
  57009. * Gets the left operand input component
  57010. */
  57011. readonly left: NodeMaterialConnectionPoint;
  57012. /**
  57013. * Gets the right operand input component
  57014. */
  57015. readonly right: NodeMaterialConnectionPoint;
  57016. /**
  57017. * Gets the output component
  57018. */
  57019. readonly output: NodeMaterialConnectionPoint;
  57020. protected _buildBlock(state: NodeMaterialBuildState): this;
  57021. }
  57022. }
  57023. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57026. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57027. /**
  57028. * Block used to step a value
  57029. */
  57030. export class StepBlock extends NodeMaterialBlock {
  57031. /**
  57032. * Creates a new AddBlock
  57033. * @param name defines the block name
  57034. */
  57035. constructor(name: string);
  57036. /**
  57037. * Gets the current class name
  57038. * @returns the class name
  57039. */
  57040. getClassName(): string;
  57041. /**
  57042. * Gets the value operand input component
  57043. */
  57044. readonly value: NodeMaterialConnectionPoint;
  57045. /**
  57046. * Gets the edge operand input component
  57047. */
  57048. readonly edge: NodeMaterialConnectionPoint;
  57049. /**
  57050. * Gets the output component
  57051. */
  57052. readonly output: NodeMaterialConnectionPoint;
  57053. protected _buildBlock(state: NodeMaterialBuildState): this;
  57054. }
  57055. }
  57056. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57060. /**
  57061. * Block used to get the opposite (1 - x) of a value
  57062. */
  57063. export class OneMinusBlock extends NodeMaterialBlock {
  57064. /**
  57065. * Creates a new OneMinusBlock
  57066. * @param name defines the block name
  57067. */
  57068. constructor(name: string);
  57069. /**
  57070. * Gets the current class name
  57071. * @returns the class name
  57072. */
  57073. getClassName(): string;
  57074. /**
  57075. * Gets the input component
  57076. */
  57077. readonly input: NodeMaterialConnectionPoint;
  57078. /**
  57079. * Gets the output component
  57080. */
  57081. readonly output: NodeMaterialConnectionPoint;
  57082. protected _buildBlock(state: NodeMaterialBuildState): this;
  57083. }
  57084. }
  57085. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57086. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57087. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57088. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57089. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57090. /**
  57091. * Block used to get the view direction
  57092. */
  57093. export class ViewDirectionBlock extends NodeMaterialBlock {
  57094. /**
  57095. * Creates a new ViewDirectionBlock
  57096. * @param name defines the block name
  57097. */
  57098. constructor(name: string);
  57099. /**
  57100. * Gets the current class name
  57101. * @returns the class name
  57102. */
  57103. getClassName(): string;
  57104. /**
  57105. * Gets the world position component
  57106. */
  57107. readonly worldPosition: NodeMaterialConnectionPoint;
  57108. /**
  57109. * Gets the camera position component
  57110. */
  57111. readonly cameraPosition: NodeMaterialConnectionPoint;
  57112. /**
  57113. * Gets the output component
  57114. */
  57115. readonly output: NodeMaterialConnectionPoint;
  57116. autoConfigure(material: NodeMaterial): void;
  57117. protected _buildBlock(state: NodeMaterialBuildState): this;
  57118. }
  57119. }
  57120. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57121. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57122. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57123. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57124. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57125. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57126. /**
  57127. * Block used to compute fresnel value
  57128. */
  57129. export class FresnelBlock extends NodeMaterialBlock {
  57130. /**
  57131. * Create a new FresnelBlock
  57132. * @param name defines the block name
  57133. */
  57134. constructor(name: string);
  57135. /**
  57136. * Gets the current class name
  57137. * @returns the class name
  57138. */
  57139. getClassName(): string;
  57140. /**
  57141. * Gets the world normal input component
  57142. */
  57143. readonly worldNormal: NodeMaterialConnectionPoint;
  57144. /**
  57145. * Gets the view direction input component
  57146. */
  57147. readonly viewDirection: NodeMaterialConnectionPoint;
  57148. /**
  57149. * Gets the bias input component
  57150. */
  57151. readonly bias: NodeMaterialConnectionPoint;
  57152. /**
  57153. * Gets the camera (or eye) position component
  57154. */
  57155. readonly power: NodeMaterialConnectionPoint;
  57156. /**
  57157. * Gets the fresnel output component
  57158. */
  57159. readonly fresnel: NodeMaterialConnectionPoint;
  57160. autoConfigure(material: NodeMaterial): void;
  57161. protected _buildBlock(state: NodeMaterialBuildState): this;
  57162. }
  57163. }
  57164. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57165. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57166. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57167. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57168. /**
  57169. * Block used to get the max of 2 values
  57170. */
  57171. export class MaxBlock extends NodeMaterialBlock {
  57172. /**
  57173. * Creates a new MaxBlock
  57174. * @param name defines the block name
  57175. */
  57176. constructor(name: string);
  57177. /**
  57178. * Gets the current class name
  57179. * @returns the class name
  57180. */
  57181. getClassName(): string;
  57182. /**
  57183. * Gets the left operand input component
  57184. */
  57185. readonly left: NodeMaterialConnectionPoint;
  57186. /**
  57187. * Gets the right operand input component
  57188. */
  57189. readonly right: NodeMaterialConnectionPoint;
  57190. /**
  57191. * Gets the output component
  57192. */
  57193. readonly output: NodeMaterialConnectionPoint;
  57194. protected _buildBlock(state: NodeMaterialBuildState): this;
  57195. }
  57196. }
  57197. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57198. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57199. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57200. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57201. /**
  57202. * Block used to get the min of 2 values
  57203. */
  57204. export class MinBlock extends NodeMaterialBlock {
  57205. /**
  57206. * Creates a new MinBlock
  57207. * @param name defines the block name
  57208. */
  57209. constructor(name: string);
  57210. /**
  57211. * Gets the current class name
  57212. * @returns the class name
  57213. */
  57214. getClassName(): string;
  57215. /**
  57216. * Gets the left operand input component
  57217. */
  57218. readonly left: NodeMaterialConnectionPoint;
  57219. /**
  57220. * Gets the right operand input component
  57221. */
  57222. readonly right: NodeMaterialConnectionPoint;
  57223. /**
  57224. * Gets the output component
  57225. */
  57226. readonly output: NodeMaterialConnectionPoint;
  57227. protected _buildBlock(state: NodeMaterialBuildState): this;
  57228. }
  57229. }
  57230. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57231. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57232. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57233. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57234. /**
  57235. * Block used to get the distance between 2 values
  57236. */
  57237. export class DistanceBlock extends NodeMaterialBlock {
  57238. /**
  57239. * Creates a new DistanceBlock
  57240. * @param name defines the block name
  57241. */
  57242. constructor(name: string);
  57243. /**
  57244. * Gets the current class name
  57245. * @returns the class name
  57246. */
  57247. getClassName(): string;
  57248. /**
  57249. * Gets the left operand input component
  57250. */
  57251. readonly left: NodeMaterialConnectionPoint;
  57252. /**
  57253. * Gets the right operand input component
  57254. */
  57255. readonly right: NodeMaterialConnectionPoint;
  57256. /**
  57257. * Gets the output component
  57258. */
  57259. readonly output: NodeMaterialConnectionPoint;
  57260. protected _buildBlock(state: NodeMaterialBuildState): this;
  57261. }
  57262. }
  57263. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57264. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57265. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57266. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57267. /**
  57268. * Block used to get the length of a vector
  57269. */
  57270. export class LengthBlock extends NodeMaterialBlock {
  57271. /**
  57272. * Creates a new LengthBlock
  57273. * @param name defines the block name
  57274. */
  57275. constructor(name: string);
  57276. /**
  57277. * Gets the current class name
  57278. * @returns the class name
  57279. */
  57280. getClassName(): string;
  57281. /**
  57282. * Gets the value input component
  57283. */
  57284. readonly value: NodeMaterialConnectionPoint;
  57285. /**
  57286. * Gets the output component
  57287. */
  57288. readonly output: NodeMaterialConnectionPoint;
  57289. protected _buildBlock(state: NodeMaterialBuildState): this;
  57290. }
  57291. }
  57292. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57293. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57294. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57295. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57296. /**
  57297. * Block used to get negative version of a value (i.e. x * -1)
  57298. */
  57299. export class NegateBlock extends NodeMaterialBlock {
  57300. /**
  57301. * Creates a new NegateBlock
  57302. * @param name defines the block name
  57303. */
  57304. constructor(name: string);
  57305. /**
  57306. * Gets the current class name
  57307. * @returns the class name
  57308. */
  57309. getClassName(): string;
  57310. /**
  57311. * Gets the value input component
  57312. */
  57313. readonly value: NodeMaterialConnectionPoint;
  57314. /**
  57315. * Gets the output component
  57316. */
  57317. readonly output: NodeMaterialConnectionPoint;
  57318. protected _buildBlock(state: NodeMaterialBuildState): this;
  57319. }
  57320. }
  57321. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57322. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57323. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57324. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57325. /**
  57326. * Block used to get the value of the first parameter raised to the power of the second
  57327. */
  57328. export class PowBlock extends NodeMaterialBlock {
  57329. /**
  57330. * Creates a new PowBlock
  57331. * @param name defines the block name
  57332. */
  57333. constructor(name: string);
  57334. /**
  57335. * Gets the current class name
  57336. * @returns the class name
  57337. */
  57338. getClassName(): string;
  57339. /**
  57340. * Gets the value operand input component
  57341. */
  57342. readonly value: NodeMaterialConnectionPoint;
  57343. /**
  57344. * Gets the power operand input component
  57345. */
  57346. readonly power: NodeMaterialConnectionPoint;
  57347. /**
  57348. * Gets the output component
  57349. */
  57350. readonly output: NodeMaterialConnectionPoint;
  57351. protected _buildBlock(state: NodeMaterialBuildState): this;
  57352. }
  57353. }
  57354. declare module "babylonjs/Materials/Node/Blocks/index" {
  57355. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  57356. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  57357. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  57358. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  57359. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  57360. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  57361. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  57362. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  57363. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  57364. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  57365. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  57366. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  57367. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  57368. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  57369. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  57370. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  57371. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  57372. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  57373. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  57374. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  57375. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  57376. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  57377. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  57378. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  57379. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  57380. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  57381. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  57382. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  57383. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  57384. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  57385. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  57386. }
  57387. declare module "babylonjs/Materials/Node/Optimizers/index" {
  57388. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  57389. }
  57390. declare module "babylonjs/Materials/Node/index" {
  57391. export * from "babylonjs/Materials/Node/Enums/index";
  57392. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57393. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  57394. export * from "babylonjs/Materials/Node/nodeMaterial";
  57395. export * from "babylonjs/Materials/Node/Blocks/index";
  57396. export * from "babylonjs/Materials/Node/Optimizers/index";
  57397. }
  57398. declare module "babylonjs/Materials/effectRenderer" {
  57399. import { Nullable } from "babylonjs/types";
  57400. import { Texture } from "babylonjs/Materials/Textures/texture";
  57401. import { Engine } from "babylonjs/Engines/engine";
  57402. import { Viewport } from "babylonjs/Maths/math.viewport";
  57403. import { Observable } from "babylonjs/Misc/observable";
  57404. import { Effect } from "babylonjs/Materials/effect";
  57405. import "babylonjs/Shaders/postprocess.vertex";
  57406. /**
  57407. * Effect Render Options
  57408. */
  57409. export interface IEffectRendererOptions {
  57410. /**
  57411. * Defines the vertices positions.
  57412. */
  57413. positions?: number[];
  57414. /**
  57415. * Defines the indices.
  57416. */
  57417. indices?: number[];
  57418. }
  57419. /**
  57420. * Helper class to render one or more effects
  57421. */
  57422. export class EffectRenderer {
  57423. private engine;
  57424. private static _DefaultOptions;
  57425. private _vertexBuffers;
  57426. private _indexBuffer;
  57427. private _ringBufferIndex;
  57428. private _ringScreenBuffer;
  57429. private _fullscreenViewport;
  57430. private _getNextFrameBuffer;
  57431. /**
  57432. * Creates an effect renderer
  57433. * @param engine the engine to use for rendering
  57434. * @param options defines the options of the effect renderer
  57435. */
  57436. constructor(engine: Engine, options?: IEffectRendererOptions);
  57437. /**
  57438. * Sets the current viewport in normalized coordinates 0-1
  57439. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  57440. */
  57441. setViewport(viewport?: Viewport): void;
  57442. /**
  57443. * Binds the embedded attributes buffer to the effect.
  57444. * @param effect Defines the effect to bind the attributes for
  57445. */
  57446. bindBuffers(effect: Effect): void;
  57447. /**
  57448. * Sets the current effect wrapper to use during draw.
  57449. * The effect needs to be ready before calling this api.
  57450. * This also sets the default full screen position attribute.
  57451. * @param effectWrapper Defines the effect to draw with
  57452. */
  57453. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  57454. /**
  57455. * Draws a full screen quad.
  57456. */
  57457. draw(): void;
  57458. /**
  57459. * renders one or more effects to a specified texture
  57460. * @param effectWrappers list of effects to renderer
  57461. * @param outputTexture texture to draw to, if null it will render to the screen
  57462. */
  57463. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  57464. /**
  57465. * Disposes of the effect renderer
  57466. */
  57467. dispose(): void;
  57468. }
  57469. /**
  57470. * Options to create an EffectWrapper
  57471. */
  57472. interface EffectWrapperCreationOptions {
  57473. /**
  57474. * Engine to use to create the effect
  57475. */
  57476. engine: Engine;
  57477. /**
  57478. * Fragment shader for the effect
  57479. */
  57480. fragmentShader: string;
  57481. /**
  57482. * Vertex shader for the effect
  57483. */
  57484. vertexShader?: string;
  57485. /**
  57486. * Attributes to use in the shader
  57487. */
  57488. attributeNames?: Array<string>;
  57489. /**
  57490. * Uniforms to use in the shader
  57491. */
  57492. uniformNames?: Array<string>;
  57493. /**
  57494. * Texture sampler names to use in the shader
  57495. */
  57496. samplerNames?: Array<string>;
  57497. /**
  57498. * The friendly name of the effect displayed in Spector.
  57499. */
  57500. name?: string;
  57501. }
  57502. /**
  57503. * Wraps an effect to be used for rendering
  57504. */
  57505. export class EffectWrapper {
  57506. /**
  57507. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  57508. */
  57509. onApplyObservable: Observable<{}>;
  57510. /**
  57511. * The underlying effect
  57512. */
  57513. effect: Effect;
  57514. /**
  57515. * Creates an effect to be renderer
  57516. * @param creationOptions options to create the effect
  57517. */
  57518. constructor(creationOptions: EffectWrapperCreationOptions);
  57519. /**
  57520. * Disposes of the effect wrapper
  57521. */
  57522. dispose(): void;
  57523. }
  57524. }
  57525. declare module "babylonjs/Materials/index" {
  57526. export * from "babylonjs/Materials/Background/index";
  57527. export * from "babylonjs/Materials/colorCurves";
  57528. export * from "babylonjs/Materials/effect";
  57529. export * from "babylonjs/Materials/fresnelParameters";
  57530. export * from "babylonjs/Materials/imageProcessingConfiguration";
  57531. export * from "babylonjs/Materials/material";
  57532. export * from "babylonjs/Materials/materialDefines";
  57533. export * from "babylonjs/Materials/materialHelper";
  57534. export * from "babylonjs/Materials/multiMaterial";
  57535. export * from "babylonjs/Materials/PBR/index";
  57536. export * from "babylonjs/Materials/pushMaterial";
  57537. export * from "babylonjs/Materials/shaderMaterial";
  57538. export * from "babylonjs/Materials/standardMaterial";
  57539. export * from "babylonjs/Materials/Textures/index";
  57540. export * from "babylonjs/Materials/uniformBuffer";
  57541. export * from "babylonjs/Materials/materialFlags";
  57542. export * from "babylonjs/Materials/Node/index";
  57543. export * from "babylonjs/Materials/effectRenderer";
  57544. }
  57545. declare module "babylonjs/Maths/index" {
  57546. export * from "babylonjs/Maths/math.scalar";
  57547. export * from "babylonjs/Maths/math";
  57548. export * from "babylonjs/Maths/sphericalPolynomial";
  57549. }
  57550. declare module "babylonjs/Misc/workerPool" {
  57551. import { IDisposable } from "babylonjs/scene";
  57552. /**
  57553. * Helper class to push actions to a pool of workers.
  57554. */
  57555. export class WorkerPool implements IDisposable {
  57556. private _workerInfos;
  57557. private _pendingActions;
  57558. /**
  57559. * Constructor
  57560. * @param workers Array of workers to use for actions
  57561. */
  57562. constructor(workers: Array<Worker>);
  57563. /**
  57564. * Terminates all workers and clears any pending actions.
  57565. */
  57566. dispose(): void;
  57567. /**
  57568. * Pushes an action to the worker pool. If all the workers are active, the action will be
  57569. * pended until a worker has completed its action.
  57570. * @param action The action to perform. Call onComplete when the action is complete.
  57571. */
  57572. push(action: (worker: Worker, onComplete: () => void) => void): void;
  57573. private _execute;
  57574. }
  57575. }
  57576. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  57577. import { IDisposable } from "babylonjs/scene";
  57578. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57579. /**
  57580. * Configuration for Draco compression
  57581. */
  57582. export interface IDracoCompressionConfiguration {
  57583. /**
  57584. * Configuration for the decoder.
  57585. */
  57586. decoder: {
  57587. /**
  57588. * The url to the WebAssembly module.
  57589. */
  57590. wasmUrl?: string;
  57591. /**
  57592. * The url to the WebAssembly binary.
  57593. */
  57594. wasmBinaryUrl?: string;
  57595. /**
  57596. * The url to the fallback JavaScript module.
  57597. */
  57598. fallbackUrl?: string;
  57599. };
  57600. }
  57601. /**
  57602. * Draco compression (https://google.github.io/draco/)
  57603. *
  57604. * This class wraps the Draco module.
  57605. *
  57606. * **Encoder**
  57607. *
  57608. * The encoder is not currently implemented.
  57609. *
  57610. * **Decoder**
  57611. *
  57612. * 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.
  57613. *
  57614. * To update the configuration, use the following code:
  57615. * ```javascript
  57616. * DracoCompression.Configuration = {
  57617. * decoder: {
  57618. * wasmUrl: "<url to the WebAssembly library>",
  57619. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  57620. * fallbackUrl: "<url to the fallback JavaScript library>",
  57621. * }
  57622. * };
  57623. * ```
  57624. *
  57625. * 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.
  57626. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  57627. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  57628. *
  57629. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  57630. * ```javascript
  57631. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  57632. * ```
  57633. *
  57634. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  57635. */
  57636. export class DracoCompression implements IDisposable {
  57637. private _workerPoolPromise?;
  57638. private _decoderModulePromise?;
  57639. /**
  57640. * The configuration. Defaults to the following urls:
  57641. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  57642. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  57643. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  57644. */
  57645. static Configuration: IDracoCompressionConfiguration;
  57646. /**
  57647. * Returns true if the decoder configuration is available.
  57648. */
  57649. static readonly DecoderAvailable: boolean;
  57650. /**
  57651. * Default number of workers to create when creating the draco compression object.
  57652. */
  57653. static DefaultNumWorkers: number;
  57654. private static GetDefaultNumWorkers;
  57655. private static _Default;
  57656. /**
  57657. * Default instance for the draco compression object.
  57658. */
  57659. static readonly Default: DracoCompression;
  57660. /**
  57661. * Constructor
  57662. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  57663. */
  57664. constructor(numWorkers?: number);
  57665. /**
  57666. * Stop all async operations and release resources.
  57667. */
  57668. dispose(): void;
  57669. /**
  57670. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  57671. * @returns a promise that resolves when ready
  57672. */
  57673. whenReadyAsync(): Promise<void>;
  57674. /**
  57675. * Decode Draco compressed mesh data to vertex data.
  57676. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  57677. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  57678. * @returns A promise that resolves with the decoded vertex data
  57679. */
  57680. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  57681. [kind: string]: number;
  57682. }): Promise<VertexData>;
  57683. }
  57684. }
  57685. declare module "babylonjs/Meshes/Compression/index" {
  57686. export * from "babylonjs/Meshes/Compression/dracoCompression";
  57687. }
  57688. declare module "babylonjs/Meshes/csg" {
  57689. import { Nullable } from "babylonjs/types";
  57690. import { Scene } from "babylonjs/scene";
  57691. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57692. import { Mesh } from "babylonjs/Meshes/mesh";
  57693. import { Material } from "babylonjs/Materials/material";
  57694. /**
  57695. * Class for building Constructive Solid Geometry
  57696. */
  57697. export class CSG {
  57698. private polygons;
  57699. /**
  57700. * The world matrix
  57701. */
  57702. matrix: Matrix;
  57703. /**
  57704. * Stores the position
  57705. */
  57706. position: Vector3;
  57707. /**
  57708. * Stores the rotation
  57709. */
  57710. rotation: Vector3;
  57711. /**
  57712. * Stores the rotation quaternion
  57713. */
  57714. rotationQuaternion: Nullable<Quaternion>;
  57715. /**
  57716. * Stores the scaling vector
  57717. */
  57718. scaling: Vector3;
  57719. /**
  57720. * Convert the Mesh to CSG
  57721. * @param mesh The Mesh to convert to CSG
  57722. * @returns A new CSG from the Mesh
  57723. */
  57724. static FromMesh(mesh: Mesh): CSG;
  57725. /**
  57726. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  57727. * @param polygons Polygons used to construct a CSG solid
  57728. */
  57729. private static FromPolygons;
  57730. /**
  57731. * Clones, or makes a deep copy, of the CSG
  57732. * @returns A new CSG
  57733. */
  57734. clone(): CSG;
  57735. /**
  57736. * Unions this CSG with another CSG
  57737. * @param csg The CSG to union against this CSG
  57738. * @returns The unioned CSG
  57739. */
  57740. union(csg: CSG): CSG;
  57741. /**
  57742. * Unions this CSG with another CSG in place
  57743. * @param csg The CSG to union against this CSG
  57744. */
  57745. unionInPlace(csg: CSG): void;
  57746. /**
  57747. * Subtracts this CSG with another CSG
  57748. * @param csg The CSG to subtract against this CSG
  57749. * @returns A new CSG
  57750. */
  57751. subtract(csg: CSG): CSG;
  57752. /**
  57753. * Subtracts this CSG with another CSG in place
  57754. * @param csg The CSG to subtact against this CSG
  57755. */
  57756. subtractInPlace(csg: CSG): void;
  57757. /**
  57758. * Intersect this CSG with another CSG
  57759. * @param csg The CSG to intersect against this CSG
  57760. * @returns A new CSG
  57761. */
  57762. intersect(csg: CSG): CSG;
  57763. /**
  57764. * Intersects this CSG with another CSG in place
  57765. * @param csg The CSG to intersect against this CSG
  57766. */
  57767. intersectInPlace(csg: CSG): void;
  57768. /**
  57769. * Return a new CSG solid with solid and empty space switched. This solid is
  57770. * not modified.
  57771. * @returns A new CSG solid with solid and empty space switched
  57772. */
  57773. inverse(): CSG;
  57774. /**
  57775. * Inverses the CSG in place
  57776. */
  57777. inverseInPlace(): void;
  57778. /**
  57779. * This is used to keep meshes transformations so they can be restored
  57780. * when we build back a Babylon Mesh
  57781. * NB : All CSG operations are performed in world coordinates
  57782. * @param csg The CSG to copy the transform attributes from
  57783. * @returns This CSG
  57784. */
  57785. copyTransformAttributes(csg: CSG): CSG;
  57786. /**
  57787. * Build Raw mesh from CSG
  57788. * Coordinates here are in world space
  57789. * @param name The name of the mesh geometry
  57790. * @param scene The Scene
  57791. * @param keepSubMeshes Specifies if the submeshes should be kept
  57792. * @returns A new Mesh
  57793. */
  57794. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57795. /**
  57796. * Build Mesh from CSG taking material and transforms into account
  57797. * @param name The name of the Mesh
  57798. * @param material The material of the Mesh
  57799. * @param scene The Scene
  57800. * @param keepSubMeshes Specifies if submeshes should be kept
  57801. * @returns The new Mesh
  57802. */
  57803. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  57804. }
  57805. }
  57806. declare module "babylonjs/Meshes/trailMesh" {
  57807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57808. import { Mesh } from "babylonjs/Meshes/mesh";
  57809. import { Scene } from "babylonjs/scene";
  57810. /**
  57811. * Class used to create a trail following a mesh
  57812. */
  57813. export class TrailMesh extends Mesh {
  57814. private _generator;
  57815. private _autoStart;
  57816. private _running;
  57817. private _diameter;
  57818. private _length;
  57819. private _sectionPolygonPointsCount;
  57820. private _sectionVectors;
  57821. private _sectionNormalVectors;
  57822. private _beforeRenderObserver;
  57823. /**
  57824. * @constructor
  57825. * @param name The value used by scene.getMeshByName() to do a lookup.
  57826. * @param generator The mesh to generate a trail.
  57827. * @param scene The scene to add this mesh to.
  57828. * @param diameter Diameter of trailing mesh. Default is 1.
  57829. * @param length Length of trailing mesh. Default is 60.
  57830. * @param autoStart Automatically start trailing mesh. Default true.
  57831. */
  57832. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  57833. /**
  57834. * "TrailMesh"
  57835. * @returns "TrailMesh"
  57836. */
  57837. getClassName(): string;
  57838. private _createMesh;
  57839. /**
  57840. * Start trailing mesh.
  57841. */
  57842. start(): void;
  57843. /**
  57844. * Stop trailing mesh.
  57845. */
  57846. stop(): void;
  57847. /**
  57848. * Update trailing mesh geometry.
  57849. */
  57850. update(): void;
  57851. /**
  57852. * Returns a new TrailMesh object.
  57853. * @param name is a string, the name given to the new mesh
  57854. * @param newGenerator use new generator object for cloned trail mesh
  57855. * @returns a new mesh
  57856. */
  57857. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  57858. /**
  57859. * Serializes this trail mesh
  57860. * @param serializationObject object to write serialization to
  57861. */
  57862. serialize(serializationObject: any): void;
  57863. /**
  57864. * Parses a serialized trail mesh
  57865. * @param parsedMesh the serialized mesh
  57866. * @param scene the scene to create the trail mesh in
  57867. * @returns the created trail mesh
  57868. */
  57869. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  57870. }
  57871. }
  57872. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  57873. import { Nullable } from "babylonjs/types";
  57874. import { Scene } from "babylonjs/scene";
  57875. import { Vector4 } from "babylonjs/Maths/math.vector";
  57876. import { Color4 } from "babylonjs/Maths/math.color";
  57877. import { Mesh } from "babylonjs/Meshes/mesh";
  57878. /**
  57879. * Class containing static functions to help procedurally build meshes
  57880. */
  57881. export class TiledBoxBuilder {
  57882. /**
  57883. * Creates a box mesh
  57884. * 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)
  57885. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57889. * @param name defines the name of the mesh
  57890. * @param options defines the options used to create the mesh
  57891. * @param scene defines the hosting scene
  57892. * @returns the box mesh
  57893. */
  57894. static CreateTiledBox(name: string, options: {
  57895. pattern?: number;
  57896. width?: number;
  57897. height?: number;
  57898. depth?: number;
  57899. tileSize?: number;
  57900. tileWidth?: number;
  57901. tileHeight?: number;
  57902. alignHorizontal?: number;
  57903. alignVertical?: number;
  57904. faceUV?: Vector4[];
  57905. faceColors?: Color4[];
  57906. sideOrientation?: number;
  57907. updatable?: boolean;
  57908. }, scene?: Nullable<Scene>): Mesh;
  57909. }
  57910. }
  57911. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  57912. import { Vector4 } from "babylonjs/Maths/math.vector";
  57913. import { Mesh } from "babylonjs/Meshes/mesh";
  57914. /**
  57915. * Class containing static functions to help procedurally build meshes
  57916. */
  57917. export class TorusKnotBuilder {
  57918. /**
  57919. * Creates a torus knot mesh
  57920. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  57921. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  57922. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  57923. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  57924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57925. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57927. * @param name defines the name of the mesh
  57928. * @param options defines the options used to create the mesh
  57929. * @param scene defines the hosting scene
  57930. * @returns the torus knot mesh
  57931. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  57932. */
  57933. static CreateTorusKnot(name: string, options: {
  57934. radius?: number;
  57935. tube?: number;
  57936. radialSegments?: number;
  57937. tubularSegments?: number;
  57938. p?: number;
  57939. q?: number;
  57940. updatable?: boolean;
  57941. sideOrientation?: number;
  57942. frontUVs?: Vector4;
  57943. backUVs?: Vector4;
  57944. }, scene: any): Mesh;
  57945. }
  57946. }
  57947. declare module "babylonjs/Meshes/polygonMesh" {
  57948. import { Scene } from "babylonjs/scene";
  57949. import { Vector2 } from "babylonjs/Maths/math.vector";
  57950. import { Mesh } from "babylonjs/Meshes/mesh";
  57951. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  57952. import { Path2 } from "babylonjs/Maths/math.path";
  57953. /**
  57954. * Polygon
  57955. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  57956. */
  57957. export class Polygon {
  57958. /**
  57959. * Creates a rectangle
  57960. * @param xmin bottom X coord
  57961. * @param ymin bottom Y coord
  57962. * @param xmax top X coord
  57963. * @param ymax top Y coord
  57964. * @returns points that make the resulting rectation
  57965. */
  57966. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  57967. /**
  57968. * Creates a circle
  57969. * @param radius radius of circle
  57970. * @param cx scale in x
  57971. * @param cy scale in y
  57972. * @param numberOfSides number of sides that make up the circle
  57973. * @returns points that make the resulting circle
  57974. */
  57975. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  57976. /**
  57977. * Creates a polygon from input string
  57978. * @param input Input polygon data
  57979. * @returns the parsed points
  57980. */
  57981. static Parse(input: string): Vector2[];
  57982. /**
  57983. * Starts building a polygon from x and y coordinates
  57984. * @param x x coordinate
  57985. * @param y y coordinate
  57986. * @returns the started path2
  57987. */
  57988. static StartingAt(x: number, y: number): Path2;
  57989. }
  57990. /**
  57991. * Builds a polygon
  57992. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  57993. */
  57994. export class PolygonMeshBuilder {
  57995. private _points;
  57996. private _outlinepoints;
  57997. private _holes;
  57998. private _name;
  57999. private _scene;
  58000. private _epoints;
  58001. private _eholes;
  58002. private _addToepoint;
  58003. /**
  58004. * Babylon reference to the earcut plugin.
  58005. */
  58006. bjsEarcut: any;
  58007. /**
  58008. * Creates a PolygonMeshBuilder
  58009. * @param name name of the builder
  58010. * @param contours Path of the polygon
  58011. * @param scene scene to add to when creating the mesh
  58012. * @param earcutInjection can be used to inject your own earcut reference
  58013. */
  58014. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58015. /**
  58016. * Adds a whole within the polygon
  58017. * @param hole Array of points defining the hole
  58018. * @returns this
  58019. */
  58020. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58021. /**
  58022. * Creates the polygon
  58023. * @param updatable If the mesh should be updatable
  58024. * @param depth The depth of the mesh created
  58025. * @returns the created mesh
  58026. */
  58027. build(updatable?: boolean, depth?: number): Mesh;
  58028. /**
  58029. * Creates the polygon
  58030. * @param depth The depth of the mesh created
  58031. * @returns the created VertexData
  58032. */
  58033. buildVertexData(depth?: number): VertexData;
  58034. /**
  58035. * Adds a side to the polygon
  58036. * @param positions points that make the polygon
  58037. * @param normals normals of the polygon
  58038. * @param uvs uvs of the polygon
  58039. * @param indices indices of the polygon
  58040. * @param bounds bounds of the polygon
  58041. * @param points points of the polygon
  58042. * @param depth depth of the polygon
  58043. * @param flip flip of the polygon
  58044. */
  58045. private addSide;
  58046. }
  58047. }
  58048. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  58049. import { Scene } from "babylonjs/scene";
  58050. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58051. import { Color4 } from "babylonjs/Maths/math.color";
  58052. import { Mesh } from "babylonjs/Meshes/mesh";
  58053. import { Nullable } from "babylonjs/types";
  58054. /**
  58055. * Class containing static functions to help procedurally build meshes
  58056. */
  58057. export class PolygonBuilder {
  58058. /**
  58059. * Creates a polygon mesh
  58060. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58061. * * 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
  58062. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58064. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58065. * * Remember you can only change the shape positions, not their number when updating a polygon
  58066. * @param name defines the name of the mesh
  58067. * @param options defines the options used to create the mesh
  58068. * @param scene defines the hosting scene
  58069. * @param earcutInjection can be used to inject your own earcut reference
  58070. * @returns the polygon mesh
  58071. */
  58072. static CreatePolygon(name: string, options: {
  58073. shape: Vector3[];
  58074. holes?: Vector3[][];
  58075. depth?: number;
  58076. faceUV?: Vector4[];
  58077. faceColors?: Color4[];
  58078. updatable?: boolean;
  58079. sideOrientation?: number;
  58080. frontUVs?: Vector4;
  58081. backUVs?: Vector4;
  58082. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58083. /**
  58084. * Creates an extruded polygon mesh, with depth in the Y direction.
  58085. * * 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)
  58086. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58087. * @param name defines the name of the mesh
  58088. * @param options defines the options used to create the mesh
  58089. * @param scene defines the hosting scene
  58090. * @param earcutInjection can be used to inject your own earcut reference
  58091. * @returns the polygon mesh
  58092. */
  58093. static ExtrudePolygon(name: string, options: {
  58094. shape: Vector3[];
  58095. holes?: Vector3[][];
  58096. depth?: number;
  58097. faceUV?: Vector4[];
  58098. faceColors?: Color4[];
  58099. updatable?: boolean;
  58100. sideOrientation?: number;
  58101. frontUVs?: Vector4;
  58102. backUVs?: Vector4;
  58103. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58104. }
  58105. }
  58106. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  58107. import { Scene } from "babylonjs/scene";
  58108. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58109. import { Mesh } from "babylonjs/Meshes/mesh";
  58110. import { Nullable } from "babylonjs/types";
  58111. /**
  58112. * Class containing static functions to help procedurally build meshes
  58113. */
  58114. export class LatheBuilder {
  58115. /**
  58116. * Creates lathe mesh.
  58117. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58118. * * 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
  58119. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58120. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58121. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58122. * * 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
  58123. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58124. * * 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
  58125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58126. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58127. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58129. * @param name defines the name of the mesh
  58130. * @param options defines the options used to create the mesh
  58131. * @param scene defines the hosting scene
  58132. * @returns the lathe mesh
  58133. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58134. */
  58135. static CreateLathe(name: string, options: {
  58136. shape: Vector3[];
  58137. radius?: number;
  58138. tessellation?: number;
  58139. clip?: number;
  58140. arc?: number;
  58141. closed?: boolean;
  58142. updatable?: boolean;
  58143. sideOrientation?: number;
  58144. frontUVs?: Vector4;
  58145. backUVs?: Vector4;
  58146. cap?: number;
  58147. invertUV?: boolean;
  58148. }, scene?: Nullable<Scene>): Mesh;
  58149. }
  58150. }
  58151. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  58152. import { Nullable } from "babylonjs/types";
  58153. import { Scene } from "babylonjs/scene";
  58154. import { Vector4 } from "babylonjs/Maths/math.vector";
  58155. import { Mesh } from "babylonjs/Meshes/mesh";
  58156. /**
  58157. * Class containing static functions to help procedurally build meshes
  58158. */
  58159. export class TiledPlaneBuilder {
  58160. /**
  58161. * Creates a tiled plane mesh
  58162. * * The parameter `pattern` will, depending on value, do nothing or
  58163. * * * flip (reflect about central vertical) alternate tiles across and up
  58164. * * * flip every tile on alternate rows
  58165. * * * rotate (180 degs) alternate tiles across and up
  58166. * * * rotate every tile on alternate rows
  58167. * * * flip and rotate alternate tiles across and up
  58168. * * * flip and rotate every tile on alternate rows
  58169. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  58170. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  58171. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58172. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58173. * * 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)
  58174. * * 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)
  58175. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58176. * @param name defines the name of the mesh
  58177. * @param options defines the options used to create the mesh
  58178. * @param scene defines the hosting scene
  58179. * @returns the box mesh
  58180. */
  58181. static CreateTiledPlane(name: string, options: {
  58182. pattern?: number;
  58183. tileSize?: number;
  58184. tileWidth?: number;
  58185. tileHeight?: number;
  58186. size?: number;
  58187. width?: number;
  58188. height?: number;
  58189. alignHorizontal?: number;
  58190. alignVertical?: number;
  58191. sideOrientation?: number;
  58192. frontUVs?: Vector4;
  58193. backUVs?: Vector4;
  58194. updatable?: boolean;
  58195. }, scene?: Nullable<Scene>): Mesh;
  58196. }
  58197. }
  58198. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  58199. import { Nullable } from "babylonjs/types";
  58200. import { Scene } from "babylonjs/scene";
  58201. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58202. import { Mesh } from "babylonjs/Meshes/mesh";
  58203. /**
  58204. * Class containing static functions to help procedurally build meshes
  58205. */
  58206. export class TubeBuilder {
  58207. /**
  58208. * Creates a tube mesh.
  58209. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58210. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58211. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58212. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58213. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58214. * * 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)
  58215. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58216. * * 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
  58217. * * 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
  58218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58219. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58220. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58222. * @param name defines the name of the mesh
  58223. * @param options defines the options used to create the mesh
  58224. * @param scene defines the hosting scene
  58225. * @returns the tube mesh
  58226. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58227. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58228. */
  58229. static CreateTube(name: string, options: {
  58230. path: Vector3[];
  58231. radius?: number;
  58232. tessellation?: number;
  58233. radiusFunction?: {
  58234. (i: number, distance: number): number;
  58235. };
  58236. cap?: number;
  58237. arc?: number;
  58238. updatable?: boolean;
  58239. sideOrientation?: number;
  58240. frontUVs?: Vector4;
  58241. backUVs?: Vector4;
  58242. instance?: Mesh;
  58243. invertUV?: boolean;
  58244. }, scene?: Nullable<Scene>): Mesh;
  58245. }
  58246. }
  58247. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  58248. import { Scene } from "babylonjs/scene";
  58249. import { Vector4 } from "babylonjs/Maths/math.vector";
  58250. import { Mesh } from "babylonjs/Meshes/mesh";
  58251. import { Nullable } from "babylonjs/types";
  58252. /**
  58253. * Class containing static functions to help procedurally build meshes
  58254. */
  58255. export class IcoSphereBuilder {
  58256. /**
  58257. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58258. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58259. * * 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`)
  58260. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58261. * * 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
  58262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58265. * @param name defines the name of the mesh
  58266. * @param options defines the options used to create the mesh
  58267. * @param scene defines the hosting scene
  58268. * @returns the icosahedron mesh
  58269. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58270. */
  58271. static CreateIcoSphere(name: string, options: {
  58272. radius?: number;
  58273. radiusX?: number;
  58274. radiusY?: number;
  58275. radiusZ?: number;
  58276. flat?: boolean;
  58277. subdivisions?: number;
  58278. sideOrientation?: number;
  58279. frontUVs?: Vector4;
  58280. backUVs?: Vector4;
  58281. updatable?: boolean;
  58282. }, scene?: Nullable<Scene>): Mesh;
  58283. }
  58284. }
  58285. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  58286. import { Vector3 } from "babylonjs/Maths/math.vector";
  58287. import { Mesh } from "babylonjs/Meshes/mesh";
  58288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58289. /**
  58290. * Class containing static functions to help procedurally build meshes
  58291. */
  58292. export class DecalBuilder {
  58293. /**
  58294. * Creates a decal mesh.
  58295. * 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
  58296. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  58297. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  58298. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  58299. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  58300. * @param name defines the name of the mesh
  58301. * @param sourceMesh defines the mesh where the decal must be applied
  58302. * @param options defines the options used to create the mesh
  58303. * @param scene defines the hosting scene
  58304. * @returns the decal mesh
  58305. * @see https://doc.babylonjs.com/how_to/decals
  58306. */
  58307. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  58308. position?: Vector3;
  58309. normal?: Vector3;
  58310. size?: Vector3;
  58311. angle?: number;
  58312. }): Mesh;
  58313. }
  58314. }
  58315. declare module "babylonjs/Meshes/meshBuilder" {
  58316. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  58317. import { Nullable } from "babylonjs/types";
  58318. import { Scene } from "babylonjs/scene";
  58319. import { Mesh } from "babylonjs/Meshes/mesh";
  58320. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  58321. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  58322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58323. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  58324. import { Plane } from "babylonjs/Maths/math.plane";
  58325. /**
  58326. * Class containing static functions to help procedurally build meshes
  58327. */
  58328. export class MeshBuilder {
  58329. /**
  58330. * Creates a box mesh
  58331. * * The parameter `size` sets the size (float) of each box side (default 1)
  58332. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  58333. * * 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)
  58334. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58335. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58336. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58338. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  58339. * @param name defines the name of the mesh
  58340. * @param options defines the options used to create the mesh
  58341. * @param scene defines the hosting scene
  58342. * @returns the box mesh
  58343. */
  58344. static CreateBox(name: string, options: {
  58345. size?: number;
  58346. width?: number;
  58347. height?: number;
  58348. depth?: number;
  58349. faceUV?: Vector4[];
  58350. faceColors?: Color4[];
  58351. sideOrientation?: number;
  58352. frontUVs?: Vector4;
  58353. backUVs?: Vector4;
  58354. updatable?: boolean;
  58355. }, scene?: Nullable<Scene>): Mesh;
  58356. /**
  58357. * Creates a tiled box mesh
  58358. * * faceTiles sets the pattern, tile size and number of tiles for a face
  58359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58360. * @param name defines the name of the mesh
  58361. * @param options defines the options used to create the mesh
  58362. * @param scene defines the hosting scene
  58363. * @returns the tiled box mesh
  58364. */
  58365. static CreateTiledBox(name: string, options: {
  58366. pattern?: number;
  58367. size?: number;
  58368. width?: number;
  58369. height?: number;
  58370. depth: number;
  58371. tileSize?: number;
  58372. tileWidth?: number;
  58373. tileHeight?: number;
  58374. faceUV?: Vector4[];
  58375. faceColors?: Color4[];
  58376. alignHorizontal?: number;
  58377. alignVertical?: number;
  58378. sideOrientation?: number;
  58379. updatable?: boolean;
  58380. }, scene?: Nullable<Scene>): Mesh;
  58381. /**
  58382. * Creates a sphere mesh
  58383. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  58384. * * 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`)
  58385. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  58386. * * 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
  58387. * * 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)
  58388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58391. * @param name defines the name of the mesh
  58392. * @param options defines the options used to create the mesh
  58393. * @param scene defines the hosting scene
  58394. * @returns the sphere mesh
  58395. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  58396. */
  58397. static CreateSphere(name: string, options: {
  58398. segments?: number;
  58399. diameter?: number;
  58400. diameterX?: number;
  58401. diameterY?: number;
  58402. diameterZ?: number;
  58403. arc?: number;
  58404. slice?: number;
  58405. sideOrientation?: number;
  58406. frontUVs?: Vector4;
  58407. backUVs?: Vector4;
  58408. updatable?: boolean;
  58409. }, scene?: Nullable<Scene>): Mesh;
  58410. /**
  58411. * Creates a plane polygonal mesh. By default, this is a disc
  58412. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  58413. * * 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
  58414. * * 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
  58415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58416. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58418. * @param name defines the name of the mesh
  58419. * @param options defines the options used to create the mesh
  58420. * @param scene defines the hosting scene
  58421. * @returns the plane polygonal mesh
  58422. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  58423. */
  58424. static CreateDisc(name: string, options: {
  58425. radius?: number;
  58426. tessellation?: number;
  58427. arc?: number;
  58428. updatable?: boolean;
  58429. sideOrientation?: number;
  58430. frontUVs?: Vector4;
  58431. backUVs?: Vector4;
  58432. }, scene?: Nullable<Scene>): Mesh;
  58433. /**
  58434. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  58435. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  58436. * * 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`)
  58437. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  58438. * * 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
  58439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58440. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58442. * @param name defines the name of the mesh
  58443. * @param options defines the options used to create the mesh
  58444. * @param scene defines the hosting scene
  58445. * @returns the icosahedron mesh
  58446. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  58447. */
  58448. static CreateIcoSphere(name: string, options: {
  58449. radius?: number;
  58450. radiusX?: number;
  58451. radiusY?: number;
  58452. radiusZ?: number;
  58453. flat?: boolean;
  58454. subdivisions?: number;
  58455. sideOrientation?: number;
  58456. frontUVs?: Vector4;
  58457. backUVs?: Vector4;
  58458. updatable?: boolean;
  58459. }, scene?: Nullable<Scene>): Mesh;
  58460. /**
  58461. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58462. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58463. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58464. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58465. * * 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
  58466. * * 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
  58467. * * 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
  58468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58469. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58470. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58471. * * 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
  58472. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58473. * * 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
  58474. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58476. * @param name defines the name of the mesh
  58477. * @param options defines the options used to create the mesh
  58478. * @param scene defines the hosting scene
  58479. * @returns the ribbon mesh
  58480. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58481. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58482. */
  58483. static CreateRibbon(name: string, options: {
  58484. pathArray: Vector3[][];
  58485. closeArray?: boolean;
  58486. closePath?: boolean;
  58487. offset?: number;
  58488. updatable?: boolean;
  58489. sideOrientation?: number;
  58490. frontUVs?: Vector4;
  58491. backUVs?: Vector4;
  58492. instance?: Mesh;
  58493. invertUV?: boolean;
  58494. uvs?: Vector2[];
  58495. colors?: Color4[];
  58496. }, scene?: Nullable<Scene>): Mesh;
  58497. /**
  58498. * Creates a cylinder or a cone mesh
  58499. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  58500. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  58501. * * 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.
  58502. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  58503. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  58504. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  58505. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  58506. * * 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).
  58507. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  58508. * * 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).
  58509. * * 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
  58510. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  58511. * * 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
  58512. * * 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.
  58513. * * If `enclose` is false, a ring surface is one element.
  58514. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  58515. * * 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
  58516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58517. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58519. * @param name defines the name of the mesh
  58520. * @param options defines the options used to create the mesh
  58521. * @param scene defines the hosting scene
  58522. * @returns the cylinder mesh
  58523. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  58524. */
  58525. static CreateCylinder(name: string, options: {
  58526. height?: number;
  58527. diameterTop?: number;
  58528. diameterBottom?: number;
  58529. diameter?: number;
  58530. tessellation?: number;
  58531. subdivisions?: number;
  58532. arc?: number;
  58533. faceColors?: Color4[];
  58534. faceUV?: Vector4[];
  58535. updatable?: boolean;
  58536. hasRings?: boolean;
  58537. enclose?: boolean;
  58538. cap?: number;
  58539. sideOrientation?: number;
  58540. frontUVs?: Vector4;
  58541. backUVs?: Vector4;
  58542. }, scene?: Nullable<Scene>): Mesh;
  58543. /**
  58544. * Creates a torus mesh
  58545. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  58546. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  58547. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  58548. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58549. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58551. * @param name defines the name of the mesh
  58552. * @param options defines the options used to create the mesh
  58553. * @param scene defines the hosting scene
  58554. * @returns the torus mesh
  58555. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  58556. */
  58557. static CreateTorus(name: string, options: {
  58558. diameter?: number;
  58559. thickness?: number;
  58560. tessellation?: number;
  58561. updatable?: boolean;
  58562. sideOrientation?: number;
  58563. frontUVs?: Vector4;
  58564. backUVs?: Vector4;
  58565. }, scene?: Nullable<Scene>): Mesh;
  58566. /**
  58567. * Creates a torus knot mesh
  58568. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58569. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58570. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58571. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58572. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58573. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58575. * @param name defines the name of the mesh
  58576. * @param options defines the options used to create the mesh
  58577. * @param scene defines the hosting scene
  58578. * @returns the torus knot mesh
  58579. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58580. */
  58581. static CreateTorusKnot(name: string, options: {
  58582. radius?: number;
  58583. tube?: number;
  58584. radialSegments?: number;
  58585. tubularSegments?: number;
  58586. p?: number;
  58587. q?: number;
  58588. updatable?: boolean;
  58589. sideOrientation?: number;
  58590. frontUVs?: Vector4;
  58591. backUVs?: Vector4;
  58592. }, scene?: Nullable<Scene>): Mesh;
  58593. /**
  58594. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  58595. * * 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
  58596. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  58597. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  58598. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  58599. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  58600. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  58601. * * 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
  58602. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  58603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58604. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  58605. * @param name defines the name of the new line system
  58606. * @param options defines the options used to create the line system
  58607. * @param scene defines the hosting scene
  58608. * @returns a new line system mesh
  58609. */
  58610. static CreateLineSystem(name: string, options: {
  58611. lines: Vector3[][];
  58612. updatable?: boolean;
  58613. instance?: Nullable<LinesMesh>;
  58614. colors?: Nullable<Color4[][]>;
  58615. useVertexAlpha?: boolean;
  58616. }, scene: Nullable<Scene>): LinesMesh;
  58617. /**
  58618. * Creates a line mesh
  58619. * 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
  58620. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58621. * * The parameter `points` is an array successive Vector3
  58622. * * 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
  58623. * * The optional parameter `colors` is an array of successive Color4, one per line point
  58624. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  58625. * * When updating an instance, remember that only point positions can change, not the number of points
  58626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58627. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  58628. * @param name defines the name of the new line system
  58629. * @param options defines the options used to create the line system
  58630. * @param scene defines the hosting scene
  58631. * @returns a new line mesh
  58632. */
  58633. static CreateLines(name: string, options: {
  58634. points: Vector3[];
  58635. updatable?: boolean;
  58636. instance?: Nullable<LinesMesh>;
  58637. colors?: Color4[];
  58638. useVertexAlpha?: boolean;
  58639. }, scene?: Nullable<Scene>): LinesMesh;
  58640. /**
  58641. * Creates a dashed line mesh
  58642. * * 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
  58643. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  58644. * * The parameter `points` is an array successive Vector3
  58645. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  58646. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  58647. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  58648. * * 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
  58649. * * When updating an instance, remember that only point positions can change, not the number of points
  58650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58651. * @param name defines the name of the mesh
  58652. * @param options defines the options used to create the mesh
  58653. * @param scene defines the hosting scene
  58654. * @returns the dashed line mesh
  58655. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  58656. */
  58657. static CreateDashedLines(name: string, options: {
  58658. points: Vector3[];
  58659. dashSize?: number;
  58660. gapSize?: number;
  58661. dashNb?: number;
  58662. updatable?: boolean;
  58663. instance?: LinesMesh;
  58664. }, scene?: Nullable<Scene>): LinesMesh;
  58665. /**
  58666. * 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.
  58667. * * 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.
  58668. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58669. * * 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.
  58670. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58671. * * 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
  58672. * * 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
  58673. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58675. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58676. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58678. * @param name defines the name of the mesh
  58679. * @param options defines the options used to create the mesh
  58680. * @param scene defines the hosting scene
  58681. * @returns the extruded shape mesh
  58682. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58683. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58684. */
  58685. static ExtrudeShape(name: string, options: {
  58686. shape: Vector3[];
  58687. path: Vector3[];
  58688. scale?: number;
  58689. rotation?: number;
  58690. cap?: number;
  58691. updatable?: boolean;
  58692. sideOrientation?: number;
  58693. frontUVs?: Vector4;
  58694. backUVs?: Vector4;
  58695. instance?: Mesh;
  58696. invertUV?: boolean;
  58697. }, scene?: Nullable<Scene>): Mesh;
  58698. /**
  58699. * Creates an custom extruded shape mesh.
  58700. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58701. * * 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.
  58702. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58703. * * 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
  58704. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58705. * * 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
  58706. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58707. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58708. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58709. * * 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
  58710. * * 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
  58711. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58712. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58713. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58714. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58716. * @param name defines the name of the mesh
  58717. * @param options defines the options used to create the mesh
  58718. * @param scene defines the hosting scene
  58719. * @returns the custom extruded shape mesh
  58720. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58721. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58722. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58723. */
  58724. static ExtrudeShapeCustom(name: string, options: {
  58725. shape: Vector3[];
  58726. path: Vector3[];
  58727. scaleFunction?: any;
  58728. rotationFunction?: any;
  58729. ribbonCloseArray?: boolean;
  58730. ribbonClosePath?: boolean;
  58731. cap?: number;
  58732. updatable?: boolean;
  58733. sideOrientation?: number;
  58734. frontUVs?: Vector4;
  58735. backUVs?: Vector4;
  58736. instance?: Mesh;
  58737. invertUV?: boolean;
  58738. }, scene?: Nullable<Scene>): Mesh;
  58739. /**
  58740. * Creates lathe mesh.
  58741. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  58742. * * 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
  58743. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  58744. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  58745. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  58746. * * 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
  58747. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  58748. * * 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
  58749. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58750. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58751. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58753. * @param name defines the name of the mesh
  58754. * @param options defines the options used to create the mesh
  58755. * @param scene defines the hosting scene
  58756. * @returns the lathe mesh
  58757. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  58758. */
  58759. static CreateLathe(name: string, options: {
  58760. shape: Vector3[];
  58761. radius?: number;
  58762. tessellation?: number;
  58763. clip?: number;
  58764. arc?: number;
  58765. closed?: boolean;
  58766. updatable?: boolean;
  58767. sideOrientation?: number;
  58768. frontUVs?: Vector4;
  58769. backUVs?: Vector4;
  58770. cap?: number;
  58771. invertUV?: boolean;
  58772. }, scene?: Nullable<Scene>): Mesh;
  58773. /**
  58774. * Creates a tiled plane mesh
  58775. * * You can set a limited pattern arrangement with the tiles
  58776. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58777. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58779. * @param name defines the name of the mesh
  58780. * @param options defines the options used to create the mesh
  58781. * @param scene defines the hosting scene
  58782. * @returns the plane mesh
  58783. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58784. */
  58785. static CreateTiledPlane(name: string, options: {
  58786. pattern?: number;
  58787. tileSize?: number;
  58788. tileWidth?: number;
  58789. tileHeight?: number;
  58790. size?: number;
  58791. width?: number;
  58792. height?: number;
  58793. alignHorizontal?: number;
  58794. alignVertical?: number;
  58795. sideOrientation?: number;
  58796. frontUVs?: Vector4;
  58797. backUVs?: Vector4;
  58798. updatable?: boolean;
  58799. }, scene?: Nullable<Scene>): Mesh;
  58800. /**
  58801. * Creates a plane mesh
  58802. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  58803. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  58804. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  58805. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58806. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58808. * @param name defines the name of the mesh
  58809. * @param options defines the options used to create the mesh
  58810. * @param scene defines the hosting scene
  58811. * @returns the plane mesh
  58812. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  58813. */
  58814. static CreatePlane(name: string, options: {
  58815. size?: number;
  58816. width?: number;
  58817. height?: number;
  58818. sideOrientation?: number;
  58819. frontUVs?: Vector4;
  58820. backUVs?: Vector4;
  58821. updatable?: boolean;
  58822. sourcePlane?: Plane;
  58823. }, scene?: Nullable<Scene>): Mesh;
  58824. /**
  58825. * Creates a ground mesh
  58826. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  58827. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  58828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58829. * @param name defines the name of the mesh
  58830. * @param options defines the options used to create the mesh
  58831. * @param scene defines the hosting scene
  58832. * @returns the ground mesh
  58833. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  58834. */
  58835. static CreateGround(name: string, options: {
  58836. width?: number;
  58837. height?: number;
  58838. subdivisions?: number;
  58839. subdivisionsX?: number;
  58840. subdivisionsY?: number;
  58841. updatable?: boolean;
  58842. }, scene?: Nullable<Scene>): Mesh;
  58843. /**
  58844. * Creates a tiled ground mesh
  58845. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  58846. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  58847. * * 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
  58848. * * 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
  58849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58850. * @param name defines the name of the mesh
  58851. * @param options defines the options used to create the mesh
  58852. * @param scene defines the hosting scene
  58853. * @returns the tiled ground mesh
  58854. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  58855. */
  58856. static CreateTiledGround(name: string, options: {
  58857. xmin: number;
  58858. zmin: number;
  58859. xmax: number;
  58860. zmax: number;
  58861. subdivisions?: {
  58862. w: number;
  58863. h: number;
  58864. };
  58865. precision?: {
  58866. w: number;
  58867. h: number;
  58868. };
  58869. updatable?: boolean;
  58870. }, scene?: Nullable<Scene>): Mesh;
  58871. /**
  58872. * Creates a ground mesh from a height map
  58873. * * The parameter `url` sets the URL of the height map image resource.
  58874. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  58875. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  58876. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  58877. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  58878. * * 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.
  58879. * * 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).
  58880. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  58881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58882. * @param name defines the name of the mesh
  58883. * @param url defines the url to the height map
  58884. * @param options defines the options used to create the mesh
  58885. * @param scene defines the hosting scene
  58886. * @returns the ground mesh
  58887. * @see https://doc.babylonjs.com/babylon101/height_map
  58888. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  58889. */
  58890. static CreateGroundFromHeightMap(name: string, url: string, options: {
  58891. width?: number;
  58892. height?: number;
  58893. subdivisions?: number;
  58894. minHeight?: number;
  58895. maxHeight?: number;
  58896. colorFilter?: Color3;
  58897. alphaFilter?: number;
  58898. updatable?: boolean;
  58899. onReady?: (mesh: GroundMesh) => void;
  58900. }, scene?: Nullable<Scene>): GroundMesh;
  58901. /**
  58902. * Creates a polygon mesh
  58903. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58904. * * 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
  58905. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58907. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58908. * * Remember you can only change the shape positions, not their number when updating a polygon
  58909. * @param name defines the name of the mesh
  58910. * @param options defines the options used to create the mesh
  58911. * @param scene defines the hosting scene
  58912. * @param earcutInjection can be used to inject your own earcut reference
  58913. * @returns the polygon mesh
  58914. */
  58915. static CreatePolygon(name: string, options: {
  58916. shape: Vector3[];
  58917. holes?: Vector3[][];
  58918. depth?: number;
  58919. faceUV?: Vector4[];
  58920. faceColors?: Color4[];
  58921. updatable?: boolean;
  58922. sideOrientation?: number;
  58923. frontUVs?: Vector4;
  58924. backUVs?: Vector4;
  58925. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58926. /**
  58927. * Creates an extruded polygon mesh, with depth in the Y direction.
  58928. * * 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)
  58929. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58930. * @param name defines the name of the mesh
  58931. * @param options defines the options used to create the mesh
  58932. * @param scene defines the hosting scene
  58933. * @param earcutInjection can be used to inject your own earcut reference
  58934. * @returns the polygon mesh
  58935. */
  58936. static ExtrudePolygon(name: string, options: {
  58937. shape: Vector3[];
  58938. holes?: Vector3[][];
  58939. depth?: number;
  58940. faceUV?: Vector4[];
  58941. faceColors?: Color4[];
  58942. updatable?: boolean;
  58943. sideOrientation?: number;
  58944. frontUVs?: Vector4;
  58945. backUVs?: Vector4;
  58946. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58947. /**
  58948. * Creates a tube mesh.
  58949. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58950. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  58951. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  58952. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  58953. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  58954. * * 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)
  58955. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  58956. * * 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
  58957. * * 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
  58958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58959. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58960. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58962. * @param name defines the name of the mesh
  58963. * @param options defines the options used to create the mesh
  58964. * @param scene defines the hosting scene
  58965. * @returns the tube mesh
  58966. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58967. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  58968. */
  58969. static CreateTube(name: string, options: {
  58970. path: Vector3[];
  58971. radius?: number;
  58972. tessellation?: number;
  58973. radiusFunction?: {
  58974. (i: number, distance: number): number;
  58975. };
  58976. cap?: number;
  58977. arc?: number;
  58978. updatable?: boolean;
  58979. sideOrientation?: number;
  58980. frontUVs?: Vector4;
  58981. backUVs?: Vector4;
  58982. instance?: Mesh;
  58983. invertUV?: boolean;
  58984. }, scene?: Nullable<Scene>): Mesh;
  58985. /**
  58986. * Creates a polyhedron mesh
  58987. * * 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
  58988. * * The parameter `size` (positive float, default 1) sets the polygon size
  58989. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  58990. * * 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`
  58991. * * 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
  58992. * * 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)`)
  58993. * * 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
  58994. * * 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
  58995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58996. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58998. * @param name defines the name of the mesh
  58999. * @param options defines the options used to create the mesh
  59000. * @param scene defines the hosting scene
  59001. * @returns the polyhedron mesh
  59002. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59003. */
  59004. static CreatePolyhedron(name: string, options: {
  59005. type?: number;
  59006. size?: number;
  59007. sizeX?: number;
  59008. sizeY?: number;
  59009. sizeZ?: number;
  59010. custom?: any;
  59011. faceUV?: Vector4[];
  59012. faceColors?: Color4[];
  59013. flat?: boolean;
  59014. updatable?: boolean;
  59015. sideOrientation?: number;
  59016. frontUVs?: Vector4;
  59017. backUVs?: Vector4;
  59018. }, scene?: Nullable<Scene>): Mesh;
  59019. /**
  59020. * Creates a decal mesh.
  59021. * 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
  59022. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59023. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59024. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59025. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59026. * @param name defines the name of the mesh
  59027. * @param sourceMesh defines the mesh where the decal must be applied
  59028. * @param options defines the options used to create the mesh
  59029. * @param scene defines the hosting scene
  59030. * @returns the decal mesh
  59031. * @see https://doc.babylonjs.com/how_to/decals
  59032. */
  59033. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59034. position?: Vector3;
  59035. normal?: Vector3;
  59036. size?: Vector3;
  59037. angle?: number;
  59038. }): Mesh;
  59039. }
  59040. }
  59041. declare module "babylonjs/Meshes/meshSimplification" {
  59042. import { Mesh } from "babylonjs/Meshes/mesh";
  59043. /**
  59044. * A simplifier interface for future simplification implementations
  59045. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59046. */
  59047. export interface ISimplifier {
  59048. /**
  59049. * Simplification of a given mesh according to the given settings.
  59050. * Since this requires computation, it is assumed that the function runs async.
  59051. * @param settings The settings of the simplification, including quality and distance
  59052. * @param successCallback A callback that will be called after the mesh was simplified.
  59053. * @param errorCallback in case of an error, this callback will be called. optional.
  59054. */
  59055. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59056. }
  59057. /**
  59058. * Expected simplification settings.
  59059. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59060. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59061. */
  59062. export interface ISimplificationSettings {
  59063. /**
  59064. * Gets or sets the expected quality
  59065. */
  59066. quality: number;
  59067. /**
  59068. * Gets or sets the distance when this optimized version should be used
  59069. */
  59070. distance: number;
  59071. /**
  59072. * Gets an already optimized mesh
  59073. */
  59074. optimizeMesh?: boolean;
  59075. }
  59076. /**
  59077. * Class used to specify simplification options
  59078. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59079. */
  59080. export class SimplificationSettings implements ISimplificationSettings {
  59081. /** expected quality */
  59082. quality: number;
  59083. /** distance when this optimized version should be used */
  59084. distance: number;
  59085. /** already optimized mesh */
  59086. optimizeMesh?: boolean | undefined;
  59087. /**
  59088. * Creates a SimplificationSettings
  59089. * @param quality expected quality
  59090. * @param distance distance when this optimized version should be used
  59091. * @param optimizeMesh already optimized mesh
  59092. */
  59093. constructor(
  59094. /** expected quality */
  59095. quality: number,
  59096. /** distance when this optimized version should be used */
  59097. distance: number,
  59098. /** already optimized mesh */
  59099. optimizeMesh?: boolean | undefined);
  59100. }
  59101. /**
  59102. * Interface used to define a simplification task
  59103. */
  59104. export interface ISimplificationTask {
  59105. /**
  59106. * Array of settings
  59107. */
  59108. settings: Array<ISimplificationSettings>;
  59109. /**
  59110. * Simplification type
  59111. */
  59112. simplificationType: SimplificationType;
  59113. /**
  59114. * Mesh to simplify
  59115. */
  59116. mesh: Mesh;
  59117. /**
  59118. * Callback called on success
  59119. */
  59120. successCallback?: () => void;
  59121. /**
  59122. * Defines if parallel processing can be used
  59123. */
  59124. parallelProcessing: boolean;
  59125. }
  59126. /**
  59127. * Queue used to order the simplification tasks
  59128. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59129. */
  59130. export class SimplificationQueue {
  59131. private _simplificationArray;
  59132. /**
  59133. * Gets a boolean indicating that the process is still running
  59134. */
  59135. running: boolean;
  59136. /**
  59137. * Creates a new queue
  59138. */
  59139. constructor();
  59140. /**
  59141. * Adds a new simplification task
  59142. * @param task defines a task to add
  59143. */
  59144. addTask(task: ISimplificationTask): void;
  59145. /**
  59146. * Execute next task
  59147. */
  59148. executeNext(): void;
  59149. /**
  59150. * Execute a simplification task
  59151. * @param task defines the task to run
  59152. */
  59153. runSimplification(task: ISimplificationTask): void;
  59154. private getSimplifier;
  59155. }
  59156. /**
  59157. * The implemented types of simplification
  59158. * At the moment only Quadratic Error Decimation is implemented
  59159. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59160. */
  59161. export enum SimplificationType {
  59162. /** Quadratic error decimation */
  59163. QUADRATIC = 0
  59164. }
  59165. }
  59166. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  59167. import { Scene } from "babylonjs/scene";
  59168. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  59169. import { ISceneComponent } from "babylonjs/sceneComponent";
  59170. module "babylonjs/scene" {
  59171. interface Scene {
  59172. /** @hidden (Backing field) */
  59173. _simplificationQueue: SimplificationQueue;
  59174. /**
  59175. * Gets or sets the simplification queue attached to the scene
  59176. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59177. */
  59178. simplificationQueue: SimplificationQueue;
  59179. }
  59180. }
  59181. module "babylonjs/Meshes/mesh" {
  59182. interface Mesh {
  59183. /**
  59184. * Simplify the mesh according to the given array of settings.
  59185. * Function will return immediately and will simplify async
  59186. * @param settings a collection of simplification settings
  59187. * @param parallelProcessing should all levels calculate parallel or one after the other
  59188. * @param simplificationType the type of simplification to run
  59189. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  59190. * @returns the current mesh
  59191. */
  59192. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  59193. }
  59194. }
  59195. /**
  59196. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  59197. * created in a scene
  59198. */
  59199. export class SimplicationQueueSceneComponent implements ISceneComponent {
  59200. /**
  59201. * The component name helpfull to identify the component in the list of scene components.
  59202. */
  59203. readonly name: string;
  59204. /**
  59205. * The scene the component belongs to.
  59206. */
  59207. scene: Scene;
  59208. /**
  59209. * Creates a new instance of the component for the given scene
  59210. * @param scene Defines the scene to register the component in
  59211. */
  59212. constructor(scene: Scene);
  59213. /**
  59214. * Registers the component in a given scene
  59215. */
  59216. register(): void;
  59217. /**
  59218. * Rebuilds the elements related to this component in case of
  59219. * context lost for instance.
  59220. */
  59221. rebuild(): void;
  59222. /**
  59223. * Disposes the component and the associated ressources
  59224. */
  59225. dispose(): void;
  59226. private _beforeCameraUpdate;
  59227. }
  59228. }
  59229. declare module "babylonjs/Meshes/Builders/index" {
  59230. export * from "babylonjs/Meshes/Builders/boxBuilder";
  59231. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  59232. export * from "babylonjs/Meshes/Builders/discBuilder";
  59233. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  59234. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  59235. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  59236. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  59237. export * from "babylonjs/Meshes/Builders/torusBuilder";
  59238. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  59239. export * from "babylonjs/Meshes/Builders/linesBuilder";
  59240. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  59241. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  59242. export * from "babylonjs/Meshes/Builders/latheBuilder";
  59243. export * from "babylonjs/Meshes/Builders/planeBuilder";
  59244. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  59245. export * from "babylonjs/Meshes/Builders/groundBuilder";
  59246. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  59247. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  59248. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  59249. export * from "babylonjs/Meshes/Builders/decalBuilder";
  59250. }
  59251. declare module "babylonjs/Meshes/index" {
  59252. export * from "babylonjs/Meshes/abstractMesh";
  59253. export * from "babylonjs/Meshes/buffer";
  59254. export * from "babylonjs/Meshes/Compression/index";
  59255. export * from "babylonjs/Meshes/csg";
  59256. export * from "babylonjs/Meshes/geometry";
  59257. export * from "babylonjs/Meshes/groundMesh";
  59258. export * from "babylonjs/Meshes/trailMesh";
  59259. export * from "babylonjs/Meshes/instancedMesh";
  59260. export * from "babylonjs/Meshes/linesMesh";
  59261. export * from "babylonjs/Meshes/mesh";
  59262. export * from "babylonjs/Meshes/mesh.vertexData";
  59263. export * from "babylonjs/Meshes/meshBuilder";
  59264. export * from "babylonjs/Meshes/meshSimplification";
  59265. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  59266. export * from "babylonjs/Meshes/polygonMesh";
  59267. export * from "babylonjs/Meshes/subMesh";
  59268. export * from "babylonjs/Meshes/meshLODLevel";
  59269. export * from "babylonjs/Meshes/transformNode";
  59270. export * from "babylonjs/Meshes/Builders/index";
  59271. export * from "babylonjs/Meshes/dataBuffer";
  59272. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  59273. }
  59274. declare module "babylonjs/Morph/index" {
  59275. export * from "babylonjs/Morph/morphTarget";
  59276. export * from "babylonjs/Morph/morphTargetManager";
  59277. }
  59278. declare module "babylonjs/Navigation/INavigationEngine" {
  59279. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59280. import { Vector3 } from "babylonjs/Maths/math";
  59281. import { Mesh } from "babylonjs/Meshes/mesh";
  59282. import { Scene } from "babylonjs/scene";
  59283. /**
  59284. * Navigation plugin interface to add navigation constrained by a navigation mesh
  59285. */
  59286. export interface INavigationEnginePlugin {
  59287. /**
  59288. * plugin name
  59289. */
  59290. name: string;
  59291. /**
  59292. * Creates a navigation mesh
  59293. * @param meshes array of all the geometry used to compute the navigatio mesh
  59294. * @param parameters bunch of parameters used to filter geometry
  59295. */
  59296. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59297. /**
  59298. * Create a navigation mesh debug mesh
  59299. * @param scene is where the mesh will be added
  59300. * @returns debug display mesh
  59301. */
  59302. createDebugNavMesh(scene: Scene): Mesh;
  59303. /**
  59304. * Get a navigation mesh constrained position, closest to the parameter position
  59305. * @param position world position
  59306. * @returns the closest point to position constrained by the navigation mesh
  59307. */
  59308. getClosestPoint(position: Vector3): Vector3;
  59309. /**
  59310. * Get a navigation mesh constrained position, within a particular radius
  59311. * @param position world position
  59312. * @param maxRadius the maximum distance to the constrained world position
  59313. * @returns the closest point to position constrained by the navigation mesh
  59314. */
  59315. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59316. /**
  59317. * Compute the final position from a segment made of destination-position
  59318. * @param position world position
  59319. * @param destination world position
  59320. * @returns the resulting point along the navmesh
  59321. */
  59322. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59323. /**
  59324. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59325. * @param start world position
  59326. * @param end world position
  59327. * @returns array containing world position composing the path
  59328. */
  59329. computePath(start: Vector3, end: Vector3): Vector3[];
  59330. /**
  59331. * If this plugin is supported
  59332. * @returns true if plugin is supported
  59333. */
  59334. isSupported(): boolean;
  59335. /**
  59336. * Create a new Crowd so you can add agents
  59337. * @param maxAgents the maximum agent count in the crowd
  59338. * @param maxAgentRadius the maximum radius an agent can have
  59339. * @param scene to attach the crowd to
  59340. * @returns the crowd you can add agents to
  59341. */
  59342. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59343. /**
  59344. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59345. * The queries will try to find a solution within those bounds
  59346. * default is (1,1,1)
  59347. * @param extent x,y,z value that define the extent around the queries point of reference
  59348. */
  59349. setDefaultQueryExtent(extent: Vector3): void;
  59350. /**
  59351. * Get the Bounding box extent specified by setDefaultQueryExtent
  59352. * @returns the box extent values
  59353. */
  59354. getDefaultQueryExtent(): Vector3;
  59355. /**
  59356. * Release all resources
  59357. */
  59358. dispose(): void;
  59359. }
  59360. /**
  59361. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  59362. */
  59363. export interface ICrowd {
  59364. /**
  59365. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59366. * You can attach anything to that node. The node position is updated in the scene update tick.
  59367. * @param pos world position that will be constrained by the navigation mesh
  59368. * @param parameters agent parameters
  59369. * @param transform hooked to the agent that will be update by the scene
  59370. * @returns agent index
  59371. */
  59372. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59373. /**
  59374. * Returns the agent position in world space
  59375. * @param index agent index returned by addAgent
  59376. * @returns world space position
  59377. */
  59378. getAgentPosition(index: number): Vector3;
  59379. /**
  59380. * Gets the agent velocity in world space
  59381. * @param index agent index returned by addAgent
  59382. * @returns world space velocity
  59383. */
  59384. getAgentVelocity(index: number): Vector3;
  59385. /**
  59386. * remove a particular agent previously created
  59387. * @param index agent index returned by addAgent
  59388. */
  59389. removeAgent(index: number): void;
  59390. /**
  59391. * get the list of all agents attached to this crowd
  59392. * @returns list of agent indices
  59393. */
  59394. getAgents(): number[];
  59395. /**
  59396. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59397. * @param deltaTime in seconds
  59398. */
  59399. update(deltaTime: number): void;
  59400. /**
  59401. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59402. * @param index agent index returned by addAgent
  59403. * @param destination targeted world position
  59404. */
  59405. agentGoto(index: number, destination: Vector3): void;
  59406. /**
  59407. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59408. * The queries will try to find a solution within those bounds
  59409. * default is (1,1,1)
  59410. * @param extent x,y,z value that define the extent around the queries point of reference
  59411. */
  59412. setDefaultQueryExtent(extent: Vector3): void;
  59413. /**
  59414. * Get the Bounding box extent specified by setDefaultQueryExtent
  59415. * @returns the box extent values
  59416. */
  59417. getDefaultQueryExtent(): Vector3;
  59418. /**
  59419. * Release all resources
  59420. */
  59421. dispose(): void;
  59422. }
  59423. /**
  59424. * Configures an agent
  59425. */
  59426. export interface IAgentParameters {
  59427. /**
  59428. * Agent radius. [Limit: >= 0]
  59429. */
  59430. radius: number;
  59431. /**
  59432. * Agent height. [Limit: > 0]
  59433. */
  59434. height: number;
  59435. /**
  59436. * Maximum allowed acceleration. [Limit: >= 0]
  59437. */
  59438. maxAcceleration: number;
  59439. /**
  59440. * Maximum allowed speed. [Limit: >= 0]
  59441. */
  59442. maxSpeed: number;
  59443. /**
  59444. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  59445. */
  59446. collisionQueryRange: number;
  59447. /**
  59448. * The path visibility optimization range. [Limit: > 0]
  59449. */
  59450. pathOptimizationRange: number;
  59451. /**
  59452. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  59453. */
  59454. separationWeight: number;
  59455. }
  59456. /**
  59457. * Configures the navigation mesh creation
  59458. */
  59459. export interface INavMeshParameters {
  59460. /**
  59461. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  59462. */
  59463. cs: number;
  59464. /**
  59465. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  59466. */
  59467. ch: number;
  59468. /**
  59469. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  59470. */
  59471. walkableSlopeAngle: number;
  59472. /**
  59473. * Minimum floor to 'ceiling' height that will still allow the floor area to
  59474. * be considered walkable. [Limit: >= 3] [Units: vx]
  59475. */
  59476. walkableHeight: number;
  59477. /**
  59478. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  59479. */
  59480. walkableClimb: number;
  59481. /**
  59482. * The distance to erode/shrink the walkable area of the heightfield away from
  59483. * obstructions. [Limit: >=0] [Units: vx]
  59484. */
  59485. walkableRadius: number;
  59486. /**
  59487. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  59488. */
  59489. maxEdgeLen: number;
  59490. /**
  59491. * The maximum distance a simplfied contour's border edges should deviate
  59492. * the original raw contour. [Limit: >=0] [Units: vx]
  59493. */
  59494. maxSimplificationError: number;
  59495. /**
  59496. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  59497. */
  59498. minRegionArea: number;
  59499. /**
  59500. * Any regions with a span count smaller than this value will, if possible,
  59501. * be merged with larger regions. [Limit: >=0] [Units: vx]
  59502. */
  59503. mergeRegionArea: number;
  59504. /**
  59505. * The maximum number of vertices allowed for polygons generated during the
  59506. * contour to polygon conversion process. [Limit: >= 3]
  59507. */
  59508. maxVertsPerPoly: number;
  59509. /**
  59510. * Sets the sampling distance to use when generating the detail mesh.
  59511. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  59512. */
  59513. detailSampleDist: number;
  59514. /**
  59515. * The maximum distance the detail mesh surface should deviate from heightfield
  59516. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  59517. */
  59518. detailSampleMaxError: number;
  59519. }
  59520. }
  59521. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  59522. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  59523. import { Mesh } from "babylonjs/Meshes/mesh";
  59524. import { Scene } from "babylonjs/scene";
  59525. import { Vector3 } from "babylonjs/Maths/math";
  59526. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59527. /**
  59528. * RecastJS navigation plugin
  59529. */
  59530. export class RecastJSPlugin implements INavigationEnginePlugin {
  59531. /**
  59532. * Reference to the Recast library
  59533. */
  59534. bjsRECAST: any;
  59535. /**
  59536. * plugin name
  59537. */
  59538. name: string;
  59539. /**
  59540. * the first navmesh created. We might extend this to support multiple navmeshes
  59541. */
  59542. navMesh: any;
  59543. /**
  59544. * Initializes the recastJS plugin
  59545. * @param recastInjection can be used to inject your own recast reference
  59546. */
  59547. constructor(recastInjection?: any);
  59548. /**
  59549. * Creates a navigation mesh
  59550. * @param meshes array of all the geometry used to compute the navigatio mesh
  59551. * @param parameters bunch of parameters used to filter geometry
  59552. */
  59553. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  59554. /**
  59555. * Create a navigation mesh debug mesh
  59556. * @param scene is where the mesh will be added
  59557. * @returns debug display mesh
  59558. */
  59559. createDebugNavMesh(scene: Scene): Mesh;
  59560. /**
  59561. * Get a navigation mesh constrained position, closest to the parameter position
  59562. * @param position world position
  59563. * @returns the closest point to position constrained by the navigation mesh
  59564. */
  59565. getClosestPoint(position: Vector3): Vector3;
  59566. /**
  59567. * Get a navigation mesh constrained position, within a particular radius
  59568. * @param position world position
  59569. * @param maxRadius the maximum distance to the constrained world position
  59570. * @returns the closest point to position constrained by the navigation mesh
  59571. */
  59572. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  59573. /**
  59574. * Compute the final position from a segment made of destination-position
  59575. * @param position world position
  59576. * @param destination world position
  59577. * @returns the resulting point along the navmesh
  59578. */
  59579. moveAlong(position: Vector3, destination: Vector3): Vector3;
  59580. /**
  59581. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  59582. * @param start world position
  59583. * @param end world position
  59584. * @returns array containing world position composing the path
  59585. */
  59586. computePath(start: Vector3, end: Vector3): Vector3[];
  59587. /**
  59588. * Create a new Crowd so you can add agents
  59589. * @param maxAgents the maximum agent count in the crowd
  59590. * @param maxAgentRadius the maximum radius an agent can have
  59591. * @param scene to attach the crowd to
  59592. * @returns the crowd you can add agents to
  59593. */
  59594. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  59595. /**
  59596. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59597. * The queries will try to find a solution within those bounds
  59598. * default is (1,1,1)
  59599. * @param extent x,y,z value that define the extent around the queries point of reference
  59600. */
  59601. setDefaultQueryExtent(extent: Vector3): void;
  59602. /**
  59603. * Get the Bounding box extent specified by setDefaultQueryExtent
  59604. * @returns the box extent values
  59605. */
  59606. getDefaultQueryExtent(): Vector3;
  59607. /**
  59608. * Disposes
  59609. */
  59610. dispose(): void;
  59611. /**
  59612. * If this plugin is supported
  59613. * @returns true if plugin is supported
  59614. */
  59615. isSupported(): boolean;
  59616. }
  59617. /**
  59618. * Recast detour crowd implementation
  59619. */
  59620. export class RecastJSCrowd implements ICrowd {
  59621. /**
  59622. * Recast/detour plugin
  59623. */
  59624. bjsRECASTPlugin: RecastJSPlugin;
  59625. /**
  59626. * Link to the detour crowd
  59627. */
  59628. recastCrowd: any;
  59629. /**
  59630. * One transform per agent
  59631. */
  59632. transforms: TransformNode[];
  59633. /**
  59634. * All agents created
  59635. */
  59636. agents: number[];
  59637. /**
  59638. * Link to the scene is kept to unregister the crowd from the scene
  59639. */
  59640. private _scene;
  59641. /**
  59642. * Observer for crowd updates
  59643. */
  59644. private _onBeforeAnimationsObserver;
  59645. /**
  59646. * Constructor
  59647. * @param plugin recastJS plugin
  59648. * @param maxAgents the maximum agent count in the crowd
  59649. * @param maxAgentRadius the maximum radius an agent can have
  59650. * @param scene to attach the crowd to
  59651. * @returns the crowd you can add agents to
  59652. */
  59653. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  59654. /**
  59655. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  59656. * You can attach anything to that node. The node position is updated in the scene update tick.
  59657. * @param pos world position that will be constrained by the navigation mesh
  59658. * @param parameters agent parameters
  59659. * @param transform hooked to the agent that will be update by the scene
  59660. * @returns agent index
  59661. */
  59662. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  59663. /**
  59664. * Returns the agent position in world space
  59665. * @param index agent index returned by addAgent
  59666. * @returns world space position
  59667. */
  59668. getAgentPosition(index: number): Vector3;
  59669. /**
  59670. * Returns the agent velocity in world space
  59671. * @param index agent index returned by addAgent
  59672. * @returns world space velocity
  59673. */
  59674. getAgentVelocity(index: number): Vector3;
  59675. /**
  59676. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  59677. * @param index agent index returned by addAgent
  59678. * @param destination targeted world position
  59679. */
  59680. agentGoto(index: number, destination: Vector3): void;
  59681. /**
  59682. * remove a particular agent previously created
  59683. * @param index agent index returned by addAgent
  59684. */
  59685. removeAgent(index: number): void;
  59686. /**
  59687. * get the list of all agents attached to this crowd
  59688. * @returns list of agent indices
  59689. */
  59690. getAgents(): number[];
  59691. /**
  59692. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  59693. * @param deltaTime in seconds
  59694. */
  59695. update(deltaTime: number): void;
  59696. /**
  59697. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  59698. * The queries will try to find a solution within those bounds
  59699. * default is (1,1,1)
  59700. * @param extent x,y,z value that define the extent around the queries point of reference
  59701. */
  59702. setDefaultQueryExtent(extent: Vector3): void;
  59703. /**
  59704. * Get the Bounding box extent specified by setDefaultQueryExtent
  59705. * @returns the box extent values
  59706. */
  59707. getDefaultQueryExtent(): Vector3;
  59708. /**
  59709. * Release all resources
  59710. */
  59711. dispose(): void;
  59712. }
  59713. }
  59714. declare module "babylonjs/Navigation/Plugins/index" {
  59715. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  59716. }
  59717. declare module "babylonjs/Navigation/index" {
  59718. export * from "babylonjs/Navigation/INavigationEngine";
  59719. export * from "babylonjs/Navigation/Plugins/index";
  59720. }
  59721. declare module "babylonjs/Offline/database" {
  59722. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  59723. /**
  59724. * Class used to enable access to IndexedDB
  59725. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  59726. */
  59727. export class Database implements IOfflineProvider {
  59728. private _callbackManifestChecked;
  59729. private _currentSceneUrl;
  59730. private _db;
  59731. private _enableSceneOffline;
  59732. private _enableTexturesOffline;
  59733. private _manifestVersionFound;
  59734. private _mustUpdateRessources;
  59735. private _hasReachedQuota;
  59736. private _isSupported;
  59737. private _idbFactory;
  59738. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  59739. private static IsUASupportingBlobStorage;
  59740. /**
  59741. * Gets a boolean indicating if Database storate is enabled (off by default)
  59742. */
  59743. static IDBStorageEnabled: boolean;
  59744. /**
  59745. * Gets a boolean indicating if scene must be saved in the database
  59746. */
  59747. readonly enableSceneOffline: boolean;
  59748. /**
  59749. * Gets a boolean indicating if textures must be saved in the database
  59750. */
  59751. readonly enableTexturesOffline: boolean;
  59752. /**
  59753. * Creates a new Database
  59754. * @param urlToScene defines the url to load the scene
  59755. * @param callbackManifestChecked defines the callback to use when manifest is checked
  59756. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  59757. */
  59758. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  59759. private static _ParseURL;
  59760. private static _ReturnFullUrlLocation;
  59761. private _checkManifestFile;
  59762. /**
  59763. * Open the database and make it available
  59764. * @param successCallback defines the callback to call on success
  59765. * @param errorCallback defines the callback to call on error
  59766. */
  59767. open(successCallback: () => void, errorCallback: () => void): void;
  59768. /**
  59769. * Loads an image from the database
  59770. * @param url defines the url to load from
  59771. * @param image defines the target DOM image
  59772. */
  59773. loadImage(url: string, image: HTMLImageElement): void;
  59774. private _loadImageFromDBAsync;
  59775. private _saveImageIntoDBAsync;
  59776. private _checkVersionFromDB;
  59777. private _loadVersionFromDBAsync;
  59778. private _saveVersionIntoDBAsync;
  59779. /**
  59780. * Loads a file from database
  59781. * @param url defines the URL to load from
  59782. * @param sceneLoaded defines a callback to call on success
  59783. * @param progressCallBack defines a callback to call when progress changed
  59784. * @param errorCallback defines a callback to call on error
  59785. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  59786. */
  59787. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  59788. private _loadFileAsync;
  59789. private _saveFileAsync;
  59790. /**
  59791. * Validates if xhr data is correct
  59792. * @param xhr defines the request to validate
  59793. * @param dataType defines the expected data type
  59794. * @returns true if data is correct
  59795. */
  59796. private static _ValidateXHRData;
  59797. }
  59798. }
  59799. declare module "babylonjs/Offline/index" {
  59800. export * from "babylonjs/Offline/database";
  59801. export * from "babylonjs/Offline/IOfflineProvider";
  59802. }
  59803. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  59804. /** @hidden */
  59805. export var gpuUpdateParticlesPixelShader: {
  59806. name: string;
  59807. shader: string;
  59808. };
  59809. }
  59810. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  59811. /** @hidden */
  59812. export var gpuUpdateParticlesVertexShader: {
  59813. name: string;
  59814. shader: string;
  59815. };
  59816. }
  59817. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  59818. /** @hidden */
  59819. export var clipPlaneFragmentDeclaration2: {
  59820. name: string;
  59821. shader: string;
  59822. };
  59823. }
  59824. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  59825. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  59826. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59827. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59828. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59829. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59830. /** @hidden */
  59831. export var gpuRenderParticlesPixelShader: {
  59832. name: string;
  59833. shader: string;
  59834. };
  59835. }
  59836. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  59837. /** @hidden */
  59838. export var clipPlaneVertexDeclaration2: {
  59839. name: string;
  59840. shader: string;
  59841. };
  59842. }
  59843. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  59844. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  59845. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59846. /** @hidden */
  59847. export var gpuRenderParticlesVertexShader: {
  59848. name: string;
  59849. shader: string;
  59850. };
  59851. }
  59852. declare module "babylonjs/Particles/gpuParticleSystem" {
  59853. import { Nullable } from "babylonjs/types";
  59854. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  59855. import { Observable } from "babylonjs/Misc/observable";
  59856. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59857. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59858. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  59859. import { Scene, IDisposable } from "babylonjs/scene";
  59860. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  59861. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59862. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  59863. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  59864. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  59865. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  59866. /**
  59867. * This represents a GPU particle system in Babylon
  59868. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  59869. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  59870. */
  59871. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  59872. /**
  59873. * The layer mask we are rendering the particles through.
  59874. */
  59875. layerMask: number;
  59876. private _capacity;
  59877. private _activeCount;
  59878. private _currentActiveCount;
  59879. private _accumulatedCount;
  59880. private _renderEffect;
  59881. private _updateEffect;
  59882. private _buffer0;
  59883. private _buffer1;
  59884. private _spriteBuffer;
  59885. private _updateVAO;
  59886. private _renderVAO;
  59887. private _targetIndex;
  59888. private _sourceBuffer;
  59889. private _targetBuffer;
  59890. private _engine;
  59891. private _currentRenderId;
  59892. private _started;
  59893. private _stopped;
  59894. private _timeDelta;
  59895. private _randomTexture;
  59896. private _randomTexture2;
  59897. private _attributesStrideSize;
  59898. private _updateEffectOptions;
  59899. private _randomTextureSize;
  59900. private _actualFrame;
  59901. private readonly _rawTextureWidth;
  59902. /**
  59903. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  59904. */
  59905. static readonly IsSupported: boolean;
  59906. /**
  59907. * An event triggered when the system is disposed.
  59908. */
  59909. onDisposeObservable: Observable<GPUParticleSystem>;
  59910. /**
  59911. * Gets the maximum number of particles active at the same time.
  59912. * @returns The max number of active particles.
  59913. */
  59914. getCapacity(): number;
  59915. /**
  59916. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  59917. * to override the particles.
  59918. */
  59919. forceDepthWrite: boolean;
  59920. /**
  59921. * Gets or set the number of active particles
  59922. */
  59923. activeParticleCount: number;
  59924. private _preWarmDone;
  59925. /**
  59926. * Is this system ready to be used/rendered
  59927. * @return true if the system is ready
  59928. */
  59929. isReady(): boolean;
  59930. /**
  59931. * Gets if the system has been started. (Note: this will still be true after stop is called)
  59932. * @returns True if it has been started, otherwise false.
  59933. */
  59934. isStarted(): boolean;
  59935. /**
  59936. * Starts the particle system and begins to emit
  59937. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  59938. */
  59939. start(delay?: number): void;
  59940. /**
  59941. * Stops the particle system.
  59942. */
  59943. stop(): void;
  59944. /**
  59945. * Remove all active particles
  59946. */
  59947. reset(): void;
  59948. /**
  59949. * Returns the string "GPUParticleSystem"
  59950. * @returns a string containing the class name
  59951. */
  59952. getClassName(): string;
  59953. private _colorGradientsTexture;
  59954. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  59955. /**
  59956. * Adds a new color gradient
  59957. * @param gradient defines the gradient to use (between 0 and 1)
  59958. * @param color1 defines the color to affect to the specified gradient
  59959. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  59960. * @returns the current particle system
  59961. */
  59962. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  59963. /**
  59964. * Remove a specific color gradient
  59965. * @param gradient defines the gradient to remove
  59966. * @returns the current particle system
  59967. */
  59968. removeColorGradient(gradient: number): GPUParticleSystem;
  59969. private _angularSpeedGradientsTexture;
  59970. private _sizeGradientsTexture;
  59971. private _velocityGradientsTexture;
  59972. private _limitVelocityGradientsTexture;
  59973. private _dragGradientsTexture;
  59974. private _addFactorGradient;
  59975. /**
  59976. * Adds a new size gradient
  59977. * @param gradient defines the gradient to use (between 0 and 1)
  59978. * @param factor defines the size factor to affect to the specified gradient
  59979. * @returns the current particle system
  59980. */
  59981. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  59982. /**
  59983. * Remove a specific size gradient
  59984. * @param gradient defines the gradient to remove
  59985. * @returns the current particle system
  59986. */
  59987. removeSizeGradient(gradient: number): GPUParticleSystem;
  59988. /**
  59989. * Adds a new angular speed gradient
  59990. * @param gradient defines the gradient to use (between 0 and 1)
  59991. * @param factor defines the angular speed to affect to the specified gradient
  59992. * @returns the current particle system
  59993. */
  59994. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  59995. /**
  59996. * Remove a specific angular speed gradient
  59997. * @param gradient defines the gradient to remove
  59998. * @returns the current particle system
  59999. */
  60000. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60001. /**
  60002. * Adds a new velocity gradient
  60003. * @param gradient defines the gradient to use (between 0 and 1)
  60004. * @param factor defines the velocity to affect to the specified gradient
  60005. * @returns the current particle system
  60006. */
  60007. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60008. /**
  60009. * Remove a specific velocity gradient
  60010. * @param gradient defines the gradient to remove
  60011. * @returns the current particle system
  60012. */
  60013. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60014. /**
  60015. * Adds a new limit velocity gradient
  60016. * @param gradient defines the gradient to use (between 0 and 1)
  60017. * @param factor defines the limit velocity value to affect to the specified gradient
  60018. * @returns the current particle system
  60019. */
  60020. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60021. /**
  60022. * Remove a specific limit velocity gradient
  60023. * @param gradient defines the gradient to remove
  60024. * @returns the current particle system
  60025. */
  60026. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60027. /**
  60028. * Adds a new drag gradient
  60029. * @param gradient defines the gradient to use (between 0 and 1)
  60030. * @param factor defines the drag value to affect to the specified gradient
  60031. * @returns the current particle system
  60032. */
  60033. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60034. /**
  60035. * Remove a specific drag gradient
  60036. * @param gradient defines the gradient to remove
  60037. * @returns the current particle system
  60038. */
  60039. removeDragGradient(gradient: number): GPUParticleSystem;
  60040. /**
  60041. * Not supported by GPUParticleSystem
  60042. * @param gradient defines the gradient to use (between 0 and 1)
  60043. * @param factor defines the emit rate value to affect to the specified gradient
  60044. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60045. * @returns the current particle system
  60046. */
  60047. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60048. /**
  60049. * Not supported by GPUParticleSystem
  60050. * @param gradient defines the gradient to remove
  60051. * @returns the current particle system
  60052. */
  60053. removeEmitRateGradient(gradient: number): IParticleSystem;
  60054. /**
  60055. * Not supported by GPUParticleSystem
  60056. * @param gradient defines the gradient to use (between 0 and 1)
  60057. * @param factor defines the start size value to affect to the specified gradient
  60058. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60059. * @returns the current particle system
  60060. */
  60061. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60062. /**
  60063. * Not supported by GPUParticleSystem
  60064. * @param gradient defines the gradient to remove
  60065. * @returns the current particle system
  60066. */
  60067. removeStartSizeGradient(gradient: number): IParticleSystem;
  60068. /**
  60069. * Not supported by GPUParticleSystem
  60070. * @param gradient defines the gradient to use (between 0 and 1)
  60071. * @param min defines the color remap minimal range
  60072. * @param max defines the color remap maximal range
  60073. * @returns the current particle system
  60074. */
  60075. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60076. /**
  60077. * Not supported by GPUParticleSystem
  60078. * @param gradient defines the gradient to remove
  60079. * @returns the current particle system
  60080. */
  60081. removeColorRemapGradient(): IParticleSystem;
  60082. /**
  60083. * Not supported by GPUParticleSystem
  60084. * @param gradient defines the gradient to use (between 0 and 1)
  60085. * @param min defines the alpha remap minimal range
  60086. * @param max defines the alpha remap maximal range
  60087. * @returns the current particle system
  60088. */
  60089. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60090. /**
  60091. * Not supported by GPUParticleSystem
  60092. * @param gradient defines the gradient to remove
  60093. * @returns the current particle system
  60094. */
  60095. removeAlphaRemapGradient(): IParticleSystem;
  60096. /**
  60097. * Not supported by GPUParticleSystem
  60098. * @param gradient defines the gradient to use (between 0 and 1)
  60099. * @param color defines the color to affect to the specified gradient
  60100. * @returns the current particle system
  60101. */
  60102. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  60103. /**
  60104. * Not supported by GPUParticleSystem
  60105. * @param gradient defines the gradient to remove
  60106. * @returns the current particle system
  60107. */
  60108. removeRampGradient(): IParticleSystem;
  60109. /**
  60110. * Not supported by GPUParticleSystem
  60111. * @returns the list of ramp gradients
  60112. */
  60113. getRampGradients(): Nullable<Array<Color3Gradient>>;
  60114. /**
  60115. * Not supported by GPUParticleSystem
  60116. * Gets or sets a boolean indicating that ramp gradients must be used
  60117. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  60118. */
  60119. useRampGradients: boolean;
  60120. /**
  60121. * Not supported by GPUParticleSystem
  60122. * @param gradient defines the gradient to use (between 0 and 1)
  60123. * @param factor defines the life time factor to affect to the specified gradient
  60124. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60125. * @returns the current particle system
  60126. */
  60127. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60128. /**
  60129. * Not supported by GPUParticleSystem
  60130. * @param gradient defines the gradient to remove
  60131. * @returns the current particle system
  60132. */
  60133. removeLifeTimeGradient(gradient: number): IParticleSystem;
  60134. /**
  60135. * Instantiates a GPU particle system.
  60136. * 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.
  60137. * @param name The name of the particle system
  60138. * @param options The options used to create the system
  60139. * @param scene The scene the particle system belongs to
  60140. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  60141. */
  60142. constructor(name: string, options: Partial<{
  60143. capacity: number;
  60144. randomTextureSize: number;
  60145. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  60146. protected _reset(): void;
  60147. private _createUpdateVAO;
  60148. private _createRenderVAO;
  60149. private _initialize;
  60150. /** @hidden */
  60151. _recreateUpdateEffect(): void;
  60152. /** @hidden */
  60153. _recreateRenderEffect(): void;
  60154. /**
  60155. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  60156. * @param preWarm defines if we are in the pre-warmimg phase
  60157. */
  60158. animate(preWarm?: boolean): void;
  60159. private _createFactorGradientTexture;
  60160. private _createSizeGradientTexture;
  60161. private _createAngularSpeedGradientTexture;
  60162. private _createVelocityGradientTexture;
  60163. private _createLimitVelocityGradientTexture;
  60164. private _createDragGradientTexture;
  60165. private _createColorGradientTexture;
  60166. /**
  60167. * Renders the particle system in its current state
  60168. * @param preWarm defines if the system should only update the particles but not render them
  60169. * @returns the current number of particles
  60170. */
  60171. render(preWarm?: boolean): number;
  60172. /**
  60173. * Rebuilds the particle system
  60174. */
  60175. rebuild(): void;
  60176. private _releaseBuffers;
  60177. private _releaseVAOs;
  60178. /**
  60179. * Disposes the particle system and free the associated resources
  60180. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  60181. */
  60182. dispose(disposeTexture?: boolean): void;
  60183. /**
  60184. * Clones the particle system.
  60185. * @param name The name of the cloned object
  60186. * @param newEmitter The new emitter to use
  60187. * @returns the cloned particle system
  60188. */
  60189. clone(name: string, newEmitter: any): GPUParticleSystem;
  60190. /**
  60191. * Serializes the particle system to a JSON object.
  60192. * @returns the JSON object
  60193. */
  60194. serialize(): any;
  60195. /**
  60196. * Parses a JSON object to create a GPU particle system.
  60197. * @param parsedParticleSystem The JSON object to parse
  60198. * @param scene The scene to create the particle system in
  60199. * @param rootUrl The root url to use to load external dependencies like texture
  60200. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  60201. * @returns the parsed GPU particle system
  60202. */
  60203. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  60204. }
  60205. }
  60206. declare module "babylonjs/Particles/particleSystemSet" {
  60207. import { Nullable } from "babylonjs/types";
  60208. import { Color3 } from "babylonjs/Maths/math.color";
  60209. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60211. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60212. import { Scene, IDisposable } from "babylonjs/scene";
  60213. /**
  60214. * Represents a set of particle systems working together to create a specific effect
  60215. */
  60216. export class ParticleSystemSet implements IDisposable {
  60217. private _emitterCreationOptions;
  60218. private _emitterNode;
  60219. /**
  60220. * Gets the particle system list
  60221. */
  60222. systems: IParticleSystem[];
  60223. /**
  60224. * Gets the emitter node used with this set
  60225. */
  60226. readonly emitterNode: Nullable<TransformNode>;
  60227. /**
  60228. * Creates a new emitter mesh as a sphere
  60229. * @param options defines the options used to create the sphere
  60230. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  60231. * @param scene defines the hosting scene
  60232. */
  60233. setEmitterAsSphere(options: {
  60234. diameter: number;
  60235. segments: number;
  60236. color: Color3;
  60237. }, renderingGroupId: number, scene: Scene): void;
  60238. /**
  60239. * Starts all particle systems of the set
  60240. * @param emitter defines an optional mesh to use as emitter for the particle systems
  60241. */
  60242. start(emitter?: AbstractMesh): void;
  60243. /**
  60244. * Release all associated resources
  60245. */
  60246. dispose(): void;
  60247. /**
  60248. * Serialize the set into a JSON compatible object
  60249. * @returns a JSON compatible representation of the set
  60250. */
  60251. serialize(): any;
  60252. /**
  60253. * Parse a new ParticleSystemSet from a serialized source
  60254. * @param data defines a JSON compatible representation of the set
  60255. * @param scene defines the hosting scene
  60256. * @param gpu defines if we want GPU particles or CPU particles
  60257. * @returns a new ParticleSystemSet
  60258. */
  60259. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  60260. }
  60261. }
  60262. declare module "babylonjs/Particles/particleHelper" {
  60263. import { Nullable } from "babylonjs/types";
  60264. import { Scene } from "babylonjs/scene";
  60265. import { Vector3 } from "babylonjs/Maths/math.vector";
  60266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60267. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60268. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  60269. /**
  60270. * This class is made for on one-liner static method to help creating particle system set.
  60271. */
  60272. export class ParticleHelper {
  60273. /**
  60274. * Gets or sets base Assets URL
  60275. */
  60276. static BaseAssetsUrl: string;
  60277. /**
  60278. * Create a default particle system that you can tweak
  60279. * @param emitter defines the emitter to use
  60280. * @param capacity defines the system capacity (default is 500 particles)
  60281. * @param scene defines the hosting scene
  60282. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  60283. * @returns the new Particle system
  60284. */
  60285. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  60286. /**
  60287. * This is the main static method (one-liner) of this helper to create different particle systems
  60288. * @param type This string represents the type to the particle system to create
  60289. * @param scene The scene where the particle system should live
  60290. * @param gpu If the system will use gpu
  60291. * @returns the ParticleSystemSet created
  60292. */
  60293. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  60294. /**
  60295. * Static function used to export a particle system to a ParticleSystemSet variable.
  60296. * Please note that the emitter shape is not exported
  60297. * @param systems defines the particle systems to export
  60298. * @returns the created particle system set
  60299. */
  60300. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  60301. }
  60302. }
  60303. declare module "babylonjs/Particles/particleSystemComponent" {
  60304. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60305. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  60306. import "babylonjs/Shaders/particles.vertex";
  60307. module "babylonjs/Engines/engine" {
  60308. interface Engine {
  60309. /**
  60310. * Create an effect to use with particle systems.
  60311. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  60312. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  60313. * @param uniformsNames defines a list of attribute names
  60314. * @param samplers defines an array of string used to represent textures
  60315. * @param defines defines the string containing the defines to use to compile the shaders
  60316. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  60317. * @param onCompiled defines a function to call when the effect creation is successful
  60318. * @param onError defines a function to call when the effect creation has failed
  60319. * @returns the new Effect
  60320. */
  60321. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  60322. }
  60323. }
  60324. module "babylonjs/Meshes/mesh" {
  60325. interface Mesh {
  60326. /**
  60327. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  60328. * @returns an array of IParticleSystem
  60329. */
  60330. getEmittedParticleSystems(): IParticleSystem[];
  60331. /**
  60332. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  60333. * @returns an array of IParticleSystem
  60334. */
  60335. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  60336. }
  60337. }
  60338. /**
  60339. * @hidden
  60340. */
  60341. export var _IDoNeedToBeInTheBuild: number;
  60342. }
  60343. declare module "babylonjs/Particles/index" {
  60344. export * from "babylonjs/Particles/baseParticleSystem";
  60345. export * from "babylonjs/Particles/EmitterTypes/index";
  60346. export * from "babylonjs/Particles/gpuParticleSystem";
  60347. export * from "babylonjs/Particles/IParticleSystem";
  60348. export * from "babylonjs/Particles/particle";
  60349. export * from "babylonjs/Particles/particleHelper";
  60350. export * from "babylonjs/Particles/particleSystem";
  60351. export * from "babylonjs/Particles/particleSystemComponent";
  60352. export * from "babylonjs/Particles/particleSystemSet";
  60353. export * from "babylonjs/Particles/solidParticle";
  60354. export * from "babylonjs/Particles/solidParticleSystem";
  60355. export * from "babylonjs/Particles/subEmitter";
  60356. }
  60357. declare module "babylonjs/Physics/physicsEngineComponent" {
  60358. import { Nullable } from "babylonjs/types";
  60359. import { Observable, Observer } from "babylonjs/Misc/observable";
  60360. import { Vector3 } from "babylonjs/Maths/math.vector";
  60361. import { Mesh } from "babylonjs/Meshes/mesh";
  60362. import { ISceneComponent } from "babylonjs/sceneComponent";
  60363. import { Scene } from "babylonjs/scene";
  60364. import { Node } from "babylonjs/node";
  60365. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  60366. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60367. module "babylonjs/scene" {
  60368. interface Scene {
  60369. /** @hidden (Backing field) */
  60370. _physicsEngine: Nullable<IPhysicsEngine>;
  60371. /**
  60372. * Gets the current physics engine
  60373. * @returns a IPhysicsEngine or null if none attached
  60374. */
  60375. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  60376. /**
  60377. * Enables physics to the current scene
  60378. * @param gravity defines the scene's gravity for the physics engine
  60379. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  60380. * @return a boolean indicating if the physics engine was initialized
  60381. */
  60382. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  60383. /**
  60384. * Disables and disposes the physics engine associated with the scene
  60385. */
  60386. disablePhysicsEngine(): void;
  60387. /**
  60388. * Gets a boolean indicating if there is an active physics engine
  60389. * @returns a boolean indicating if there is an active physics engine
  60390. */
  60391. isPhysicsEnabled(): boolean;
  60392. /**
  60393. * Deletes a physics compound impostor
  60394. * @param compound defines the compound to delete
  60395. */
  60396. deleteCompoundImpostor(compound: any): void;
  60397. /**
  60398. * An event triggered when physic simulation is about to be run
  60399. */
  60400. onBeforePhysicsObservable: Observable<Scene>;
  60401. /**
  60402. * An event triggered when physic simulation has been done
  60403. */
  60404. onAfterPhysicsObservable: Observable<Scene>;
  60405. }
  60406. }
  60407. module "babylonjs/Meshes/abstractMesh" {
  60408. interface AbstractMesh {
  60409. /** @hidden */
  60410. _physicsImpostor: Nullable<PhysicsImpostor>;
  60411. /**
  60412. * Gets or sets impostor used for physic simulation
  60413. * @see http://doc.babylonjs.com/features/physics_engine
  60414. */
  60415. physicsImpostor: Nullable<PhysicsImpostor>;
  60416. /**
  60417. * Gets the current physics impostor
  60418. * @see http://doc.babylonjs.com/features/physics_engine
  60419. * @returns a physics impostor or null
  60420. */
  60421. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  60422. /** Apply a physic impulse to the mesh
  60423. * @param force defines the force to apply
  60424. * @param contactPoint defines where to apply the force
  60425. * @returns the current mesh
  60426. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  60427. */
  60428. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  60429. /**
  60430. * Creates a physic joint between two meshes
  60431. * @param otherMesh defines the other mesh to use
  60432. * @param pivot1 defines the pivot to use on this mesh
  60433. * @param pivot2 defines the pivot to use on the other mesh
  60434. * @param options defines additional options (can be plugin dependent)
  60435. * @returns the current mesh
  60436. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  60437. */
  60438. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  60439. /** @hidden */
  60440. _disposePhysicsObserver: Nullable<Observer<Node>>;
  60441. }
  60442. }
  60443. /**
  60444. * Defines the physics engine scene component responsible to manage a physics engine
  60445. */
  60446. export class PhysicsEngineSceneComponent implements ISceneComponent {
  60447. /**
  60448. * The component name helpful to identify the component in the list of scene components.
  60449. */
  60450. readonly name: string;
  60451. /**
  60452. * The scene the component belongs to.
  60453. */
  60454. scene: Scene;
  60455. /**
  60456. * Creates a new instance of the component for the given scene
  60457. * @param scene Defines the scene to register the component in
  60458. */
  60459. constructor(scene: Scene);
  60460. /**
  60461. * Registers the component in a given scene
  60462. */
  60463. register(): void;
  60464. /**
  60465. * Rebuilds the elements related to this component in case of
  60466. * context lost for instance.
  60467. */
  60468. rebuild(): void;
  60469. /**
  60470. * Disposes the component and the associated ressources
  60471. */
  60472. dispose(): void;
  60473. }
  60474. }
  60475. declare module "babylonjs/Physics/physicsHelper" {
  60476. import { Nullable } from "babylonjs/types";
  60477. import { Vector3 } from "babylonjs/Maths/math.vector";
  60478. import { Mesh } from "babylonjs/Meshes/mesh";
  60479. import { Scene } from "babylonjs/scene";
  60480. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  60481. /**
  60482. * A helper for physics simulations
  60483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60484. */
  60485. export class PhysicsHelper {
  60486. private _scene;
  60487. private _physicsEngine;
  60488. /**
  60489. * Initializes the Physics helper
  60490. * @param scene Babylon.js scene
  60491. */
  60492. constructor(scene: Scene);
  60493. /**
  60494. * Applies a radial explosion impulse
  60495. * @param origin the origin of the explosion
  60496. * @param radiusOrEventOptions the radius or the options of radial explosion
  60497. * @param strength the explosion strength
  60498. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60499. * @returns A physics radial explosion event, or null
  60500. */
  60501. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60502. /**
  60503. * Applies a radial explosion force
  60504. * @param origin the origin of the explosion
  60505. * @param radiusOrEventOptions the radius or the options of radial explosion
  60506. * @param strength the explosion strength
  60507. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60508. * @returns A physics radial explosion event, or null
  60509. */
  60510. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  60511. /**
  60512. * Creates a gravitational field
  60513. * @param origin the origin of the explosion
  60514. * @param radiusOrEventOptions the radius or the options of radial explosion
  60515. * @param strength the explosion strength
  60516. * @param falloff possible options: Constant & Linear. Defaults to Constant
  60517. * @returns A physics gravitational field event, or null
  60518. */
  60519. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  60520. /**
  60521. * Creates a physics updraft event
  60522. * @param origin the origin of the updraft
  60523. * @param radiusOrEventOptions the radius or the options of the updraft
  60524. * @param strength the strength of the updraft
  60525. * @param height the height of the updraft
  60526. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  60527. * @returns A physics updraft event, or null
  60528. */
  60529. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  60530. /**
  60531. * Creates a physics vortex event
  60532. * @param origin the of the vortex
  60533. * @param radiusOrEventOptions the radius or the options of the vortex
  60534. * @param strength the strength of the vortex
  60535. * @param height the height of the vortex
  60536. * @returns a Physics vortex event, or null
  60537. * A physics vortex event or null
  60538. */
  60539. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  60540. }
  60541. /**
  60542. * Represents a physics radial explosion event
  60543. */
  60544. class PhysicsRadialExplosionEvent {
  60545. private _scene;
  60546. private _options;
  60547. private _sphere;
  60548. private _dataFetched;
  60549. /**
  60550. * Initializes a radial explosioin event
  60551. * @param _scene BabylonJS scene
  60552. * @param _options The options for the vortex event
  60553. */
  60554. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  60555. /**
  60556. * Returns the data related to the radial explosion event (sphere).
  60557. * @returns The radial explosion event data
  60558. */
  60559. getData(): PhysicsRadialExplosionEventData;
  60560. /**
  60561. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  60562. * @param impostor A physics imposter
  60563. * @param origin the origin of the explosion
  60564. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  60565. */
  60566. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  60567. /**
  60568. * Triggers affecterd impostors callbacks
  60569. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  60570. */
  60571. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  60572. /**
  60573. * Disposes the sphere.
  60574. * @param force Specifies if the sphere should be disposed by force
  60575. */
  60576. dispose(force?: boolean): void;
  60577. /*** Helpers ***/
  60578. private _prepareSphere;
  60579. private _intersectsWithSphere;
  60580. }
  60581. /**
  60582. * Represents a gravitational field event
  60583. */
  60584. class PhysicsGravitationalFieldEvent {
  60585. private _physicsHelper;
  60586. private _scene;
  60587. private _origin;
  60588. private _options;
  60589. private _tickCallback;
  60590. private _sphere;
  60591. private _dataFetched;
  60592. /**
  60593. * Initializes the physics gravitational field event
  60594. * @param _physicsHelper A physics helper
  60595. * @param _scene BabylonJS scene
  60596. * @param _origin The origin position of the gravitational field event
  60597. * @param _options The options for the vortex event
  60598. */
  60599. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  60600. /**
  60601. * Returns the data related to the gravitational field event (sphere).
  60602. * @returns A gravitational field event
  60603. */
  60604. getData(): PhysicsGravitationalFieldEventData;
  60605. /**
  60606. * Enables the gravitational field.
  60607. */
  60608. enable(): void;
  60609. /**
  60610. * Disables the gravitational field.
  60611. */
  60612. disable(): void;
  60613. /**
  60614. * Disposes the sphere.
  60615. * @param force The force to dispose from the gravitational field event
  60616. */
  60617. dispose(force?: boolean): void;
  60618. private _tick;
  60619. }
  60620. /**
  60621. * Represents a physics updraft event
  60622. */
  60623. class PhysicsUpdraftEvent {
  60624. private _scene;
  60625. private _origin;
  60626. private _options;
  60627. private _physicsEngine;
  60628. private _originTop;
  60629. private _originDirection;
  60630. private _tickCallback;
  60631. private _cylinder;
  60632. private _cylinderPosition;
  60633. private _dataFetched;
  60634. /**
  60635. * Initializes the physics updraft event
  60636. * @param _scene BabylonJS scene
  60637. * @param _origin The origin position of the updraft
  60638. * @param _options The options for the updraft event
  60639. */
  60640. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  60641. /**
  60642. * Returns the data related to the updraft event (cylinder).
  60643. * @returns A physics updraft event
  60644. */
  60645. getData(): PhysicsUpdraftEventData;
  60646. /**
  60647. * Enables the updraft.
  60648. */
  60649. enable(): void;
  60650. /**
  60651. * Disables the updraft.
  60652. */
  60653. disable(): void;
  60654. /**
  60655. * Disposes the cylinder.
  60656. * @param force Specifies if the updraft should be disposed by force
  60657. */
  60658. dispose(force?: boolean): void;
  60659. private getImpostorHitData;
  60660. private _tick;
  60661. /*** Helpers ***/
  60662. private _prepareCylinder;
  60663. private _intersectsWithCylinder;
  60664. }
  60665. /**
  60666. * Represents a physics vortex event
  60667. */
  60668. class PhysicsVortexEvent {
  60669. private _scene;
  60670. private _origin;
  60671. private _options;
  60672. private _physicsEngine;
  60673. private _originTop;
  60674. private _tickCallback;
  60675. private _cylinder;
  60676. private _cylinderPosition;
  60677. private _dataFetched;
  60678. /**
  60679. * Initializes the physics vortex event
  60680. * @param _scene The BabylonJS scene
  60681. * @param _origin The origin position of the vortex
  60682. * @param _options The options for the vortex event
  60683. */
  60684. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  60685. /**
  60686. * Returns the data related to the vortex event (cylinder).
  60687. * @returns The physics vortex event data
  60688. */
  60689. getData(): PhysicsVortexEventData;
  60690. /**
  60691. * Enables the vortex.
  60692. */
  60693. enable(): void;
  60694. /**
  60695. * Disables the cortex.
  60696. */
  60697. disable(): void;
  60698. /**
  60699. * Disposes the sphere.
  60700. * @param force
  60701. */
  60702. dispose(force?: boolean): void;
  60703. private getImpostorHitData;
  60704. private _tick;
  60705. /*** Helpers ***/
  60706. private _prepareCylinder;
  60707. private _intersectsWithCylinder;
  60708. }
  60709. /**
  60710. * Options fot the radial explosion event
  60711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60712. */
  60713. export class PhysicsRadialExplosionEventOptions {
  60714. /**
  60715. * The radius of the sphere for the radial explosion.
  60716. */
  60717. radius: number;
  60718. /**
  60719. * The strenth of the explosion.
  60720. */
  60721. strength: number;
  60722. /**
  60723. * The strenght of the force in correspondence to the distance of the affected object
  60724. */
  60725. falloff: PhysicsRadialImpulseFalloff;
  60726. /**
  60727. * Sphere options for the radial explosion.
  60728. */
  60729. sphere: {
  60730. segments: number;
  60731. diameter: number;
  60732. };
  60733. /**
  60734. * Sphere options for the radial explosion.
  60735. */
  60736. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  60737. }
  60738. /**
  60739. * Options fot the updraft event
  60740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60741. */
  60742. export class PhysicsUpdraftEventOptions {
  60743. /**
  60744. * The radius of the cylinder for the vortex
  60745. */
  60746. radius: number;
  60747. /**
  60748. * The strenth of the updraft.
  60749. */
  60750. strength: number;
  60751. /**
  60752. * The height of the cylinder for the updraft.
  60753. */
  60754. height: number;
  60755. /**
  60756. * The mode for the the updraft.
  60757. */
  60758. updraftMode: PhysicsUpdraftMode;
  60759. }
  60760. /**
  60761. * Options fot the vortex event
  60762. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60763. */
  60764. export class PhysicsVortexEventOptions {
  60765. /**
  60766. * The radius of the cylinder for the vortex
  60767. */
  60768. radius: number;
  60769. /**
  60770. * The strenth of the vortex.
  60771. */
  60772. strength: number;
  60773. /**
  60774. * The height of the cylinder for the vortex.
  60775. */
  60776. height: number;
  60777. /**
  60778. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  60779. */
  60780. centripetalForceThreshold: number;
  60781. /**
  60782. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  60783. */
  60784. centripetalForceMultiplier: number;
  60785. /**
  60786. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  60787. */
  60788. centrifugalForceMultiplier: number;
  60789. /**
  60790. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  60791. */
  60792. updraftForceMultiplier: number;
  60793. }
  60794. /**
  60795. * The strenght of the force in correspondence to the distance of the affected object
  60796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60797. */
  60798. export enum PhysicsRadialImpulseFalloff {
  60799. /** Defines that impulse is constant in strength across it's whole radius */
  60800. Constant = 0,
  60801. /** Defines that impulse gets weaker if it's further from the origin */
  60802. Linear = 1
  60803. }
  60804. /**
  60805. * The strength of the force in correspondence to the distance of the affected object
  60806. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60807. */
  60808. export enum PhysicsUpdraftMode {
  60809. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  60810. Center = 0,
  60811. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  60812. Perpendicular = 1
  60813. }
  60814. /**
  60815. * Interface for a physics hit data
  60816. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60817. */
  60818. export interface PhysicsHitData {
  60819. /**
  60820. * The force applied at the contact point
  60821. */
  60822. force: Vector3;
  60823. /**
  60824. * The contact point
  60825. */
  60826. contactPoint: Vector3;
  60827. /**
  60828. * The distance from the origin to the contact point
  60829. */
  60830. distanceFromOrigin: number;
  60831. }
  60832. /**
  60833. * Interface for radial explosion event data
  60834. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60835. */
  60836. export interface PhysicsRadialExplosionEventData {
  60837. /**
  60838. * A sphere used for the radial explosion event
  60839. */
  60840. sphere: Mesh;
  60841. }
  60842. /**
  60843. * Interface for gravitational field event data
  60844. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60845. */
  60846. export interface PhysicsGravitationalFieldEventData {
  60847. /**
  60848. * A sphere mesh used for the gravitational field event
  60849. */
  60850. sphere: Mesh;
  60851. }
  60852. /**
  60853. * Interface for updraft event data
  60854. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60855. */
  60856. export interface PhysicsUpdraftEventData {
  60857. /**
  60858. * A cylinder used for the updraft event
  60859. */
  60860. cylinder: Mesh;
  60861. }
  60862. /**
  60863. * Interface for vortex event data
  60864. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60865. */
  60866. export interface PhysicsVortexEventData {
  60867. /**
  60868. * A cylinder used for the vortex event
  60869. */
  60870. cylinder: Mesh;
  60871. }
  60872. /**
  60873. * Interface for an affected physics impostor
  60874. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  60875. */
  60876. export interface PhysicsAffectedImpostorWithData {
  60877. /**
  60878. * The impostor affected by the effect
  60879. */
  60880. impostor: PhysicsImpostor;
  60881. /**
  60882. * The data about the hit/horce from the explosion
  60883. */
  60884. hitData: PhysicsHitData;
  60885. }
  60886. }
  60887. declare module "babylonjs/Physics/Plugins/index" {
  60888. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  60889. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  60890. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  60891. }
  60892. declare module "babylonjs/Physics/index" {
  60893. export * from "babylonjs/Physics/IPhysicsEngine";
  60894. export * from "babylonjs/Physics/physicsEngine";
  60895. export * from "babylonjs/Physics/physicsEngineComponent";
  60896. export * from "babylonjs/Physics/physicsHelper";
  60897. export * from "babylonjs/Physics/physicsImpostor";
  60898. export * from "babylonjs/Physics/physicsJoint";
  60899. export * from "babylonjs/Physics/Plugins/index";
  60900. }
  60901. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  60902. /** @hidden */
  60903. export var blackAndWhitePixelShader: {
  60904. name: string;
  60905. shader: string;
  60906. };
  60907. }
  60908. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  60909. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60910. import { Camera } from "babylonjs/Cameras/camera";
  60911. import { Engine } from "babylonjs/Engines/engine";
  60912. import "babylonjs/Shaders/blackAndWhite.fragment";
  60913. /**
  60914. * Post process used to render in black and white
  60915. */
  60916. export class BlackAndWhitePostProcess extends PostProcess {
  60917. /**
  60918. * Linear about to convert he result to black and white (default: 1)
  60919. */
  60920. degree: number;
  60921. /**
  60922. * Creates a black and white post process
  60923. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  60924. * @param name The name of the effect.
  60925. * @param options The required width/height ratio to downsize to before computing the render pass.
  60926. * @param camera The camera to apply the render pass to.
  60927. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60928. * @param engine The engine which the post process will be applied. (default: current engine)
  60929. * @param reusable If the post process can be reused on the same frame. (default: false)
  60930. */
  60931. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60932. }
  60933. }
  60934. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  60935. import { Nullable } from "babylonjs/types";
  60936. import { Camera } from "babylonjs/Cameras/camera";
  60937. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60938. import { Engine } from "babylonjs/Engines/engine";
  60939. /**
  60940. * This represents a set of one or more post processes in Babylon.
  60941. * A post process can be used to apply a shader to a texture after it is rendered.
  60942. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60943. */
  60944. export class PostProcessRenderEffect {
  60945. private _postProcesses;
  60946. private _getPostProcesses;
  60947. private _singleInstance;
  60948. private _cameras;
  60949. private _indicesForCamera;
  60950. /**
  60951. * Name of the effect
  60952. * @hidden
  60953. */
  60954. _name: string;
  60955. /**
  60956. * Instantiates a post process render effect.
  60957. * A post process can be used to apply a shader to a texture after it is rendered.
  60958. * @param engine The engine the effect is tied to
  60959. * @param name The name of the effect
  60960. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  60961. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  60962. */
  60963. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  60964. /**
  60965. * Checks if all the post processes in the effect are supported.
  60966. */
  60967. readonly isSupported: boolean;
  60968. /**
  60969. * Updates the current state of the effect
  60970. * @hidden
  60971. */
  60972. _update(): void;
  60973. /**
  60974. * Attaches the effect on cameras
  60975. * @param cameras The camera to attach to.
  60976. * @hidden
  60977. */
  60978. _attachCameras(cameras: Camera): void;
  60979. /**
  60980. * Attaches the effect on cameras
  60981. * @param cameras The camera to attach to.
  60982. * @hidden
  60983. */
  60984. _attachCameras(cameras: Camera[]): void;
  60985. /**
  60986. * Detaches the effect on cameras
  60987. * @param cameras The camera to detatch from.
  60988. * @hidden
  60989. */
  60990. _detachCameras(cameras: Camera): void;
  60991. /**
  60992. * Detatches the effect on cameras
  60993. * @param cameras The camera to detatch from.
  60994. * @hidden
  60995. */
  60996. _detachCameras(cameras: Camera[]): void;
  60997. /**
  60998. * Enables the effect on given cameras
  60999. * @param cameras The camera to enable.
  61000. * @hidden
  61001. */
  61002. _enable(cameras: Camera): void;
  61003. /**
  61004. * Enables the effect on given cameras
  61005. * @param cameras The camera to enable.
  61006. * @hidden
  61007. */
  61008. _enable(cameras: Nullable<Camera[]>): void;
  61009. /**
  61010. * Disables the effect on the given cameras
  61011. * @param cameras The camera to disable.
  61012. * @hidden
  61013. */
  61014. _disable(cameras: Camera): void;
  61015. /**
  61016. * Disables the effect on the given cameras
  61017. * @param cameras The camera to disable.
  61018. * @hidden
  61019. */
  61020. _disable(cameras: Nullable<Camera[]>): void;
  61021. /**
  61022. * Gets a list of the post processes contained in the effect.
  61023. * @param camera The camera to get the post processes on.
  61024. * @returns The list of the post processes in the effect.
  61025. */
  61026. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61027. }
  61028. }
  61029. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  61030. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61031. /** @hidden */
  61032. export var extractHighlightsPixelShader: {
  61033. name: string;
  61034. shader: string;
  61035. };
  61036. }
  61037. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  61038. import { Nullable } from "babylonjs/types";
  61039. import { Camera } from "babylonjs/Cameras/camera";
  61040. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61041. import { Engine } from "babylonjs/Engines/engine";
  61042. import "babylonjs/Shaders/extractHighlights.fragment";
  61043. /**
  61044. * 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.
  61045. */
  61046. export class ExtractHighlightsPostProcess extends PostProcess {
  61047. /**
  61048. * The luminance threshold, pixels below this value will be set to black.
  61049. */
  61050. threshold: number;
  61051. /** @hidden */
  61052. _exposure: number;
  61053. /**
  61054. * Post process which has the input texture to be used when performing highlight extraction
  61055. * @hidden
  61056. */
  61057. _inputPostProcess: Nullable<PostProcess>;
  61058. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61059. }
  61060. }
  61061. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  61062. /** @hidden */
  61063. export var bloomMergePixelShader: {
  61064. name: string;
  61065. shader: string;
  61066. };
  61067. }
  61068. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  61069. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61070. import { Nullable } from "babylonjs/types";
  61071. import { Engine } from "babylonjs/Engines/engine";
  61072. import { Camera } from "babylonjs/Cameras/camera";
  61073. import "babylonjs/Shaders/bloomMerge.fragment";
  61074. /**
  61075. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61076. */
  61077. export class BloomMergePostProcess extends PostProcess {
  61078. /** Weight of the bloom to be added to the original input. */
  61079. weight: number;
  61080. /**
  61081. * Creates a new instance of @see BloomMergePostProcess
  61082. * @param name The name of the effect.
  61083. * @param originalFromInput Post process which's input will be used for the merge.
  61084. * @param blurred Blurred highlights post process which's output will be used.
  61085. * @param weight Weight of the bloom to be added to the original input.
  61086. * @param options The required width/height ratio to downsize to before computing the render pass.
  61087. * @param camera The camera to apply the render pass to.
  61088. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61089. * @param engine The engine which the post process will be applied. (default: current engine)
  61090. * @param reusable If the post process can be reused on the same frame. (default: false)
  61091. * @param textureType Type of textures used when performing the post process. (default: 0)
  61092. * @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)
  61093. */
  61094. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  61095. /** Weight of the bloom to be added to the original input. */
  61096. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61097. }
  61098. }
  61099. declare module "babylonjs/PostProcesses/bloomEffect" {
  61100. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61101. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61102. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61103. import { Camera } from "babylonjs/Cameras/camera";
  61104. import { Scene } from "babylonjs/scene";
  61105. /**
  61106. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  61107. */
  61108. export class BloomEffect extends PostProcessRenderEffect {
  61109. private bloomScale;
  61110. /**
  61111. * @hidden Internal
  61112. */
  61113. _effects: Array<PostProcess>;
  61114. /**
  61115. * @hidden Internal
  61116. */
  61117. _downscale: ExtractHighlightsPostProcess;
  61118. private _blurX;
  61119. private _blurY;
  61120. private _merge;
  61121. /**
  61122. * The luminance threshold to find bright areas of the image to bloom.
  61123. */
  61124. threshold: number;
  61125. /**
  61126. * The strength of the bloom.
  61127. */
  61128. weight: number;
  61129. /**
  61130. * Specifies the size of the bloom blur kernel, relative to the final output size
  61131. */
  61132. kernel: number;
  61133. /**
  61134. * Creates a new instance of @see BloomEffect
  61135. * @param scene The scene the effect belongs to.
  61136. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  61137. * @param bloomKernel The size of the kernel to be used when applying the blur.
  61138. * @param bloomWeight The the strength of bloom.
  61139. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61140. * @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)
  61141. */
  61142. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  61143. /**
  61144. * Disposes each of the internal effects for a given camera.
  61145. * @param camera The camera to dispose the effect on.
  61146. */
  61147. disposeEffects(camera: Camera): void;
  61148. /**
  61149. * @hidden Internal
  61150. */
  61151. _updateEffects(): void;
  61152. /**
  61153. * Internal
  61154. * @returns if all the contained post processes are ready.
  61155. * @hidden
  61156. */
  61157. _isReady(): boolean;
  61158. }
  61159. }
  61160. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  61161. /** @hidden */
  61162. export var chromaticAberrationPixelShader: {
  61163. name: string;
  61164. shader: string;
  61165. };
  61166. }
  61167. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  61168. import { Vector2 } from "babylonjs/Maths/math.vector";
  61169. import { Nullable } from "babylonjs/types";
  61170. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61171. import { Camera } from "babylonjs/Cameras/camera";
  61172. import { Engine } from "babylonjs/Engines/engine";
  61173. import "babylonjs/Shaders/chromaticAberration.fragment";
  61174. /**
  61175. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  61176. */
  61177. export class ChromaticAberrationPostProcess extends PostProcess {
  61178. /**
  61179. * The amount of seperation of rgb channels (default: 30)
  61180. */
  61181. aberrationAmount: number;
  61182. /**
  61183. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  61184. */
  61185. radialIntensity: number;
  61186. /**
  61187. * 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))
  61188. */
  61189. direction: Vector2;
  61190. /**
  61191. * 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))
  61192. */
  61193. centerPosition: Vector2;
  61194. /**
  61195. * Creates a new instance ChromaticAberrationPostProcess
  61196. * @param name The name of the effect.
  61197. * @param screenWidth The width of the screen to apply the effect on.
  61198. * @param screenHeight The height of the screen to apply the effect on.
  61199. * @param options The required width/height ratio to downsize to before computing the render pass.
  61200. * @param camera The camera to apply the render pass to.
  61201. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61202. * @param engine The engine which the post process will be applied. (default: current engine)
  61203. * @param reusable If the post process can be reused on the same frame. (default: false)
  61204. * @param textureType Type of textures used when performing the post process. (default: 0)
  61205. * @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)
  61206. */
  61207. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61208. }
  61209. }
  61210. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  61211. /** @hidden */
  61212. export var circleOfConfusionPixelShader: {
  61213. name: string;
  61214. shader: string;
  61215. };
  61216. }
  61217. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  61218. import { Nullable } from "babylonjs/types";
  61219. import { Engine } from "babylonjs/Engines/engine";
  61220. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61221. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61222. import { Camera } from "babylonjs/Cameras/camera";
  61223. import "babylonjs/Shaders/circleOfConfusion.fragment";
  61224. /**
  61225. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  61226. */
  61227. export class CircleOfConfusionPostProcess extends PostProcess {
  61228. /**
  61229. * 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.
  61230. */
  61231. lensSize: number;
  61232. /**
  61233. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61234. */
  61235. fStop: number;
  61236. /**
  61237. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61238. */
  61239. focusDistance: number;
  61240. /**
  61241. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  61242. */
  61243. focalLength: number;
  61244. private _depthTexture;
  61245. /**
  61246. * Creates a new instance CircleOfConfusionPostProcess
  61247. * @param name The name of the effect.
  61248. * @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.
  61249. * @param options The required width/height ratio to downsize to before computing the render pass.
  61250. * @param camera The camera to apply the render pass to.
  61251. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61252. * @param engine The engine which the post process will be applied. (default: current engine)
  61253. * @param reusable If the post process can be reused on the same frame. (default: false)
  61254. * @param textureType Type of textures used when performing the post process. (default: 0)
  61255. * @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)
  61256. */
  61257. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61258. /**
  61259. * 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.
  61260. */
  61261. depthTexture: RenderTargetTexture;
  61262. }
  61263. }
  61264. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  61265. /** @hidden */
  61266. export var colorCorrectionPixelShader: {
  61267. name: string;
  61268. shader: string;
  61269. };
  61270. }
  61271. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  61272. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61273. import { Engine } from "babylonjs/Engines/engine";
  61274. import { Camera } from "babylonjs/Cameras/camera";
  61275. import "babylonjs/Shaders/colorCorrection.fragment";
  61276. /**
  61277. *
  61278. * This post-process allows the modification of rendered colors by using
  61279. * a 'look-up table' (LUT). This effect is also called Color Grading.
  61280. *
  61281. * The object needs to be provided an url to a texture containing the color
  61282. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  61283. * Use an image editing software to tweak the LUT to match your needs.
  61284. *
  61285. * For an example of a color LUT, see here:
  61286. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  61287. * For explanations on color grading, see here:
  61288. * @see http://udn.epicgames.com/Three/ColorGrading.html
  61289. *
  61290. */
  61291. export class ColorCorrectionPostProcess extends PostProcess {
  61292. private _colorTableTexture;
  61293. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61294. }
  61295. }
  61296. declare module "babylonjs/Shaders/convolution.fragment" {
  61297. /** @hidden */
  61298. export var convolutionPixelShader: {
  61299. name: string;
  61300. shader: string;
  61301. };
  61302. }
  61303. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  61304. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61305. import { Nullable } from "babylonjs/types";
  61306. import { Camera } from "babylonjs/Cameras/camera";
  61307. import { Engine } from "babylonjs/Engines/engine";
  61308. import "babylonjs/Shaders/convolution.fragment";
  61309. /**
  61310. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  61311. * input texture to perform effects such as edge detection or sharpening
  61312. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  61313. */
  61314. export class ConvolutionPostProcess extends PostProcess {
  61315. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61316. kernel: number[];
  61317. /**
  61318. * Creates a new instance ConvolutionPostProcess
  61319. * @param name The name of the effect.
  61320. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  61321. * @param options The required width/height ratio to downsize to before computing the render pass.
  61322. * @param camera The camera to apply the render pass to.
  61323. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61324. * @param engine The engine which the post process will be applied. (default: current engine)
  61325. * @param reusable If the post process can be reused on the same frame. (default: false)
  61326. * @param textureType Type of textures used when performing the post process. (default: 0)
  61327. */
  61328. constructor(name: string,
  61329. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  61330. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61331. /**
  61332. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61333. */
  61334. static EdgeDetect0Kernel: number[];
  61335. /**
  61336. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61337. */
  61338. static EdgeDetect1Kernel: number[];
  61339. /**
  61340. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61341. */
  61342. static EdgeDetect2Kernel: number[];
  61343. /**
  61344. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61345. */
  61346. static SharpenKernel: number[];
  61347. /**
  61348. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61349. */
  61350. static EmbossKernel: number[];
  61351. /**
  61352. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  61353. */
  61354. static GaussianKernel: number[];
  61355. }
  61356. }
  61357. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  61358. import { Nullable } from "babylonjs/types";
  61359. import { Vector2 } from "babylonjs/Maths/math.vector";
  61360. import { Camera } from "babylonjs/Cameras/camera";
  61361. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61362. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  61363. import { Engine } from "babylonjs/Engines/engine";
  61364. import { Scene } from "babylonjs/scene";
  61365. /**
  61366. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  61367. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  61368. * based on samples that have a large difference in distance than the center pixel.
  61369. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  61370. */
  61371. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  61372. direction: Vector2;
  61373. /**
  61374. * Creates a new instance CircleOfConfusionPostProcess
  61375. * @param name The name of the effect.
  61376. * @param scene The scene the effect belongs to.
  61377. * @param direction The direction the blur should be applied.
  61378. * @param kernel The size of the kernel used to blur.
  61379. * @param options The required width/height ratio to downsize to before computing the render pass.
  61380. * @param camera The camera to apply the render pass to.
  61381. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  61382. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  61383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61384. * @param engine The engine which the post process will be applied. (default: current engine)
  61385. * @param reusable If the post process can be reused on the same frame. (default: false)
  61386. * @param textureType Type of textures used when performing the post process. (default: 0)
  61387. * @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)
  61388. */
  61389. 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);
  61390. }
  61391. }
  61392. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  61393. /** @hidden */
  61394. export var depthOfFieldMergePixelShader: {
  61395. name: string;
  61396. shader: string;
  61397. };
  61398. }
  61399. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  61400. import { Nullable } from "babylonjs/types";
  61401. import { Camera } from "babylonjs/Cameras/camera";
  61402. import { Effect } from "babylonjs/Materials/effect";
  61403. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61404. import { Engine } from "babylonjs/Engines/engine";
  61405. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  61406. /**
  61407. * Options to be set when merging outputs from the default pipeline.
  61408. */
  61409. export class DepthOfFieldMergePostProcessOptions {
  61410. /**
  61411. * The original image to merge on top of
  61412. */
  61413. originalFromInput: PostProcess;
  61414. /**
  61415. * Parameters to perform the merge of the depth of field effect
  61416. */
  61417. depthOfField?: {
  61418. circleOfConfusion: PostProcess;
  61419. blurSteps: Array<PostProcess>;
  61420. };
  61421. /**
  61422. * Parameters to perform the merge of bloom effect
  61423. */
  61424. bloom?: {
  61425. blurred: PostProcess;
  61426. weight: number;
  61427. };
  61428. }
  61429. /**
  61430. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61431. */
  61432. export class DepthOfFieldMergePostProcess extends PostProcess {
  61433. private blurSteps;
  61434. /**
  61435. * Creates a new instance of DepthOfFieldMergePostProcess
  61436. * @param name The name of the effect.
  61437. * @param originalFromInput Post process which's input will be used for the merge.
  61438. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  61439. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  61440. * @param options The required width/height ratio to downsize to before computing the render pass.
  61441. * @param camera The camera to apply the render pass to.
  61442. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61443. * @param engine The engine which the post process will be applied. (default: current engine)
  61444. * @param reusable If the post process can be reused on the same frame. (default: false)
  61445. * @param textureType Type of textures used when performing the post process. (default: 0)
  61446. * @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)
  61447. */
  61448. 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);
  61449. /**
  61450. * Updates the effect with the current post process compile time values and recompiles the shader.
  61451. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  61452. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  61453. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  61454. * @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
  61455. * @param onCompiled Called when the shader has been compiled.
  61456. * @param onError Called if there is an error when compiling a shader.
  61457. */
  61458. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  61459. }
  61460. }
  61461. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  61462. import { Nullable } from "babylonjs/types";
  61463. import { Camera } from "babylonjs/Cameras/camera";
  61464. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61465. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61466. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61467. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  61468. import { Scene } from "babylonjs/scene";
  61469. /**
  61470. * Specifies the level of max blur that should be applied when using the depth of field effect
  61471. */
  61472. export enum DepthOfFieldEffectBlurLevel {
  61473. /**
  61474. * Subtle blur
  61475. */
  61476. Low = 0,
  61477. /**
  61478. * Medium blur
  61479. */
  61480. Medium = 1,
  61481. /**
  61482. * Large blur
  61483. */
  61484. High = 2
  61485. }
  61486. /**
  61487. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  61488. */
  61489. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  61490. private _circleOfConfusion;
  61491. /**
  61492. * @hidden Internal, blurs from high to low
  61493. */
  61494. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  61495. private _depthOfFieldBlurY;
  61496. private _dofMerge;
  61497. /**
  61498. * @hidden Internal post processes in depth of field effect
  61499. */
  61500. _effects: Array<PostProcess>;
  61501. /**
  61502. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  61503. */
  61504. focalLength: number;
  61505. /**
  61506. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  61507. */
  61508. fStop: number;
  61509. /**
  61510. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  61511. */
  61512. focusDistance: number;
  61513. /**
  61514. * 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.
  61515. */
  61516. lensSize: number;
  61517. /**
  61518. * Creates a new instance DepthOfFieldEffect
  61519. * @param scene The scene the effect belongs to.
  61520. * @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.
  61521. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  61522. * @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)
  61523. */
  61524. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  61525. /**
  61526. * Get the current class name of the current effet
  61527. * @returns "DepthOfFieldEffect"
  61528. */
  61529. getClassName(): string;
  61530. /**
  61531. * 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.
  61532. */
  61533. depthTexture: RenderTargetTexture;
  61534. /**
  61535. * Disposes each of the internal effects for a given camera.
  61536. * @param camera The camera to dispose the effect on.
  61537. */
  61538. disposeEffects(camera: Camera): void;
  61539. /**
  61540. * @hidden Internal
  61541. */
  61542. _updateEffects(): void;
  61543. /**
  61544. * Internal
  61545. * @returns if all the contained post processes are ready.
  61546. * @hidden
  61547. */
  61548. _isReady(): boolean;
  61549. }
  61550. }
  61551. declare module "babylonjs/Shaders/displayPass.fragment" {
  61552. /** @hidden */
  61553. export var displayPassPixelShader: {
  61554. name: string;
  61555. shader: string;
  61556. };
  61557. }
  61558. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  61559. import { Nullable } from "babylonjs/types";
  61560. import { Camera } from "babylonjs/Cameras/camera";
  61561. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61562. import { Engine } from "babylonjs/Engines/engine";
  61563. import "babylonjs/Shaders/displayPass.fragment";
  61564. /**
  61565. * DisplayPassPostProcess which produces an output the same as it's input
  61566. */
  61567. export class DisplayPassPostProcess extends PostProcess {
  61568. /**
  61569. * Creates the DisplayPassPostProcess
  61570. * @param name The name of the effect.
  61571. * @param options The required width/height ratio to downsize to before computing the render pass.
  61572. * @param camera The camera to apply the render pass to.
  61573. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61574. * @param engine The engine which the post process will be applied. (default: current engine)
  61575. * @param reusable If the post process can be reused on the same frame. (default: false)
  61576. */
  61577. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61578. }
  61579. }
  61580. declare module "babylonjs/Shaders/filter.fragment" {
  61581. /** @hidden */
  61582. export var filterPixelShader: {
  61583. name: string;
  61584. shader: string;
  61585. };
  61586. }
  61587. declare module "babylonjs/PostProcesses/filterPostProcess" {
  61588. import { Nullable } from "babylonjs/types";
  61589. import { Matrix } from "babylonjs/Maths/math.vector";
  61590. import { Camera } from "babylonjs/Cameras/camera";
  61591. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61592. import { Engine } from "babylonjs/Engines/engine";
  61593. import "babylonjs/Shaders/filter.fragment";
  61594. /**
  61595. * Applies a kernel filter to the image
  61596. */
  61597. export class FilterPostProcess extends PostProcess {
  61598. /** The matrix to be applied to the image */
  61599. kernelMatrix: Matrix;
  61600. /**
  61601. *
  61602. * @param name The name of the effect.
  61603. * @param kernelMatrix The matrix to be applied to the image
  61604. * @param options The required width/height ratio to downsize to before computing the render pass.
  61605. * @param camera The camera to apply the render pass to.
  61606. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61607. * @param engine The engine which the post process will be applied. (default: current engine)
  61608. * @param reusable If the post process can be reused on the same frame. (default: false)
  61609. */
  61610. constructor(name: string,
  61611. /** The matrix to be applied to the image */
  61612. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61613. }
  61614. }
  61615. declare module "babylonjs/Shaders/fxaa.fragment" {
  61616. /** @hidden */
  61617. export var fxaaPixelShader: {
  61618. name: string;
  61619. shader: string;
  61620. };
  61621. }
  61622. declare module "babylonjs/Shaders/fxaa.vertex" {
  61623. /** @hidden */
  61624. export var fxaaVertexShader: {
  61625. name: string;
  61626. shader: string;
  61627. };
  61628. }
  61629. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  61630. import { Nullable } from "babylonjs/types";
  61631. import { Camera } from "babylonjs/Cameras/camera";
  61632. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61633. import { Engine } from "babylonjs/Engines/engine";
  61634. import "babylonjs/Shaders/fxaa.fragment";
  61635. import "babylonjs/Shaders/fxaa.vertex";
  61636. /**
  61637. * Fxaa post process
  61638. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  61639. */
  61640. export class FxaaPostProcess extends PostProcess {
  61641. /** @hidden */
  61642. texelWidth: number;
  61643. /** @hidden */
  61644. texelHeight: number;
  61645. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61646. private _getDefines;
  61647. }
  61648. }
  61649. declare module "babylonjs/Shaders/grain.fragment" {
  61650. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61651. /** @hidden */
  61652. export var grainPixelShader: {
  61653. name: string;
  61654. shader: string;
  61655. };
  61656. }
  61657. declare module "babylonjs/PostProcesses/grainPostProcess" {
  61658. import { Nullable } from "babylonjs/types";
  61659. import { Camera } from "babylonjs/Cameras/camera";
  61660. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61661. import { Engine } from "babylonjs/Engines/engine";
  61662. import "babylonjs/Shaders/grain.fragment";
  61663. /**
  61664. * The GrainPostProcess adds noise to the image at mid luminance levels
  61665. */
  61666. export class GrainPostProcess extends PostProcess {
  61667. /**
  61668. * The intensity of the grain added (default: 30)
  61669. */
  61670. intensity: number;
  61671. /**
  61672. * If the grain should be randomized on every frame
  61673. */
  61674. animated: boolean;
  61675. /**
  61676. * Creates a new instance of @see GrainPostProcess
  61677. * @param name The name of the effect.
  61678. * @param options The required width/height ratio to downsize to before computing the render pass.
  61679. * @param camera The camera to apply the render pass to.
  61680. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61681. * @param engine The engine which the post process will be applied. (default: current engine)
  61682. * @param reusable If the post process can be reused on the same frame. (default: false)
  61683. * @param textureType Type of textures used when performing the post process. (default: 0)
  61684. * @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)
  61685. */
  61686. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61687. }
  61688. }
  61689. declare module "babylonjs/Shaders/highlights.fragment" {
  61690. /** @hidden */
  61691. export var highlightsPixelShader: {
  61692. name: string;
  61693. shader: string;
  61694. };
  61695. }
  61696. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  61697. import { Nullable } from "babylonjs/types";
  61698. import { Camera } from "babylonjs/Cameras/camera";
  61699. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61700. import { Engine } from "babylonjs/Engines/engine";
  61701. import "babylonjs/Shaders/highlights.fragment";
  61702. /**
  61703. * Extracts highlights from the image
  61704. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61705. */
  61706. export class HighlightsPostProcess extends PostProcess {
  61707. /**
  61708. * Extracts highlights from the image
  61709. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  61710. * @param name The name of the effect.
  61711. * @param options The required width/height ratio to downsize to before computing the render pass.
  61712. * @param camera The camera to apply the render pass to.
  61713. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61714. * @param engine The engine which the post process will be applied. (default: current engine)
  61715. * @param reusable If the post process can be reused on the same frame. (default: false)
  61716. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  61717. */
  61718. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  61719. }
  61720. }
  61721. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  61722. /** @hidden */
  61723. export var mrtFragmentDeclaration: {
  61724. name: string;
  61725. shader: string;
  61726. };
  61727. }
  61728. declare module "babylonjs/Shaders/geometry.fragment" {
  61729. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  61730. /** @hidden */
  61731. export var geometryPixelShader: {
  61732. name: string;
  61733. shader: string;
  61734. };
  61735. }
  61736. declare module "babylonjs/Shaders/geometry.vertex" {
  61737. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61738. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61739. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61740. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61741. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61742. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61743. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61744. /** @hidden */
  61745. export var geometryVertexShader: {
  61746. name: string;
  61747. shader: string;
  61748. };
  61749. }
  61750. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  61751. import { Matrix } from "babylonjs/Maths/math.vector";
  61752. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61753. import { Mesh } from "babylonjs/Meshes/mesh";
  61754. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  61755. import { Effect } from "babylonjs/Materials/effect";
  61756. import { Scene } from "babylonjs/scene";
  61757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61758. import "babylonjs/Shaders/geometry.fragment";
  61759. import "babylonjs/Shaders/geometry.vertex";
  61760. /** @hidden */
  61761. interface ISavedTransformationMatrix {
  61762. world: Matrix;
  61763. viewProjection: Matrix;
  61764. }
  61765. /**
  61766. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  61767. */
  61768. export class GeometryBufferRenderer {
  61769. /**
  61770. * Constant used to retrieve the position texture index in the G-Buffer textures array
  61771. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  61772. */
  61773. static readonly POSITION_TEXTURE_TYPE: number;
  61774. /**
  61775. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  61776. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  61777. */
  61778. static readonly VELOCITY_TEXTURE_TYPE: number;
  61779. /**
  61780. * Dictionary used to store the previous transformation matrices of each rendered mesh
  61781. * in order to compute objects velocities when enableVelocity is set to "true"
  61782. * @hidden
  61783. */
  61784. _previousTransformationMatrices: {
  61785. [index: number]: ISavedTransformationMatrix;
  61786. };
  61787. /**
  61788. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  61789. * in order to compute objects velocities when enableVelocity is set to "true"
  61790. * @hidden
  61791. */
  61792. _previousBonesTransformationMatrices: {
  61793. [index: number]: Float32Array;
  61794. };
  61795. /**
  61796. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  61797. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  61798. */
  61799. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  61800. private _scene;
  61801. private _multiRenderTarget;
  61802. private _ratio;
  61803. private _enablePosition;
  61804. private _enableVelocity;
  61805. private _positionIndex;
  61806. private _velocityIndex;
  61807. protected _effect: Effect;
  61808. protected _cachedDefines: string;
  61809. /**
  61810. * Set the render list (meshes to be rendered) used in the G buffer.
  61811. */
  61812. renderList: Mesh[];
  61813. /**
  61814. * Gets wether or not G buffer are supported by the running hardware.
  61815. * This requires draw buffer supports
  61816. */
  61817. readonly isSupported: boolean;
  61818. /**
  61819. * Returns the index of the given texture type in the G-Buffer textures array
  61820. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  61821. * @returns the index of the given texture type in the G-Buffer textures array
  61822. */
  61823. getTextureIndex(textureType: number): number;
  61824. /**
  61825. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  61826. */
  61827. /**
  61828. * Sets whether or not objects positions are enabled for the G buffer.
  61829. */
  61830. enablePosition: boolean;
  61831. /**
  61832. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  61833. */
  61834. /**
  61835. * Sets wether or not objects velocities are enabled for the G buffer.
  61836. */
  61837. enableVelocity: boolean;
  61838. /**
  61839. * Gets the scene associated with the buffer.
  61840. */
  61841. readonly scene: Scene;
  61842. /**
  61843. * Gets the ratio used by the buffer during its creation.
  61844. * How big is the buffer related to the main canvas.
  61845. */
  61846. readonly ratio: number;
  61847. /** @hidden */
  61848. static _SceneComponentInitialization: (scene: Scene) => void;
  61849. /**
  61850. * Creates a new G Buffer for the scene
  61851. * @param scene The scene the buffer belongs to
  61852. * @param ratio How big is the buffer related to the main canvas.
  61853. */
  61854. constructor(scene: Scene, ratio?: number);
  61855. /**
  61856. * Checks wether everything is ready to render a submesh to the G buffer.
  61857. * @param subMesh the submesh to check readiness for
  61858. * @param useInstances is the mesh drawn using instance or not
  61859. * @returns true if ready otherwise false
  61860. */
  61861. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61862. /**
  61863. * Gets the current underlying G Buffer.
  61864. * @returns the buffer
  61865. */
  61866. getGBuffer(): MultiRenderTarget;
  61867. /**
  61868. * Gets the number of samples used to render the buffer (anti aliasing).
  61869. */
  61870. /**
  61871. * Sets the number of samples used to render the buffer (anti aliasing).
  61872. */
  61873. samples: number;
  61874. /**
  61875. * Disposes the renderer and frees up associated resources.
  61876. */
  61877. dispose(): void;
  61878. protected _createRenderTargets(): void;
  61879. private _copyBonesTransformationMatrices;
  61880. }
  61881. }
  61882. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  61883. import { Nullable } from "babylonjs/types";
  61884. import { Scene } from "babylonjs/scene";
  61885. import { ISceneComponent } from "babylonjs/sceneComponent";
  61886. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  61887. module "babylonjs/scene" {
  61888. interface Scene {
  61889. /** @hidden (Backing field) */
  61890. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61891. /**
  61892. * Gets or Sets the current geometry buffer associated to the scene.
  61893. */
  61894. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  61895. /**
  61896. * Enables a GeometryBufferRender and associates it with the scene
  61897. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  61898. * @returns the GeometryBufferRenderer
  61899. */
  61900. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  61901. /**
  61902. * Disables the GeometryBufferRender associated with the scene
  61903. */
  61904. disableGeometryBufferRenderer(): void;
  61905. }
  61906. }
  61907. /**
  61908. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  61909. * in several rendering techniques.
  61910. */
  61911. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  61912. /**
  61913. * The component name helpful to identify the component in the list of scene components.
  61914. */
  61915. readonly name: string;
  61916. /**
  61917. * The scene the component belongs to.
  61918. */
  61919. scene: Scene;
  61920. /**
  61921. * Creates a new instance of the component for the given scene
  61922. * @param scene Defines the scene to register the component in
  61923. */
  61924. constructor(scene: Scene);
  61925. /**
  61926. * Registers the component in a given scene
  61927. */
  61928. register(): void;
  61929. /**
  61930. * Rebuilds the elements related to this component in case of
  61931. * context lost for instance.
  61932. */
  61933. rebuild(): void;
  61934. /**
  61935. * Disposes the component and the associated ressources
  61936. */
  61937. dispose(): void;
  61938. private _gatherRenderTargets;
  61939. }
  61940. }
  61941. declare module "babylonjs/Shaders/motionBlur.fragment" {
  61942. /** @hidden */
  61943. export var motionBlurPixelShader: {
  61944. name: string;
  61945. shader: string;
  61946. };
  61947. }
  61948. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  61949. import { Nullable } from "babylonjs/types";
  61950. import { Camera } from "babylonjs/Cameras/camera";
  61951. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61952. import { Scene } from "babylonjs/scene";
  61953. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61954. import "babylonjs/Animations/animatable";
  61955. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  61956. import "babylonjs/Shaders/motionBlur.fragment";
  61957. import { Engine } from "babylonjs/Engines/engine";
  61958. /**
  61959. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  61960. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  61961. * As an example, all you have to do is to create the post-process:
  61962. * var mb = new BABYLON.MotionBlurPostProcess(
  61963. * 'mb', // The name of the effect.
  61964. * scene, // The scene containing the objects to blur according to their velocity.
  61965. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  61966. * camera // The camera to apply the render pass to.
  61967. * );
  61968. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  61969. */
  61970. export class MotionBlurPostProcess extends PostProcess {
  61971. /**
  61972. * Defines how much the image is blurred by the movement. Default value is equal to 1
  61973. */
  61974. motionStrength: number;
  61975. /**
  61976. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  61977. */
  61978. /**
  61979. * Sets the number of iterations to be used for motion blur quality
  61980. */
  61981. motionBlurSamples: number;
  61982. private _motionBlurSamples;
  61983. private _geometryBufferRenderer;
  61984. /**
  61985. * Creates a new instance MotionBlurPostProcess
  61986. * @param name The name of the effect.
  61987. * @param scene The scene containing the objects to blur according to their velocity.
  61988. * @param options The required width/height ratio to downsize to before computing the render pass.
  61989. * @param camera The camera to apply the render pass to.
  61990. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61991. * @param engine The engine which the post process will be applied. (default: current engine)
  61992. * @param reusable If the post process can be reused on the same frame. (default: false)
  61993. * @param textureType Type of textures used when performing the post process. (default: 0)
  61994. * @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)
  61995. */
  61996. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61997. /**
  61998. * Excludes the given skinned mesh from computing bones velocities.
  61999. * 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.
  62000. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62001. */
  62002. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62003. /**
  62004. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62005. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62006. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62007. */
  62008. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62009. /**
  62010. * Disposes the post process.
  62011. * @param camera The camera to dispose the post process on.
  62012. */
  62013. dispose(camera?: Camera): void;
  62014. }
  62015. }
  62016. declare module "babylonjs/Shaders/refraction.fragment" {
  62017. /** @hidden */
  62018. export var refractionPixelShader: {
  62019. name: string;
  62020. shader: string;
  62021. };
  62022. }
  62023. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  62024. import { Color3 } from "babylonjs/Maths/math.color";
  62025. import { Camera } from "babylonjs/Cameras/camera";
  62026. import { Texture } from "babylonjs/Materials/Textures/texture";
  62027. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62028. import { Engine } from "babylonjs/Engines/engine";
  62029. import "babylonjs/Shaders/refraction.fragment";
  62030. /**
  62031. * Post process which applies a refractin texture
  62032. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62033. */
  62034. export class RefractionPostProcess extends PostProcess {
  62035. /** the base color of the refraction (used to taint the rendering) */
  62036. color: Color3;
  62037. /** simulated refraction depth */
  62038. depth: number;
  62039. /** the coefficient of the base color (0 to remove base color tainting) */
  62040. colorLevel: number;
  62041. private _refTexture;
  62042. private _ownRefractionTexture;
  62043. /**
  62044. * Gets or sets the refraction texture
  62045. * Please note that you are responsible for disposing the texture if you set it manually
  62046. */
  62047. refractionTexture: Texture;
  62048. /**
  62049. * Initializes the RefractionPostProcess
  62050. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62051. * @param name The name of the effect.
  62052. * @param refractionTextureUrl Url of the refraction texture to use
  62053. * @param color the base color of the refraction (used to taint the rendering)
  62054. * @param depth simulated refraction depth
  62055. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  62056. * @param camera The camera to apply the render pass to.
  62057. * @param options The required width/height ratio to downsize to before computing the render pass.
  62058. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62059. * @param engine The engine which the post process will be applied. (default: current engine)
  62060. * @param reusable If the post process can be reused on the same frame. (default: false)
  62061. */
  62062. constructor(name: string, refractionTextureUrl: string,
  62063. /** the base color of the refraction (used to taint the rendering) */
  62064. color: Color3,
  62065. /** simulated refraction depth */
  62066. depth: number,
  62067. /** the coefficient of the base color (0 to remove base color tainting) */
  62068. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62069. /**
  62070. * Disposes of the post process
  62071. * @param camera Camera to dispose post process on
  62072. */
  62073. dispose(camera: Camera): void;
  62074. }
  62075. }
  62076. declare module "babylonjs/Shaders/sharpen.fragment" {
  62077. /** @hidden */
  62078. export var sharpenPixelShader: {
  62079. name: string;
  62080. shader: string;
  62081. };
  62082. }
  62083. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  62084. import { Nullable } from "babylonjs/types";
  62085. import { Camera } from "babylonjs/Cameras/camera";
  62086. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62087. import "babylonjs/Shaders/sharpen.fragment";
  62088. import { Engine } from "babylonjs/Engines/engine";
  62089. /**
  62090. * The SharpenPostProcess applies a sharpen kernel to every pixel
  62091. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62092. */
  62093. export class SharpenPostProcess extends PostProcess {
  62094. /**
  62095. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  62096. */
  62097. colorAmount: number;
  62098. /**
  62099. * How much sharpness should be applied (default: 0.3)
  62100. */
  62101. edgeAmount: number;
  62102. /**
  62103. * Creates a new instance ConvolutionPostProcess
  62104. * @param name The name of the effect.
  62105. * @param options The required width/height ratio to downsize to before computing the render pass.
  62106. * @param camera The camera to apply the render pass to.
  62107. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62108. * @param engine The engine which the post process will be applied. (default: current engine)
  62109. * @param reusable If the post process can be reused on the same frame. (default: false)
  62110. * @param textureType Type of textures used when performing the post process. (default: 0)
  62111. * @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)
  62112. */
  62113. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62114. }
  62115. }
  62116. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  62117. import { Nullable } from "babylonjs/types";
  62118. import { Camera } from "babylonjs/Cameras/camera";
  62119. import { Engine } from "babylonjs/Engines/engine";
  62120. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62121. import { IInspectable } from "babylonjs/Misc/iInspectable";
  62122. /**
  62123. * PostProcessRenderPipeline
  62124. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62125. */
  62126. export class PostProcessRenderPipeline {
  62127. private engine;
  62128. private _renderEffects;
  62129. private _renderEffectsForIsolatedPass;
  62130. /**
  62131. * List of inspectable custom properties (used by the Inspector)
  62132. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  62133. */
  62134. inspectableCustomProperties: IInspectable[];
  62135. /**
  62136. * @hidden
  62137. */
  62138. protected _cameras: Camera[];
  62139. /** @hidden */
  62140. _name: string;
  62141. /**
  62142. * Gets pipeline name
  62143. */
  62144. readonly name: string;
  62145. /**
  62146. * Initializes a PostProcessRenderPipeline
  62147. * @param engine engine to add the pipeline to
  62148. * @param name name of the pipeline
  62149. */
  62150. constructor(engine: Engine, name: string);
  62151. /**
  62152. * Gets the class name
  62153. * @returns "PostProcessRenderPipeline"
  62154. */
  62155. getClassName(): string;
  62156. /**
  62157. * If all the render effects in the pipeline are supported
  62158. */
  62159. readonly isSupported: boolean;
  62160. /**
  62161. * Adds an effect to the pipeline
  62162. * @param renderEffect the effect to add
  62163. */
  62164. addEffect(renderEffect: PostProcessRenderEffect): void;
  62165. /** @hidden */
  62166. _rebuild(): void;
  62167. /** @hidden */
  62168. _enableEffect(renderEffectName: string, cameras: Camera): void;
  62169. /** @hidden */
  62170. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  62171. /** @hidden */
  62172. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62173. /** @hidden */
  62174. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  62175. /** @hidden */
  62176. _attachCameras(cameras: Camera, unique: boolean): void;
  62177. /** @hidden */
  62178. _attachCameras(cameras: Camera[], unique: boolean): void;
  62179. /** @hidden */
  62180. _detachCameras(cameras: Camera): void;
  62181. /** @hidden */
  62182. _detachCameras(cameras: Nullable<Camera[]>): void;
  62183. /** @hidden */
  62184. _update(): void;
  62185. /** @hidden */
  62186. _reset(): void;
  62187. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  62188. /**
  62189. * Disposes of the pipeline
  62190. */
  62191. dispose(): void;
  62192. }
  62193. }
  62194. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  62195. import { Camera } from "babylonjs/Cameras/camera";
  62196. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62197. /**
  62198. * PostProcessRenderPipelineManager class
  62199. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62200. */
  62201. export class PostProcessRenderPipelineManager {
  62202. private _renderPipelines;
  62203. /**
  62204. * Initializes a PostProcessRenderPipelineManager
  62205. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62206. */
  62207. constructor();
  62208. /**
  62209. * Gets the list of supported render pipelines
  62210. */
  62211. readonly supportedPipelines: PostProcessRenderPipeline[];
  62212. /**
  62213. * Adds a pipeline to the manager
  62214. * @param renderPipeline The pipeline to add
  62215. */
  62216. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  62217. /**
  62218. * Attaches a camera to the pipeline
  62219. * @param renderPipelineName The name of the pipeline to attach to
  62220. * @param cameras the camera to attach
  62221. * @param unique if the camera can be attached multiple times to the pipeline
  62222. */
  62223. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  62224. /**
  62225. * Detaches a camera from the pipeline
  62226. * @param renderPipelineName The name of the pipeline to detach from
  62227. * @param cameras the camera to detach
  62228. */
  62229. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  62230. /**
  62231. * Enables an effect by name on a pipeline
  62232. * @param renderPipelineName the name of the pipeline to enable the effect in
  62233. * @param renderEffectName the name of the effect to enable
  62234. * @param cameras the cameras that the effect should be enabled on
  62235. */
  62236. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62237. /**
  62238. * Disables an effect by name on a pipeline
  62239. * @param renderPipelineName the name of the pipeline to disable the effect in
  62240. * @param renderEffectName the name of the effect to disable
  62241. * @param cameras the cameras that the effect should be disabled on
  62242. */
  62243. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  62244. /**
  62245. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  62246. */
  62247. update(): void;
  62248. /** @hidden */
  62249. _rebuild(): void;
  62250. /**
  62251. * Disposes of the manager and pipelines
  62252. */
  62253. dispose(): void;
  62254. }
  62255. }
  62256. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  62257. import { ISceneComponent } from "babylonjs/sceneComponent";
  62258. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  62259. import { Scene } from "babylonjs/scene";
  62260. module "babylonjs/scene" {
  62261. interface Scene {
  62262. /** @hidden (Backing field) */
  62263. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62264. /**
  62265. * Gets the postprocess render pipeline manager
  62266. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  62267. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62268. */
  62269. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  62270. }
  62271. }
  62272. /**
  62273. * Defines the Render Pipeline scene component responsible to rendering pipelines
  62274. */
  62275. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  62276. /**
  62277. * The component name helpfull to identify the component in the list of scene components.
  62278. */
  62279. readonly name: string;
  62280. /**
  62281. * The scene the component belongs to.
  62282. */
  62283. scene: Scene;
  62284. /**
  62285. * Creates a new instance of the component for the given scene
  62286. * @param scene Defines the scene to register the component in
  62287. */
  62288. constructor(scene: Scene);
  62289. /**
  62290. * Registers the component in a given scene
  62291. */
  62292. register(): void;
  62293. /**
  62294. * Rebuilds the elements related to this component in case of
  62295. * context lost for instance.
  62296. */
  62297. rebuild(): void;
  62298. /**
  62299. * Disposes the component and the associated ressources
  62300. */
  62301. dispose(): void;
  62302. private _gatherRenderTargets;
  62303. }
  62304. }
  62305. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  62306. import { Nullable } from "babylonjs/types";
  62307. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  62308. import { Camera } from "babylonjs/Cameras/camera";
  62309. import { IDisposable } from "babylonjs/scene";
  62310. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  62311. import { Scene } from "babylonjs/scene";
  62312. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  62313. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  62314. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  62315. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  62316. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  62317. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62318. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  62319. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62320. import { Animation } from "babylonjs/Animations/animation";
  62321. /**
  62322. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  62323. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  62324. */
  62325. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  62326. private _scene;
  62327. private _camerasToBeAttached;
  62328. /**
  62329. * ID of the sharpen post process,
  62330. */
  62331. private readonly SharpenPostProcessId;
  62332. /**
  62333. * @ignore
  62334. * ID of the image processing post process;
  62335. */
  62336. readonly ImageProcessingPostProcessId: string;
  62337. /**
  62338. * @ignore
  62339. * ID of the Fast Approximate Anti-Aliasing post process;
  62340. */
  62341. readonly FxaaPostProcessId: string;
  62342. /**
  62343. * ID of the chromatic aberration post process,
  62344. */
  62345. private readonly ChromaticAberrationPostProcessId;
  62346. /**
  62347. * ID of the grain post process
  62348. */
  62349. private readonly GrainPostProcessId;
  62350. /**
  62351. * Sharpen post process which will apply a sharpen convolution to enhance edges
  62352. */
  62353. sharpen: SharpenPostProcess;
  62354. private _sharpenEffect;
  62355. private bloom;
  62356. /**
  62357. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  62358. */
  62359. depthOfField: DepthOfFieldEffect;
  62360. /**
  62361. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  62362. */
  62363. fxaa: FxaaPostProcess;
  62364. /**
  62365. * Image post processing pass used to perform operations such as tone mapping or color grading.
  62366. */
  62367. imageProcessing: ImageProcessingPostProcess;
  62368. /**
  62369. * Chromatic aberration post process which will shift rgb colors in the image
  62370. */
  62371. chromaticAberration: ChromaticAberrationPostProcess;
  62372. private _chromaticAberrationEffect;
  62373. /**
  62374. * Grain post process which add noise to the image
  62375. */
  62376. grain: GrainPostProcess;
  62377. private _grainEffect;
  62378. /**
  62379. * Glow post process which adds a glow to emissive areas of the image
  62380. */
  62381. private _glowLayer;
  62382. /**
  62383. * Animations which can be used to tweak settings over a period of time
  62384. */
  62385. animations: Animation[];
  62386. private _imageProcessingConfigurationObserver;
  62387. private _sharpenEnabled;
  62388. private _bloomEnabled;
  62389. private _depthOfFieldEnabled;
  62390. private _depthOfFieldBlurLevel;
  62391. private _fxaaEnabled;
  62392. private _imageProcessingEnabled;
  62393. private _defaultPipelineTextureType;
  62394. private _bloomScale;
  62395. private _chromaticAberrationEnabled;
  62396. private _grainEnabled;
  62397. private _buildAllowed;
  62398. /**
  62399. * Gets active scene
  62400. */
  62401. readonly scene: Scene;
  62402. /**
  62403. * Enable or disable the sharpen process from the pipeline
  62404. */
  62405. sharpenEnabled: boolean;
  62406. private _resizeObserver;
  62407. private _hardwareScaleLevel;
  62408. private _bloomKernel;
  62409. /**
  62410. * Specifies the size of the bloom blur kernel, relative to the final output size
  62411. */
  62412. bloomKernel: number;
  62413. /**
  62414. * Specifies the weight of the bloom in the final rendering
  62415. */
  62416. private _bloomWeight;
  62417. /**
  62418. * Specifies the luma threshold for the area that will be blurred by the bloom
  62419. */
  62420. private _bloomThreshold;
  62421. private _hdr;
  62422. /**
  62423. * The strength of the bloom.
  62424. */
  62425. bloomWeight: number;
  62426. /**
  62427. * The strength of the bloom.
  62428. */
  62429. bloomThreshold: number;
  62430. /**
  62431. * The scale of the bloom, lower value will provide better performance.
  62432. */
  62433. bloomScale: number;
  62434. /**
  62435. * Enable or disable the bloom from the pipeline
  62436. */
  62437. bloomEnabled: boolean;
  62438. private _rebuildBloom;
  62439. /**
  62440. * If the depth of field is enabled.
  62441. */
  62442. depthOfFieldEnabled: boolean;
  62443. /**
  62444. * Blur level of the depth of field effect. (Higher blur will effect performance)
  62445. */
  62446. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  62447. /**
  62448. * If the anti aliasing is enabled.
  62449. */
  62450. fxaaEnabled: boolean;
  62451. private _samples;
  62452. /**
  62453. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  62454. */
  62455. samples: number;
  62456. /**
  62457. * If image processing is enabled.
  62458. */
  62459. imageProcessingEnabled: boolean;
  62460. /**
  62461. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  62462. */
  62463. glowLayerEnabled: boolean;
  62464. /**
  62465. * Gets the glow layer (or null if not defined)
  62466. */
  62467. readonly glowLayer: Nullable<GlowLayer>;
  62468. /**
  62469. * Enable or disable the chromaticAberration process from the pipeline
  62470. */
  62471. chromaticAberrationEnabled: boolean;
  62472. /**
  62473. * Enable or disable the grain process from the pipeline
  62474. */
  62475. grainEnabled: boolean;
  62476. /**
  62477. * @constructor
  62478. * @param name - The rendering pipeline name (default: "")
  62479. * @param hdr - If high dynamic range textures should be used (default: true)
  62480. * @param scene - The scene linked to this pipeline (default: the last created scene)
  62481. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  62482. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  62483. */
  62484. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  62485. /**
  62486. * Get the class name
  62487. * @returns "DefaultRenderingPipeline"
  62488. */
  62489. getClassName(): string;
  62490. /**
  62491. * Force the compilation of the entire pipeline.
  62492. */
  62493. prepare(): void;
  62494. private _hasCleared;
  62495. private _prevPostProcess;
  62496. private _prevPrevPostProcess;
  62497. private _setAutoClearAndTextureSharing;
  62498. private _depthOfFieldSceneObserver;
  62499. private _buildPipeline;
  62500. private _disposePostProcesses;
  62501. /**
  62502. * Adds a camera to the pipeline
  62503. * @param camera the camera to be added
  62504. */
  62505. addCamera(camera: Camera): void;
  62506. /**
  62507. * Removes a camera from the pipeline
  62508. * @param camera the camera to remove
  62509. */
  62510. removeCamera(camera: Camera): void;
  62511. /**
  62512. * Dispose of the pipeline and stop all post processes
  62513. */
  62514. dispose(): void;
  62515. /**
  62516. * Serialize the rendering pipeline (Used when exporting)
  62517. * @returns the serialized object
  62518. */
  62519. serialize(): any;
  62520. /**
  62521. * Parse the serialized pipeline
  62522. * @param source Source pipeline.
  62523. * @param scene The scene to load the pipeline to.
  62524. * @param rootUrl The URL of the serialized pipeline.
  62525. * @returns An instantiated pipeline from the serialized object.
  62526. */
  62527. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  62528. }
  62529. }
  62530. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  62531. /** @hidden */
  62532. export var lensHighlightsPixelShader: {
  62533. name: string;
  62534. shader: string;
  62535. };
  62536. }
  62537. declare module "babylonjs/Shaders/depthOfField.fragment" {
  62538. /** @hidden */
  62539. export var depthOfFieldPixelShader: {
  62540. name: string;
  62541. shader: string;
  62542. };
  62543. }
  62544. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  62545. import { Camera } from "babylonjs/Cameras/camera";
  62546. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62547. import { Scene } from "babylonjs/scene";
  62548. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62549. import "babylonjs/Shaders/chromaticAberration.fragment";
  62550. import "babylonjs/Shaders/lensHighlights.fragment";
  62551. import "babylonjs/Shaders/depthOfField.fragment";
  62552. /**
  62553. * BABYLON.JS Chromatic Aberration GLSL Shader
  62554. * Author: Olivier Guyot
  62555. * Separates very slightly R, G and B colors on the edges of the screen
  62556. * Inspired by Francois Tarlier & Martins Upitis
  62557. */
  62558. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  62559. /**
  62560. * @ignore
  62561. * The chromatic aberration PostProcess id in the pipeline
  62562. */
  62563. LensChromaticAberrationEffect: string;
  62564. /**
  62565. * @ignore
  62566. * The highlights enhancing PostProcess id in the pipeline
  62567. */
  62568. HighlightsEnhancingEffect: string;
  62569. /**
  62570. * @ignore
  62571. * The depth-of-field PostProcess id in the pipeline
  62572. */
  62573. LensDepthOfFieldEffect: string;
  62574. private _scene;
  62575. private _depthTexture;
  62576. private _grainTexture;
  62577. private _chromaticAberrationPostProcess;
  62578. private _highlightsPostProcess;
  62579. private _depthOfFieldPostProcess;
  62580. private _edgeBlur;
  62581. private _grainAmount;
  62582. private _chromaticAberration;
  62583. private _distortion;
  62584. private _highlightsGain;
  62585. private _highlightsThreshold;
  62586. private _dofDistance;
  62587. private _dofAperture;
  62588. private _dofDarken;
  62589. private _dofPentagon;
  62590. private _blurNoise;
  62591. /**
  62592. * @constructor
  62593. *
  62594. * Effect parameters are as follow:
  62595. * {
  62596. * chromatic_aberration: number; // from 0 to x (1 for realism)
  62597. * edge_blur: number; // from 0 to x (1 for realism)
  62598. * distortion: number; // from 0 to x (1 for realism)
  62599. * grain_amount: number; // from 0 to 1
  62600. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  62601. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  62602. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  62603. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  62604. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  62605. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  62606. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  62607. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  62608. * }
  62609. * Note: if an effect parameter is unset, effect is disabled
  62610. *
  62611. * @param name The rendering pipeline name
  62612. * @param parameters - An object containing all parameters (see above)
  62613. * @param scene The scene linked to this pipeline
  62614. * @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)
  62615. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62616. */
  62617. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  62618. /**
  62619. * Get the class name
  62620. * @returns "LensRenderingPipeline"
  62621. */
  62622. getClassName(): string;
  62623. /**
  62624. * Gets associated scene
  62625. */
  62626. readonly scene: Scene;
  62627. /**
  62628. * Gets or sets the edge blur
  62629. */
  62630. edgeBlur: number;
  62631. /**
  62632. * Gets or sets the grain amount
  62633. */
  62634. grainAmount: number;
  62635. /**
  62636. * Gets or sets the chromatic aberration amount
  62637. */
  62638. chromaticAberration: number;
  62639. /**
  62640. * Gets or sets the depth of field aperture
  62641. */
  62642. dofAperture: number;
  62643. /**
  62644. * Gets or sets the edge distortion
  62645. */
  62646. edgeDistortion: number;
  62647. /**
  62648. * Gets or sets the depth of field distortion
  62649. */
  62650. dofDistortion: number;
  62651. /**
  62652. * Gets or sets the darken out of focus amount
  62653. */
  62654. darkenOutOfFocus: number;
  62655. /**
  62656. * Gets or sets a boolean indicating if blur noise is enabled
  62657. */
  62658. blurNoise: boolean;
  62659. /**
  62660. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  62661. */
  62662. pentagonBokeh: boolean;
  62663. /**
  62664. * Gets or sets the highlight grain amount
  62665. */
  62666. highlightsGain: number;
  62667. /**
  62668. * Gets or sets the highlight threshold
  62669. */
  62670. highlightsThreshold: number;
  62671. /**
  62672. * Sets the amount of blur at the edges
  62673. * @param amount blur amount
  62674. */
  62675. setEdgeBlur(amount: number): void;
  62676. /**
  62677. * Sets edge blur to 0
  62678. */
  62679. disableEdgeBlur(): void;
  62680. /**
  62681. * Sets the amout of grain
  62682. * @param amount Amount of grain
  62683. */
  62684. setGrainAmount(amount: number): void;
  62685. /**
  62686. * Set grain amount to 0
  62687. */
  62688. disableGrain(): void;
  62689. /**
  62690. * Sets the chromatic aberration amount
  62691. * @param amount amount of chromatic aberration
  62692. */
  62693. setChromaticAberration(amount: number): void;
  62694. /**
  62695. * Sets chromatic aberration amount to 0
  62696. */
  62697. disableChromaticAberration(): void;
  62698. /**
  62699. * Sets the EdgeDistortion amount
  62700. * @param amount amount of EdgeDistortion
  62701. */
  62702. setEdgeDistortion(amount: number): void;
  62703. /**
  62704. * Sets edge distortion to 0
  62705. */
  62706. disableEdgeDistortion(): void;
  62707. /**
  62708. * Sets the FocusDistance amount
  62709. * @param amount amount of FocusDistance
  62710. */
  62711. setFocusDistance(amount: number): void;
  62712. /**
  62713. * Disables depth of field
  62714. */
  62715. disableDepthOfField(): void;
  62716. /**
  62717. * Sets the Aperture amount
  62718. * @param amount amount of Aperture
  62719. */
  62720. setAperture(amount: number): void;
  62721. /**
  62722. * Sets the DarkenOutOfFocus amount
  62723. * @param amount amount of DarkenOutOfFocus
  62724. */
  62725. setDarkenOutOfFocus(amount: number): void;
  62726. private _pentagonBokehIsEnabled;
  62727. /**
  62728. * Creates a pentagon bokeh effect
  62729. */
  62730. enablePentagonBokeh(): void;
  62731. /**
  62732. * Disables the pentagon bokeh effect
  62733. */
  62734. disablePentagonBokeh(): void;
  62735. /**
  62736. * Enables noise blur
  62737. */
  62738. enableNoiseBlur(): void;
  62739. /**
  62740. * Disables noise blur
  62741. */
  62742. disableNoiseBlur(): void;
  62743. /**
  62744. * Sets the HighlightsGain amount
  62745. * @param amount amount of HighlightsGain
  62746. */
  62747. setHighlightsGain(amount: number): void;
  62748. /**
  62749. * Sets the HighlightsThreshold amount
  62750. * @param amount amount of HighlightsThreshold
  62751. */
  62752. setHighlightsThreshold(amount: number): void;
  62753. /**
  62754. * Disables highlights
  62755. */
  62756. disableHighlights(): void;
  62757. /**
  62758. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  62759. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  62760. */
  62761. dispose(disableDepthRender?: boolean): void;
  62762. private _createChromaticAberrationPostProcess;
  62763. private _createHighlightsPostProcess;
  62764. private _createDepthOfFieldPostProcess;
  62765. private _createGrainTexture;
  62766. }
  62767. }
  62768. declare module "babylonjs/Shaders/ssao2.fragment" {
  62769. /** @hidden */
  62770. export var ssao2PixelShader: {
  62771. name: string;
  62772. shader: string;
  62773. };
  62774. }
  62775. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  62776. /** @hidden */
  62777. export var ssaoCombinePixelShader: {
  62778. name: string;
  62779. shader: string;
  62780. };
  62781. }
  62782. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  62783. import { Camera } from "babylonjs/Cameras/camera";
  62784. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62785. import { Scene } from "babylonjs/scene";
  62786. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62787. import "babylonjs/Shaders/ssao2.fragment";
  62788. import "babylonjs/Shaders/ssaoCombine.fragment";
  62789. /**
  62790. * Render pipeline to produce ssao effect
  62791. */
  62792. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  62793. /**
  62794. * @ignore
  62795. * The PassPostProcess id in the pipeline that contains the original scene color
  62796. */
  62797. SSAOOriginalSceneColorEffect: string;
  62798. /**
  62799. * @ignore
  62800. * The SSAO PostProcess id in the pipeline
  62801. */
  62802. SSAORenderEffect: string;
  62803. /**
  62804. * @ignore
  62805. * The horizontal blur PostProcess id in the pipeline
  62806. */
  62807. SSAOBlurHRenderEffect: string;
  62808. /**
  62809. * @ignore
  62810. * The vertical blur PostProcess id in the pipeline
  62811. */
  62812. SSAOBlurVRenderEffect: string;
  62813. /**
  62814. * @ignore
  62815. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62816. */
  62817. SSAOCombineRenderEffect: string;
  62818. /**
  62819. * The output strength of the SSAO post-process. Default value is 1.0.
  62820. */
  62821. totalStrength: number;
  62822. /**
  62823. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  62824. */
  62825. maxZ: number;
  62826. /**
  62827. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  62828. */
  62829. minZAspect: number;
  62830. private _samples;
  62831. /**
  62832. * Number of samples used for the SSAO calculations. Default value is 8
  62833. */
  62834. samples: number;
  62835. private _textureSamples;
  62836. /**
  62837. * Number of samples to use for antialiasing
  62838. */
  62839. textureSamples: number;
  62840. /**
  62841. * Ratio object used for SSAO ratio and blur ratio
  62842. */
  62843. private _ratio;
  62844. /**
  62845. * Dynamically generated sphere sampler.
  62846. */
  62847. private _sampleSphere;
  62848. /**
  62849. * Blur filter offsets
  62850. */
  62851. private _samplerOffsets;
  62852. private _expensiveBlur;
  62853. /**
  62854. * If bilateral blur should be used
  62855. */
  62856. expensiveBlur: boolean;
  62857. /**
  62858. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  62859. */
  62860. radius: number;
  62861. /**
  62862. * The base color of the SSAO post-process
  62863. * The final result is "base + ssao" between [0, 1]
  62864. */
  62865. base: number;
  62866. /**
  62867. * Support test.
  62868. */
  62869. static readonly IsSupported: boolean;
  62870. private _scene;
  62871. private _depthTexture;
  62872. private _normalTexture;
  62873. private _randomTexture;
  62874. private _originalColorPostProcess;
  62875. private _ssaoPostProcess;
  62876. private _blurHPostProcess;
  62877. private _blurVPostProcess;
  62878. private _ssaoCombinePostProcess;
  62879. private _firstUpdate;
  62880. /**
  62881. * Gets active scene
  62882. */
  62883. readonly scene: Scene;
  62884. /**
  62885. * @constructor
  62886. * @param name The rendering pipeline name
  62887. * @param scene The scene linked to this pipeline
  62888. * @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 }
  62889. * @param cameras The array of cameras that the rendering pipeline will be attached to
  62890. */
  62891. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  62892. /**
  62893. * Get the class name
  62894. * @returns "SSAO2RenderingPipeline"
  62895. */
  62896. getClassName(): string;
  62897. /**
  62898. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  62899. */
  62900. dispose(disableGeometryBufferRenderer?: boolean): void;
  62901. private _createBlurPostProcess;
  62902. /** @hidden */
  62903. _rebuild(): void;
  62904. private _bits;
  62905. private _radicalInverse_VdC;
  62906. private _hammersley;
  62907. private _hemisphereSample_uniform;
  62908. private _generateHemisphere;
  62909. private _createSSAOPostProcess;
  62910. private _createSSAOCombinePostProcess;
  62911. private _createRandomTexture;
  62912. /**
  62913. * Serialize the rendering pipeline (Used when exporting)
  62914. * @returns the serialized object
  62915. */
  62916. serialize(): any;
  62917. /**
  62918. * Parse the serialized pipeline
  62919. * @param source Source pipeline.
  62920. * @param scene The scene to load the pipeline to.
  62921. * @param rootUrl The URL of the serialized pipeline.
  62922. * @returns An instantiated pipeline from the serialized object.
  62923. */
  62924. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  62925. }
  62926. }
  62927. declare module "babylonjs/Shaders/ssao.fragment" {
  62928. /** @hidden */
  62929. export var ssaoPixelShader: {
  62930. name: string;
  62931. shader: string;
  62932. };
  62933. }
  62934. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  62935. import { Camera } from "babylonjs/Cameras/camera";
  62936. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  62937. import { Scene } from "babylonjs/scene";
  62938. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  62939. import "babylonjs/Shaders/ssao.fragment";
  62940. import "babylonjs/Shaders/ssaoCombine.fragment";
  62941. /**
  62942. * Render pipeline to produce ssao effect
  62943. */
  62944. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  62945. /**
  62946. * @ignore
  62947. * The PassPostProcess id in the pipeline that contains the original scene color
  62948. */
  62949. SSAOOriginalSceneColorEffect: string;
  62950. /**
  62951. * @ignore
  62952. * The SSAO PostProcess id in the pipeline
  62953. */
  62954. SSAORenderEffect: string;
  62955. /**
  62956. * @ignore
  62957. * The horizontal blur PostProcess id in the pipeline
  62958. */
  62959. SSAOBlurHRenderEffect: string;
  62960. /**
  62961. * @ignore
  62962. * The vertical blur PostProcess id in the pipeline
  62963. */
  62964. SSAOBlurVRenderEffect: string;
  62965. /**
  62966. * @ignore
  62967. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  62968. */
  62969. SSAOCombineRenderEffect: string;
  62970. /**
  62971. * The output strength of the SSAO post-process. Default value is 1.0.
  62972. */
  62973. totalStrength: number;
  62974. /**
  62975. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  62976. */
  62977. radius: number;
  62978. /**
  62979. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  62980. * Must not be equal to fallOff and superior to fallOff.
  62981. * Default value is 0.0075
  62982. */
  62983. area: number;
  62984. /**
  62985. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  62986. * Must not be equal to area and inferior to area.
  62987. * Default value is 0.000001
  62988. */
  62989. fallOff: number;
  62990. /**
  62991. * The base color of the SSAO post-process
  62992. * The final result is "base + ssao" between [0, 1]
  62993. */
  62994. base: number;
  62995. private _scene;
  62996. private _depthTexture;
  62997. private _randomTexture;
  62998. private _originalColorPostProcess;
  62999. private _ssaoPostProcess;
  63000. private _blurHPostProcess;
  63001. private _blurVPostProcess;
  63002. private _ssaoCombinePostProcess;
  63003. private _firstUpdate;
  63004. /**
  63005. * Gets active scene
  63006. */
  63007. readonly scene: Scene;
  63008. /**
  63009. * @constructor
  63010. * @param name - The rendering pipeline name
  63011. * @param scene - The scene linked to this pipeline
  63012. * @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 }
  63013. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63014. */
  63015. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63016. /**
  63017. * Get the class name
  63018. * @returns "SSAORenderingPipeline"
  63019. */
  63020. getClassName(): string;
  63021. /**
  63022. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63023. */
  63024. dispose(disableDepthRender?: boolean): void;
  63025. private _createBlurPostProcess;
  63026. /** @hidden */
  63027. _rebuild(): void;
  63028. private _createSSAOPostProcess;
  63029. private _createSSAOCombinePostProcess;
  63030. private _createRandomTexture;
  63031. }
  63032. }
  63033. declare module "babylonjs/Shaders/standard.fragment" {
  63034. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63035. /** @hidden */
  63036. export var standardPixelShader: {
  63037. name: string;
  63038. shader: string;
  63039. };
  63040. }
  63041. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  63042. import { Nullable } from "babylonjs/types";
  63043. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63044. import { Camera } from "babylonjs/Cameras/camera";
  63045. import { Texture } from "babylonjs/Materials/Textures/texture";
  63046. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63047. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63048. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63049. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63050. import { IDisposable } from "babylonjs/scene";
  63051. import { SpotLight } from "babylonjs/Lights/spotLight";
  63052. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63053. import { Scene } from "babylonjs/scene";
  63054. import { Animation } from "babylonjs/Animations/animation";
  63055. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63056. import "babylonjs/Shaders/standard.fragment";
  63057. /**
  63058. * Standard rendering pipeline
  63059. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63060. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  63061. */
  63062. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63063. /**
  63064. * Public members
  63065. */
  63066. /**
  63067. * Post-process which contains the original scene color before the pipeline applies all the effects
  63068. */
  63069. originalPostProcess: Nullable<PostProcess>;
  63070. /**
  63071. * Post-process used to down scale an image x4
  63072. */
  63073. downSampleX4PostProcess: Nullable<PostProcess>;
  63074. /**
  63075. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  63076. */
  63077. brightPassPostProcess: Nullable<PostProcess>;
  63078. /**
  63079. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  63080. */
  63081. blurHPostProcesses: PostProcess[];
  63082. /**
  63083. * Post-process array storing all the vertical blur post-processes used by the pipeline
  63084. */
  63085. blurVPostProcesses: PostProcess[];
  63086. /**
  63087. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  63088. */
  63089. textureAdderPostProcess: Nullable<PostProcess>;
  63090. /**
  63091. * Post-process used to create volumetric lighting effect
  63092. */
  63093. volumetricLightPostProcess: Nullable<PostProcess>;
  63094. /**
  63095. * Post-process used to smooth the previous volumetric light post-process on the X axis
  63096. */
  63097. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  63098. /**
  63099. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  63100. */
  63101. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  63102. /**
  63103. * Post-process used to merge the volumetric light effect and the real scene color
  63104. */
  63105. volumetricLightMergePostProces: Nullable<PostProcess>;
  63106. /**
  63107. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  63108. */
  63109. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  63110. /**
  63111. * Base post-process used to calculate the average luminance of the final image for HDR
  63112. */
  63113. luminancePostProcess: Nullable<PostProcess>;
  63114. /**
  63115. * Post-processes used to create down sample post-processes in order to get
  63116. * the average luminance of the final image for HDR
  63117. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  63118. */
  63119. luminanceDownSamplePostProcesses: PostProcess[];
  63120. /**
  63121. * Post-process used to create a HDR effect (light adaptation)
  63122. */
  63123. hdrPostProcess: Nullable<PostProcess>;
  63124. /**
  63125. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  63126. */
  63127. textureAdderFinalPostProcess: Nullable<PostProcess>;
  63128. /**
  63129. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  63130. */
  63131. lensFlareFinalPostProcess: Nullable<PostProcess>;
  63132. /**
  63133. * Post-process used to merge the final HDR post-process and the real scene color
  63134. */
  63135. hdrFinalPostProcess: Nullable<PostProcess>;
  63136. /**
  63137. * Post-process used to create a lens flare effect
  63138. */
  63139. lensFlarePostProcess: Nullable<PostProcess>;
  63140. /**
  63141. * Post-process that merges the result of the lens flare post-process and the real scene color
  63142. */
  63143. lensFlareComposePostProcess: Nullable<PostProcess>;
  63144. /**
  63145. * Post-process used to create a motion blur effect
  63146. */
  63147. motionBlurPostProcess: Nullable<PostProcess>;
  63148. /**
  63149. * Post-process used to create a depth of field effect
  63150. */
  63151. depthOfFieldPostProcess: Nullable<PostProcess>;
  63152. /**
  63153. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63154. */
  63155. fxaaPostProcess: Nullable<FxaaPostProcess>;
  63156. /**
  63157. * Represents the brightness threshold in order to configure the illuminated surfaces
  63158. */
  63159. brightThreshold: number;
  63160. /**
  63161. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  63162. */
  63163. blurWidth: number;
  63164. /**
  63165. * Sets if the blur for highlighted surfaces must be only horizontal
  63166. */
  63167. horizontalBlur: boolean;
  63168. /**
  63169. * Gets the overall exposure used by the pipeline
  63170. */
  63171. /**
  63172. * Sets the overall exposure used by the pipeline
  63173. */
  63174. exposure: number;
  63175. /**
  63176. * Texture used typically to simulate "dirty" on camera lens
  63177. */
  63178. lensTexture: Nullable<Texture>;
  63179. /**
  63180. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  63181. */
  63182. volumetricLightCoefficient: number;
  63183. /**
  63184. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  63185. */
  63186. volumetricLightPower: number;
  63187. /**
  63188. * Used the set the blur intensity to smooth the volumetric lights
  63189. */
  63190. volumetricLightBlurScale: number;
  63191. /**
  63192. * Light (spot or directional) used to generate the volumetric lights rays
  63193. * The source light must have a shadow generate so the pipeline can get its
  63194. * depth map
  63195. */
  63196. sourceLight: Nullable<SpotLight | DirectionalLight>;
  63197. /**
  63198. * For eye adaptation, represents the minimum luminance the eye can see
  63199. */
  63200. hdrMinimumLuminance: number;
  63201. /**
  63202. * For eye adaptation, represents the decrease luminance speed
  63203. */
  63204. hdrDecreaseRate: number;
  63205. /**
  63206. * For eye adaptation, represents the increase luminance speed
  63207. */
  63208. hdrIncreaseRate: number;
  63209. /**
  63210. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63211. */
  63212. /**
  63213. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  63214. */
  63215. hdrAutoExposure: boolean;
  63216. /**
  63217. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  63218. */
  63219. lensColorTexture: Nullable<Texture>;
  63220. /**
  63221. * The overall strengh for the lens flare effect
  63222. */
  63223. lensFlareStrength: number;
  63224. /**
  63225. * Dispersion coefficient for lens flare ghosts
  63226. */
  63227. lensFlareGhostDispersal: number;
  63228. /**
  63229. * Main lens flare halo width
  63230. */
  63231. lensFlareHaloWidth: number;
  63232. /**
  63233. * Based on the lens distortion effect, defines how much the lens flare result
  63234. * is distorted
  63235. */
  63236. lensFlareDistortionStrength: number;
  63237. /**
  63238. * Configures the blur intensity used for for lens flare (halo)
  63239. */
  63240. lensFlareBlurWidth: number;
  63241. /**
  63242. * Lens star texture must be used to simulate rays on the flares and is available
  63243. * in the documentation
  63244. */
  63245. lensStarTexture: Nullable<Texture>;
  63246. /**
  63247. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  63248. * flare effect by taking account of the dirt texture
  63249. */
  63250. lensFlareDirtTexture: Nullable<Texture>;
  63251. /**
  63252. * Represents the focal length for the depth of field effect
  63253. */
  63254. depthOfFieldDistance: number;
  63255. /**
  63256. * Represents the blur intensity for the blurred part of the depth of field effect
  63257. */
  63258. depthOfFieldBlurWidth: number;
  63259. /**
  63260. * Gets how much the image is blurred by the movement while using the motion blur post-process
  63261. */
  63262. /**
  63263. * Sets how much the image is blurred by the movement while using the motion blur post-process
  63264. */
  63265. motionStrength: number;
  63266. /**
  63267. * Gets wether or not the motion blur post-process is object based or screen based.
  63268. */
  63269. /**
  63270. * Sets wether or not the motion blur post-process should be object based or screen based
  63271. */
  63272. objectBasedMotionBlur: boolean;
  63273. /**
  63274. * List of animations for the pipeline (IAnimatable implementation)
  63275. */
  63276. animations: Animation[];
  63277. /**
  63278. * Private members
  63279. */
  63280. private _scene;
  63281. private _currentDepthOfFieldSource;
  63282. private _basePostProcess;
  63283. private _fixedExposure;
  63284. private _currentExposure;
  63285. private _hdrAutoExposure;
  63286. private _hdrCurrentLuminance;
  63287. private _motionStrength;
  63288. private _isObjectBasedMotionBlur;
  63289. private _floatTextureType;
  63290. private _camerasToBeAttached;
  63291. private _ratio;
  63292. private _bloomEnabled;
  63293. private _depthOfFieldEnabled;
  63294. private _vlsEnabled;
  63295. private _lensFlareEnabled;
  63296. private _hdrEnabled;
  63297. private _motionBlurEnabled;
  63298. private _fxaaEnabled;
  63299. private _motionBlurSamples;
  63300. private _volumetricLightStepsCount;
  63301. private _samples;
  63302. /**
  63303. * @ignore
  63304. * Specifies if the bloom pipeline is enabled
  63305. */
  63306. BloomEnabled: boolean;
  63307. /**
  63308. * @ignore
  63309. * Specifies if the depth of field pipeline is enabed
  63310. */
  63311. DepthOfFieldEnabled: boolean;
  63312. /**
  63313. * @ignore
  63314. * Specifies if the lens flare pipeline is enabed
  63315. */
  63316. LensFlareEnabled: boolean;
  63317. /**
  63318. * @ignore
  63319. * Specifies if the HDR pipeline is enabled
  63320. */
  63321. HDREnabled: boolean;
  63322. /**
  63323. * @ignore
  63324. * Specifies if the volumetric lights scattering effect is enabled
  63325. */
  63326. VLSEnabled: boolean;
  63327. /**
  63328. * @ignore
  63329. * Specifies if the motion blur effect is enabled
  63330. */
  63331. MotionBlurEnabled: boolean;
  63332. /**
  63333. * Specifies if anti-aliasing is enabled
  63334. */
  63335. fxaaEnabled: boolean;
  63336. /**
  63337. * Specifies the number of steps used to calculate the volumetric lights
  63338. * Typically in interval [50, 200]
  63339. */
  63340. volumetricLightStepsCount: number;
  63341. /**
  63342. * Specifies the number of samples used for the motion blur effect
  63343. * Typically in interval [16, 64]
  63344. */
  63345. motionBlurSamples: number;
  63346. /**
  63347. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63348. */
  63349. samples: number;
  63350. /**
  63351. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63352. * @constructor
  63353. * @param name The rendering pipeline name
  63354. * @param scene The scene linked to this pipeline
  63355. * @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)
  63356. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  63357. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63358. */
  63359. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  63360. private _buildPipeline;
  63361. private _createDownSampleX4PostProcess;
  63362. private _createBrightPassPostProcess;
  63363. private _createBlurPostProcesses;
  63364. private _createTextureAdderPostProcess;
  63365. private _createVolumetricLightPostProcess;
  63366. private _createLuminancePostProcesses;
  63367. private _createHdrPostProcess;
  63368. private _createLensFlarePostProcess;
  63369. private _createDepthOfFieldPostProcess;
  63370. private _createMotionBlurPostProcess;
  63371. private _getDepthTexture;
  63372. private _disposePostProcesses;
  63373. /**
  63374. * Dispose of the pipeline and stop all post processes
  63375. */
  63376. dispose(): void;
  63377. /**
  63378. * Serialize the rendering pipeline (Used when exporting)
  63379. * @returns the serialized object
  63380. */
  63381. serialize(): any;
  63382. /**
  63383. * Parse the serialized pipeline
  63384. * @param source Source pipeline.
  63385. * @param scene The scene to load the pipeline to.
  63386. * @param rootUrl The URL of the serialized pipeline.
  63387. * @returns An instantiated pipeline from the serialized object.
  63388. */
  63389. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  63390. /**
  63391. * Luminance steps
  63392. */
  63393. static LuminanceSteps: number;
  63394. }
  63395. }
  63396. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  63397. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  63398. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  63399. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  63400. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  63401. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  63402. }
  63403. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  63404. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  63405. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63406. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63407. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63408. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63409. }
  63410. declare module "babylonjs/Shaders/tonemap.fragment" {
  63411. /** @hidden */
  63412. export var tonemapPixelShader: {
  63413. name: string;
  63414. shader: string;
  63415. };
  63416. }
  63417. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  63418. import { Camera } from "babylonjs/Cameras/camera";
  63419. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63420. import "babylonjs/Shaders/tonemap.fragment";
  63421. import { Engine } from "babylonjs/Engines/engine";
  63422. /** Defines operator used for tonemapping */
  63423. export enum TonemappingOperator {
  63424. /** Hable */
  63425. Hable = 0,
  63426. /** Reinhard */
  63427. Reinhard = 1,
  63428. /** HejiDawson */
  63429. HejiDawson = 2,
  63430. /** Photographic */
  63431. Photographic = 3
  63432. }
  63433. /**
  63434. * Defines a post process to apply tone mapping
  63435. */
  63436. export class TonemapPostProcess extends PostProcess {
  63437. private _operator;
  63438. /** Defines the required exposure adjustement */
  63439. exposureAdjustment: number;
  63440. /**
  63441. * Creates a new TonemapPostProcess
  63442. * @param name defines the name of the postprocess
  63443. * @param _operator defines the operator to use
  63444. * @param exposureAdjustment defines the required exposure adjustement
  63445. * @param camera defines the camera to use (can be null)
  63446. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  63447. * @param engine defines the hosting engine (can be ignore if camera is set)
  63448. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63449. */
  63450. constructor(name: string, _operator: TonemappingOperator,
  63451. /** Defines the required exposure adjustement */
  63452. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  63453. }
  63454. }
  63455. declare module "babylonjs/Shaders/depth.vertex" {
  63456. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63457. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63458. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63459. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63460. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63461. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63462. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63463. /** @hidden */
  63464. export var depthVertexShader: {
  63465. name: string;
  63466. shader: string;
  63467. };
  63468. }
  63469. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  63470. /** @hidden */
  63471. export var volumetricLightScatteringPixelShader: {
  63472. name: string;
  63473. shader: string;
  63474. };
  63475. }
  63476. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  63477. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63478. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63479. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63480. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63481. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63482. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63483. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63484. /** @hidden */
  63485. export var volumetricLightScatteringPassVertexShader: {
  63486. name: string;
  63487. shader: string;
  63488. };
  63489. }
  63490. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  63491. /** @hidden */
  63492. export var volumetricLightScatteringPassPixelShader: {
  63493. name: string;
  63494. shader: string;
  63495. };
  63496. }
  63497. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  63498. import { Vector3 } from "babylonjs/Maths/math.vector";
  63499. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63500. import { Mesh } from "babylonjs/Meshes/mesh";
  63501. import { Camera } from "babylonjs/Cameras/camera";
  63502. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63503. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63504. import { Scene } from "babylonjs/scene";
  63505. import "babylonjs/Meshes/Builders/planeBuilder";
  63506. import "babylonjs/Shaders/depth.vertex";
  63507. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  63508. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  63509. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  63510. import { Engine } from "babylonjs/Engines/engine";
  63511. /**
  63512. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  63513. */
  63514. export class VolumetricLightScatteringPostProcess extends PostProcess {
  63515. private _volumetricLightScatteringPass;
  63516. private _volumetricLightScatteringRTT;
  63517. private _viewPort;
  63518. private _screenCoordinates;
  63519. private _cachedDefines;
  63520. /**
  63521. * If not undefined, the mesh position is computed from the attached node position
  63522. */
  63523. attachedNode: {
  63524. position: Vector3;
  63525. };
  63526. /**
  63527. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  63528. */
  63529. customMeshPosition: Vector3;
  63530. /**
  63531. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  63532. */
  63533. useCustomMeshPosition: boolean;
  63534. /**
  63535. * If the post-process should inverse the light scattering direction
  63536. */
  63537. invert: boolean;
  63538. /**
  63539. * The internal mesh used by the post-process
  63540. */
  63541. mesh: Mesh;
  63542. /**
  63543. * @hidden
  63544. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  63545. */
  63546. useDiffuseColor: boolean;
  63547. /**
  63548. * Array containing the excluded meshes not rendered in the internal pass
  63549. */
  63550. excludedMeshes: AbstractMesh[];
  63551. /**
  63552. * Controls the overall intensity of the post-process
  63553. */
  63554. exposure: number;
  63555. /**
  63556. * Dissipates each sample's contribution in range [0, 1]
  63557. */
  63558. decay: number;
  63559. /**
  63560. * Controls the overall intensity of each sample
  63561. */
  63562. weight: number;
  63563. /**
  63564. * Controls the density of each sample
  63565. */
  63566. density: number;
  63567. /**
  63568. * @constructor
  63569. * @param name The post-process name
  63570. * @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)
  63571. * @param camera The camera that the post-process will be attached to
  63572. * @param mesh The mesh used to create the light scattering
  63573. * @param samples The post-process quality, default 100
  63574. * @param samplingModeThe post-process filtering mode
  63575. * @param engine The babylon engine
  63576. * @param reusable If the post-process is reusable
  63577. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  63578. */
  63579. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  63580. /**
  63581. * Returns the string "VolumetricLightScatteringPostProcess"
  63582. * @returns "VolumetricLightScatteringPostProcess"
  63583. */
  63584. getClassName(): string;
  63585. private _isReady;
  63586. /**
  63587. * Sets the new light position for light scattering effect
  63588. * @param position The new custom light position
  63589. */
  63590. setCustomMeshPosition(position: Vector3): void;
  63591. /**
  63592. * Returns the light position for light scattering effect
  63593. * @return Vector3 The custom light position
  63594. */
  63595. getCustomMeshPosition(): Vector3;
  63596. /**
  63597. * Disposes the internal assets and detaches the post-process from the camera
  63598. */
  63599. dispose(camera: Camera): void;
  63600. /**
  63601. * Returns the render target texture used by the post-process
  63602. * @return the render target texture used by the post-process
  63603. */
  63604. getPass(): RenderTargetTexture;
  63605. private _meshExcluded;
  63606. private _createPass;
  63607. private _updateMeshScreenCoordinates;
  63608. /**
  63609. * Creates a default mesh for the Volumeric Light Scattering post-process
  63610. * @param name The mesh name
  63611. * @param scene The scene where to create the mesh
  63612. * @return the default mesh
  63613. */
  63614. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  63615. }
  63616. }
  63617. declare module "babylonjs/PostProcesses/index" {
  63618. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  63619. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  63620. export * from "babylonjs/PostProcesses/bloomEffect";
  63621. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  63622. export * from "babylonjs/PostProcesses/blurPostProcess";
  63623. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63624. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  63625. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  63626. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  63627. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  63628. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  63629. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  63630. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  63631. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  63632. export * from "babylonjs/PostProcesses/filterPostProcess";
  63633. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  63634. export * from "babylonjs/PostProcesses/grainPostProcess";
  63635. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  63636. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63637. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  63638. export * from "babylonjs/PostProcesses/passPostProcess";
  63639. export * from "babylonjs/PostProcesses/postProcess";
  63640. export * from "babylonjs/PostProcesses/postProcessManager";
  63641. export * from "babylonjs/PostProcesses/refractionPostProcess";
  63642. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  63643. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  63644. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  63645. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  63646. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  63647. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  63648. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  63649. }
  63650. declare module "babylonjs/Probes/index" {
  63651. export * from "babylonjs/Probes/reflectionProbe";
  63652. }
  63653. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  63654. import { Scene } from "babylonjs/scene";
  63655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63656. import { SmartArray } from "babylonjs/Misc/smartArray";
  63657. import { ISceneComponent } from "babylonjs/sceneComponent";
  63658. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  63659. import "babylonjs/Meshes/Builders/boxBuilder";
  63660. import "babylonjs/Shaders/color.fragment";
  63661. import "babylonjs/Shaders/color.vertex";
  63662. import { Color3 } from "babylonjs/Maths/math.color";
  63663. module "babylonjs/scene" {
  63664. interface Scene {
  63665. /** @hidden (Backing field) */
  63666. _boundingBoxRenderer: BoundingBoxRenderer;
  63667. /** @hidden (Backing field) */
  63668. _forceShowBoundingBoxes: boolean;
  63669. /**
  63670. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  63671. */
  63672. forceShowBoundingBoxes: boolean;
  63673. /**
  63674. * Gets the bounding box renderer associated with the scene
  63675. * @returns a BoundingBoxRenderer
  63676. */
  63677. getBoundingBoxRenderer(): BoundingBoxRenderer;
  63678. }
  63679. }
  63680. module "babylonjs/Meshes/abstractMesh" {
  63681. interface AbstractMesh {
  63682. /** @hidden (Backing field) */
  63683. _showBoundingBox: boolean;
  63684. /**
  63685. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  63686. */
  63687. showBoundingBox: boolean;
  63688. }
  63689. }
  63690. /**
  63691. * Component responsible of rendering the bounding box of the meshes in a scene.
  63692. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  63693. */
  63694. export class BoundingBoxRenderer implements ISceneComponent {
  63695. /**
  63696. * The component name helpfull to identify the component in the list of scene components.
  63697. */
  63698. readonly name: string;
  63699. /**
  63700. * The scene the component belongs to.
  63701. */
  63702. scene: Scene;
  63703. /**
  63704. * Color of the bounding box lines placed in front of an object
  63705. */
  63706. frontColor: Color3;
  63707. /**
  63708. * Color of the bounding box lines placed behind an object
  63709. */
  63710. backColor: Color3;
  63711. /**
  63712. * Defines if the renderer should show the back lines or not
  63713. */
  63714. showBackLines: boolean;
  63715. /**
  63716. * @hidden
  63717. */
  63718. renderList: SmartArray<BoundingBox>;
  63719. private _colorShader;
  63720. private _vertexBuffers;
  63721. private _indexBuffer;
  63722. private _fillIndexBuffer;
  63723. private _fillIndexData;
  63724. /**
  63725. * Instantiates a new bounding box renderer in a scene.
  63726. * @param scene the scene the renderer renders in
  63727. */
  63728. constructor(scene: Scene);
  63729. /**
  63730. * Registers the component in a given scene
  63731. */
  63732. register(): void;
  63733. private _evaluateSubMesh;
  63734. private _activeMesh;
  63735. private _prepareRessources;
  63736. private _createIndexBuffer;
  63737. /**
  63738. * Rebuilds the elements related to this component in case of
  63739. * context lost for instance.
  63740. */
  63741. rebuild(): void;
  63742. /**
  63743. * @hidden
  63744. */
  63745. reset(): void;
  63746. /**
  63747. * Render the bounding boxes of a specific rendering group
  63748. * @param renderingGroupId defines the rendering group to render
  63749. */
  63750. render(renderingGroupId: number): void;
  63751. /**
  63752. * In case of occlusion queries, we can render the occlusion bounding box through this method
  63753. * @param mesh Define the mesh to render the occlusion bounding box for
  63754. */
  63755. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  63756. /**
  63757. * Dispose and release the resources attached to this renderer.
  63758. */
  63759. dispose(): void;
  63760. }
  63761. }
  63762. declare module "babylonjs/Shaders/depth.fragment" {
  63763. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63764. /** @hidden */
  63765. export var depthPixelShader: {
  63766. name: string;
  63767. shader: string;
  63768. };
  63769. }
  63770. declare module "babylonjs/Rendering/depthRenderer" {
  63771. import { Nullable } from "babylonjs/types";
  63772. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63773. import { Scene } from "babylonjs/scene";
  63774. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63775. import { Camera } from "babylonjs/Cameras/camera";
  63776. import "babylonjs/Shaders/depth.fragment";
  63777. import "babylonjs/Shaders/depth.vertex";
  63778. /**
  63779. * This represents a depth renderer in Babylon.
  63780. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63781. */
  63782. export class DepthRenderer {
  63783. private _scene;
  63784. private _depthMap;
  63785. private _effect;
  63786. private readonly _storeNonLinearDepth;
  63787. private readonly _clearColor;
  63788. /** Get if the depth renderer is using packed depth or not */
  63789. readonly isPacked: boolean;
  63790. private _cachedDefines;
  63791. private _camera;
  63792. /**
  63793. * Specifiess that the depth renderer will only be used within
  63794. * the camera it is created for.
  63795. * This can help forcing its rendering during the camera processing.
  63796. */
  63797. useOnlyInActiveCamera: boolean;
  63798. /** @hidden */
  63799. static _SceneComponentInitialization: (scene: Scene) => void;
  63800. /**
  63801. * Instantiates a depth renderer
  63802. * @param scene The scene the renderer belongs to
  63803. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63804. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63805. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63806. */
  63807. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63808. /**
  63809. * Creates the depth rendering effect and checks if the effect is ready.
  63810. * @param subMesh The submesh to be used to render the depth map of
  63811. * @param useInstances If multiple world instances should be used
  63812. * @returns if the depth renderer is ready to render the depth map
  63813. */
  63814. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63815. /**
  63816. * Gets the texture which the depth map will be written to.
  63817. * @returns The depth map texture
  63818. */
  63819. getDepthMap(): RenderTargetTexture;
  63820. /**
  63821. * Disposes of the depth renderer.
  63822. */
  63823. dispose(): void;
  63824. }
  63825. }
  63826. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  63827. import { Nullable } from "babylonjs/types";
  63828. import { Scene } from "babylonjs/scene";
  63829. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63830. import { Camera } from "babylonjs/Cameras/camera";
  63831. import { ISceneComponent } from "babylonjs/sceneComponent";
  63832. module "babylonjs/scene" {
  63833. interface Scene {
  63834. /** @hidden (Backing field) */
  63835. _depthRenderer: {
  63836. [id: string]: DepthRenderer;
  63837. };
  63838. /**
  63839. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  63840. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  63841. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63842. * @returns the created depth renderer
  63843. */
  63844. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  63845. /**
  63846. * Disables a depth renderer for a given camera
  63847. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  63848. */
  63849. disableDepthRenderer(camera?: Nullable<Camera>): void;
  63850. }
  63851. }
  63852. /**
  63853. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  63854. * in several rendering techniques.
  63855. */
  63856. export class DepthRendererSceneComponent implements ISceneComponent {
  63857. /**
  63858. * The component name helpfull to identify the component in the list of scene components.
  63859. */
  63860. readonly name: string;
  63861. /**
  63862. * The scene the component belongs to.
  63863. */
  63864. scene: Scene;
  63865. /**
  63866. * Creates a new instance of the component for the given scene
  63867. * @param scene Defines the scene to register the component in
  63868. */
  63869. constructor(scene: Scene);
  63870. /**
  63871. * Registers the component in a given scene
  63872. */
  63873. register(): void;
  63874. /**
  63875. * Rebuilds the elements related to this component in case of
  63876. * context lost for instance.
  63877. */
  63878. rebuild(): void;
  63879. /**
  63880. * Disposes the component and the associated ressources
  63881. */
  63882. dispose(): void;
  63883. private _gatherRenderTargets;
  63884. private _gatherActiveCameraRenderTargets;
  63885. }
  63886. }
  63887. declare module "babylonjs/Shaders/outline.fragment" {
  63888. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63889. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  63890. /** @hidden */
  63891. export var outlinePixelShader: {
  63892. name: string;
  63893. shader: string;
  63894. };
  63895. }
  63896. declare module "babylonjs/Shaders/outline.vertex" {
  63897. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63898. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63899. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63900. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63901. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  63902. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63903. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63904. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63905. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  63906. /** @hidden */
  63907. export var outlineVertexShader: {
  63908. name: string;
  63909. shader: string;
  63910. };
  63911. }
  63912. declare module "babylonjs/Rendering/outlineRenderer" {
  63913. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63914. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  63915. import { Scene } from "babylonjs/scene";
  63916. import { ISceneComponent } from "babylonjs/sceneComponent";
  63917. import "babylonjs/Shaders/outline.fragment";
  63918. import "babylonjs/Shaders/outline.vertex";
  63919. module "babylonjs/scene" {
  63920. interface Scene {
  63921. /** @hidden */
  63922. _outlineRenderer: OutlineRenderer;
  63923. /**
  63924. * Gets the outline renderer associated with the scene
  63925. * @returns a OutlineRenderer
  63926. */
  63927. getOutlineRenderer(): OutlineRenderer;
  63928. }
  63929. }
  63930. module "babylonjs/Meshes/abstractMesh" {
  63931. interface AbstractMesh {
  63932. /** @hidden (Backing field) */
  63933. _renderOutline: boolean;
  63934. /**
  63935. * Gets or sets a boolean indicating if the outline must be rendered as well
  63936. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  63937. */
  63938. renderOutline: boolean;
  63939. /** @hidden (Backing field) */
  63940. _renderOverlay: boolean;
  63941. /**
  63942. * Gets or sets a boolean indicating if the overlay must be rendered as well
  63943. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  63944. */
  63945. renderOverlay: boolean;
  63946. }
  63947. }
  63948. /**
  63949. * This class is responsible to draw bothe outline/overlay of meshes.
  63950. * It should not be used directly but through the available method on mesh.
  63951. */
  63952. export class OutlineRenderer implements ISceneComponent {
  63953. /**
  63954. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  63955. */
  63956. private static _StencilReference;
  63957. /**
  63958. * The name of the component. Each component must have a unique name.
  63959. */
  63960. name: string;
  63961. /**
  63962. * The scene the component belongs to.
  63963. */
  63964. scene: Scene;
  63965. /**
  63966. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  63967. */
  63968. zOffset: number;
  63969. private _engine;
  63970. private _effect;
  63971. private _cachedDefines;
  63972. private _savedDepthWrite;
  63973. /**
  63974. * Instantiates a new outline renderer. (There could be only one per scene).
  63975. * @param scene Defines the scene it belongs to
  63976. */
  63977. constructor(scene: Scene);
  63978. /**
  63979. * Register the component to one instance of a scene.
  63980. */
  63981. register(): void;
  63982. /**
  63983. * Rebuilds the elements related to this component in case of
  63984. * context lost for instance.
  63985. */
  63986. rebuild(): void;
  63987. /**
  63988. * Disposes the component and the associated ressources.
  63989. */
  63990. dispose(): void;
  63991. /**
  63992. * Renders the outline in the canvas.
  63993. * @param subMesh Defines the sumesh to render
  63994. * @param batch Defines the batch of meshes in case of instances
  63995. * @param useOverlay Defines if the rendering is for the overlay or the outline
  63996. */
  63997. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  63998. /**
  63999. * Returns whether or not the outline renderer is ready for a given submesh.
  64000. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64001. * @param subMesh Defines the submesh to check readyness for
  64002. * @param useInstances Defines wheter wee are trying to render instances or not
  64003. * @returns true if ready otherwise false
  64004. */
  64005. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64006. private _beforeRenderingMesh;
  64007. private _afterRenderingMesh;
  64008. }
  64009. }
  64010. declare module "babylonjs/Rendering/index" {
  64011. export * from "babylonjs/Rendering/boundingBoxRenderer";
  64012. export * from "babylonjs/Rendering/depthRenderer";
  64013. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  64014. export * from "babylonjs/Rendering/edgesRenderer";
  64015. export * from "babylonjs/Rendering/geometryBufferRenderer";
  64016. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64017. export * from "babylonjs/Rendering/outlineRenderer";
  64018. export * from "babylonjs/Rendering/renderingGroup";
  64019. export * from "babylonjs/Rendering/renderingManager";
  64020. export * from "babylonjs/Rendering/utilityLayerRenderer";
  64021. }
  64022. declare module "babylonjs/Sprites/spritePackedManager" {
  64023. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  64024. import { Scene } from "babylonjs/scene";
  64025. /**
  64026. * Class used to manage multiple sprites of different sizes on the same spritesheet
  64027. * @see http://doc.babylonjs.com/babylon101/sprites
  64028. */
  64029. export class SpritePackedManager extends SpriteManager {
  64030. /** defines the packed manager's name */
  64031. name: string;
  64032. /**
  64033. * Creates a new sprite manager from a packed sprite sheet
  64034. * @param name defines the manager's name
  64035. * @param imgUrl defines the sprite sheet url
  64036. * @param capacity defines the maximum allowed number of sprites
  64037. * @param scene defines the hosting scene
  64038. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  64039. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  64040. * @param samplingMode defines the smapling mode to use with spritesheet
  64041. * @param fromPacked set to true; do not alter
  64042. */
  64043. constructor(
  64044. /** defines the packed manager's name */
  64045. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  64046. }
  64047. }
  64048. declare module "babylonjs/Sprites/index" {
  64049. export * from "babylonjs/Sprites/sprite";
  64050. export * from "babylonjs/Sprites/spriteManager";
  64051. export * from "babylonjs/Sprites/spritePackedManager";
  64052. export * from "babylonjs/Sprites/spriteSceneComponent";
  64053. }
  64054. declare module "babylonjs/Misc/assetsManager" {
  64055. import { Scene } from "babylonjs/scene";
  64056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64057. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64058. import { Skeleton } from "babylonjs/Bones/skeleton";
  64059. import { Observable } from "babylonjs/Misc/observable";
  64060. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64061. import { Texture } from "babylonjs/Materials/Textures/texture";
  64062. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64063. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  64064. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64065. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  64066. /**
  64067. * Defines the list of states available for a task inside a AssetsManager
  64068. */
  64069. export enum AssetTaskState {
  64070. /**
  64071. * Initialization
  64072. */
  64073. INIT = 0,
  64074. /**
  64075. * Running
  64076. */
  64077. RUNNING = 1,
  64078. /**
  64079. * Done
  64080. */
  64081. DONE = 2,
  64082. /**
  64083. * Error
  64084. */
  64085. ERROR = 3
  64086. }
  64087. /**
  64088. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  64089. */
  64090. export abstract class AbstractAssetTask {
  64091. /**
  64092. * Task name
  64093. */ name: string;
  64094. /**
  64095. * Callback called when the task is successful
  64096. */
  64097. onSuccess: (task: any) => void;
  64098. /**
  64099. * Callback called when the task is not successful
  64100. */
  64101. onError: (task: any, message?: string, exception?: any) => void;
  64102. /**
  64103. * Creates a new AssetsManager
  64104. * @param name defines the name of the task
  64105. */
  64106. constructor(
  64107. /**
  64108. * Task name
  64109. */ name: string);
  64110. private _isCompleted;
  64111. private _taskState;
  64112. private _errorObject;
  64113. /**
  64114. * Get if the task is completed
  64115. */
  64116. readonly isCompleted: boolean;
  64117. /**
  64118. * Gets the current state of the task
  64119. */
  64120. readonly taskState: AssetTaskState;
  64121. /**
  64122. * Gets the current error object (if task is in error)
  64123. */
  64124. readonly errorObject: {
  64125. message?: string;
  64126. exception?: any;
  64127. };
  64128. /**
  64129. * Internal only
  64130. * @hidden
  64131. */
  64132. _setErrorObject(message?: string, exception?: any): void;
  64133. /**
  64134. * Execute the current task
  64135. * @param scene defines the scene where you want your assets to be loaded
  64136. * @param onSuccess is a callback called when the task is successfully executed
  64137. * @param onError is a callback called if an error occurs
  64138. */
  64139. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64140. /**
  64141. * Execute the current task
  64142. * @param scene defines the scene where you want your assets to be loaded
  64143. * @param onSuccess is a callback called when the task is successfully executed
  64144. * @param onError is a callback called if an error occurs
  64145. */
  64146. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64147. /**
  64148. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  64149. * This can be used with failed tasks that have the reason for failure fixed.
  64150. */
  64151. reset(): void;
  64152. private onErrorCallback;
  64153. private onDoneCallback;
  64154. }
  64155. /**
  64156. * Define the interface used by progress events raised during assets loading
  64157. */
  64158. export interface IAssetsProgressEvent {
  64159. /**
  64160. * Defines the number of remaining tasks to process
  64161. */
  64162. remainingCount: number;
  64163. /**
  64164. * Defines the total number of tasks
  64165. */
  64166. totalCount: number;
  64167. /**
  64168. * Defines the task that was just processed
  64169. */
  64170. task: AbstractAssetTask;
  64171. }
  64172. /**
  64173. * Class used to share progress information about assets loading
  64174. */
  64175. export class AssetsProgressEvent implements IAssetsProgressEvent {
  64176. /**
  64177. * Defines the number of remaining tasks to process
  64178. */
  64179. remainingCount: number;
  64180. /**
  64181. * Defines the total number of tasks
  64182. */
  64183. totalCount: number;
  64184. /**
  64185. * Defines the task that was just processed
  64186. */
  64187. task: AbstractAssetTask;
  64188. /**
  64189. * Creates a AssetsProgressEvent
  64190. * @param remainingCount defines the number of remaining tasks to process
  64191. * @param totalCount defines the total number of tasks
  64192. * @param task defines the task that was just processed
  64193. */
  64194. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  64195. }
  64196. /**
  64197. * Define a task used by AssetsManager to load meshes
  64198. */
  64199. export class MeshAssetTask extends AbstractAssetTask {
  64200. /**
  64201. * Defines the name of the task
  64202. */
  64203. name: string;
  64204. /**
  64205. * Defines the list of mesh's names you want to load
  64206. */
  64207. meshesNames: any;
  64208. /**
  64209. * Defines the root url to use as a base to load your meshes and associated resources
  64210. */
  64211. rootUrl: string;
  64212. /**
  64213. * Defines the filename of the scene to load from
  64214. */
  64215. sceneFilename: string;
  64216. /**
  64217. * Gets the list of loaded meshes
  64218. */
  64219. loadedMeshes: Array<AbstractMesh>;
  64220. /**
  64221. * Gets the list of loaded particle systems
  64222. */
  64223. loadedParticleSystems: Array<IParticleSystem>;
  64224. /**
  64225. * Gets the list of loaded skeletons
  64226. */
  64227. loadedSkeletons: Array<Skeleton>;
  64228. /**
  64229. * Gets the list of loaded animation groups
  64230. */
  64231. loadedAnimationGroups: Array<AnimationGroup>;
  64232. /**
  64233. * Callback called when the task is successful
  64234. */
  64235. onSuccess: (task: MeshAssetTask) => void;
  64236. /**
  64237. * Callback called when the task is successful
  64238. */
  64239. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  64240. /**
  64241. * Creates a new MeshAssetTask
  64242. * @param name defines the name of the task
  64243. * @param meshesNames defines the list of mesh's names you want to load
  64244. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  64245. * @param sceneFilename defines the filename of the scene to load from
  64246. */
  64247. constructor(
  64248. /**
  64249. * Defines the name of the task
  64250. */
  64251. name: string,
  64252. /**
  64253. * Defines the list of mesh's names you want to load
  64254. */
  64255. meshesNames: any,
  64256. /**
  64257. * Defines the root url to use as a base to load your meshes and associated resources
  64258. */
  64259. rootUrl: string,
  64260. /**
  64261. * Defines the filename of the scene to load from
  64262. */
  64263. sceneFilename: string);
  64264. /**
  64265. * Execute the current task
  64266. * @param scene defines the scene where you want your assets to be loaded
  64267. * @param onSuccess is a callback called when the task is successfully executed
  64268. * @param onError is a callback called if an error occurs
  64269. */
  64270. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64271. }
  64272. /**
  64273. * Define a task used by AssetsManager to load text content
  64274. */
  64275. export class TextFileAssetTask extends AbstractAssetTask {
  64276. /**
  64277. * Defines the name of the task
  64278. */
  64279. name: string;
  64280. /**
  64281. * Defines the location of the file to load
  64282. */
  64283. url: string;
  64284. /**
  64285. * Gets the loaded text string
  64286. */
  64287. text: string;
  64288. /**
  64289. * Callback called when the task is successful
  64290. */
  64291. onSuccess: (task: TextFileAssetTask) => void;
  64292. /**
  64293. * Callback called when the task is successful
  64294. */
  64295. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  64296. /**
  64297. * Creates a new TextFileAssetTask object
  64298. * @param name defines the name of the task
  64299. * @param url defines the location of the file to load
  64300. */
  64301. constructor(
  64302. /**
  64303. * Defines the name of the task
  64304. */
  64305. name: string,
  64306. /**
  64307. * Defines the location of the file to load
  64308. */
  64309. url: string);
  64310. /**
  64311. * Execute the current task
  64312. * @param scene defines the scene where you want your assets to be loaded
  64313. * @param onSuccess is a callback called when the task is successfully executed
  64314. * @param onError is a callback called if an error occurs
  64315. */
  64316. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64317. }
  64318. /**
  64319. * Define a task used by AssetsManager to load binary data
  64320. */
  64321. export class BinaryFileAssetTask extends AbstractAssetTask {
  64322. /**
  64323. * Defines the name of the task
  64324. */
  64325. name: string;
  64326. /**
  64327. * Defines the location of the file to load
  64328. */
  64329. url: string;
  64330. /**
  64331. * Gets the lodaded data (as an array buffer)
  64332. */
  64333. data: ArrayBuffer;
  64334. /**
  64335. * Callback called when the task is successful
  64336. */
  64337. onSuccess: (task: BinaryFileAssetTask) => void;
  64338. /**
  64339. * Callback called when the task is successful
  64340. */
  64341. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  64342. /**
  64343. * Creates a new BinaryFileAssetTask object
  64344. * @param name defines the name of the new task
  64345. * @param url defines the location of the file to load
  64346. */
  64347. constructor(
  64348. /**
  64349. * Defines the name of the task
  64350. */
  64351. name: string,
  64352. /**
  64353. * Defines the location of the file to load
  64354. */
  64355. url: string);
  64356. /**
  64357. * Execute the current task
  64358. * @param scene defines the scene where you want your assets to be loaded
  64359. * @param onSuccess is a callback called when the task is successfully executed
  64360. * @param onError is a callback called if an error occurs
  64361. */
  64362. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64363. }
  64364. /**
  64365. * Define a task used by AssetsManager to load images
  64366. */
  64367. export class ImageAssetTask extends AbstractAssetTask {
  64368. /**
  64369. * Defines the name of the task
  64370. */
  64371. name: string;
  64372. /**
  64373. * Defines the location of the image to load
  64374. */
  64375. url: string;
  64376. /**
  64377. * Gets the loaded images
  64378. */
  64379. image: HTMLImageElement;
  64380. /**
  64381. * Callback called when the task is successful
  64382. */
  64383. onSuccess: (task: ImageAssetTask) => void;
  64384. /**
  64385. * Callback called when the task is successful
  64386. */
  64387. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  64388. /**
  64389. * Creates a new ImageAssetTask
  64390. * @param name defines the name of the task
  64391. * @param url defines the location of the image to load
  64392. */
  64393. constructor(
  64394. /**
  64395. * Defines the name of the task
  64396. */
  64397. name: string,
  64398. /**
  64399. * Defines the location of the image to load
  64400. */
  64401. url: string);
  64402. /**
  64403. * Execute the current task
  64404. * @param scene defines the scene where you want your assets to be loaded
  64405. * @param onSuccess is a callback called when the task is successfully executed
  64406. * @param onError is a callback called if an error occurs
  64407. */
  64408. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64409. }
  64410. /**
  64411. * Defines the interface used by texture loading tasks
  64412. */
  64413. export interface ITextureAssetTask<TEX extends BaseTexture> {
  64414. /**
  64415. * Gets the loaded texture
  64416. */
  64417. texture: TEX;
  64418. }
  64419. /**
  64420. * Define a task used by AssetsManager to load 2D textures
  64421. */
  64422. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  64423. /**
  64424. * Defines the name of the task
  64425. */
  64426. name: string;
  64427. /**
  64428. * Defines the location of the file to load
  64429. */
  64430. url: string;
  64431. /**
  64432. * Defines if mipmap should not be generated (default is false)
  64433. */
  64434. noMipmap?: boolean | undefined;
  64435. /**
  64436. * Defines if texture must be inverted on Y axis (default is false)
  64437. */
  64438. invertY?: boolean | undefined;
  64439. /**
  64440. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64441. */
  64442. samplingMode: number;
  64443. /**
  64444. * Gets the loaded texture
  64445. */
  64446. texture: Texture;
  64447. /**
  64448. * Callback called when the task is successful
  64449. */
  64450. onSuccess: (task: TextureAssetTask) => void;
  64451. /**
  64452. * Callback called when the task is successful
  64453. */
  64454. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  64455. /**
  64456. * Creates a new TextureAssetTask object
  64457. * @param name defines the name of the task
  64458. * @param url defines the location of the file to load
  64459. * @param noMipmap defines if mipmap should not be generated (default is false)
  64460. * @param invertY defines if texture must be inverted on Y axis (default is false)
  64461. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64462. */
  64463. constructor(
  64464. /**
  64465. * Defines the name of the task
  64466. */
  64467. name: string,
  64468. /**
  64469. * Defines the location of the file to load
  64470. */
  64471. url: string,
  64472. /**
  64473. * Defines if mipmap should not be generated (default is false)
  64474. */
  64475. noMipmap?: boolean | undefined,
  64476. /**
  64477. * Defines if texture must be inverted on Y axis (default is false)
  64478. */
  64479. invertY?: boolean | undefined,
  64480. /**
  64481. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  64482. */
  64483. samplingMode?: number);
  64484. /**
  64485. * Execute the current task
  64486. * @param scene defines the scene where you want your assets to be loaded
  64487. * @param onSuccess is a callback called when the task is successfully executed
  64488. * @param onError is a callback called if an error occurs
  64489. */
  64490. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64491. }
  64492. /**
  64493. * Define a task used by AssetsManager to load cube textures
  64494. */
  64495. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  64496. /**
  64497. * Defines the name of the task
  64498. */
  64499. name: string;
  64500. /**
  64501. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64502. */
  64503. url: string;
  64504. /**
  64505. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64506. */
  64507. extensions?: string[] | undefined;
  64508. /**
  64509. * Defines if mipmaps should not be generated (default is false)
  64510. */
  64511. noMipmap?: boolean | undefined;
  64512. /**
  64513. * Defines the explicit list of files (undefined by default)
  64514. */
  64515. files?: string[] | undefined;
  64516. /**
  64517. * Gets the loaded texture
  64518. */
  64519. texture: CubeTexture;
  64520. /**
  64521. * Callback called when the task is successful
  64522. */
  64523. onSuccess: (task: CubeTextureAssetTask) => void;
  64524. /**
  64525. * Callback called when the task is successful
  64526. */
  64527. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  64528. /**
  64529. * Creates a new CubeTextureAssetTask
  64530. * @param name defines the name of the task
  64531. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64532. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64533. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64534. * @param files defines the explicit list of files (undefined by default)
  64535. */
  64536. constructor(
  64537. /**
  64538. * Defines the name of the task
  64539. */
  64540. name: string,
  64541. /**
  64542. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  64543. */
  64544. url: string,
  64545. /**
  64546. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  64547. */
  64548. extensions?: string[] | undefined,
  64549. /**
  64550. * Defines if mipmaps should not be generated (default is false)
  64551. */
  64552. noMipmap?: boolean | undefined,
  64553. /**
  64554. * Defines the explicit list of files (undefined by default)
  64555. */
  64556. files?: string[] | undefined);
  64557. /**
  64558. * Execute the current task
  64559. * @param scene defines the scene where you want your assets to be loaded
  64560. * @param onSuccess is a callback called when the task is successfully executed
  64561. * @param onError is a callback called if an error occurs
  64562. */
  64563. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64564. }
  64565. /**
  64566. * Define a task used by AssetsManager to load HDR cube textures
  64567. */
  64568. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  64569. /**
  64570. * Defines the name of the task
  64571. */
  64572. name: string;
  64573. /**
  64574. * Defines the location of the file to load
  64575. */
  64576. url: string;
  64577. /**
  64578. * Defines the desired size (the more it increases the longer the generation will be)
  64579. */
  64580. size: number;
  64581. /**
  64582. * Defines if mipmaps should not be generated (default is false)
  64583. */
  64584. noMipmap: boolean;
  64585. /**
  64586. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64587. */
  64588. generateHarmonics: boolean;
  64589. /**
  64590. * 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)
  64591. */
  64592. gammaSpace: boolean;
  64593. /**
  64594. * Internal Use Only
  64595. */
  64596. reserved: boolean;
  64597. /**
  64598. * Gets the loaded texture
  64599. */
  64600. texture: HDRCubeTexture;
  64601. /**
  64602. * Callback called when the task is successful
  64603. */
  64604. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  64605. /**
  64606. * Callback called when the task is successful
  64607. */
  64608. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  64609. /**
  64610. * Creates a new HDRCubeTextureAssetTask object
  64611. * @param name defines the name of the task
  64612. * @param url defines the location of the file to load
  64613. * @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.
  64614. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64615. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64616. * @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)
  64617. * @param reserved Internal use only
  64618. */
  64619. constructor(
  64620. /**
  64621. * Defines the name of the task
  64622. */
  64623. name: string,
  64624. /**
  64625. * Defines the location of the file to load
  64626. */
  64627. url: string,
  64628. /**
  64629. * Defines the desired size (the more it increases the longer the generation will be)
  64630. */
  64631. size: number,
  64632. /**
  64633. * Defines if mipmaps should not be generated (default is false)
  64634. */
  64635. noMipmap?: boolean,
  64636. /**
  64637. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  64638. */
  64639. generateHarmonics?: boolean,
  64640. /**
  64641. * 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)
  64642. */
  64643. gammaSpace?: boolean,
  64644. /**
  64645. * Internal Use Only
  64646. */
  64647. reserved?: boolean);
  64648. /**
  64649. * Execute the current task
  64650. * @param scene defines the scene where you want your assets to be loaded
  64651. * @param onSuccess is a callback called when the task is successfully executed
  64652. * @param onError is a callback called if an error occurs
  64653. */
  64654. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64655. }
  64656. /**
  64657. * Define a task used by AssetsManager to load Equirectangular cube textures
  64658. */
  64659. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  64660. /**
  64661. * Defines the name of the task
  64662. */
  64663. name: string;
  64664. /**
  64665. * Defines the location of the file to load
  64666. */
  64667. url: string;
  64668. /**
  64669. * Defines the desired size (the more it increases the longer the generation will be)
  64670. */
  64671. size: number;
  64672. /**
  64673. * Defines if mipmaps should not be generated (default is false)
  64674. */
  64675. noMipmap: boolean;
  64676. /**
  64677. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64678. * but the standard material would require them in Gamma space) (default is true)
  64679. */
  64680. gammaSpace: boolean;
  64681. /**
  64682. * Gets the loaded texture
  64683. */
  64684. texture: EquiRectangularCubeTexture;
  64685. /**
  64686. * Callback called when the task is successful
  64687. */
  64688. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  64689. /**
  64690. * Callback called when the task is successful
  64691. */
  64692. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  64693. /**
  64694. * Creates a new EquiRectangularCubeTextureAssetTask object
  64695. * @param name defines the name of the task
  64696. * @param url defines the location of the file to load
  64697. * @param size defines the desired size (the more it increases the longer the generation will be)
  64698. * If the size is omitted this implies you are using a preprocessed cubemap.
  64699. * @param noMipmap defines if mipmaps should not be generated (default is false)
  64700. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  64701. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  64702. * (default is true)
  64703. */
  64704. constructor(
  64705. /**
  64706. * Defines the name of the task
  64707. */
  64708. name: string,
  64709. /**
  64710. * Defines the location of the file to load
  64711. */
  64712. url: string,
  64713. /**
  64714. * Defines the desired size (the more it increases the longer the generation will be)
  64715. */
  64716. size: number,
  64717. /**
  64718. * Defines if mipmaps should not be generated (default is false)
  64719. */
  64720. noMipmap?: boolean,
  64721. /**
  64722. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  64723. * but the standard material would require them in Gamma space) (default is true)
  64724. */
  64725. gammaSpace?: boolean);
  64726. /**
  64727. * Execute the current task
  64728. * @param scene defines the scene where you want your assets to be loaded
  64729. * @param onSuccess is a callback called when the task is successfully executed
  64730. * @param onError is a callback called if an error occurs
  64731. */
  64732. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  64733. }
  64734. /**
  64735. * This class can be used to easily import assets into a scene
  64736. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  64737. */
  64738. export class AssetsManager {
  64739. private _scene;
  64740. private _isLoading;
  64741. protected _tasks: AbstractAssetTask[];
  64742. protected _waitingTasksCount: number;
  64743. protected _totalTasksCount: number;
  64744. /**
  64745. * Callback called when all tasks are processed
  64746. */
  64747. onFinish: (tasks: AbstractAssetTask[]) => void;
  64748. /**
  64749. * Callback called when a task is successful
  64750. */
  64751. onTaskSuccess: (task: AbstractAssetTask) => void;
  64752. /**
  64753. * Callback called when a task had an error
  64754. */
  64755. onTaskError: (task: AbstractAssetTask) => void;
  64756. /**
  64757. * Callback called when a task is done (whatever the result is)
  64758. */
  64759. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  64760. /**
  64761. * Observable called when all tasks are processed
  64762. */
  64763. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  64764. /**
  64765. * Observable called when a task had an error
  64766. */
  64767. onTaskErrorObservable: Observable<AbstractAssetTask>;
  64768. /**
  64769. * Observable called when all tasks were executed
  64770. */
  64771. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  64772. /**
  64773. * Observable called when a task is done (whatever the result is)
  64774. */
  64775. onProgressObservable: Observable<IAssetsProgressEvent>;
  64776. /**
  64777. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  64778. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  64779. */
  64780. useDefaultLoadingScreen: boolean;
  64781. /**
  64782. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  64783. * when all assets have been downloaded.
  64784. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  64785. */
  64786. autoHideLoadingUI: boolean;
  64787. /**
  64788. * Creates a new AssetsManager
  64789. * @param scene defines the scene to work on
  64790. */
  64791. constructor(scene: Scene);
  64792. /**
  64793. * Add a MeshAssetTask to the list of active tasks
  64794. * @param taskName defines the name of the new task
  64795. * @param meshesNames defines the name of meshes to load
  64796. * @param rootUrl defines the root url to use to locate files
  64797. * @param sceneFilename defines the filename of the scene file
  64798. * @returns a new MeshAssetTask object
  64799. */
  64800. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  64801. /**
  64802. * Add a TextFileAssetTask to the list of active tasks
  64803. * @param taskName defines the name of the new task
  64804. * @param url defines the url of the file to load
  64805. * @returns a new TextFileAssetTask object
  64806. */
  64807. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  64808. /**
  64809. * Add a BinaryFileAssetTask to the list of active tasks
  64810. * @param taskName defines the name of the new task
  64811. * @param url defines the url of the file to load
  64812. * @returns a new BinaryFileAssetTask object
  64813. */
  64814. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  64815. /**
  64816. * Add a ImageAssetTask to the list of active tasks
  64817. * @param taskName defines the name of the new task
  64818. * @param url defines the url of the file to load
  64819. * @returns a new ImageAssetTask object
  64820. */
  64821. addImageTask(taskName: string, url: string): ImageAssetTask;
  64822. /**
  64823. * Add a TextureAssetTask to the list of active tasks
  64824. * @param taskName defines the name of the new task
  64825. * @param url defines the url of the file to load
  64826. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64827. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  64828. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64829. * @returns a new TextureAssetTask object
  64830. */
  64831. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  64832. /**
  64833. * Add a CubeTextureAssetTask to the list of active tasks
  64834. * @param taskName defines the name of the new task
  64835. * @param url defines the url of the file to load
  64836. * @param extensions defines the extension to use to load the cube map (can be null)
  64837. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64838. * @param files defines the list of files to load (can be null)
  64839. * @returns a new CubeTextureAssetTask object
  64840. */
  64841. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  64842. /**
  64843. *
  64844. * Add a HDRCubeTextureAssetTask to the list of active tasks
  64845. * @param taskName defines the name of the new task
  64846. * @param url defines the url of the file to load
  64847. * @param size defines the size you want for the cubemap (can be null)
  64848. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64849. * @param generateHarmonics defines if you want to automatically generate (true by default)
  64850. * @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)
  64851. * @param reserved Internal use only
  64852. * @returns a new HDRCubeTextureAssetTask object
  64853. */
  64854. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  64855. /**
  64856. *
  64857. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  64858. * @param taskName defines the name of the new task
  64859. * @param url defines the url of the file to load
  64860. * @param size defines the size you want for the cubemap (can be null)
  64861. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  64862. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64863. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64864. * @returns a new EquiRectangularCubeTextureAssetTask object
  64865. */
  64866. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  64867. /**
  64868. * Remove a task from the assets manager.
  64869. * @param task the task to remove
  64870. */
  64871. removeTask(task: AbstractAssetTask): void;
  64872. private _decreaseWaitingTasksCount;
  64873. private _runTask;
  64874. /**
  64875. * Reset the AssetsManager and remove all tasks
  64876. * @return the current instance of the AssetsManager
  64877. */
  64878. reset(): AssetsManager;
  64879. /**
  64880. * Start the loading process
  64881. * @return the current instance of the AssetsManager
  64882. */
  64883. load(): AssetsManager;
  64884. /**
  64885. * Start the loading process as an async operation
  64886. * @return a promise returning the list of failed tasks
  64887. */
  64888. loadAsync(): Promise<void>;
  64889. }
  64890. }
  64891. declare module "babylonjs/Misc/deferred" {
  64892. /**
  64893. * Wrapper class for promise with external resolve and reject.
  64894. */
  64895. export class Deferred<T> {
  64896. /**
  64897. * The promise associated with this deferred object.
  64898. */
  64899. readonly promise: Promise<T>;
  64900. private _resolve;
  64901. private _reject;
  64902. /**
  64903. * The resolve method of the promise associated with this deferred object.
  64904. */
  64905. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  64906. /**
  64907. * The reject method of the promise associated with this deferred object.
  64908. */
  64909. readonly reject: (reason?: any) => void;
  64910. /**
  64911. * Constructor for this deferred object.
  64912. */
  64913. constructor();
  64914. }
  64915. }
  64916. declare module "babylonjs/Misc/meshExploder" {
  64917. import { Mesh } from "babylonjs/Meshes/mesh";
  64918. /**
  64919. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  64920. */
  64921. export class MeshExploder {
  64922. private _centerMesh;
  64923. private _meshes;
  64924. private _meshesOrigins;
  64925. private _toCenterVectors;
  64926. private _scaledDirection;
  64927. private _newPosition;
  64928. private _centerPosition;
  64929. /**
  64930. * Explodes meshes from a center mesh.
  64931. * @param meshes The meshes to explode.
  64932. * @param centerMesh The mesh to be center of explosion.
  64933. */
  64934. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  64935. private _setCenterMesh;
  64936. /**
  64937. * Get class name
  64938. * @returns "MeshExploder"
  64939. */
  64940. getClassName(): string;
  64941. /**
  64942. * "Exploded meshes"
  64943. * @returns Array of meshes with the centerMesh at index 0.
  64944. */
  64945. getMeshes(): Array<Mesh>;
  64946. /**
  64947. * Explodes meshes giving a specific direction
  64948. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  64949. */
  64950. explode(direction?: number): void;
  64951. }
  64952. }
  64953. declare module "babylonjs/Misc/filesInput" {
  64954. import { Engine } from "babylonjs/Engines/engine";
  64955. import { Scene } from "babylonjs/scene";
  64956. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  64957. /**
  64958. * Class used to help managing file picking and drag'n'drop
  64959. */
  64960. export class FilesInput {
  64961. /**
  64962. * List of files ready to be loaded
  64963. */
  64964. static readonly FilesToLoad: {
  64965. [key: string]: File;
  64966. };
  64967. /**
  64968. * Callback called when a file is processed
  64969. */
  64970. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  64971. private _engine;
  64972. private _currentScene;
  64973. private _sceneLoadedCallback;
  64974. private _progressCallback;
  64975. private _additionalRenderLoopLogicCallback;
  64976. private _textureLoadingCallback;
  64977. private _startingProcessingFilesCallback;
  64978. private _onReloadCallback;
  64979. private _errorCallback;
  64980. private _elementToMonitor;
  64981. private _sceneFileToLoad;
  64982. private _filesToLoad;
  64983. /**
  64984. * Creates a new FilesInput
  64985. * @param engine defines the rendering engine
  64986. * @param scene defines the hosting scene
  64987. * @param sceneLoadedCallback callback called when scene is loaded
  64988. * @param progressCallback callback called to track progress
  64989. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  64990. * @param textureLoadingCallback callback called when a texture is loading
  64991. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  64992. * @param onReloadCallback callback called when a reload is requested
  64993. * @param errorCallback callback call if an error occurs
  64994. */
  64995. 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);
  64996. private _dragEnterHandler;
  64997. private _dragOverHandler;
  64998. private _dropHandler;
  64999. /**
  65000. * Calls this function to listen to drag'n'drop events on a specific DOM element
  65001. * @param elementToMonitor defines the DOM element to track
  65002. */
  65003. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  65004. /**
  65005. * Release all associated resources
  65006. */
  65007. dispose(): void;
  65008. private renderFunction;
  65009. private drag;
  65010. private drop;
  65011. private _traverseFolder;
  65012. private _processFiles;
  65013. /**
  65014. * Load files from a drop event
  65015. * @param event defines the drop event to use as source
  65016. */
  65017. loadFiles(event: any): void;
  65018. private _processReload;
  65019. /**
  65020. * Reload the current scene from the loaded files
  65021. */
  65022. reload(): void;
  65023. }
  65024. }
  65025. declare module "babylonjs/Misc/HighDynamicRange/index" {
  65026. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  65027. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  65028. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  65029. }
  65030. declare module "babylonjs/Misc/sceneOptimizer" {
  65031. import { Scene, IDisposable } from "babylonjs/scene";
  65032. import { Observable } from "babylonjs/Misc/observable";
  65033. /**
  65034. * Defines the root class used to create scene optimization to use with SceneOptimizer
  65035. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65036. */
  65037. export class SceneOptimization {
  65038. /**
  65039. * Defines the priority of this optimization (0 by default which means first in the list)
  65040. */
  65041. priority: number;
  65042. /**
  65043. * Gets a string describing the action executed by the current optimization
  65044. * @returns description string
  65045. */
  65046. getDescription(): string;
  65047. /**
  65048. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65049. * @param scene defines the current scene where to apply this optimization
  65050. * @param optimizer defines the current optimizer
  65051. * @returns true if everything that can be done was applied
  65052. */
  65053. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65054. /**
  65055. * Creates the SceneOptimization object
  65056. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65057. * @param desc defines the description associated with the optimization
  65058. */
  65059. constructor(
  65060. /**
  65061. * Defines the priority of this optimization (0 by default which means first in the list)
  65062. */
  65063. priority?: number);
  65064. }
  65065. /**
  65066. * Defines an optimization used to reduce the size of render target textures
  65067. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65068. */
  65069. export class TextureOptimization extends SceneOptimization {
  65070. /**
  65071. * Defines the priority of this optimization (0 by default which means first in the list)
  65072. */
  65073. priority: number;
  65074. /**
  65075. * 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
  65076. */
  65077. maximumSize: number;
  65078. /**
  65079. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65080. */
  65081. step: number;
  65082. /**
  65083. * Gets a string describing the action executed by the current optimization
  65084. * @returns description string
  65085. */
  65086. getDescription(): string;
  65087. /**
  65088. * Creates the TextureOptimization object
  65089. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65090. * @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
  65091. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65092. */
  65093. constructor(
  65094. /**
  65095. * Defines the priority of this optimization (0 by default which means first in the list)
  65096. */
  65097. priority?: number,
  65098. /**
  65099. * 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
  65100. */
  65101. maximumSize?: number,
  65102. /**
  65103. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65104. */
  65105. step?: number);
  65106. /**
  65107. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65108. * @param scene defines the current scene where to apply this optimization
  65109. * @param optimizer defines the current optimizer
  65110. * @returns true if everything that can be done was applied
  65111. */
  65112. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65113. }
  65114. /**
  65115. * Defines an optimization used to increase or decrease the rendering resolution
  65116. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65117. */
  65118. export class HardwareScalingOptimization extends SceneOptimization {
  65119. /**
  65120. * Defines the priority of this optimization (0 by default which means first in the list)
  65121. */
  65122. priority: number;
  65123. /**
  65124. * Defines the maximum scale to use (2 by default)
  65125. */
  65126. maximumScale: number;
  65127. /**
  65128. * Defines the step to use between two passes (0.5 by default)
  65129. */
  65130. step: number;
  65131. private _currentScale;
  65132. private _directionOffset;
  65133. /**
  65134. * Gets a string describing the action executed by the current optimization
  65135. * @return description string
  65136. */
  65137. getDescription(): string;
  65138. /**
  65139. * Creates the HardwareScalingOptimization object
  65140. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65141. * @param maximumScale defines the maximum scale to use (2 by default)
  65142. * @param step defines the step to use between two passes (0.5 by default)
  65143. */
  65144. constructor(
  65145. /**
  65146. * Defines the priority of this optimization (0 by default which means first in the list)
  65147. */
  65148. priority?: number,
  65149. /**
  65150. * Defines the maximum scale to use (2 by default)
  65151. */
  65152. maximumScale?: number,
  65153. /**
  65154. * Defines the step to use between two passes (0.5 by default)
  65155. */
  65156. step?: number);
  65157. /**
  65158. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65159. * @param scene defines the current scene where to apply this optimization
  65160. * @param optimizer defines the current optimizer
  65161. * @returns true if everything that can be done was applied
  65162. */
  65163. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65164. }
  65165. /**
  65166. * Defines an optimization used to remove shadows
  65167. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65168. */
  65169. export class ShadowsOptimization extends SceneOptimization {
  65170. /**
  65171. * Gets a string describing the action executed by the current optimization
  65172. * @return description string
  65173. */
  65174. getDescription(): string;
  65175. /**
  65176. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65177. * @param scene defines the current scene where to apply this optimization
  65178. * @param optimizer defines the current optimizer
  65179. * @returns true if everything that can be done was applied
  65180. */
  65181. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65182. }
  65183. /**
  65184. * Defines an optimization used to turn post-processes off
  65185. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65186. */
  65187. export class PostProcessesOptimization extends SceneOptimization {
  65188. /**
  65189. * Gets a string describing the action executed by the current optimization
  65190. * @return description string
  65191. */
  65192. getDescription(): string;
  65193. /**
  65194. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65195. * @param scene defines the current scene where to apply this optimization
  65196. * @param optimizer defines the current optimizer
  65197. * @returns true if everything that can be done was applied
  65198. */
  65199. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65200. }
  65201. /**
  65202. * Defines an optimization used to turn lens flares off
  65203. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65204. */
  65205. export class LensFlaresOptimization extends SceneOptimization {
  65206. /**
  65207. * Gets a string describing the action executed by the current optimization
  65208. * @return description string
  65209. */
  65210. getDescription(): string;
  65211. /**
  65212. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65213. * @param scene defines the current scene where to apply this optimization
  65214. * @param optimizer defines the current optimizer
  65215. * @returns true if everything that can be done was applied
  65216. */
  65217. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65218. }
  65219. /**
  65220. * Defines an optimization based on user defined callback.
  65221. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65222. */
  65223. export class CustomOptimization extends SceneOptimization {
  65224. /**
  65225. * Callback called to apply the custom optimization.
  65226. */
  65227. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  65228. /**
  65229. * Callback called to get custom description
  65230. */
  65231. onGetDescription: () => string;
  65232. /**
  65233. * Gets a string describing the action executed by the current optimization
  65234. * @returns description string
  65235. */
  65236. getDescription(): string;
  65237. /**
  65238. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65239. * @param scene defines the current scene where to apply this optimization
  65240. * @param optimizer defines the current optimizer
  65241. * @returns true if everything that can be done was applied
  65242. */
  65243. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65244. }
  65245. /**
  65246. * Defines an optimization used to turn particles off
  65247. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65248. */
  65249. export class ParticlesOptimization extends SceneOptimization {
  65250. /**
  65251. * Gets a string describing the action executed by the current optimization
  65252. * @return description string
  65253. */
  65254. getDescription(): string;
  65255. /**
  65256. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65257. * @param scene defines the current scene where to apply this optimization
  65258. * @param optimizer defines the current optimizer
  65259. * @returns true if everything that can be done was applied
  65260. */
  65261. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65262. }
  65263. /**
  65264. * Defines an optimization used to turn render targets off
  65265. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65266. */
  65267. export class RenderTargetsOptimization extends SceneOptimization {
  65268. /**
  65269. * Gets a string describing the action executed by the current optimization
  65270. * @return description string
  65271. */
  65272. getDescription(): string;
  65273. /**
  65274. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65275. * @param scene defines the current scene where to apply this optimization
  65276. * @param optimizer defines the current optimizer
  65277. * @returns true if everything that can be done was applied
  65278. */
  65279. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65280. }
  65281. /**
  65282. * Defines an optimization used to merge meshes with compatible materials
  65283. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65284. */
  65285. export class MergeMeshesOptimization extends SceneOptimization {
  65286. private static _UpdateSelectionTree;
  65287. /**
  65288. * Gets or sets a boolean which defines if optimization octree has to be updated
  65289. */
  65290. /**
  65291. * Gets or sets a boolean which defines if optimization octree has to be updated
  65292. */
  65293. static UpdateSelectionTree: boolean;
  65294. /**
  65295. * Gets a string describing the action executed by the current optimization
  65296. * @return description string
  65297. */
  65298. getDescription(): string;
  65299. private _canBeMerged;
  65300. /**
  65301. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65302. * @param scene defines the current scene where to apply this optimization
  65303. * @param optimizer defines the current optimizer
  65304. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  65305. * @returns true if everything that can be done was applied
  65306. */
  65307. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  65308. }
  65309. /**
  65310. * Defines a list of options used by SceneOptimizer
  65311. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65312. */
  65313. export class SceneOptimizerOptions {
  65314. /**
  65315. * Defines the target frame rate to reach (60 by default)
  65316. */
  65317. targetFrameRate: number;
  65318. /**
  65319. * Defines the interval between two checkes (2000ms by default)
  65320. */
  65321. trackerDuration: number;
  65322. /**
  65323. * Gets the list of optimizations to apply
  65324. */
  65325. optimizations: SceneOptimization[];
  65326. /**
  65327. * Creates a new list of options used by SceneOptimizer
  65328. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  65329. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  65330. */
  65331. constructor(
  65332. /**
  65333. * Defines the target frame rate to reach (60 by default)
  65334. */
  65335. targetFrameRate?: number,
  65336. /**
  65337. * Defines the interval between two checkes (2000ms by default)
  65338. */
  65339. trackerDuration?: number);
  65340. /**
  65341. * Add a new optimization
  65342. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  65343. * @returns the current SceneOptimizerOptions
  65344. */
  65345. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  65346. /**
  65347. * Add a new custom optimization
  65348. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  65349. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  65350. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65351. * @returns the current SceneOptimizerOptions
  65352. */
  65353. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  65354. /**
  65355. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  65356. * @param targetFrameRate defines the target frame rate (60 by default)
  65357. * @returns a SceneOptimizerOptions object
  65358. */
  65359. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65360. /**
  65361. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  65362. * @param targetFrameRate defines the target frame rate (60 by default)
  65363. * @returns a SceneOptimizerOptions object
  65364. */
  65365. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65366. /**
  65367. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  65368. * @param targetFrameRate defines the target frame rate (60 by default)
  65369. * @returns a SceneOptimizerOptions object
  65370. */
  65371. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  65372. }
  65373. /**
  65374. * Class used to run optimizations in order to reach a target frame rate
  65375. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65376. */
  65377. export class SceneOptimizer implements IDisposable {
  65378. private _isRunning;
  65379. private _options;
  65380. private _scene;
  65381. private _currentPriorityLevel;
  65382. private _targetFrameRate;
  65383. private _trackerDuration;
  65384. private _currentFrameRate;
  65385. private _sceneDisposeObserver;
  65386. private _improvementMode;
  65387. /**
  65388. * Defines an observable called when the optimizer reaches the target frame rate
  65389. */
  65390. onSuccessObservable: Observable<SceneOptimizer>;
  65391. /**
  65392. * Defines an observable called when the optimizer enables an optimization
  65393. */
  65394. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  65395. /**
  65396. * Defines an observable called when the optimizer is not able to reach the target frame rate
  65397. */
  65398. onFailureObservable: Observable<SceneOptimizer>;
  65399. /**
  65400. * Gets a boolean indicating if the optimizer is in improvement mode
  65401. */
  65402. readonly isInImprovementMode: boolean;
  65403. /**
  65404. * Gets the current priority level (0 at start)
  65405. */
  65406. readonly currentPriorityLevel: number;
  65407. /**
  65408. * Gets the current frame rate checked by the SceneOptimizer
  65409. */
  65410. readonly currentFrameRate: number;
  65411. /**
  65412. * Gets or sets the current target frame rate (60 by default)
  65413. */
  65414. /**
  65415. * Gets or sets the current target frame rate (60 by default)
  65416. */
  65417. targetFrameRate: number;
  65418. /**
  65419. * Gets or sets the current interval between two checks (every 2000ms by default)
  65420. */
  65421. /**
  65422. * Gets or sets the current interval between two checks (every 2000ms by default)
  65423. */
  65424. trackerDuration: number;
  65425. /**
  65426. * Gets the list of active optimizations
  65427. */
  65428. readonly optimizations: SceneOptimization[];
  65429. /**
  65430. * Creates a new SceneOptimizer
  65431. * @param scene defines the scene to work on
  65432. * @param options defines the options to use with the SceneOptimizer
  65433. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  65434. * @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)
  65435. */
  65436. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  65437. /**
  65438. * Stops the current optimizer
  65439. */
  65440. stop(): void;
  65441. /**
  65442. * Reset the optimizer to initial step (current priority level = 0)
  65443. */
  65444. reset(): void;
  65445. /**
  65446. * Start the optimizer. By default it will try to reach a specific framerate
  65447. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  65448. */
  65449. start(): void;
  65450. private _checkCurrentState;
  65451. /**
  65452. * Release all resources
  65453. */
  65454. dispose(): void;
  65455. /**
  65456. * Helper function to create a SceneOptimizer with one single line of code
  65457. * @param scene defines the scene to work on
  65458. * @param options defines the options to use with the SceneOptimizer
  65459. * @param onSuccess defines a callback to call on success
  65460. * @param onFailure defines a callback to call on failure
  65461. * @returns the new SceneOptimizer object
  65462. */
  65463. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  65464. }
  65465. }
  65466. declare module "babylonjs/Misc/sceneSerializer" {
  65467. import { Scene } from "babylonjs/scene";
  65468. /**
  65469. * Class used to serialize a scene into a string
  65470. */
  65471. export class SceneSerializer {
  65472. /**
  65473. * Clear cache used by a previous serialization
  65474. */
  65475. static ClearCache(): void;
  65476. /**
  65477. * Serialize a scene into a JSON compatible object
  65478. * @param scene defines the scene to serialize
  65479. * @returns a JSON compatible object
  65480. */
  65481. static Serialize(scene: Scene): any;
  65482. /**
  65483. * Serialize a mesh into a JSON compatible object
  65484. * @param toSerialize defines the mesh to serialize
  65485. * @param withParents defines if parents must be serialized as well
  65486. * @param withChildren defines if children must be serialized as well
  65487. * @returns a JSON compatible object
  65488. */
  65489. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  65490. }
  65491. }
  65492. declare module "babylonjs/Misc/textureTools" {
  65493. import { Texture } from "babylonjs/Materials/Textures/texture";
  65494. /**
  65495. * Class used to host texture specific utilities
  65496. */
  65497. export class TextureTools {
  65498. /**
  65499. * Uses the GPU to create a copy texture rescaled at a given size
  65500. * @param texture Texture to copy from
  65501. * @param width defines the desired width
  65502. * @param height defines the desired height
  65503. * @param useBilinearMode defines if bilinear mode has to be used
  65504. * @return the generated texture
  65505. */
  65506. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  65507. }
  65508. }
  65509. declare module "babylonjs/Misc/videoRecorder" {
  65510. import { Nullable } from "babylonjs/types";
  65511. import { Engine } from "babylonjs/Engines/engine";
  65512. /**
  65513. * This represents the different options available for the video capture.
  65514. */
  65515. export interface VideoRecorderOptions {
  65516. /** Defines the mime type of the video. */
  65517. mimeType: string;
  65518. /** Defines the FPS the video should be recorded at. */
  65519. fps: number;
  65520. /** Defines the chunk size for the recording data. */
  65521. recordChunckSize: number;
  65522. /** The audio tracks to attach to the recording. */
  65523. audioTracks?: MediaStreamTrack[];
  65524. }
  65525. /**
  65526. * This can help with recording videos from BabylonJS.
  65527. * This is based on the available WebRTC functionalities of the browser.
  65528. *
  65529. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  65530. */
  65531. export class VideoRecorder {
  65532. private static readonly _defaultOptions;
  65533. /**
  65534. * Returns whether or not the VideoRecorder is available in your browser.
  65535. * @param engine Defines the Babylon Engine.
  65536. * @returns true if supported otherwise false.
  65537. */
  65538. static IsSupported(engine: Engine): boolean;
  65539. private readonly _options;
  65540. private _canvas;
  65541. private _mediaRecorder;
  65542. private _recordedChunks;
  65543. private _fileName;
  65544. private _resolve;
  65545. private _reject;
  65546. /**
  65547. * True when a recording is already in progress.
  65548. */
  65549. readonly isRecording: boolean;
  65550. /**
  65551. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  65552. * @param engine Defines the BabylonJS Engine you wish to record.
  65553. * @param options Defines options that can be used to customize the capture.
  65554. */
  65555. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  65556. /**
  65557. * Stops the current recording before the default capture timeout passed in the startRecording function.
  65558. */
  65559. stopRecording(): void;
  65560. /**
  65561. * Starts recording the canvas for a max duration specified in parameters.
  65562. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  65563. * If null no automatic download will start and you can rely on the promise to get the data back.
  65564. * @param maxDuration Defines the maximum recording time in seconds.
  65565. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  65566. * @return A promise callback at the end of the recording with the video data in Blob.
  65567. */
  65568. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  65569. /**
  65570. * Releases internal resources used during the recording.
  65571. */
  65572. dispose(): void;
  65573. private _handleDataAvailable;
  65574. private _handleError;
  65575. private _handleStop;
  65576. }
  65577. }
  65578. declare module "babylonjs/Misc/screenshotTools" {
  65579. import { Camera } from "babylonjs/Cameras/camera";
  65580. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  65581. import { Engine } from "babylonjs/Engines/engine";
  65582. /**
  65583. * Class containing a set of static utilities functions for screenshots
  65584. */
  65585. export class ScreenshotTools {
  65586. /**
  65587. * Captures a screenshot of the current rendering
  65588. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65589. * @param engine defines the rendering engine
  65590. * @param camera defines the source camera
  65591. * @param size This parameter can be set to a single number or to an object with the
  65592. * following (optional) properties: precision, width, height. If a single number is passed,
  65593. * it will be used for both width and height. If an object is passed, the screenshot size
  65594. * will be derived from the parameters. The precision property is a multiplier allowing
  65595. * rendering at a higher or lower resolution
  65596. * @param successCallback defines the callback receives a single parameter which contains the
  65597. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65598. * src parameter of an <img> to display it
  65599. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65600. * Check your browser for supported MIME types
  65601. */
  65602. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  65603. /**
  65604. * Captures a screenshot of the current rendering
  65605. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65606. * @param engine defines the rendering engine
  65607. * @param camera defines the source camera
  65608. * @param size This parameter can be set to a single number or to an object with the
  65609. * following (optional) properties: precision, width, height. If a single number is passed,
  65610. * it will be used for both width and height. If an object is passed, the screenshot size
  65611. * will be derived from the parameters. The precision property is a multiplier allowing
  65612. * rendering at a higher or lower resolution
  65613. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  65614. * Check your browser for supported MIME types
  65615. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65616. * to the src parameter of an <img> to display it
  65617. */
  65618. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  65619. /**
  65620. * Generates an image screenshot from the specified camera.
  65621. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65622. * @param engine The engine to use for rendering
  65623. * @param camera The camera to use for rendering
  65624. * @param size This parameter can be set to a single number or to an object with the
  65625. * following (optional) properties: precision, width, height. If a single number is passed,
  65626. * it will be used for both width and height. If an object is passed, the screenshot size
  65627. * will be derived from the parameters. The precision property is a multiplier allowing
  65628. * rendering at a higher or lower resolution
  65629. * @param successCallback The callback receives a single parameter which contains the
  65630. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  65631. * src parameter of an <img> to display it
  65632. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65633. * Check your browser for supported MIME types
  65634. * @param samples Texture samples (default: 1)
  65635. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65636. * @param fileName A name for for the downloaded file.
  65637. */
  65638. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  65639. /**
  65640. * Generates an image screenshot from the specified camera.
  65641. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  65642. * @param engine The engine to use for rendering
  65643. * @param camera The camera to use for rendering
  65644. * @param size This parameter can be set to a single number or to an object with the
  65645. * following (optional) properties: precision, width, height. If a single number is passed,
  65646. * it will be used for both width and height. If an object is passed, the screenshot size
  65647. * will be derived from the parameters. The precision property is a multiplier allowing
  65648. * rendering at a higher or lower resolution
  65649. * @param mimeType The MIME type of the screenshot image (default: image/png).
  65650. * Check your browser for supported MIME types
  65651. * @param samples Texture samples (default: 1)
  65652. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  65653. * @param fileName A name for for the downloaded file.
  65654. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  65655. * to the src parameter of an <img> to display it
  65656. */
  65657. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  65658. /**
  65659. * Gets height and width for screenshot size
  65660. * @private
  65661. */
  65662. private static _getScreenshotSize;
  65663. }
  65664. }
  65665. declare module "babylonjs/Misc/index" {
  65666. export * from "babylonjs/Misc/andOrNotEvaluator";
  65667. export * from "babylonjs/Misc/assetsManager";
  65668. export * from "babylonjs/Misc/dds";
  65669. export * from "babylonjs/Misc/decorators";
  65670. export * from "babylonjs/Misc/deferred";
  65671. export * from "babylonjs/Misc/environmentTextureTools";
  65672. export * from "babylonjs/Misc/meshExploder";
  65673. export * from "babylonjs/Misc/filesInput";
  65674. export * from "babylonjs/Misc/HighDynamicRange/index";
  65675. export * from "babylonjs/Misc/khronosTextureContainer";
  65676. export * from "babylonjs/Misc/observable";
  65677. export * from "babylonjs/Misc/performanceMonitor";
  65678. export * from "babylonjs/Misc/promise";
  65679. export * from "babylonjs/Misc/sceneOptimizer";
  65680. export * from "babylonjs/Misc/sceneSerializer";
  65681. export * from "babylonjs/Misc/smartArray";
  65682. export * from "babylonjs/Misc/stringDictionary";
  65683. export * from "babylonjs/Misc/tags";
  65684. export * from "babylonjs/Misc/textureTools";
  65685. export * from "babylonjs/Misc/tga";
  65686. export * from "babylonjs/Misc/tools";
  65687. export * from "babylonjs/Misc/videoRecorder";
  65688. export * from "babylonjs/Misc/virtualJoystick";
  65689. export * from "babylonjs/Misc/workerPool";
  65690. export * from "babylonjs/Misc/logger";
  65691. export * from "babylonjs/Misc/typeStore";
  65692. export * from "babylonjs/Misc/filesInputStore";
  65693. export * from "babylonjs/Misc/deepCopier";
  65694. export * from "babylonjs/Misc/pivotTools";
  65695. export * from "babylonjs/Misc/precisionDate";
  65696. export * from "babylonjs/Misc/screenshotTools";
  65697. export * from "babylonjs/Misc/typeStore";
  65698. export * from "babylonjs/Misc/webRequest";
  65699. export * from "babylonjs/Misc/iInspectable";
  65700. export * from "babylonjs/Misc/brdfTextureTools";
  65701. export * from "babylonjs/Misc/rgbdTextureTools";
  65702. export * from "babylonjs/Misc/gradients";
  65703. export * from "babylonjs/Misc/perfCounter";
  65704. export * from "babylonjs/Misc/fileRequest";
  65705. export * from "babylonjs/Misc/customAnimationFrameRequester";
  65706. export * from "babylonjs/Misc/retryStrategy";
  65707. export * from "babylonjs/Misc/loadFileError";
  65708. export * from "babylonjs/Misc/interfaces/screenshotSize";
  65709. }
  65710. declare module "babylonjs/index" {
  65711. export * from "babylonjs/abstractScene";
  65712. export * from "babylonjs/Actions/index";
  65713. export * from "babylonjs/Animations/index";
  65714. export * from "babylonjs/assetContainer";
  65715. export * from "babylonjs/Audio/index";
  65716. export * from "babylonjs/Behaviors/index";
  65717. export * from "babylonjs/Bones/index";
  65718. export * from "babylonjs/Cameras/index";
  65719. export * from "babylonjs/Collisions/index";
  65720. export * from "babylonjs/Culling/index";
  65721. export * from "babylonjs/Debug/index";
  65722. export * from "babylonjs/Engines/index";
  65723. export * from "babylonjs/Events/index";
  65724. export * from "babylonjs/Gamepads/index";
  65725. export * from "babylonjs/Gizmos/index";
  65726. export * from "babylonjs/Helpers/index";
  65727. export * from "babylonjs/Instrumentation/index";
  65728. export * from "babylonjs/Layers/index";
  65729. export * from "babylonjs/LensFlares/index";
  65730. export * from "babylonjs/Lights/index";
  65731. export * from "babylonjs/Loading/index";
  65732. export * from "babylonjs/Materials/index";
  65733. export * from "babylonjs/Maths/index";
  65734. export * from "babylonjs/Meshes/index";
  65735. export * from "babylonjs/Morph/index";
  65736. export * from "babylonjs/Navigation/index";
  65737. export * from "babylonjs/node";
  65738. export * from "babylonjs/Offline/index";
  65739. export * from "babylonjs/Particles/index";
  65740. export * from "babylonjs/Physics/index";
  65741. export * from "babylonjs/PostProcesses/index";
  65742. export * from "babylonjs/Probes/index";
  65743. export * from "babylonjs/Rendering/index";
  65744. export * from "babylonjs/scene";
  65745. export * from "babylonjs/sceneComponent";
  65746. export * from "babylonjs/Sprites/index";
  65747. export * from "babylonjs/States/index";
  65748. export * from "babylonjs/Misc/index";
  65749. export * from "babylonjs/types";
  65750. }
  65751. declare module "babylonjs/Animations/pathCursor" {
  65752. import { Vector3 } from "babylonjs/Maths/math.vector";
  65753. import { Path2 } from "babylonjs/Maths/math.path";
  65754. /**
  65755. * A cursor which tracks a point on a path
  65756. */
  65757. export class PathCursor {
  65758. private path;
  65759. /**
  65760. * Stores path cursor callbacks for when an onchange event is triggered
  65761. */
  65762. private _onchange;
  65763. /**
  65764. * The value of the path cursor
  65765. */
  65766. value: number;
  65767. /**
  65768. * The animation array of the path cursor
  65769. */
  65770. animations: Animation[];
  65771. /**
  65772. * Initializes the path cursor
  65773. * @param path The path to track
  65774. */
  65775. constructor(path: Path2);
  65776. /**
  65777. * Gets the cursor point on the path
  65778. * @returns A point on the path cursor at the cursor location
  65779. */
  65780. getPoint(): Vector3;
  65781. /**
  65782. * Moves the cursor ahead by the step amount
  65783. * @param step The amount to move the cursor forward
  65784. * @returns This path cursor
  65785. */
  65786. moveAhead(step?: number): PathCursor;
  65787. /**
  65788. * Moves the cursor behind by the step amount
  65789. * @param step The amount to move the cursor back
  65790. * @returns This path cursor
  65791. */
  65792. moveBack(step?: number): PathCursor;
  65793. /**
  65794. * Moves the cursor by the step amount
  65795. * If the step amount is greater than one, an exception is thrown
  65796. * @param step The amount to move the cursor
  65797. * @returns This path cursor
  65798. */
  65799. move(step: number): PathCursor;
  65800. /**
  65801. * Ensures that the value is limited between zero and one
  65802. * @returns This path cursor
  65803. */
  65804. private ensureLimits;
  65805. /**
  65806. * Runs onchange callbacks on change (used by the animation engine)
  65807. * @returns This path cursor
  65808. */
  65809. private raiseOnChange;
  65810. /**
  65811. * Executes a function on change
  65812. * @param f A path cursor onchange callback
  65813. * @returns This path cursor
  65814. */
  65815. onchange(f: (cursor: PathCursor) => void): PathCursor;
  65816. }
  65817. }
  65818. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  65819. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  65820. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  65821. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  65822. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  65823. }
  65824. declare module "babylonjs/Engines/Processors/Expressions/index" {
  65825. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  65826. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  65827. }
  65828. declare module "babylonjs/Engines/Processors/index" {
  65829. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  65830. export * from "babylonjs/Engines/Processors/Expressions/index";
  65831. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  65832. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  65833. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  65834. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  65835. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  65836. export * from "babylonjs/Engines/Processors/shaderProcessor";
  65837. }
  65838. declare module "babylonjs/Legacy/legacy" {
  65839. import * as Babylon from "babylonjs/index";
  65840. export * from "babylonjs/index";
  65841. }
  65842. declare module "babylonjs/Shaders/blur.fragment" {
  65843. /** @hidden */
  65844. export var blurPixelShader: {
  65845. name: string;
  65846. shader: string;
  65847. };
  65848. }
  65849. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  65850. /** @hidden */
  65851. export var pointCloudVertexDeclaration: {
  65852. name: string;
  65853. shader: string;
  65854. };
  65855. }
  65856. declare module "babylonjs" {
  65857. export * from "babylonjs/Legacy/legacy";
  65858. }
  65859. declare module BABYLON {
  65860. /** Alias type for value that can be null */
  65861. export type Nullable<T> = T | null;
  65862. /**
  65863. * Alias type for number that are floats
  65864. * @ignorenaming
  65865. */
  65866. export type float = number;
  65867. /**
  65868. * Alias type for number that are doubles.
  65869. * @ignorenaming
  65870. */
  65871. export type double = number;
  65872. /**
  65873. * Alias type for number that are integer
  65874. * @ignorenaming
  65875. */
  65876. export type int = number;
  65877. /** Alias type for number array or Float32Array */
  65878. export type FloatArray = number[] | Float32Array;
  65879. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  65880. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  65881. /**
  65882. * Alias for types that can be used by a Buffer or VertexBuffer.
  65883. */
  65884. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  65885. /**
  65886. * Alias type for primitive types
  65887. * @ignorenaming
  65888. */
  65889. type Primitive = undefined | null | boolean | string | number | Function;
  65890. /**
  65891. * Type modifier to make all the properties of an object Readonly
  65892. */
  65893. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  65894. /**
  65895. * Type modifier to make all the properties of an object Readonly recursively
  65896. */
  65897. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  65898. /** @hidden */
  65899. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  65900. }
  65901. /** @hidden */
  65902. /** @hidden */
  65903. type DeepImmutableObject<T> = {
  65904. readonly [K in keyof T]: DeepImmutable<T[K]>;
  65905. };
  65906. }
  65907. declare module BABYLON {
  65908. /**
  65909. * A class serves as a medium between the observable and its observers
  65910. */
  65911. export class EventState {
  65912. /**
  65913. * Create a new EventState
  65914. * @param mask defines the mask associated with this state
  65915. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65916. * @param target defines the original target of the state
  65917. * @param currentTarget defines the current target of the state
  65918. */
  65919. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  65920. /**
  65921. * Initialize the current event state
  65922. * @param mask defines the mask associated with this state
  65923. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  65924. * @param target defines the original target of the state
  65925. * @param currentTarget defines the current target of the state
  65926. * @returns the current event state
  65927. */
  65928. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  65929. /**
  65930. * An Observer can set this property to true to prevent subsequent observers of being notified
  65931. */
  65932. skipNextObservers: boolean;
  65933. /**
  65934. * Get the mask value that were used to trigger the event corresponding to this EventState object
  65935. */
  65936. mask: number;
  65937. /**
  65938. * The object that originally notified the event
  65939. */
  65940. target?: any;
  65941. /**
  65942. * The current object in the bubbling phase
  65943. */
  65944. currentTarget?: any;
  65945. /**
  65946. * This will be populated with the return value of the last function that was executed.
  65947. * If it is the first function in the callback chain it will be the event data.
  65948. */
  65949. lastReturnValue?: any;
  65950. }
  65951. /**
  65952. * Represent an Observer registered to a given Observable object.
  65953. */
  65954. export class Observer<T> {
  65955. /**
  65956. * Defines the callback to call when the observer is notified
  65957. */
  65958. callback: (eventData: T, eventState: EventState) => void;
  65959. /**
  65960. * Defines the mask of the observer (used to filter notifications)
  65961. */
  65962. mask: number;
  65963. /**
  65964. * Defines the current scope used to restore the JS context
  65965. */
  65966. scope: any;
  65967. /** @hidden */
  65968. _willBeUnregistered: boolean;
  65969. /**
  65970. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  65971. */
  65972. unregisterOnNextCall: boolean;
  65973. /**
  65974. * Creates a new observer
  65975. * @param callback defines the callback to call when the observer is notified
  65976. * @param mask defines the mask of the observer (used to filter notifications)
  65977. * @param scope defines the current scope used to restore the JS context
  65978. */
  65979. constructor(
  65980. /**
  65981. * Defines the callback to call when the observer is notified
  65982. */
  65983. callback: (eventData: T, eventState: EventState) => void,
  65984. /**
  65985. * Defines the mask of the observer (used to filter notifications)
  65986. */
  65987. mask: number,
  65988. /**
  65989. * Defines the current scope used to restore the JS context
  65990. */
  65991. scope?: any);
  65992. }
  65993. /**
  65994. * Represent a list of observers registered to multiple Observables object.
  65995. */
  65996. export class MultiObserver<T> {
  65997. private _observers;
  65998. private _observables;
  65999. /**
  66000. * Release associated resources
  66001. */
  66002. dispose(): void;
  66003. /**
  66004. * Raise a callback when one of the observable will notify
  66005. * @param observables defines a list of observables to watch
  66006. * @param callback defines the callback to call on notification
  66007. * @param mask defines the mask used to filter notifications
  66008. * @param scope defines the current scope used to restore the JS context
  66009. * @returns the new MultiObserver
  66010. */
  66011. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66012. }
  66013. /**
  66014. * The Observable class is a simple implementation of the Observable pattern.
  66015. *
  66016. * 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.
  66017. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66018. * 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).
  66019. * 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.
  66020. */
  66021. export class Observable<T> {
  66022. private _observers;
  66023. private _eventState;
  66024. private _onObserverAdded;
  66025. /**
  66026. * Gets the list of observers
  66027. */
  66028. readonly observers: Array<Observer<T>>;
  66029. /**
  66030. * Creates a new observable
  66031. * @param onObserverAdded defines a callback to call when a new observer is added
  66032. */
  66033. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66034. /**
  66035. * Create a new Observer with the specified callback
  66036. * @param callback the callback that will be executed for that Observer
  66037. * @param mask the mask used to filter observers
  66038. * @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.
  66039. * @param scope optional scope for the callback to be called from
  66040. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66041. * @returns the new observer created for the callback
  66042. */
  66043. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66044. /**
  66045. * Create a new Observer with the specified callback and unregisters after the next notification
  66046. * @param callback the callback that will be executed for that Observer
  66047. * @returns the new observer created for the callback
  66048. */
  66049. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66050. /**
  66051. * Remove an Observer from the Observable object
  66052. * @param observer the instance of the Observer to remove
  66053. * @returns false if it doesn't belong to this Observable
  66054. */
  66055. remove(observer: Nullable<Observer<T>>): boolean;
  66056. /**
  66057. * Remove a callback from the Observable object
  66058. * @param callback the callback to remove
  66059. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66060. * @returns false if it doesn't belong to this Observable
  66061. */
  66062. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66063. private _deferUnregister;
  66064. private _remove;
  66065. /**
  66066. * Moves the observable to the top of the observer list making it get called first when notified
  66067. * @param observer the observer to move
  66068. */
  66069. makeObserverTopPriority(observer: Observer<T>): void;
  66070. /**
  66071. * Moves the observable to the bottom of the observer list making it get called last when notified
  66072. * @param observer the observer to move
  66073. */
  66074. makeObserverBottomPriority(observer: Observer<T>): void;
  66075. /**
  66076. * Notify all Observers by calling their respective callback with the given data
  66077. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66078. * @param eventData defines the data to send to all observers
  66079. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66080. * @param target defines the original target of the state
  66081. * @param currentTarget defines the current target of the state
  66082. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66083. */
  66084. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66085. /**
  66086. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66087. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66088. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66089. * and it is crucial that all callbacks will be executed.
  66090. * The order of the callbacks is kept, callbacks are not executed parallel.
  66091. *
  66092. * @param eventData The data to be sent to each callback
  66093. * @param mask is used to filter observers defaults to -1
  66094. * @param target defines the callback target (see EventState)
  66095. * @param currentTarget defines he current object in the bubbling phase
  66096. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66097. */
  66098. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66099. /**
  66100. * Notify a specific observer
  66101. * @param observer defines the observer to notify
  66102. * @param eventData defines the data to be sent to each callback
  66103. * @param mask is used to filter observers defaults to -1
  66104. */
  66105. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66106. /**
  66107. * Gets a boolean indicating if the observable has at least one observer
  66108. * @returns true is the Observable has at least one Observer registered
  66109. */
  66110. hasObservers(): boolean;
  66111. /**
  66112. * Clear the list of observers
  66113. */
  66114. clear(): void;
  66115. /**
  66116. * Clone the current observable
  66117. * @returns a new observable
  66118. */
  66119. clone(): Observable<T>;
  66120. /**
  66121. * Does this observable handles observer registered with a given mask
  66122. * @param mask defines the mask to be tested
  66123. * @return whether or not one observer registered with the given mask is handeled
  66124. **/
  66125. hasSpecificMask(mask?: number): boolean;
  66126. }
  66127. }
  66128. declare module BABYLON {
  66129. /**
  66130. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  66131. * Babylon.js
  66132. */
  66133. export class DomManagement {
  66134. /**
  66135. * Checks if the window object exists
  66136. * @returns true if the window object exists
  66137. */
  66138. static IsWindowObjectExist(): boolean;
  66139. /**
  66140. * Checks if the navigator object exists
  66141. * @returns true if the navigator object exists
  66142. */
  66143. static IsNavigatorAvailable(): boolean;
  66144. /**
  66145. * Extracts text content from a DOM element hierarchy
  66146. * @param element defines the root element
  66147. * @returns a string
  66148. */
  66149. static GetDOMTextContent(element: HTMLElement): string;
  66150. }
  66151. }
  66152. declare module BABYLON {
  66153. /**
  66154. * Logger used througouht the application to allow configuration of
  66155. * the log level required for the messages.
  66156. */
  66157. export class Logger {
  66158. /**
  66159. * No log
  66160. */
  66161. static readonly NoneLogLevel: number;
  66162. /**
  66163. * Only message logs
  66164. */
  66165. static readonly MessageLogLevel: number;
  66166. /**
  66167. * Only warning logs
  66168. */
  66169. static readonly WarningLogLevel: number;
  66170. /**
  66171. * Only error logs
  66172. */
  66173. static readonly ErrorLogLevel: number;
  66174. /**
  66175. * All logs
  66176. */
  66177. static readonly AllLogLevel: number;
  66178. private static _LogCache;
  66179. /**
  66180. * Gets a value indicating the number of loading errors
  66181. * @ignorenaming
  66182. */
  66183. static errorsCount: number;
  66184. /**
  66185. * Callback called when a new log is added
  66186. */
  66187. static OnNewCacheEntry: (entry: string) => void;
  66188. private static _AddLogEntry;
  66189. private static _FormatMessage;
  66190. private static _LogDisabled;
  66191. private static _LogEnabled;
  66192. private static _WarnDisabled;
  66193. private static _WarnEnabled;
  66194. private static _ErrorDisabled;
  66195. private static _ErrorEnabled;
  66196. /**
  66197. * Log a message to the console
  66198. */
  66199. static Log: (message: string) => void;
  66200. /**
  66201. * Write a warning message to the console
  66202. */
  66203. static Warn: (message: string) => void;
  66204. /**
  66205. * Write an error message to the console
  66206. */
  66207. static Error: (message: string) => void;
  66208. /**
  66209. * Gets current log cache (list of logs)
  66210. */
  66211. static readonly LogCache: string;
  66212. /**
  66213. * Clears the log cache
  66214. */
  66215. static ClearLogCache(): void;
  66216. /**
  66217. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  66218. */
  66219. static LogLevels: number;
  66220. }
  66221. }
  66222. declare module BABYLON {
  66223. /** @hidden */
  66224. export class _TypeStore {
  66225. /** @hidden */
  66226. static RegisteredTypes: {
  66227. [key: string]: Object;
  66228. };
  66229. /** @hidden */
  66230. static GetClass(fqdn: string): any;
  66231. }
  66232. }
  66233. declare module BABYLON {
  66234. /**
  66235. * Class containing a set of static utilities functions for deep copy.
  66236. */
  66237. export class DeepCopier {
  66238. /**
  66239. * Tries to copy an object by duplicating every property
  66240. * @param source defines the source object
  66241. * @param destination defines the target object
  66242. * @param doNotCopyList defines a list of properties to avoid
  66243. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  66244. */
  66245. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  66246. }
  66247. }
  66248. declare module BABYLON {
  66249. /**
  66250. * Class containing a set of static utilities functions for precision date
  66251. */
  66252. export class PrecisionDate {
  66253. /**
  66254. * Gets either window.performance.now() if supported or Date.now() else
  66255. */
  66256. static readonly Now: number;
  66257. }
  66258. }
  66259. declare module BABYLON {
  66260. /** @hidden */
  66261. export class _DevTools {
  66262. static WarnImport(name: string): string;
  66263. }
  66264. }
  66265. declare module BABYLON {
  66266. /**
  66267. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  66268. */
  66269. export class WebRequest {
  66270. private _xhr;
  66271. /**
  66272. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  66273. * i.e. when loading files, where the server/service expects an Authorization header
  66274. */
  66275. static CustomRequestHeaders: {
  66276. [key: string]: string;
  66277. };
  66278. /**
  66279. * Add callback functions in this array to update all the requests before they get sent to the network
  66280. */
  66281. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  66282. private _injectCustomRequestHeaders;
  66283. /**
  66284. * Gets or sets a function to be called when loading progress changes
  66285. */
  66286. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  66287. /**
  66288. * Returns client's state
  66289. */
  66290. readonly readyState: number;
  66291. /**
  66292. * Returns client's status
  66293. */
  66294. readonly status: number;
  66295. /**
  66296. * Returns client's status as a text
  66297. */
  66298. readonly statusText: string;
  66299. /**
  66300. * Returns client's response
  66301. */
  66302. readonly response: any;
  66303. /**
  66304. * Returns client's response url
  66305. */
  66306. readonly responseURL: string;
  66307. /**
  66308. * Returns client's response as text
  66309. */
  66310. readonly responseText: string;
  66311. /**
  66312. * Gets or sets the expected response type
  66313. */
  66314. responseType: XMLHttpRequestResponseType;
  66315. /** @hidden */
  66316. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  66317. /** @hidden */
  66318. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  66319. /**
  66320. * Cancels any network activity
  66321. */
  66322. abort(): void;
  66323. /**
  66324. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  66325. * @param body defines an optional request body
  66326. */
  66327. send(body?: Document | BodyInit | null): void;
  66328. /**
  66329. * Sets the request method, request URL
  66330. * @param method defines the method to use (GET, POST, etc..)
  66331. * @param url defines the url to connect with
  66332. */
  66333. open(method: string, url: string): void;
  66334. }
  66335. }
  66336. declare module BABYLON {
  66337. /**
  66338. * File request interface
  66339. */
  66340. export interface IFileRequest {
  66341. /**
  66342. * Raised when the request is complete (success or error).
  66343. */
  66344. onCompleteObservable: Observable<IFileRequest>;
  66345. /**
  66346. * Aborts the request for a file.
  66347. */
  66348. abort: () => void;
  66349. }
  66350. }
  66351. declare module BABYLON {
  66352. /**
  66353. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  66354. */
  66355. export class PerformanceMonitor {
  66356. private _enabled;
  66357. private _rollingFrameTime;
  66358. private _lastFrameTimeMs;
  66359. /**
  66360. * constructor
  66361. * @param frameSampleSize The number of samples required to saturate the sliding window
  66362. */
  66363. constructor(frameSampleSize?: number);
  66364. /**
  66365. * Samples current frame
  66366. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  66367. */
  66368. sampleFrame(timeMs?: number): void;
  66369. /**
  66370. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  66371. */
  66372. readonly averageFrameTime: number;
  66373. /**
  66374. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  66375. */
  66376. readonly averageFrameTimeVariance: number;
  66377. /**
  66378. * Returns the frame time of the most recent frame
  66379. */
  66380. readonly instantaneousFrameTime: number;
  66381. /**
  66382. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  66383. */
  66384. readonly averageFPS: number;
  66385. /**
  66386. * Returns the average framerate in frames per second using the most recent frame time
  66387. */
  66388. readonly instantaneousFPS: number;
  66389. /**
  66390. * Returns true if enough samples have been taken to completely fill the sliding window
  66391. */
  66392. readonly isSaturated: boolean;
  66393. /**
  66394. * Enables contributions to the sliding window sample set
  66395. */
  66396. enable(): void;
  66397. /**
  66398. * Disables contributions to the sliding window sample set
  66399. * Samples will not be interpolated over the disabled period
  66400. */
  66401. disable(): void;
  66402. /**
  66403. * Returns true if sampling is enabled
  66404. */
  66405. readonly isEnabled: boolean;
  66406. /**
  66407. * Resets performance monitor
  66408. */
  66409. reset(): void;
  66410. }
  66411. /**
  66412. * RollingAverage
  66413. *
  66414. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  66415. */
  66416. export class RollingAverage {
  66417. /**
  66418. * Current average
  66419. */
  66420. average: number;
  66421. /**
  66422. * Current variance
  66423. */
  66424. variance: number;
  66425. protected _samples: Array<number>;
  66426. protected _sampleCount: number;
  66427. protected _pos: number;
  66428. protected _m2: number;
  66429. /**
  66430. * constructor
  66431. * @param length The number of samples required to saturate the sliding window
  66432. */
  66433. constructor(length: number);
  66434. /**
  66435. * Adds a sample to the sample set
  66436. * @param v The sample value
  66437. */
  66438. add(v: number): void;
  66439. /**
  66440. * Returns previously added values or null if outside of history or outside the sliding window domain
  66441. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  66442. * @return Value previously recorded with add() or null if outside of range
  66443. */
  66444. history(i: number): number;
  66445. /**
  66446. * Returns true if enough samples have been taken to completely fill the sliding window
  66447. * @return true if sample-set saturated
  66448. */
  66449. isSaturated(): boolean;
  66450. /**
  66451. * Resets the rolling average (equivalent to 0 samples taken so far)
  66452. */
  66453. reset(): void;
  66454. /**
  66455. * Wraps a value around the sample range boundaries
  66456. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  66457. * @return Wrapped position in sample range
  66458. */
  66459. protected _wrapPosition(i: number): number;
  66460. }
  66461. }
  66462. declare module BABYLON {
  66463. /**
  66464. * This class implement a typical dictionary using a string as key and the generic type T as value.
  66465. * The underlying implementation relies on an associative array to ensure the best performances.
  66466. * The value can be anything including 'null' but except 'undefined'
  66467. */
  66468. export class StringDictionary<T> {
  66469. /**
  66470. * This will clear this dictionary and copy the content from the 'source' one.
  66471. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  66472. * @param source the dictionary to take the content from and copy to this dictionary
  66473. */
  66474. copyFrom(source: StringDictionary<T>): void;
  66475. /**
  66476. * Get a value based from its key
  66477. * @param key the given key to get the matching value from
  66478. * @return the value if found, otherwise undefined is returned
  66479. */
  66480. get(key: string): T | undefined;
  66481. /**
  66482. * Get a value from its key or add it if it doesn't exist.
  66483. * This method will ensure you that a given key/data will be present in the dictionary.
  66484. * @param key the given key to get the matching value from
  66485. * @param factory the factory that will create the value if the key is not present in the dictionary.
  66486. * The factory will only be invoked if there's no data for the given key.
  66487. * @return the value corresponding to the key.
  66488. */
  66489. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  66490. /**
  66491. * Get a value from its key if present in the dictionary otherwise add it
  66492. * @param key the key to get the value from
  66493. * @param val if there's no such key/value pair in the dictionary add it with this value
  66494. * @return the value corresponding to the key
  66495. */
  66496. getOrAdd(key: string, val: T): T;
  66497. /**
  66498. * Check if there's a given key in the dictionary
  66499. * @param key the key to check for
  66500. * @return true if the key is present, false otherwise
  66501. */
  66502. contains(key: string): boolean;
  66503. /**
  66504. * Add a new key and its corresponding value
  66505. * @param key the key to add
  66506. * @param value the value corresponding to the key
  66507. * @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
  66508. */
  66509. add(key: string, value: T): boolean;
  66510. /**
  66511. * Update a specific value associated to a key
  66512. * @param key defines the key to use
  66513. * @param value defines the value to store
  66514. * @returns true if the value was updated (or false if the key was not found)
  66515. */
  66516. set(key: string, value: T): boolean;
  66517. /**
  66518. * Get the element of the given key and remove it from the dictionary
  66519. * @param key defines the key to search
  66520. * @returns the value associated with the key or null if not found
  66521. */
  66522. getAndRemove(key: string): Nullable<T>;
  66523. /**
  66524. * Remove a key/value from the dictionary.
  66525. * @param key the key to remove
  66526. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  66527. */
  66528. remove(key: string): boolean;
  66529. /**
  66530. * Clear the whole content of the dictionary
  66531. */
  66532. clear(): void;
  66533. /**
  66534. * Gets the current count
  66535. */
  66536. readonly count: number;
  66537. /**
  66538. * Execute a callback on each key/val of the dictionary.
  66539. * Note that you can remove any element in this dictionary in the callback implementation
  66540. * @param callback the callback to execute on a given key/value pair
  66541. */
  66542. forEach(callback: (key: string, val: T) => void): void;
  66543. /**
  66544. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  66545. * If the callback returns null or undefined the method will iterate to the next key/value pair
  66546. * Note that you can remove any element in this dictionary in the callback implementation
  66547. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  66548. * @returns the first item
  66549. */
  66550. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  66551. private _count;
  66552. private _data;
  66553. }
  66554. }
  66555. declare module BABYLON {
  66556. /**
  66557. * Class used to store gfx data (like WebGLBuffer)
  66558. */
  66559. export class DataBuffer {
  66560. /**
  66561. * Gets or sets the number of objects referencing this buffer
  66562. */
  66563. references: number;
  66564. /** Gets or sets the size of the underlying buffer */
  66565. capacity: number;
  66566. /**
  66567. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  66568. */
  66569. is32Bits: boolean;
  66570. /**
  66571. * Gets the underlying buffer
  66572. */
  66573. readonly underlyingResource: any;
  66574. }
  66575. }
  66576. declare module BABYLON {
  66577. /**
  66578. * Class used to store data that will be store in GPU memory
  66579. */
  66580. export class Buffer {
  66581. private _engine;
  66582. private _buffer;
  66583. /** @hidden */
  66584. _data: Nullable<DataArray>;
  66585. private _updatable;
  66586. private _instanced;
  66587. /**
  66588. * Gets the byte stride.
  66589. */
  66590. readonly byteStride: number;
  66591. /**
  66592. * Constructor
  66593. * @param engine the engine
  66594. * @param data the data to use for this buffer
  66595. * @param updatable whether the data is updatable
  66596. * @param stride the stride (optional)
  66597. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66598. * @param instanced whether the buffer is instanced (optional)
  66599. * @param useBytes set to true if the stride in in bytes (optional)
  66600. */
  66601. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  66602. /**
  66603. * Create a new VertexBuffer based on the current buffer
  66604. * @param kind defines the vertex buffer kind (position, normal, etc.)
  66605. * @param offset defines offset in the buffer (0 by default)
  66606. * @param size defines the size in floats of attributes (position is 3 for instance)
  66607. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  66608. * @param instanced defines if the vertex buffer contains indexed data
  66609. * @param useBytes defines if the offset and stride are in bytes
  66610. * @returns the new vertex buffer
  66611. */
  66612. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  66613. /**
  66614. * Gets a boolean indicating if the Buffer is updatable?
  66615. * @returns true if the buffer is updatable
  66616. */
  66617. isUpdatable(): boolean;
  66618. /**
  66619. * Gets current buffer's data
  66620. * @returns a DataArray or null
  66621. */
  66622. getData(): Nullable<DataArray>;
  66623. /**
  66624. * Gets underlying native buffer
  66625. * @returns underlying native buffer
  66626. */
  66627. getBuffer(): Nullable<DataBuffer>;
  66628. /**
  66629. * Gets the stride in float32 units (i.e. byte stride / 4).
  66630. * May not be an integer if the byte stride is not divisible by 4.
  66631. * DEPRECATED. Use byteStride instead.
  66632. * @returns the stride in float32 units
  66633. */
  66634. getStrideSize(): number;
  66635. /**
  66636. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66637. * @param data defines the data to store
  66638. */
  66639. create(data?: Nullable<DataArray>): void;
  66640. /** @hidden */
  66641. _rebuild(): void;
  66642. /**
  66643. * Update current buffer data
  66644. * @param data defines the data to store
  66645. */
  66646. update(data: DataArray): void;
  66647. /**
  66648. * Updates the data directly.
  66649. * @param data the new data
  66650. * @param offset the new offset
  66651. * @param vertexCount the vertex count (optional)
  66652. * @param useBytes set to true if the offset is in bytes
  66653. */
  66654. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  66655. /**
  66656. * Release all resources
  66657. */
  66658. dispose(): void;
  66659. }
  66660. /**
  66661. * Specialized buffer used to store vertex data
  66662. */
  66663. export class VertexBuffer {
  66664. /** @hidden */
  66665. _buffer: Buffer;
  66666. private _kind;
  66667. private _size;
  66668. private _ownsBuffer;
  66669. private _instanced;
  66670. private _instanceDivisor;
  66671. /**
  66672. * The byte type.
  66673. */
  66674. static readonly BYTE: number;
  66675. /**
  66676. * The unsigned byte type.
  66677. */
  66678. static readonly UNSIGNED_BYTE: number;
  66679. /**
  66680. * The short type.
  66681. */
  66682. static readonly SHORT: number;
  66683. /**
  66684. * The unsigned short type.
  66685. */
  66686. static readonly UNSIGNED_SHORT: number;
  66687. /**
  66688. * The integer type.
  66689. */
  66690. static readonly INT: number;
  66691. /**
  66692. * The unsigned integer type.
  66693. */
  66694. static readonly UNSIGNED_INT: number;
  66695. /**
  66696. * The float type.
  66697. */
  66698. static readonly FLOAT: number;
  66699. /**
  66700. * Gets or sets the instance divisor when in instanced mode
  66701. */
  66702. instanceDivisor: number;
  66703. /**
  66704. * Gets the byte stride.
  66705. */
  66706. readonly byteStride: number;
  66707. /**
  66708. * Gets the byte offset.
  66709. */
  66710. readonly byteOffset: number;
  66711. /**
  66712. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  66713. */
  66714. readonly normalized: boolean;
  66715. /**
  66716. * Gets the data type of each component in the array.
  66717. */
  66718. readonly type: number;
  66719. /**
  66720. * Constructor
  66721. * @param engine the engine
  66722. * @param data the data to use for this vertex buffer
  66723. * @param kind the vertex buffer kind
  66724. * @param updatable whether the data is updatable
  66725. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  66726. * @param stride the stride (optional)
  66727. * @param instanced whether the buffer is instanced (optional)
  66728. * @param offset the offset of the data (optional)
  66729. * @param size the number of components (optional)
  66730. * @param type the type of the component (optional)
  66731. * @param normalized whether the data contains normalized data (optional)
  66732. * @param useBytes set to true if stride and offset are in bytes (optional)
  66733. */
  66734. 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);
  66735. /** @hidden */
  66736. _rebuild(): void;
  66737. /**
  66738. * Returns the kind of the VertexBuffer (string)
  66739. * @returns a string
  66740. */
  66741. getKind(): string;
  66742. /**
  66743. * Gets a boolean indicating if the VertexBuffer is updatable?
  66744. * @returns true if the buffer is updatable
  66745. */
  66746. isUpdatable(): boolean;
  66747. /**
  66748. * Gets current buffer's data
  66749. * @returns a DataArray or null
  66750. */
  66751. getData(): Nullable<DataArray>;
  66752. /**
  66753. * Gets underlying native buffer
  66754. * @returns underlying native buffer
  66755. */
  66756. getBuffer(): Nullable<DataBuffer>;
  66757. /**
  66758. * Gets the stride in float32 units (i.e. byte stride / 4).
  66759. * May not be an integer if the byte stride is not divisible by 4.
  66760. * DEPRECATED. Use byteStride instead.
  66761. * @returns the stride in float32 units
  66762. */
  66763. getStrideSize(): number;
  66764. /**
  66765. * Returns the offset as a multiple of the type byte length.
  66766. * DEPRECATED. Use byteOffset instead.
  66767. * @returns the offset in bytes
  66768. */
  66769. getOffset(): number;
  66770. /**
  66771. * Returns the number of components per vertex attribute (integer)
  66772. * @returns the size in float
  66773. */
  66774. getSize(): number;
  66775. /**
  66776. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  66777. * @returns true if this buffer is instanced
  66778. */
  66779. getIsInstanced(): boolean;
  66780. /**
  66781. * Returns the instancing divisor, zero for non-instanced (integer).
  66782. * @returns a number
  66783. */
  66784. getInstanceDivisor(): number;
  66785. /**
  66786. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  66787. * @param data defines the data to store
  66788. */
  66789. create(data?: DataArray): void;
  66790. /**
  66791. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  66792. * This function will create a new buffer if the current one is not updatable
  66793. * @param data defines the data to store
  66794. */
  66795. update(data: DataArray): void;
  66796. /**
  66797. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  66798. * Returns the directly updated WebGLBuffer.
  66799. * @param data the new data
  66800. * @param offset the new offset
  66801. * @param useBytes set to true if the offset is in bytes
  66802. */
  66803. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  66804. /**
  66805. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  66806. */
  66807. dispose(): void;
  66808. /**
  66809. * Enumerates each value of this vertex buffer as numbers.
  66810. * @param count the number of values to enumerate
  66811. * @param callback the callback function called for each value
  66812. */
  66813. forEach(count: number, callback: (value: number, index: number) => void): void;
  66814. /**
  66815. * Positions
  66816. */
  66817. static readonly PositionKind: string;
  66818. /**
  66819. * Normals
  66820. */
  66821. static readonly NormalKind: string;
  66822. /**
  66823. * Tangents
  66824. */
  66825. static readonly TangentKind: string;
  66826. /**
  66827. * Texture coordinates
  66828. */
  66829. static readonly UVKind: string;
  66830. /**
  66831. * Texture coordinates 2
  66832. */
  66833. static readonly UV2Kind: string;
  66834. /**
  66835. * Texture coordinates 3
  66836. */
  66837. static readonly UV3Kind: string;
  66838. /**
  66839. * Texture coordinates 4
  66840. */
  66841. static readonly UV4Kind: string;
  66842. /**
  66843. * Texture coordinates 5
  66844. */
  66845. static readonly UV5Kind: string;
  66846. /**
  66847. * Texture coordinates 6
  66848. */
  66849. static readonly UV6Kind: string;
  66850. /**
  66851. * Colors
  66852. */
  66853. static readonly ColorKind: string;
  66854. /**
  66855. * Matrix indices (for bones)
  66856. */
  66857. static readonly MatricesIndicesKind: string;
  66858. /**
  66859. * Matrix weights (for bones)
  66860. */
  66861. static readonly MatricesWeightsKind: string;
  66862. /**
  66863. * Additional matrix indices (for bones)
  66864. */
  66865. static readonly MatricesIndicesExtraKind: string;
  66866. /**
  66867. * Additional matrix weights (for bones)
  66868. */
  66869. static readonly MatricesWeightsExtraKind: string;
  66870. /**
  66871. * Deduces the stride given a kind.
  66872. * @param kind The kind string to deduce
  66873. * @returns The deduced stride
  66874. */
  66875. static DeduceStride(kind: string): number;
  66876. /**
  66877. * Gets the byte length of the given type.
  66878. * @param type the type
  66879. * @returns the number of bytes
  66880. */
  66881. static GetTypeByteLength(type: number): number;
  66882. /**
  66883. * Enumerates each value of the given parameters as numbers.
  66884. * @param data the data to enumerate
  66885. * @param byteOffset the byte offset of the data
  66886. * @param byteStride the byte stride of the data
  66887. * @param componentCount the number of components per element
  66888. * @param componentType the type of the component
  66889. * @param count the number of values to enumerate
  66890. * @param normalized whether the data is normalized
  66891. * @param callback the callback function called for each value
  66892. */
  66893. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  66894. private static _GetFloatValue;
  66895. }
  66896. }
  66897. declare module BABYLON {
  66898. /**
  66899. * Scalar computation library
  66900. */
  66901. export class Scalar {
  66902. /**
  66903. * Two pi constants convenient for computation.
  66904. */
  66905. static TwoPi: number;
  66906. /**
  66907. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66908. * @param a number
  66909. * @param b number
  66910. * @param epsilon (default = 1.401298E-45)
  66911. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  66912. */
  66913. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  66914. /**
  66915. * Returns a string : the upper case translation of the number i to hexadecimal.
  66916. * @param i number
  66917. * @returns the upper case translation of the number i to hexadecimal.
  66918. */
  66919. static ToHex(i: number): string;
  66920. /**
  66921. * Returns -1 if value is negative and +1 is value is positive.
  66922. * @param value the value
  66923. * @returns the value itself if it's equal to zero.
  66924. */
  66925. static Sign(value: number): number;
  66926. /**
  66927. * Returns the value itself if it's between min and max.
  66928. * Returns min if the value is lower than min.
  66929. * Returns max if the value is greater than max.
  66930. * @param value the value to clmap
  66931. * @param min the min value to clamp to (default: 0)
  66932. * @param max the max value to clamp to (default: 1)
  66933. * @returns the clamped value
  66934. */
  66935. static Clamp(value: number, min?: number, max?: number): number;
  66936. /**
  66937. * the log2 of value.
  66938. * @param value the value to compute log2 of
  66939. * @returns the log2 of value.
  66940. */
  66941. static Log2(value: number): number;
  66942. /**
  66943. * Loops the value, so that it is never larger than length and never smaller than 0.
  66944. *
  66945. * This is similar to the modulo operator but it works with floating point numbers.
  66946. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  66947. * With t = 5 and length = 2.5, the result would be 0.0.
  66948. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  66949. * @param value the value
  66950. * @param length the length
  66951. * @returns the looped value
  66952. */
  66953. static Repeat(value: number, length: number): number;
  66954. /**
  66955. * Normalize the value between 0.0 and 1.0 using min and max values
  66956. * @param value value to normalize
  66957. * @param min max to normalize between
  66958. * @param max min to normalize between
  66959. * @returns the normalized value
  66960. */
  66961. static Normalize(value: number, min: number, max: number): number;
  66962. /**
  66963. * Denormalize the value from 0.0 and 1.0 using min and max values
  66964. * @param normalized value to denormalize
  66965. * @param min max to denormalize between
  66966. * @param max min to denormalize between
  66967. * @returns the denormalized value
  66968. */
  66969. static Denormalize(normalized: number, min: number, max: number): number;
  66970. /**
  66971. * Calculates the shortest difference between two given angles given in degrees.
  66972. * @param current current angle in degrees
  66973. * @param target target angle in degrees
  66974. * @returns the delta
  66975. */
  66976. static DeltaAngle(current: number, target: number): number;
  66977. /**
  66978. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  66979. * @param tx value
  66980. * @param length length
  66981. * @returns The returned value will move back and forth between 0 and length
  66982. */
  66983. static PingPong(tx: number, length: number): number;
  66984. /**
  66985. * Interpolates between min and max with smoothing at the limits.
  66986. *
  66987. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  66988. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  66989. * @param from from
  66990. * @param to to
  66991. * @param tx value
  66992. * @returns the smooth stepped value
  66993. */
  66994. static SmoothStep(from: number, to: number, tx: number): number;
  66995. /**
  66996. * Moves a value current towards target.
  66997. *
  66998. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  66999. * Negative values of maxDelta pushes the value away from target.
  67000. * @param current current value
  67001. * @param target target value
  67002. * @param maxDelta max distance to move
  67003. * @returns resulting value
  67004. */
  67005. static MoveTowards(current: number, target: number, maxDelta: number): number;
  67006. /**
  67007. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67008. *
  67009. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  67010. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  67011. * @param current current value
  67012. * @param target target value
  67013. * @param maxDelta max distance to move
  67014. * @returns resulting angle
  67015. */
  67016. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  67017. /**
  67018. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  67019. * @param start start value
  67020. * @param end target value
  67021. * @param amount amount to lerp between
  67022. * @returns the lerped value
  67023. */
  67024. static Lerp(start: number, end: number, amount: number): number;
  67025. /**
  67026. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67027. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  67028. * @param start start value
  67029. * @param end target value
  67030. * @param amount amount to lerp between
  67031. * @returns the lerped value
  67032. */
  67033. static LerpAngle(start: number, end: number, amount: number): number;
  67034. /**
  67035. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  67036. * @param a start value
  67037. * @param b target value
  67038. * @param value value between a and b
  67039. * @returns the inverseLerp value
  67040. */
  67041. static InverseLerp(a: number, b: number, value: number): number;
  67042. /**
  67043. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  67044. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  67045. * @param value1 spline value
  67046. * @param tangent1 spline value
  67047. * @param value2 spline value
  67048. * @param tangent2 spline value
  67049. * @param amount input value
  67050. * @returns hermite result
  67051. */
  67052. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  67053. /**
  67054. * Returns a random float number between and min and max values
  67055. * @param min min value of random
  67056. * @param max max value of random
  67057. * @returns random value
  67058. */
  67059. static RandomRange(min: number, max: number): number;
  67060. /**
  67061. * This function returns percentage of a number in a given range.
  67062. *
  67063. * RangeToPercent(40,20,60) will return 0.5 (50%)
  67064. * RangeToPercent(34,0,100) will return 0.34 (34%)
  67065. * @param number to convert to percentage
  67066. * @param min min range
  67067. * @param max max range
  67068. * @returns the percentage
  67069. */
  67070. static RangeToPercent(number: number, min: number, max: number): number;
  67071. /**
  67072. * This function returns number that corresponds to the percentage in a given range.
  67073. *
  67074. * PercentToRange(0.34,0,100) will return 34.
  67075. * @param percent to convert to number
  67076. * @param min min range
  67077. * @param max max range
  67078. * @returns the number
  67079. */
  67080. static PercentToRange(percent: number, min: number, max: number): number;
  67081. /**
  67082. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  67083. * @param angle The angle to normalize in radian.
  67084. * @return The converted angle.
  67085. */
  67086. static NormalizeRadians(angle: number): number;
  67087. }
  67088. }
  67089. declare module BABYLON {
  67090. /**
  67091. * Constant used to convert a value to gamma space
  67092. * @ignorenaming
  67093. */
  67094. export const ToGammaSpace: number;
  67095. /**
  67096. * Constant used to convert a value to linear space
  67097. * @ignorenaming
  67098. */
  67099. export const ToLinearSpace = 2.2;
  67100. /**
  67101. * Constant used to define the minimal number value in Babylon.js
  67102. * @ignorenaming
  67103. */
  67104. let Epsilon: number;
  67105. }
  67106. declare module BABYLON {
  67107. /**
  67108. * Class used to represent a viewport on screen
  67109. */
  67110. export class Viewport {
  67111. /** viewport left coordinate */
  67112. x: number;
  67113. /** viewport top coordinate */
  67114. y: number;
  67115. /**viewport width */
  67116. width: number;
  67117. /** viewport height */
  67118. height: number;
  67119. /**
  67120. * Creates a Viewport object located at (x, y) and sized (width, height)
  67121. * @param x defines viewport left coordinate
  67122. * @param y defines viewport top coordinate
  67123. * @param width defines the viewport width
  67124. * @param height defines the viewport height
  67125. */
  67126. constructor(
  67127. /** viewport left coordinate */
  67128. x: number,
  67129. /** viewport top coordinate */
  67130. y: number,
  67131. /**viewport width */
  67132. width: number,
  67133. /** viewport height */
  67134. height: number);
  67135. /**
  67136. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  67137. * @param renderWidth defines the rendering width
  67138. * @param renderHeight defines the rendering height
  67139. * @returns a new Viewport
  67140. */
  67141. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  67142. /**
  67143. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  67144. * @param renderWidth defines the rendering width
  67145. * @param renderHeight defines the rendering height
  67146. * @param ref defines the target viewport
  67147. * @returns the current viewport
  67148. */
  67149. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  67150. /**
  67151. * Returns a new Viewport copied from the current one
  67152. * @returns a new Viewport
  67153. */
  67154. clone(): Viewport;
  67155. }
  67156. }
  67157. declare module BABYLON {
  67158. /**
  67159. * Class containing a set of static utilities functions for arrays.
  67160. */
  67161. export class ArrayTools {
  67162. /**
  67163. * Returns an array of the given size filled with element built from the given constructor and the paramters
  67164. * @param size the number of element to construct and put in the array
  67165. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  67166. * @returns a new array filled with new objects
  67167. */
  67168. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  67169. }
  67170. }
  67171. declare module BABYLON {
  67172. /**
  67173. * @hidden
  67174. */
  67175. export interface IColor4Like {
  67176. r: float;
  67177. g: float;
  67178. b: float;
  67179. a: float;
  67180. }
  67181. /**
  67182. * @hidden
  67183. */
  67184. export interface IColor3Like {
  67185. r: float;
  67186. g: float;
  67187. b: float;
  67188. }
  67189. /**
  67190. * @hidden
  67191. */
  67192. export interface IVector4Like {
  67193. x: float;
  67194. y: float;
  67195. z: float;
  67196. w: float;
  67197. }
  67198. /**
  67199. * @hidden
  67200. */
  67201. export interface IVector3Like {
  67202. x: float;
  67203. y: float;
  67204. z: float;
  67205. }
  67206. /**
  67207. * @hidden
  67208. */
  67209. export interface IVector2Like {
  67210. x: float;
  67211. y: float;
  67212. }
  67213. /**
  67214. * @hidden
  67215. */
  67216. export interface IMatrixLike {
  67217. toArray(): DeepImmutable<Float32Array>;
  67218. updateFlag: int;
  67219. }
  67220. /**
  67221. * @hidden
  67222. */
  67223. export interface IViewportLike {
  67224. x: float;
  67225. y: float;
  67226. width: float;
  67227. height: float;
  67228. }
  67229. /**
  67230. * @hidden
  67231. */
  67232. export interface IPlaneLike {
  67233. normal: IVector3Like;
  67234. d: float;
  67235. normalize(): void;
  67236. }
  67237. }
  67238. declare module BABYLON {
  67239. /**
  67240. * Class representing a vector containing 2 coordinates
  67241. */
  67242. export class Vector2 {
  67243. /** defines the first coordinate */
  67244. x: number;
  67245. /** defines the second coordinate */
  67246. y: number;
  67247. /**
  67248. * Creates a new Vector2 from the given x and y coordinates
  67249. * @param x defines the first coordinate
  67250. * @param y defines the second coordinate
  67251. */
  67252. constructor(
  67253. /** defines the first coordinate */
  67254. x?: number,
  67255. /** defines the second coordinate */
  67256. y?: number);
  67257. /**
  67258. * Gets a string with the Vector2 coordinates
  67259. * @returns a string with the Vector2 coordinates
  67260. */
  67261. toString(): string;
  67262. /**
  67263. * Gets class name
  67264. * @returns the string "Vector2"
  67265. */
  67266. getClassName(): string;
  67267. /**
  67268. * Gets current vector hash code
  67269. * @returns the Vector2 hash code as a number
  67270. */
  67271. getHashCode(): number;
  67272. /**
  67273. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  67274. * @param array defines the source array
  67275. * @param index defines the offset in source array
  67276. * @returns the current Vector2
  67277. */
  67278. toArray(array: FloatArray, index?: number): Vector2;
  67279. /**
  67280. * Copy the current vector to an array
  67281. * @returns a new array with 2 elements: the Vector2 coordinates.
  67282. */
  67283. asArray(): number[];
  67284. /**
  67285. * Sets the Vector2 coordinates with the given Vector2 coordinates
  67286. * @param source defines the source Vector2
  67287. * @returns the current updated Vector2
  67288. */
  67289. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  67290. /**
  67291. * Sets the Vector2 coordinates with the given floats
  67292. * @param x defines the first coordinate
  67293. * @param y defines the second coordinate
  67294. * @returns the current updated Vector2
  67295. */
  67296. copyFromFloats(x: number, y: number): Vector2;
  67297. /**
  67298. * Sets the Vector2 coordinates with the given floats
  67299. * @param x defines the first coordinate
  67300. * @param y defines the second coordinate
  67301. * @returns the current updated Vector2
  67302. */
  67303. set(x: number, y: number): Vector2;
  67304. /**
  67305. * Add another vector with the current one
  67306. * @param otherVector defines the other vector
  67307. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  67308. */
  67309. add(otherVector: DeepImmutable<Vector2>): Vector2;
  67310. /**
  67311. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  67312. * @param otherVector defines the other vector
  67313. * @param result defines the target vector
  67314. * @returns the unmodified current Vector2
  67315. */
  67316. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67317. /**
  67318. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  67319. * @param otherVector defines the other vector
  67320. * @returns the current updated Vector2
  67321. */
  67322. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67323. /**
  67324. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  67325. * @param otherVector defines the other vector
  67326. * @returns a new Vector2
  67327. */
  67328. addVector3(otherVector: Vector3): Vector2;
  67329. /**
  67330. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  67331. * @param otherVector defines the other vector
  67332. * @returns a new Vector2
  67333. */
  67334. subtract(otherVector: Vector2): Vector2;
  67335. /**
  67336. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  67337. * @param otherVector defines the other vector
  67338. * @param result defines the target vector
  67339. * @returns the unmodified current Vector2
  67340. */
  67341. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67342. /**
  67343. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  67344. * @param otherVector defines the other vector
  67345. * @returns the current updated Vector2
  67346. */
  67347. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67348. /**
  67349. * Multiplies in place the current Vector2 coordinates by the given ones
  67350. * @param otherVector defines the other vector
  67351. * @returns the current updated Vector2
  67352. */
  67353. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67354. /**
  67355. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  67356. * @param otherVector defines the other vector
  67357. * @returns a new Vector2
  67358. */
  67359. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  67360. /**
  67361. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  67362. * @param otherVector defines the other vector
  67363. * @param result defines the target vector
  67364. * @returns the unmodified current Vector2
  67365. */
  67366. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67367. /**
  67368. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  67369. * @param x defines the first coordinate
  67370. * @param y defines the second coordinate
  67371. * @returns a new Vector2
  67372. */
  67373. multiplyByFloats(x: number, y: number): Vector2;
  67374. /**
  67375. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  67376. * @param otherVector defines the other vector
  67377. * @returns a new Vector2
  67378. */
  67379. divide(otherVector: Vector2): Vector2;
  67380. /**
  67381. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67382. * @param otherVector defines the other vector
  67383. * @param result defines the target vector
  67384. * @returns the unmodified current Vector2
  67385. */
  67386. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67387. /**
  67388. * Divides the current Vector2 coordinates by the given ones
  67389. * @param otherVector defines the other vector
  67390. * @returns the current updated Vector2
  67391. */
  67392. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67393. /**
  67394. * Gets a new Vector2 with current Vector2 negated coordinates
  67395. * @returns a new Vector2
  67396. */
  67397. negate(): Vector2;
  67398. /**
  67399. * Multiply the Vector2 coordinates by scale
  67400. * @param scale defines the scaling factor
  67401. * @returns the current updated Vector2
  67402. */
  67403. scaleInPlace(scale: number): Vector2;
  67404. /**
  67405. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67406. * @param scale defines the scaling factor
  67407. * @returns a new Vector2
  67408. */
  67409. scale(scale: number): Vector2;
  67410. /**
  67411. * Scale the current Vector2 values by a factor to a given Vector2
  67412. * @param scale defines the scale factor
  67413. * @param result defines the Vector2 object where to store the result
  67414. * @returns the unmodified current Vector2
  67415. */
  67416. scaleToRef(scale: number, result: Vector2): Vector2;
  67417. /**
  67418. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67419. * @param scale defines the scale factor
  67420. * @param result defines the Vector2 object where to store the result
  67421. * @returns the unmodified current Vector2
  67422. */
  67423. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  67424. /**
  67425. * Gets a boolean if two vectors are equals
  67426. * @param otherVector defines the other vector
  67427. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67428. */
  67429. equals(otherVector: DeepImmutable<Vector2>): boolean;
  67430. /**
  67431. * Gets a boolean if two vectors are equals (using an epsilon value)
  67432. * @param otherVector defines the other vector
  67433. * @param epsilon defines the minimal distance to consider equality
  67434. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67435. */
  67436. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  67437. /**
  67438. * Gets a new Vector2 from current Vector2 floored values
  67439. * @returns a new Vector2
  67440. */
  67441. floor(): Vector2;
  67442. /**
  67443. * Gets a new Vector2 from current Vector2 floored values
  67444. * @returns a new Vector2
  67445. */
  67446. fract(): Vector2;
  67447. /**
  67448. * Gets the length of the vector
  67449. * @returns the vector length (float)
  67450. */
  67451. length(): number;
  67452. /**
  67453. * Gets the vector squared length
  67454. * @returns the vector squared length (float)
  67455. */
  67456. lengthSquared(): number;
  67457. /**
  67458. * Normalize the vector
  67459. * @returns the current updated Vector2
  67460. */
  67461. normalize(): Vector2;
  67462. /**
  67463. * Gets a new Vector2 copied from the Vector2
  67464. * @returns a new Vector2
  67465. */
  67466. clone(): Vector2;
  67467. /**
  67468. * Gets a new Vector2(0, 0)
  67469. * @returns a new Vector2
  67470. */
  67471. static Zero(): Vector2;
  67472. /**
  67473. * Gets a new Vector2(1, 1)
  67474. * @returns a new Vector2
  67475. */
  67476. static One(): Vector2;
  67477. /**
  67478. * Gets a new Vector2 set from the given index element of the given array
  67479. * @param array defines the data source
  67480. * @param offset defines the offset in the data source
  67481. * @returns a new Vector2
  67482. */
  67483. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  67484. /**
  67485. * Sets "result" from the given index element of the given array
  67486. * @param array defines the data source
  67487. * @param offset defines the offset in the data source
  67488. * @param result defines the target vector
  67489. */
  67490. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  67491. /**
  67492. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  67493. * @param value1 defines 1st point of control
  67494. * @param value2 defines 2nd point of control
  67495. * @param value3 defines 3rd point of control
  67496. * @param value4 defines 4th point of control
  67497. * @param amount defines the interpolation factor
  67498. * @returns a new Vector2
  67499. */
  67500. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  67501. /**
  67502. * 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".
  67503. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  67504. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  67505. * @param value defines the value to clamp
  67506. * @param min defines the lower limit
  67507. * @param max defines the upper limit
  67508. * @returns a new Vector2
  67509. */
  67510. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  67511. /**
  67512. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  67513. * @param value1 defines the 1st control point
  67514. * @param tangent1 defines the outgoing tangent
  67515. * @param value2 defines the 2nd control point
  67516. * @param tangent2 defines the incoming tangent
  67517. * @param amount defines the interpolation factor
  67518. * @returns a new Vector2
  67519. */
  67520. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  67521. /**
  67522. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  67523. * @param start defines the start vector
  67524. * @param end defines the end vector
  67525. * @param amount defines the interpolation factor
  67526. * @returns a new Vector2
  67527. */
  67528. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  67529. /**
  67530. * Gets the dot product of the vector "left" and the vector "right"
  67531. * @param left defines first vector
  67532. * @param right defines second vector
  67533. * @returns the dot product (float)
  67534. */
  67535. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  67536. /**
  67537. * Returns a new Vector2 equal to the normalized given vector
  67538. * @param vector defines the vector to normalize
  67539. * @returns a new Vector2
  67540. */
  67541. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  67542. /**
  67543. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  67544. * @param left defines 1st vector
  67545. * @param right defines 2nd vector
  67546. * @returns a new Vector2
  67547. */
  67548. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67549. /**
  67550. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  67551. * @param left defines 1st vector
  67552. * @param right defines 2nd vector
  67553. * @returns a new Vector2
  67554. */
  67555. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67556. /**
  67557. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  67558. * @param vector defines the vector to transform
  67559. * @param transformation defines the matrix to apply
  67560. * @returns a new Vector2
  67561. */
  67562. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  67563. /**
  67564. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  67565. * @param vector defines the vector to transform
  67566. * @param transformation defines the matrix to apply
  67567. * @param result defines the target vector
  67568. */
  67569. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  67570. /**
  67571. * Determines if a given vector is included in a triangle
  67572. * @param p defines the vector to test
  67573. * @param p0 defines 1st triangle point
  67574. * @param p1 defines 2nd triangle point
  67575. * @param p2 defines 3rd triangle point
  67576. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  67577. */
  67578. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  67579. /**
  67580. * Gets the distance between the vectors "value1" and "value2"
  67581. * @param value1 defines first vector
  67582. * @param value2 defines second vector
  67583. * @returns the distance between vectors
  67584. */
  67585. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67586. /**
  67587. * Returns the squared distance between the vectors "value1" and "value2"
  67588. * @param value1 defines first vector
  67589. * @param value2 defines second vector
  67590. * @returns the squared distance between vectors
  67591. */
  67592. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67593. /**
  67594. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  67595. * @param value1 defines first vector
  67596. * @param value2 defines second vector
  67597. * @returns a new Vector2
  67598. */
  67599. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  67600. /**
  67601. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  67602. * @param p defines the middle point
  67603. * @param segA defines one point of the segment
  67604. * @param segB defines the other point of the segment
  67605. * @returns the shortest distance
  67606. */
  67607. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  67608. }
  67609. /**
  67610. * Classed used to store (x,y,z) vector representation
  67611. * A Vector3 is the main object used in 3D geometry
  67612. * It can represent etiher the coordinates of a point the space, either a direction
  67613. * Reminder: js uses a left handed forward facing system
  67614. */
  67615. export class Vector3 {
  67616. /**
  67617. * Defines the first coordinates (on X axis)
  67618. */
  67619. x: number;
  67620. /**
  67621. * Defines the second coordinates (on Y axis)
  67622. */
  67623. y: number;
  67624. /**
  67625. * Defines the third coordinates (on Z axis)
  67626. */
  67627. z: number;
  67628. private static _UpReadOnly;
  67629. private static _ZeroReadOnly;
  67630. /**
  67631. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  67632. * @param x defines the first coordinates (on X axis)
  67633. * @param y defines the second coordinates (on Y axis)
  67634. * @param z defines the third coordinates (on Z axis)
  67635. */
  67636. constructor(
  67637. /**
  67638. * Defines the first coordinates (on X axis)
  67639. */
  67640. x?: number,
  67641. /**
  67642. * Defines the second coordinates (on Y axis)
  67643. */
  67644. y?: number,
  67645. /**
  67646. * Defines the third coordinates (on Z axis)
  67647. */
  67648. z?: number);
  67649. /**
  67650. * Creates a string representation of the Vector3
  67651. * @returns a string with the Vector3 coordinates.
  67652. */
  67653. toString(): string;
  67654. /**
  67655. * Gets the class name
  67656. * @returns the string "Vector3"
  67657. */
  67658. getClassName(): string;
  67659. /**
  67660. * Creates the Vector3 hash code
  67661. * @returns a number which tends to be unique between Vector3 instances
  67662. */
  67663. getHashCode(): number;
  67664. /**
  67665. * Creates an array containing three elements : the coordinates of the Vector3
  67666. * @returns a new array of numbers
  67667. */
  67668. asArray(): number[];
  67669. /**
  67670. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  67671. * @param array defines the destination array
  67672. * @param index defines the offset in the destination array
  67673. * @returns the current Vector3
  67674. */
  67675. toArray(array: FloatArray, index?: number): Vector3;
  67676. /**
  67677. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  67678. * @returns a new Quaternion object, computed from the Vector3 coordinates
  67679. */
  67680. toQuaternion(): Quaternion;
  67681. /**
  67682. * Adds the given vector to the current Vector3
  67683. * @param otherVector defines the second operand
  67684. * @returns the current updated Vector3
  67685. */
  67686. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67687. /**
  67688. * Adds the given coordinates to the current Vector3
  67689. * @param x defines the x coordinate of the operand
  67690. * @param y defines the y coordinate of the operand
  67691. * @param z defines the z coordinate of the operand
  67692. * @returns the current updated Vector3
  67693. */
  67694. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67695. /**
  67696. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  67697. * @param otherVector defines the second operand
  67698. * @returns the resulting Vector3
  67699. */
  67700. add(otherVector: DeepImmutable<Vector3>): Vector3;
  67701. /**
  67702. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  67703. * @param otherVector defines the second operand
  67704. * @param result defines the Vector3 object where to store the result
  67705. * @returns the current Vector3
  67706. */
  67707. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67708. /**
  67709. * Subtract the given vector from the current Vector3
  67710. * @param otherVector defines the second operand
  67711. * @returns the current updated Vector3
  67712. */
  67713. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67714. /**
  67715. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  67716. * @param otherVector defines the second operand
  67717. * @returns the resulting Vector3
  67718. */
  67719. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  67720. /**
  67721. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  67722. * @param otherVector defines the second operand
  67723. * @param result defines the Vector3 object where to store the result
  67724. * @returns the current Vector3
  67725. */
  67726. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67727. /**
  67728. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  67729. * @param x defines the x coordinate of the operand
  67730. * @param y defines the y coordinate of the operand
  67731. * @param z defines the z coordinate of the operand
  67732. * @returns the resulting Vector3
  67733. */
  67734. subtractFromFloats(x: number, y: number, z: number): Vector3;
  67735. /**
  67736. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  67737. * @param x defines the x coordinate of the operand
  67738. * @param y defines the y coordinate of the operand
  67739. * @param z defines the z coordinate of the operand
  67740. * @param result defines the Vector3 object where to store the result
  67741. * @returns the current Vector3
  67742. */
  67743. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  67744. /**
  67745. * Gets a new Vector3 set with the current Vector3 negated coordinates
  67746. * @returns a new Vector3
  67747. */
  67748. negate(): Vector3;
  67749. /**
  67750. * Multiplies the Vector3 coordinates by the float "scale"
  67751. * @param scale defines the multiplier factor
  67752. * @returns the current updated Vector3
  67753. */
  67754. scaleInPlace(scale: number): Vector3;
  67755. /**
  67756. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  67757. * @param scale defines the multiplier factor
  67758. * @returns a new Vector3
  67759. */
  67760. scale(scale: number): Vector3;
  67761. /**
  67762. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  67763. * @param scale defines the multiplier factor
  67764. * @param result defines the Vector3 object where to store the result
  67765. * @returns the current Vector3
  67766. */
  67767. scaleToRef(scale: number, result: Vector3): Vector3;
  67768. /**
  67769. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  67770. * @param scale defines the scale factor
  67771. * @param result defines the Vector3 object where to store the result
  67772. * @returns the unmodified current Vector3
  67773. */
  67774. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  67775. /**
  67776. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  67777. * @param otherVector defines the second operand
  67778. * @returns true if both vectors are equals
  67779. */
  67780. equals(otherVector: DeepImmutable<Vector3>): boolean;
  67781. /**
  67782. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  67783. * @param otherVector defines the second operand
  67784. * @param epsilon defines the minimal distance to define values as equals
  67785. * @returns true if both vectors are distant less than epsilon
  67786. */
  67787. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  67788. /**
  67789. * Returns true if the current Vector3 coordinates equals the given floats
  67790. * @param x defines the x coordinate of the operand
  67791. * @param y defines the y coordinate of the operand
  67792. * @param z defines the z coordinate of the operand
  67793. * @returns true if both vectors are equals
  67794. */
  67795. equalsToFloats(x: number, y: number, z: number): boolean;
  67796. /**
  67797. * Multiplies the current Vector3 coordinates by the given ones
  67798. * @param otherVector defines the second operand
  67799. * @returns the current updated Vector3
  67800. */
  67801. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  67802. /**
  67803. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  67804. * @param otherVector defines the second operand
  67805. * @returns the new Vector3
  67806. */
  67807. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  67808. /**
  67809. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  67810. * @param otherVector defines the second operand
  67811. * @param result defines the Vector3 object where to store the result
  67812. * @returns the current Vector3
  67813. */
  67814. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67815. /**
  67816. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  67817. * @param x defines the x coordinate of the operand
  67818. * @param y defines the y coordinate of the operand
  67819. * @param z defines the z coordinate of the operand
  67820. * @returns the new Vector3
  67821. */
  67822. multiplyByFloats(x: number, y: number, z: number): Vector3;
  67823. /**
  67824. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  67825. * @param otherVector defines the second operand
  67826. * @returns the new Vector3
  67827. */
  67828. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  67829. /**
  67830. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  67831. * @param otherVector defines the second operand
  67832. * @param result defines the Vector3 object where to store the result
  67833. * @returns the current Vector3
  67834. */
  67835. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  67836. /**
  67837. * Divides the current Vector3 coordinates by the given ones.
  67838. * @param otherVector defines the second operand
  67839. * @returns the current updated Vector3
  67840. */
  67841. divideInPlace(otherVector: Vector3): Vector3;
  67842. /**
  67843. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  67844. * @param other defines the second operand
  67845. * @returns the current updated Vector3
  67846. */
  67847. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67848. /**
  67849. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  67850. * @param other defines the second operand
  67851. * @returns the current updated Vector3
  67852. */
  67853. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  67854. /**
  67855. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  67856. * @param x defines the x coordinate of the operand
  67857. * @param y defines the y coordinate of the operand
  67858. * @param z defines the z coordinate of the operand
  67859. * @returns the current updated Vector3
  67860. */
  67861. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67862. /**
  67863. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  67864. * @param x defines the x coordinate of the operand
  67865. * @param y defines the y coordinate of the operand
  67866. * @param z defines the z coordinate of the operand
  67867. * @returns the current updated Vector3
  67868. */
  67869. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  67870. /**
  67871. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  67872. * Check if is non uniform within a certain amount of decimal places to account for this
  67873. * @param epsilon the amount the values can differ
  67874. * @returns if the the vector is non uniform to a certain number of decimal places
  67875. */
  67876. isNonUniformWithinEpsilon(epsilon: number): boolean;
  67877. /**
  67878. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  67879. */
  67880. readonly isNonUniform: boolean;
  67881. /**
  67882. * Gets a new Vector3 from current Vector3 floored values
  67883. * @returns a new Vector3
  67884. */
  67885. floor(): Vector3;
  67886. /**
  67887. * Gets a new Vector3 from current Vector3 floored values
  67888. * @returns a new Vector3
  67889. */
  67890. fract(): Vector3;
  67891. /**
  67892. * Gets the length of the Vector3
  67893. * @returns the length of the Vector3
  67894. */
  67895. length(): number;
  67896. /**
  67897. * Gets the squared length of the Vector3
  67898. * @returns squared length of the Vector3
  67899. */
  67900. lengthSquared(): number;
  67901. /**
  67902. * Normalize the current Vector3.
  67903. * Please note that this is an in place operation.
  67904. * @returns the current updated Vector3
  67905. */
  67906. normalize(): Vector3;
  67907. /**
  67908. * Reorders the x y z properties of the vector in place
  67909. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  67910. * @returns the current updated vector
  67911. */
  67912. reorderInPlace(order: string): this;
  67913. /**
  67914. * Rotates the vector around 0,0,0 by a quaternion
  67915. * @param quaternion the rotation quaternion
  67916. * @param result vector to store the result
  67917. * @returns the resulting vector
  67918. */
  67919. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  67920. /**
  67921. * Rotates a vector around a given point
  67922. * @param quaternion the rotation quaternion
  67923. * @param point the point to rotate around
  67924. * @param result vector to store the result
  67925. * @returns the resulting vector
  67926. */
  67927. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  67928. /**
  67929. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  67930. * The cross product is then orthogonal to both current and "other"
  67931. * @param other defines the right operand
  67932. * @returns the cross product
  67933. */
  67934. cross(other: Vector3): Vector3;
  67935. /**
  67936. * Normalize the current Vector3 with the given input length.
  67937. * Please note that this is an in place operation.
  67938. * @param len the length of the vector
  67939. * @returns the current updated Vector3
  67940. */
  67941. normalizeFromLength(len: number): Vector3;
  67942. /**
  67943. * Normalize the current Vector3 to a new vector
  67944. * @returns the new Vector3
  67945. */
  67946. normalizeToNew(): Vector3;
  67947. /**
  67948. * Normalize the current Vector3 to the reference
  67949. * @param reference define the Vector3 to update
  67950. * @returns the updated Vector3
  67951. */
  67952. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  67953. /**
  67954. * Creates a new Vector3 copied from the current Vector3
  67955. * @returns the new Vector3
  67956. */
  67957. clone(): Vector3;
  67958. /**
  67959. * Copies the given vector coordinates to the current Vector3 ones
  67960. * @param source defines the source Vector3
  67961. * @returns the current updated Vector3
  67962. */
  67963. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  67964. /**
  67965. * Copies the given floats to the current Vector3 coordinates
  67966. * @param x defines the x coordinate of the operand
  67967. * @param y defines the y coordinate of the operand
  67968. * @param z defines the z coordinate of the operand
  67969. * @returns the current updated Vector3
  67970. */
  67971. copyFromFloats(x: number, y: number, z: number): Vector3;
  67972. /**
  67973. * Copies the given floats to the current Vector3 coordinates
  67974. * @param x defines the x coordinate of the operand
  67975. * @param y defines the y coordinate of the operand
  67976. * @param z defines the z coordinate of the operand
  67977. * @returns the current updated Vector3
  67978. */
  67979. set(x: number, y: number, z: number): Vector3;
  67980. /**
  67981. * Copies the given float to the current Vector3 coordinates
  67982. * @param v defines the x, y and z coordinates of the operand
  67983. * @returns the current updated Vector3
  67984. */
  67985. setAll(v: number): Vector3;
  67986. /**
  67987. * Get the clip factor between two vectors
  67988. * @param vector0 defines the first operand
  67989. * @param vector1 defines the second operand
  67990. * @param axis defines the axis to use
  67991. * @param size defines the size along the axis
  67992. * @returns the clip factor
  67993. */
  67994. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  67995. /**
  67996. * Get angle between two vectors
  67997. * @param vector0 angle between vector0 and vector1
  67998. * @param vector1 angle between vector0 and vector1
  67999. * @param normal direction of the normal
  68000. * @return the angle between vector0 and vector1
  68001. */
  68002. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  68003. /**
  68004. * Returns a new Vector3 set from the index "offset" of the given array
  68005. * @param array defines the source array
  68006. * @param offset defines the offset in the source array
  68007. * @returns the new Vector3
  68008. */
  68009. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  68010. /**
  68011. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  68012. * This function is deprecated. Use FromArray instead
  68013. * @param array defines the source array
  68014. * @param offset defines the offset in the source array
  68015. * @returns the new Vector3
  68016. */
  68017. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  68018. /**
  68019. * Sets the given vector "result" with the element values from the index "offset" of the given array
  68020. * @param array defines the source array
  68021. * @param offset defines the offset in the source array
  68022. * @param result defines the Vector3 where to store the result
  68023. */
  68024. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  68025. /**
  68026. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  68027. * This function is deprecated. Use FromArrayToRef instead.
  68028. * @param array defines the source array
  68029. * @param offset defines the offset in the source array
  68030. * @param result defines the Vector3 where to store the result
  68031. */
  68032. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  68033. /**
  68034. * Sets the given vector "result" with the given floats.
  68035. * @param x defines the x coordinate of the source
  68036. * @param y defines the y coordinate of the source
  68037. * @param z defines the z coordinate of the source
  68038. * @param result defines the Vector3 where to store the result
  68039. */
  68040. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  68041. /**
  68042. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  68043. * @returns a new empty Vector3
  68044. */
  68045. static Zero(): Vector3;
  68046. /**
  68047. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  68048. * @returns a new unit Vector3
  68049. */
  68050. static One(): Vector3;
  68051. /**
  68052. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  68053. * @returns a new up Vector3
  68054. */
  68055. static Up(): Vector3;
  68056. /**
  68057. * Gets a up Vector3 that must not be updated
  68058. */
  68059. static readonly UpReadOnly: DeepImmutable<Vector3>;
  68060. /**
  68061. * Gets a zero Vector3 that must not be updated
  68062. */
  68063. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  68064. /**
  68065. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  68066. * @returns a new down Vector3
  68067. */
  68068. static Down(): Vector3;
  68069. /**
  68070. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  68071. * @returns a new forward Vector3
  68072. */
  68073. static Forward(): Vector3;
  68074. /**
  68075. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  68076. * @returns a new forward Vector3
  68077. */
  68078. static Backward(): Vector3;
  68079. /**
  68080. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  68081. * @returns a new right Vector3
  68082. */
  68083. static Right(): Vector3;
  68084. /**
  68085. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  68086. * @returns a new left Vector3
  68087. */
  68088. static Left(): Vector3;
  68089. /**
  68090. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  68091. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68092. * @param vector defines the Vector3 to transform
  68093. * @param transformation defines the transformation matrix
  68094. * @returns the transformed Vector3
  68095. */
  68096. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68097. /**
  68098. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  68099. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68100. * @param vector defines the Vector3 to transform
  68101. * @param transformation defines the transformation matrix
  68102. * @param result defines the Vector3 where to store the result
  68103. */
  68104. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68105. /**
  68106. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  68107. * This method computes tranformed coordinates only, not transformed direction vectors
  68108. * @param x define the x coordinate of the source vector
  68109. * @param y define the y coordinate of the source vector
  68110. * @param z define the z coordinate of the source vector
  68111. * @param transformation defines the transformation matrix
  68112. * @param result defines the Vector3 where to store the result
  68113. */
  68114. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68115. /**
  68116. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  68117. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68118. * @param vector defines the Vector3 to transform
  68119. * @param transformation defines the transformation matrix
  68120. * @returns the new Vector3
  68121. */
  68122. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68123. /**
  68124. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  68125. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68126. * @param vector defines the Vector3 to transform
  68127. * @param transformation defines the transformation matrix
  68128. * @param result defines the Vector3 where to store the result
  68129. */
  68130. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68131. /**
  68132. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  68133. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68134. * @param x define the x coordinate of the source vector
  68135. * @param y define the y coordinate of the source vector
  68136. * @param z define the z coordinate of the source vector
  68137. * @param transformation defines the transformation matrix
  68138. * @param result defines the Vector3 where to store the result
  68139. */
  68140. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68141. /**
  68142. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  68143. * @param value1 defines the first control point
  68144. * @param value2 defines the second control point
  68145. * @param value3 defines the third control point
  68146. * @param value4 defines the fourth control point
  68147. * @param amount defines the amount on the spline to use
  68148. * @returns the new Vector3
  68149. */
  68150. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  68151. /**
  68152. * 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"
  68153. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68154. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68155. * @param value defines the current value
  68156. * @param min defines the lower range value
  68157. * @param max defines the upper range value
  68158. * @returns the new Vector3
  68159. */
  68160. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  68161. /**
  68162. * 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"
  68163. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68164. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68165. * @param value defines the current value
  68166. * @param min defines the lower range value
  68167. * @param max defines the upper range value
  68168. * @param result defines the Vector3 where to store the result
  68169. */
  68170. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  68171. /**
  68172. * Checks if a given vector is inside a specific range
  68173. * @param v defines the vector to test
  68174. * @param min defines the minimum range
  68175. * @param max defines the maximum range
  68176. */
  68177. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  68178. /**
  68179. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  68180. * @param value1 defines the first control point
  68181. * @param tangent1 defines the first tangent vector
  68182. * @param value2 defines the second control point
  68183. * @param tangent2 defines the second tangent vector
  68184. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  68185. * @returns the new Vector3
  68186. */
  68187. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  68188. /**
  68189. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  68190. * @param start defines the start value
  68191. * @param end defines the end value
  68192. * @param amount max defines amount between both (between 0 and 1)
  68193. * @returns the new Vector3
  68194. */
  68195. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  68196. /**
  68197. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  68198. * @param start defines the start value
  68199. * @param end defines the end value
  68200. * @param amount max defines amount between both (between 0 and 1)
  68201. * @param result defines the Vector3 where to store the result
  68202. */
  68203. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  68204. /**
  68205. * Returns the dot product (float) between the vectors "left" and "right"
  68206. * @param left defines the left operand
  68207. * @param right defines the right operand
  68208. * @returns the dot product
  68209. */
  68210. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  68211. /**
  68212. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  68213. * The cross product is then orthogonal to both "left" and "right"
  68214. * @param left defines the left operand
  68215. * @param right defines the right operand
  68216. * @returns the cross product
  68217. */
  68218. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68219. /**
  68220. * Sets the given vector "result" with the cross product of "left" and "right"
  68221. * The cross product is then orthogonal to both "left" and "right"
  68222. * @param left defines the left operand
  68223. * @param right defines the right operand
  68224. * @param result defines the Vector3 where to store the result
  68225. */
  68226. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  68227. /**
  68228. * Returns a new Vector3 as the normalization of the given vector
  68229. * @param vector defines the Vector3 to normalize
  68230. * @returns the new Vector3
  68231. */
  68232. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  68233. /**
  68234. * Sets the given vector "result" with the normalization of the given first vector
  68235. * @param vector defines the Vector3 to normalize
  68236. * @param result defines the Vector3 where to store the result
  68237. */
  68238. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  68239. /**
  68240. * Project a Vector3 onto screen space
  68241. * @param vector defines the Vector3 to project
  68242. * @param world defines the world matrix to use
  68243. * @param transform defines the transform (view x projection) matrix to use
  68244. * @param viewport defines the screen viewport to use
  68245. * @returns the new Vector3
  68246. */
  68247. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  68248. /** @hidden */
  68249. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  68250. /**
  68251. * Unproject from screen space to object space
  68252. * @param source defines the screen space Vector3 to use
  68253. * @param viewportWidth defines the current width of the viewport
  68254. * @param viewportHeight defines the current height of the viewport
  68255. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68256. * @param transform defines the transform (view x projection) matrix to use
  68257. * @returns the new Vector3
  68258. */
  68259. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  68260. /**
  68261. * Unproject from screen space to object space
  68262. * @param source defines the screen space Vector3 to use
  68263. * @param viewportWidth defines the current width of the viewport
  68264. * @param viewportHeight defines the current height of the viewport
  68265. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68266. * @param view defines the view matrix to use
  68267. * @param projection defines the projection matrix to use
  68268. * @returns the new Vector3
  68269. */
  68270. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  68271. /**
  68272. * Unproject from screen space to object space
  68273. * @param source defines the screen space Vector3 to use
  68274. * @param viewportWidth defines the current width of the viewport
  68275. * @param viewportHeight defines the current height of the viewport
  68276. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68277. * @param view defines the view matrix to use
  68278. * @param projection defines the projection matrix to use
  68279. * @param result defines the Vector3 where to store the result
  68280. */
  68281. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68282. /**
  68283. * Unproject from screen space to object space
  68284. * @param sourceX defines the screen space x coordinate to use
  68285. * @param sourceY defines the screen space y coordinate to use
  68286. * @param sourceZ defines the screen space z coordinate to use
  68287. * @param viewportWidth defines the current width of the viewport
  68288. * @param viewportHeight defines the current height of the viewport
  68289. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68290. * @param view defines the view matrix to use
  68291. * @param projection defines the projection matrix to use
  68292. * @param result defines the Vector3 where to store the result
  68293. */
  68294. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68295. /**
  68296. * Gets the minimal coordinate values between two Vector3
  68297. * @param left defines the first operand
  68298. * @param right defines the second operand
  68299. * @returns the new Vector3
  68300. */
  68301. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68302. /**
  68303. * Gets the maximal coordinate values between two Vector3
  68304. * @param left defines the first operand
  68305. * @param right defines the second operand
  68306. * @returns the new Vector3
  68307. */
  68308. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68309. /**
  68310. * Returns the distance between the vectors "value1" and "value2"
  68311. * @param value1 defines the first operand
  68312. * @param value2 defines the second operand
  68313. * @returns the distance
  68314. */
  68315. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68316. /**
  68317. * Returns the squared distance between the vectors "value1" and "value2"
  68318. * @param value1 defines the first operand
  68319. * @param value2 defines the second operand
  68320. * @returns the squared distance
  68321. */
  68322. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68323. /**
  68324. * Returns a new Vector3 located at the center between "value1" and "value2"
  68325. * @param value1 defines the first operand
  68326. * @param value2 defines the second operand
  68327. * @returns the new Vector3
  68328. */
  68329. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  68330. /**
  68331. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  68332. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  68333. * to something in order to rotate it from its local system to the given target system
  68334. * Note: axis1, axis2 and axis3 are normalized during this operation
  68335. * @param axis1 defines the first axis
  68336. * @param axis2 defines the second axis
  68337. * @param axis3 defines the third axis
  68338. * @returns a new Vector3
  68339. */
  68340. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  68341. /**
  68342. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  68343. * @param axis1 defines the first axis
  68344. * @param axis2 defines the second axis
  68345. * @param axis3 defines the third axis
  68346. * @param ref defines the Vector3 where to store the result
  68347. */
  68348. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  68349. }
  68350. /**
  68351. * Vector4 class created for EulerAngle class conversion to Quaternion
  68352. */
  68353. export class Vector4 {
  68354. /** x value of the vector */
  68355. x: number;
  68356. /** y value of the vector */
  68357. y: number;
  68358. /** z value of the vector */
  68359. z: number;
  68360. /** w value of the vector */
  68361. w: number;
  68362. /**
  68363. * Creates a Vector4 object from the given floats.
  68364. * @param x x value of the vector
  68365. * @param y y value of the vector
  68366. * @param z z value of the vector
  68367. * @param w w value of the vector
  68368. */
  68369. constructor(
  68370. /** x value of the vector */
  68371. x: number,
  68372. /** y value of the vector */
  68373. y: number,
  68374. /** z value of the vector */
  68375. z: number,
  68376. /** w value of the vector */
  68377. w: number);
  68378. /**
  68379. * Returns the string with the Vector4 coordinates.
  68380. * @returns a string containing all the vector values
  68381. */
  68382. toString(): string;
  68383. /**
  68384. * Returns the string "Vector4".
  68385. * @returns "Vector4"
  68386. */
  68387. getClassName(): string;
  68388. /**
  68389. * Returns the Vector4 hash code.
  68390. * @returns a unique hash code
  68391. */
  68392. getHashCode(): number;
  68393. /**
  68394. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  68395. * @returns the resulting array
  68396. */
  68397. asArray(): number[];
  68398. /**
  68399. * Populates the given array from the given index with the Vector4 coordinates.
  68400. * @param array array to populate
  68401. * @param index index of the array to start at (default: 0)
  68402. * @returns the Vector4.
  68403. */
  68404. toArray(array: FloatArray, index?: number): Vector4;
  68405. /**
  68406. * Adds the given vector to the current Vector4.
  68407. * @param otherVector the vector to add
  68408. * @returns the updated Vector4.
  68409. */
  68410. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68411. /**
  68412. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  68413. * @param otherVector the vector to add
  68414. * @returns the resulting vector
  68415. */
  68416. add(otherVector: DeepImmutable<Vector4>): Vector4;
  68417. /**
  68418. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  68419. * @param otherVector the vector to add
  68420. * @param result the vector to store the result
  68421. * @returns the current Vector4.
  68422. */
  68423. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68424. /**
  68425. * Subtract in place the given vector from the current Vector4.
  68426. * @param otherVector the vector to subtract
  68427. * @returns the updated Vector4.
  68428. */
  68429. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68430. /**
  68431. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  68432. * @param otherVector the vector to add
  68433. * @returns the new vector with the result
  68434. */
  68435. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  68436. /**
  68437. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  68438. * @param otherVector the vector to subtract
  68439. * @param result the vector to store the result
  68440. * @returns the current Vector4.
  68441. */
  68442. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68443. /**
  68444. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68445. */
  68446. /**
  68447. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68448. * @param x value to subtract
  68449. * @param y value to subtract
  68450. * @param z value to subtract
  68451. * @param w value to subtract
  68452. * @returns new vector containing the result
  68453. */
  68454. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68455. /**
  68456. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68457. * @param x value to subtract
  68458. * @param y value to subtract
  68459. * @param z value to subtract
  68460. * @param w value to subtract
  68461. * @param result the vector to store the result in
  68462. * @returns the current Vector4.
  68463. */
  68464. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  68465. /**
  68466. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  68467. * @returns a new vector with the negated values
  68468. */
  68469. negate(): Vector4;
  68470. /**
  68471. * Multiplies the current Vector4 coordinates by scale (float).
  68472. * @param scale the number to scale with
  68473. * @returns the updated Vector4.
  68474. */
  68475. scaleInPlace(scale: number): Vector4;
  68476. /**
  68477. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  68478. * @param scale the number to scale with
  68479. * @returns a new vector with the result
  68480. */
  68481. scale(scale: number): Vector4;
  68482. /**
  68483. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  68484. * @param scale the number to scale with
  68485. * @param result a vector to store the result in
  68486. * @returns the current Vector4.
  68487. */
  68488. scaleToRef(scale: number, result: Vector4): Vector4;
  68489. /**
  68490. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  68491. * @param scale defines the scale factor
  68492. * @param result defines the Vector4 object where to store the result
  68493. * @returns the unmodified current Vector4
  68494. */
  68495. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  68496. /**
  68497. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  68498. * @param otherVector the vector to compare against
  68499. * @returns true if they are equal
  68500. */
  68501. equals(otherVector: DeepImmutable<Vector4>): boolean;
  68502. /**
  68503. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  68504. * @param otherVector vector to compare against
  68505. * @param epsilon (Default: very small number)
  68506. * @returns true if they are equal
  68507. */
  68508. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  68509. /**
  68510. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  68511. * @param x x value to compare against
  68512. * @param y y value to compare against
  68513. * @param z z value to compare against
  68514. * @param w w value to compare against
  68515. * @returns true if equal
  68516. */
  68517. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  68518. /**
  68519. * Multiplies in place the current Vector4 by the given one.
  68520. * @param otherVector vector to multiple with
  68521. * @returns the updated Vector4.
  68522. */
  68523. multiplyInPlace(otherVector: Vector4): Vector4;
  68524. /**
  68525. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  68526. * @param otherVector vector to multiple with
  68527. * @returns resulting new vector
  68528. */
  68529. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  68530. /**
  68531. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  68532. * @param otherVector vector to multiple with
  68533. * @param result vector to store the result
  68534. * @returns the current Vector4.
  68535. */
  68536. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68537. /**
  68538. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  68539. * @param x x value multiply with
  68540. * @param y y value multiply with
  68541. * @param z z value multiply with
  68542. * @param w w value multiply with
  68543. * @returns resulting new vector
  68544. */
  68545. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  68546. /**
  68547. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  68548. * @param otherVector vector to devide with
  68549. * @returns resulting new vector
  68550. */
  68551. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  68552. /**
  68553. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  68554. * @param otherVector vector to devide with
  68555. * @param result vector to store the result
  68556. * @returns the current Vector4.
  68557. */
  68558. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68559. /**
  68560. * Divides the current Vector3 coordinates by the given ones.
  68561. * @param otherVector vector to devide with
  68562. * @returns the updated Vector3.
  68563. */
  68564. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68565. /**
  68566. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  68567. * @param other defines the second operand
  68568. * @returns the current updated Vector4
  68569. */
  68570. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68571. /**
  68572. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  68573. * @param other defines the second operand
  68574. * @returns the current updated Vector4
  68575. */
  68576. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68577. /**
  68578. * Gets a new Vector4 from current Vector4 floored values
  68579. * @returns a new Vector4
  68580. */
  68581. floor(): Vector4;
  68582. /**
  68583. * Gets a new Vector4 from current Vector3 floored values
  68584. * @returns a new Vector4
  68585. */
  68586. fract(): Vector4;
  68587. /**
  68588. * Returns the Vector4 length (float).
  68589. * @returns the length
  68590. */
  68591. length(): number;
  68592. /**
  68593. * Returns the Vector4 squared length (float).
  68594. * @returns the length squared
  68595. */
  68596. lengthSquared(): number;
  68597. /**
  68598. * Normalizes in place the Vector4.
  68599. * @returns the updated Vector4.
  68600. */
  68601. normalize(): Vector4;
  68602. /**
  68603. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  68604. * @returns this converted to a new vector3
  68605. */
  68606. toVector3(): Vector3;
  68607. /**
  68608. * Returns a new Vector4 copied from the current one.
  68609. * @returns the new cloned vector
  68610. */
  68611. clone(): Vector4;
  68612. /**
  68613. * Updates the current Vector4 with the given one coordinates.
  68614. * @param source the source vector to copy from
  68615. * @returns the updated Vector4.
  68616. */
  68617. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  68618. /**
  68619. * Updates the current Vector4 coordinates with the given floats.
  68620. * @param x float to copy from
  68621. * @param y float to copy from
  68622. * @param z float to copy from
  68623. * @param w float to copy from
  68624. * @returns the updated Vector4.
  68625. */
  68626. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68627. /**
  68628. * Updates the current Vector4 coordinates with the given floats.
  68629. * @param x float to set from
  68630. * @param y float to set from
  68631. * @param z float to set from
  68632. * @param w float to set from
  68633. * @returns the updated Vector4.
  68634. */
  68635. set(x: number, y: number, z: number, w: number): Vector4;
  68636. /**
  68637. * Copies the given float to the current Vector3 coordinates
  68638. * @param v defines the x, y, z and w coordinates of the operand
  68639. * @returns the current updated Vector3
  68640. */
  68641. setAll(v: number): Vector4;
  68642. /**
  68643. * Returns a new Vector4 set from the starting index of the given array.
  68644. * @param array the array to pull values from
  68645. * @param offset the offset into the array to start at
  68646. * @returns the new vector
  68647. */
  68648. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  68649. /**
  68650. * Updates the given vector "result" from the starting index of the given array.
  68651. * @param array the array to pull values from
  68652. * @param offset the offset into the array to start at
  68653. * @param result the vector to store the result in
  68654. */
  68655. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  68656. /**
  68657. * Updates the given vector "result" from the starting index of the given Float32Array.
  68658. * @param array the array to pull values from
  68659. * @param offset the offset into the array to start at
  68660. * @param result the vector to store the result in
  68661. */
  68662. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  68663. /**
  68664. * Updates the given vector "result" coordinates from the given floats.
  68665. * @param x float to set from
  68666. * @param y float to set from
  68667. * @param z float to set from
  68668. * @param w float to set from
  68669. * @param result the vector to the floats in
  68670. */
  68671. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  68672. /**
  68673. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  68674. * @returns the new vector
  68675. */
  68676. static Zero(): Vector4;
  68677. /**
  68678. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  68679. * @returns the new vector
  68680. */
  68681. static One(): Vector4;
  68682. /**
  68683. * Returns a new normalized Vector4 from the given one.
  68684. * @param vector the vector to normalize
  68685. * @returns the vector
  68686. */
  68687. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  68688. /**
  68689. * Updates the given vector "result" from the normalization of the given one.
  68690. * @param vector the vector to normalize
  68691. * @param result the vector to store the result in
  68692. */
  68693. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  68694. /**
  68695. * Returns a vector with the minimum values from the left and right vectors
  68696. * @param left left vector to minimize
  68697. * @param right right vector to minimize
  68698. * @returns a new vector with the minimum of the left and right vector values
  68699. */
  68700. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68701. /**
  68702. * Returns a vector with the maximum values from the left and right vectors
  68703. * @param left left vector to maximize
  68704. * @param right right vector to maximize
  68705. * @returns a new vector with the maximum of the left and right vector values
  68706. */
  68707. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  68708. /**
  68709. * Returns the distance (float) between the vectors "value1" and "value2".
  68710. * @param value1 value to calulate the distance between
  68711. * @param value2 value to calulate the distance between
  68712. * @return the distance between the two vectors
  68713. */
  68714. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68715. /**
  68716. * Returns the squared distance (float) between the vectors "value1" and "value2".
  68717. * @param value1 value to calulate the distance between
  68718. * @param value2 value to calulate the distance between
  68719. * @return the distance between the two vectors squared
  68720. */
  68721. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  68722. /**
  68723. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  68724. * @param value1 value to calulate the center between
  68725. * @param value2 value to calulate the center between
  68726. * @return the center between the two vectors
  68727. */
  68728. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  68729. /**
  68730. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  68731. * This methods computes transformed normalized direction vectors only.
  68732. * @param vector the vector to transform
  68733. * @param transformation the transformation matrix to apply
  68734. * @returns the new vector
  68735. */
  68736. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  68737. /**
  68738. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  68739. * This methods computes transformed normalized direction vectors only.
  68740. * @param vector the vector to transform
  68741. * @param transformation the transformation matrix to apply
  68742. * @param result the vector to store the result in
  68743. */
  68744. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68745. /**
  68746. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  68747. * This methods computes transformed normalized direction vectors only.
  68748. * @param x value to transform
  68749. * @param y value to transform
  68750. * @param z value to transform
  68751. * @param w value to transform
  68752. * @param transformation the transformation matrix to apply
  68753. * @param result the vector to store the results in
  68754. */
  68755. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  68756. /**
  68757. * Creates a new Vector4 from a Vector3
  68758. * @param source defines the source data
  68759. * @param w defines the 4th component (default is 0)
  68760. * @returns a new Vector4
  68761. */
  68762. static FromVector3(source: Vector3, w?: number): Vector4;
  68763. }
  68764. /**
  68765. * Class used to store quaternion data
  68766. * @see https://en.wikipedia.org/wiki/Quaternion
  68767. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  68768. */
  68769. export class Quaternion {
  68770. /** defines the first component (0 by default) */
  68771. x: number;
  68772. /** defines the second component (0 by default) */
  68773. y: number;
  68774. /** defines the third component (0 by default) */
  68775. z: number;
  68776. /** defines the fourth component (1.0 by default) */
  68777. w: number;
  68778. /**
  68779. * Creates a new Quaternion from the given floats
  68780. * @param x defines the first component (0 by default)
  68781. * @param y defines the second component (0 by default)
  68782. * @param z defines the third component (0 by default)
  68783. * @param w defines the fourth component (1.0 by default)
  68784. */
  68785. constructor(
  68786. /** defines the first component (0 by default) */
  68787. x?: number,
  68788. /** defines the second component (0 by default) */
  68789. y?: number,
  68790. /** defines the third component (0 by default) */
  68791. z?: number,
  68792. /** defines the fourth component (1.0 by default) */
  68793. w?: number);
  68794. /**
  68795. * Gets a string representation for the current quaternion
  68796. * @returns a string with the Quaternion coordinates
  68797. */
  68798. toString(): string;
  68799. /**
  68800. * Gets the class name of the quaternion
  68801. * @returns the string "Quaternion"
  68802. */
  68803. getClassName(): string;
  68804. /**
  68805. * Gets a hash code for this quaternion
  68806. * @returns the quaternion hash code
  68807. */
  68808. getHashCode(): number;
  68809. /**
  68810. * Copy the quaternion to an array
  68811. * @returns a new array populated with 4 elements from the quaternion coordinates
  68812. */
  68813. asArray(): number[];
  68814. /**
  68815. * Check if two quaternions are equals
  68816. * @param otherQuaternion defines the second operand
  68817. * @return true if the current quaternion and the given one coordinates are strictly equals
  68818. */
  68819. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  68820. /**
  68821. * Clone the current quaternion
  68822. * @returns a new quaternion copied from the current one
  68823. */
  68824. clone(): Quaternion;
  68825. /**
  68826. * Copy a quaternion to the current one
  68827. * @param other defines the other quaternion
  68828. * @returns the updated current quaternion
  68829. */
  68830. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  68831. /**
  68832. * Updates the current quaternion with the given float coordinates
  68833. * @param x defines the x coordinate
  68834. * @param y defines the y coordinate
  68835. * @param z defines the z coordinate
  68836. * @param w defines the w coordinate
  68837. * @returns the updated current quaternion
  68838. */
  68839. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  68840. /**
  68841. * Updates the current quaternion from the given float coordinates
  68842. * @param x defines the x coordinate
  68843. * @param y defines the y coordinate
  68844. * @param z defines the z coordinate
  68845. * @param w defines the w coordinate
  68846. * @returns the updated current quaternion
  68847. */
  68848. set(x: number, y: number, z: number, w: number): Quaternion;
  68849. /**
  68850. * Adds two quaternions
  68851. * @param other defines the second operand
  68852. * @returns a new quaternion as the addition result of the given one and the current quaternion
  68853. */
  68854. add(other: DeepImmutable<Quaternion>): Quaternion;
  68855. /**
  68856. * Add a quaternion to the current one
  68857. * @param other defines the quaternion to add
  68858. * @returns the current quaternion
  68859. */
  68860. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  68861. /**
  68862. * Subtract two quaternions
  68863. * @param other defines the second operand
  68864. * @returns a new quaternion as the subtraction result of the given one from the current one
  68865. */
  68866. subtract(other: Quaternion): Quaternion;
  68867. /**
  68868. * Multiplies the current quaternion by a scale factor
  68869. * @param value defines the scale factor
  68870. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  68871. */
  68872. scale(value: number): Quaternion;
  68873. /**
  68874. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  68875. * @param scale defines the scale factor
  68876. * @param result defines the Quaternion object where to store the result
  68877. * @returns the unmodified current quaternion
  68878. */
  68879. scaleToRef(scale: number, result: Quaternion): Quaternion;
  68880. /**
  68881. * Multiplies in place the current quaternion by a scale factor
  68882. * @param value defines the scale factor
  68883. * @returns the current modified quaternion
  68884. */
  68885. scaleInPlace(value: number): Quaternion;
  68886. /**
  68887. * Scale the current quaternion values by a factor and add the result to a given quaternion
  68888. * @param scale defines the scale factor
  68889. * @param result defines the Quaternion object where to store the result
  68890. * @returns the unmodified current quaternion
  68891. */
  68892. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  68893. /**
  68894. * Multiplies two quaternions
  68895. * @param q1 defines the second operand
  68896. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  68897. */
  68898. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  68899. /**
  68900. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  68901. * @param q1 defines the second operand
  68902. * @param result defines the target quaternion
  68903. * @returns the current quaternion
  68904. */
  68905. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  68906. /**
  68907. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  68908. * @param q1 defines the second operand
  68909. * @returns the currentupdated quaternion
  68910. */
  68911. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  68912. /**
  68913. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  68914. * @param ref defines the target quaternion
  68915. * @returns the current quaternion
  68916. */
  68917. conjugateToRef(ref: Quaternion): Quaternion;
  68918. /**
  68919. * Conjugates in place (1-q) the current quaternion
  68920. * @returns the current updated quaternion
  68921. */
  68922. conjugateInPlace(): Quaternion;
  68923. /**
  68924. * Conjugates in place (1-q) the current quaternion
  68925. * @returns a new quaternion
  68926. */
  68927. conjugate(): Quaternion;
  68928. /**
  68929. * Gets length of current quaternion
  68930. * @returns the quaternion length (float)
  68931. */
  68932. length(): number;
  68933. /**
  68934. * Normalize in place the current quaternion
  68935. * @returns the current updated quaternion
  68936. */
  68937. normalize(): Quaternion;
  68938. /**
  68939. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  68940. * @param order is a reserved parameter and is ignore for now
  68941. * @returns a new Vector3 containing the Euler angles
  68942. */
  68943. toEulerAngles(order?: string): Vector3;
  68944. /**
  68945. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  68946. * @param result defines the vector which will be filled with the Euler angles
  68947. * @param order is a reserved parameter and is ignore for now
  68948. * @returns the current unchanged quaternion
  68949. */
  68950. toEulerAnglesToRef(result: Vector3): Quaternion;
  68951. /**
  68952. * Updates the given rotation matrix with the current quaternion values
  68953. * @param result defines the target matrix
  68954. * @returns the current unchanged quaternion
  68955. */
  68956. toRotationMatrix(result: Matrix): Quaternion;
  68957. /**
  68958. * Updates the current quaternion from the given rotation matrix values
  68959. * @param matrix defines the source matrix
  68960. * @returns the current updated quaternion
  68961. */
  68962. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68963. /**
  68964. * Creates a new quaternion from a rotation matrix
  68965. * @param matrix defines the source matrix
  68966. * @returns a new quaternion created from the given rotation matrix values
  68967. */
  68968. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  68969. /**
  68970. * Updates the given quaternion with the given rotation matrix values
  68971. * @param matrix defines the source matrix
  68972. * @param result defines the target quaternion
  68973. */
  68974. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  68975. /**
  68976. * Returns the dot product (float) between the quaternions "left" and "right"
  68977. * @param left defines the left operand
  68978. * @param right defines the right operand
  68979. * @returns the dot product
  68980. */
  68981. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  68982. /**
  68983. * Checks if the two quaternions are close to each other
  68984. * @param quat0 defines the first quaternion to check
  68985. * @param quat1 defines the second quaternion to check
  68986. * @returns true if the two quaternions are close to each other
  68987. */
  68988. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  68989. /**
  68990. * Creates an empty quaternion
  68991. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  68992. */
  68993. static Zero(): Quaternion;
  68994. /**
  68995. * Inverse a given quaternion
  68996. * @param q defines the source quaternion
  68997. * @returns a new quaternion as the inverted current quaternion
  68998. */
  68999. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  69000. /**
  69001. * Inverse a given quaternion
  69002. * @param q defines the source quaternion
  69003. * @param result the quaternion the result will be stored in
  69004. * @returns the result quaternion
  69005. */
  69006. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  69007. /**
  69008. * Creates an identity quaternion
  69009. * @returns the identity quaternion
  69010. */
  69011. static Identity(): Quaternion;
  69012. /**
  69013. * Gets a boolean indicating if the given quaternion is identity
  69014. * @param quaternion defines the quaternion to check
  69015. * @returns true if the quaternion is identity
  69016. */
  69017. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  69018. /**
  69019. * Creates a quaternion from a rotation around an axis
  69020. * @param axis defines the axis to use
  69021. * @param angle defines the angle to use
  69022. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  69023. */
  69024. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  69025. /**
  69026. * Creates a rotation around an axis and stores it into the given quaternion
  69027. * @param axis defines the axis to use
  69028. * @param angle defines the angle to use
  69029. * @param result defines the target quaternion
  69030. * @returns the target quaternion
  69031. */
  69032. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  69033. /**
  69034. * Creates a new quaternion from data stored into an array
  69035. * @param array defines the data source
  69036. * @param offset defines the offset in the source array where the data starts
  69037. * @returns a new quaternion
  69038. */
  69039. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  69040. /**
  69041. * Create a quaternion from Euler rotation angles
  69042. * @param x Pitch
  69043. * @param y Yaw
  69044. * @param z Roll
  69045. * @returns the new Quaternion
  69046. */
  69047. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  69048. /**
  69049. * Updates a quaternion from Euler rotation angles
  69050. * @param x Pitch
  69051. * @param y Yaw
  69052. * @param z Roll
  69053. * @param result the quaternion to store the result
  69054. * @returns the updated quaternion
  69055. */
  69056. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  69057. /**
  69058. * Create a quaternion from Euler rotation vector
  69059. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69060. * @returns the new Quaternion
  69061. */
  69062. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  69063. /**
  69064. * Updates a quaternion from Euler rotation vector
  69065. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69066. * @param result the quaternion to store the result
  69067. * @returns the updated quaternion
  69068. */
  69069. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  69070. /**
  69071. * Creates a new quaternion from the given Euler float angles (y, x, z)
  69072. * @param yaw defines the rotation around Y axis
  69073. * @param pitch defines the rotation around X axis
  69074. * @param roll defines the rotation around Z axis
  69075. * @returns the new quaternion
  69076. */
  69077. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  69078. /**
  69079. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  69080. * @param yaw defines the rotation around Y axis
  69081. * @param pitch defines the rotation around X axis
  69082. * @param roll defines the rotation around Z axis
  69083. * @param result defines the target quaternion
  69084. */
  69085. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  69086. /**
  69087. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  69088. * @param alpha defines the rotation around first axis
  69089. * @param beta defines the rotation around second axis
  69090. * @param gamma defines the rotation around third axis
  69091. * @returns the new quaternion
  69092. */
  69093. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  69094. /**
  69095. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  69096. * @param alpha defines the rotation around first axis
  69097. * @param beta defines the rotation around second axis
  69098. * @param gamma defines the rotation around third axis
  69099. * @param result defines the target quaternion
  69100. */
  69101. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  69102. /**
  69103. * 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)
  69104. * @param axis1 defines the first axis
  69105. * @param axis2 defines the second axis
  69106. * @param axis3 defines the third axis
  69107. * @returns the new quaternion
  69108. */
  69109. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  69110. /**
  69111. * 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
  69112. * @param axis1 defines the first axis
  69113. * @param axis2 defines the second axis
  69114. * @param axis3 defines the third axis
  69115. * @param ref defines the target quaternion
  69116. */
  69117. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  69118. /**
  69119. * Interpolates between two quaternions
  69120. * @param left defines first quaternion
  69121. * @param right defines second quaternion
  69122. * @param amount defines the gradient to use
  69123. * @returns the new interpolated quaternion
  69124. */
  69125. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69126. /**
  69127. * Interpolates between two quaternions and stores it into a target quaternion
  69128. * @param left defines first quaternion
  69129. * @param right defines second quaternion
  69130. * @param amount defines the gradient to use
  69131. * @param result defines the target quaternion
  69132. */
  69133. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  69134. /**
  69135. * Interpolate between two quaternions using Hermite interpolation
  69136. * @param value1 defines first quaternion
  69137. * @param tangent1 defines the incoming tangent
  69138. * @param value2 defines second quaternion
  69139. * @param tangent2 defines the outgoing tangent
  69140. * @param amount defines the target quaternion
  69141. * @returns the new interpolated quaternion
  69142. */
  69143. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69144. }
  69145. /**
  69146. * Class used to store matrix data (4x4)
  69147. */
  69148. export class Matrix {
  69149. private static _updateFlagSeed;
  69150. private static _identityReadOnly;
  69151. private _isIdentity;
  69152. private _isIdentityDirty;
  69153. private _isIdentity3x2;
  69154. private _isIdentity3x2Dirty;
  69155. /**
  69156. * Gets the update flag of the matrix which is an unique number for the matrix.
  69157. * It will be incremented every time the matrix data change.
  69158. * You can use it to speed the comparison between two versions of the same matrix.
  69159. */
  69160. updateFlag: number;
  69161. private readonly _m;
  69162. /**
  69163. * Gets the internal data of the matrix
  69164. */
  69165. readonly m: DeepImmutable<Float32Array>;
  69166. /** @hidden */
  69167. _markAsUpdated(): void;
  69168. /** @hidden */
  69169. private _updateIdentityStatus;
  69170. /**
  69171. * Creates an empty matrix (filled with zeros)
  69172. */
  69173. constructor();
  69174. /**
  69175. * Check if the current matrix is identity
  69176. * @returns true is the matrix is the identity matrix
  69177. */
  69178. isIdentity(): boolean;
  69179. /**
  69180. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  69181. * @returns true is the matrix is the identity matrix
  69182. */
  69183. isIdentityAs3x2(): boolean;
  69184. /**
  69185. * Gets the determinant of the matrix
  69186. * @returns the matrix determinant
  69187. */
  69188. determinant(): number;
  69189. /**
  69190. * Returns the matrix as a Float32Array
  69191. * @returns the matrix underlying array
  69192. */
  69193. toArray(): DeepImmutable<Float32Array>;
  69194. /**
  69195. * Returns the matrix as a Float32Array
  69196. * @returns the matrix underlying array.
  69197. */
  69198. asArray(): DeepImmutable<Float32Array>;
  69199. /**
  69200. * Inverts the current matrix in place
  69201. * @returns the current inverted matrix
  69202. */
  69203. invert(): Matrix;
  69204. /**
  69205. * Sets all the matrix elements to zero
  69206. * @returns the current matrix
  69207. */
  69208. reset(): Matrix;
  69209. /**
  69210. * Adds the current matrix with a second one
  69211. * @param other defines the matrix to add
  69212. * @returns a new matrix as the addition of the current matrix and the given one
  69213. */
  69214. add(other: DeepImmutable<Matrix>): Matrix;
  69215. /**
  69216. * Sets the given matrix "result" to the addition of the current matrix and the given one
  69217. * @param other defines the matrix to add
  69218. * @param result defines the target matrix
  69219. * @returns the current matrix
  69220. */
  69221. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69222. /**
  69223. * Adds in place the given matrix to the current matrix
  69224. * @param other defines the second operand
  69225. * @returns the current updated matrix
  69226. */
  69227. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  69228. /**
  69229. * Sets the given matrix to the current inverted Matrix
  69230. * @param other defines the target matrix
  69231. * @returns the unmodified current matrix
  69232. */
  69233. invertToRef(other: Matrix): Matrix;
  69234. /**
  69235. * add a value at the specified position in the current Matrix
  69236. * @param index the index of the value within the matrix. between 0 and 15.
  69237. * @param value the value to be added
  69238. * @returns the current updated matrix
  69239. */
  69240. addAtIndex(index: number, value: number): Matrix;
  69241. /**
  69242. * mutiply the specified position in the current Matrix by a value
  69243. * @param index the index of the value within the matrix. between 0 and 15.
  69244. * @param value the value to be added
  69245. * @returns the current updated matrix
  69246. */
  69247. multiplyAtIndex(index: number, value: number): Matrix;
  69248. /**
  69249. * Inserts the translation vector (using 3 floats) in the current matrix
  69250. * @param x defines the 1st component of the translation
  69251. * @param y defines the 2nd component of the translation
  69252. * @param z defines the 3rd component of the translation
  69253. * @returns the current updated matrix
  69254. */
  69255. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69256. /**
  69257. * Adds the translation vector (using 3 floats) in the current matrix
  69258. * @param x defines the 1st component of the translation
  69259. * @param y defines the 2nd component of the translation
  69260. * @param z defines the 3rd component of the translation
  69261. * @returns the current updated matrix
  69262. */
  69263. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69264. /**
  69265. * Inserts the translation vector in the current matrix
  69266. * @param vector3 defines the translation to insert
  69267. * @returns the current updated matrix
  69268. */
  69269. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  69270. /**
  69271. * Gets the translation value of the current matrix
  69272. * @returns a new Vector3 as the extracted translation from the matrix
  69273. */
  69274. getTranslation(): Vector3;
  69275. /**
  69276. * Fill a Vector3 with the extracted translation from the matrix
  69277. * @param result defines the Vector3 where to store the translation
  69278. * @returns the current matrix
  69279. */
  69280. getTranslationToRef(result: Vector3): Matrix;
  69281. /**
  69282. * Remove rotation and scaling part from the matrix
  69283. * @returns the updated matrix
  69284. */
  69285. removeRotationAndScaling(): Matrix;
  69286. /**
  69287. * Multiply two matrices
  69288. * @param other defines the second operand
  69289. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  69290. */
  69291. multiply(other: DeepImmutable<Matrix>): Matrix;
  69292. /**
  69293. * Copy the current matrix from the given one
  69294. * @param other defines the source matrix
  69295. * @returns the current updated matrix
  69296. */
  69297. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  69298. /**
  69299. * Populates the given array from the starting index with the current matrix values
  69300. * @param array defines the target array
  69301. * @param offset defines the offset in the target array where to start storing values
  69302. * @returns the current matrix
  69303. */
  69304. copyToArray(array: Float32Array, offset?: number): Matrix;
  69305. /**
  69306. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  69307. * @param other defines the second operand
  69308. * @param result defines the matrix where to store the multiplication
  69309. * @returns the current matrix
  69310. */
  69311. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69312. /**
  69313. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  69314. * @param other defines the second operand
  69315. * @param result defines the array where to store the multiplication
  69316. * @param offset defines the offset in the target array where to start storing values
  69317. * @returns the current matrix
  69318. */
  69319. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  69320. /**
  69321. * Check equality between this matrix and a second one
  69322. * @param value defines the second matrix to compare
  69323. * @returns true is the current matrix and the given one values are strictly equal
  69324. */
  69325. equals(value: DeepImmutable<Matrix>): boolean;
  69326. /**
  69327. * Clone the current matrix
  69328. * @returns a new matrix from the current matrix
  69329. */
  69330. clone(): Matrix;
  69331. /**
  69332. * Returns the name of the current matrix class
  69333. * @returns the string "Matrix"
  69334. */
  69335. getClassName(): string;
  69336. /**
  69337. * Gets the hash code of the current matrix
  69338. * @returns the hash code
  69339. */
  69340. getHashCode(): number;
  69341. /**
  69342. * Decomposes the current Matrix into a translation, rotation and scaling components
  69343. * @param scale defines the scale vector3 given as a reference to update
  69344. * @param rotation defines the rotation quaternion given as a reference to update
  69345. * @param translation defines the translation vector3 given as a reference to update
  69346. * @returns true if operation was successful
  69347. */
  69348. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  69349. /**
  69350. * Gets specific row of the matrix
  69351. * @param index defines the number of the row to get
  69352. * @returns the index-th row of the current matrix as a new Vector4
  69353. */
  69354. getRow(index: number): Nullable<Vector4>;
  69355. /**
  69356. * Sets the index-th row of the current matrix to the vector4 values
  69357. * @param index defines the number of the row to set
  69358. * @param row defines the target vector4
  69359. * @returns the updated current matrix
  69360. */
  69361. setRow(index: number, row: Vector4): Matrix;
  69362. /**
  69363. * Compute the transpose of the matrix
  69364. * @returns the new transposed matrix
  69365. */
  69366. transpose(): Matrix;
  69367. /**
  69368. * Compute the transpose of the matrix and store it in a given matrix
  69369. * @param result defines the target matrix
  69370. * @returns the current matrix
  69371. */
  69372. transposeToRef(result: Matrix): Matrix;
  69373. /**
  69374. * Sets the index-th row of the current matrix with the given 4 x float values
  69375. * @param index defines the row index
  69376. * @param x defines the x component to set
  69377. * @param y defines the y component to set
  69378. * @param z defines the z component to set
  69379. * @param w defines the w component to set
  69380. * @returns the updated current matrix
  69381. */
  69382. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  69383. /**
  69384. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  69385. * @param scale defines the scale factor
  69386. * @returns a new matrix
  69387. */
  69388. scale(scale: number): Matrix;
  69389. /**
  69390. * Scale the current matrix values by a factor to a given result matrix
  69391. * @param scale defines the scale factor
  69392. * @param result defines the matrix to store the result
  69393. * @returns the current matrix
  69394. */
  69395. scaleToRef(scale: number, result: Matrix): Matrix;
  69396. /**
  69397. * Scale the current matrix values by a factor and add the result to a given matrix
  69398. * @param scale defines the scale factor
  69399. * @param result defines the Matrix to store the result
  69400. * @returns the current matrix
  69401. */
  69402. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  69403. /**
  69404. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  69405. * @param ref matrix to store the result
  69406. */
  69407. toNormalMatrix(ref: Matrix): void;
  69408. /**
  69409. * Gets only rotation part of the current matrix
  69410. * @returns a new matrix sets to the extracted rotation matrix from the current one
  69411. */
  69412. getRotationMatrix(): Matrix;
  69413. /**
  69414. * Extracts the rotation matrix from the current one and sets it as the given "result"
  69415. * @param result defines the target matrix to store data to
  69416. * @returns the current matrix
  69417. */
  69418. getRotationMatrixToRef(result: Matrix): Matrix;
  69419. /**
  69420. * Toggles model matrix from being right handed to left handed in place and vice versa
  69421. */
  69422. toggleModelMatrixHandInPlace(): void;
  69423. /**
  69424. * Toggles projection matrix from being right handed to left handed in place and vice versa
  69425. */
  69426. toggleProjectionMatrixHandInPlace(): void;
  69427. /**
  69428. * Creates a matrix from an array
  69429. * @param array defines the source array
  69430. * @param offset defines an offset in the source array
  69431. * @returns a new Matrix set from the starting index of the given array
  69432. */
  69433. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  69434. /**
  69435. * Copy the content of an array into a given matrix
  69436. * @param array defines the source array
  69437. * @param offset defines an offset in the source array
  69438. * @param result defines the target matrix
  69439. */
  69440. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  69441. /**
  69442. * Stores an array into a matrix after having multiplied each component by a given factor
  69443. * @param array defines the source array
  69444. * @param offset defines the offset in the source array
  69445. * @param scale defines the scaling factor
  69446. * @param result defines the target matrix
  69447. */
  69448. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  69449. /**
  69450. * Gets an identity matrix that must not be updated
  69451. */
  69452. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  69453. /**
  69454. * Stores a list of values (16) inside a given matrix
  69455. * @param initialM11 defines 1st value of 1st row
  69456. * @param initialM12 defines 2nd value of 1st row
  69457. * @param initialM13 defines 3rd value of 1st row
  69458. * @param initialM14 defines 4th value of 1st row
  69459. * @param initialM21 defines 1st value of 2nd row
  69460. * @param initialM22 defines 2nd value of 2nd row
  69461. * @param initialM23 defines 3rd value of 2nd row
  69462. * @param initialM24 defines 4th value of 2nd row
  69463. * @param initialM31 defines 1st value of 3rd row
  69464. * @param initialM32 defines 2nd value of 3rd row
  69465. * @param initialM33 defines 3rd value of 3rd row
  69466. * @param initialM34 defines 4th value of 3rd row
  69467. * @param initialM41 defines 1st value of 4th row
  69468. * @param initialM42 defines 2nd value of 4th row
  69469. * @param initialM43 defines 3rd value of 4th row
  69470. * @param initialM44 defines 4th value of 4th row
  69471. * @param result defines the target matrix
  69472. */
  69473. 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;
  69474. /**
  69475. * Creates new matrix from a list of values (16)
  69476. * @param initialM11 defines 1st value of 1st row
  69477. * @param initialM12 defines 2nd value of 1st row
  69478. * @param initialM13 defines 3rd value of 1st row
  69479. * @param initialM14 defines 4th value of 1st row
  69480. * @param initialM21 defines 1st value of 2nd row
  69481. * @param initialM22 defines 2nd value of 2nd row
  69482. * @param initialM23 defines 3rd value of 2nd row
  69483. * @param initialM24 defines 4th value of 2nd row
  69484. * @param initialM31 defines 1st value of 3rd row
  69485. * @param initialM32 defines 2nd value of 3rd row
  69486. * @param initialM33 defines 3rd value of 3rd row
  69487. * @param initialM34 defines 4th value of 3rd row
  69488. * @param initialM41 defines 1st value of 4th row
  69489. * @param initialM42 defines 2nd value of 4th row
  69490. * @param initialM43 defines 3rd value of 4th row
  69491. * @param initialM44 defines 4th value of 4th row
  69492. * @returns the new matrix
  69493. */
  69494. 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;
  69495. /**
  69496. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69497. * @param scale defines the scale vector3
  69498. * @param rotation defines the rotation quaternion
  69499. * @param translation defines the translation vector3
  69500. * @returns a new matrix
  69501. */
  69502. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  69503. /**
  69504. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69505. * @param scale defines the scale vector3
  69506. * @param rotation defines the rotation quaternion
  69507. * @param translation defines the translation vector3
  69508. * @param result defines the target matrix
  69509. */
  69510. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  69511. /**
  69512. * Creates a new identity matrix
  69513. * @returns a new identity matrix
  69514. */
  69515. static Identity(): Matrix;
  69516. /**
  69517. * Creates a new identity matrix and stores the result in a given matrix
  69518. * @param result defines the target matrix
  69519. */
  69520. static IdentityToRef(result: Matrix): void;
  69521. /**
  69522. * Creates a new zero matrix
  69523. * @returns a new zero matrix
  69524. */
  69525. static Zero(): Matrix;
  69526. /**
  69527. * Creates a new rotation matrix for "angle" radians around the X axis
  69528. * @param angle defines the angle (in radians) to use
  69529. * @return the new matrix
  69530. */
  69531. static RotationX(angle: number): Matrix;
  69532. /**
  69533. * Creates a new matrix as the invert of a given matrix
  69534. * @param source defines the source matrix
  69535. * @returns the new matrix
  69536. */
  69537. static Invert(source: DeepImmutable<Matrix>): Matrix;
  69538. /**
  69539. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  69540. * @param angle defines the angle (in radians) to use
  69541. * @param result defines the target matrix
  69542. */
  69543. static RotationXToRef(angle: number, result: Matrix): void;
  69544. /**
  69545. * Creates a new rotation matrix for "angle" radians around the Y axis
  69546. * @param angle defines the angle (in radians) to use
  69547. * @return the new matrix
  69548. */
  69549. static RotationY(angle: number): Matrix;
  69550. /**
  69551. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  69552. * @param angle defines the angle (in radians) to use
  69553. * @param result defines the target matrix
  69554. */
  69555. static RotationYToRef(angle: number, result: Matrix): void;
  69556. /**
  69557. * Creates a new rotation matrix for "angle" radians around the Z axis
  69558. * @param angle defines the angle (in radians) to use
  69559. * @return the new matrix
  69560. */
  69561. static RotationZ(angle: number): Matrix;
  69562. /**
  69563. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  69564. * @param angle defines the angle (in radians) to use
  69565. * @param result defines the target matrix
  69566. */
  69567. static RotationZToRef(angle: number, result: Matrix): void;
  69568. /**
  69569. * Creates a new rotation matrix for "angle" radians around the given axis
  69570. * @param axis defines the axis to use
  69571. * @param angle defines the angle (in radians) to use
  69572. * @return the new matrix
  69573. */
  69574. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  69575. /**
  69576. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  69577. * @param axis defines the axis to use
  69578. * @param angle defines the angle (in radians) to use
  69579. * @param result defines the target matrix
  69580. */
  69581. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  69582. /**
  69583. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  69584. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  69585. * @param from defines the vector to align
  69586. * @param to defines the vector to align to
  69587. * @param result defines the target matrix
  69588. */
  69589. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  69590. /**
  69591. * Creates a rotation matrix
  69592. * @param yaw defines the yaw angle in radians (Y axis)
  69593. * @param pitch defines the pitch angle in radians (X axis)
  69594. * @param roll defines the roll angle in radians (X axis)
  69595. * @returns the new rotation matrix
  69596. */
  69597. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  69598. /**
  69599. * Creates a rotation matrix and stores it in a given matrix
  69600. * @param yaw defines the yaw angle in radians (Y axis)
  69601. * @param pitch defines the pitch angle in radians (X axis)
  69602. * @param roll defines the roll angle in radians (X axis)
  69603. * @param result defines the target matrix
  69604. */
  69605. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  69606. /**
  69607. * Creates a scaling matrix
  69608. * @param x defines the scale factor on X axis
  69609. * @param y defines the scale factor on Y axis
  69610. * @param z defines the scale factor on Z axis
  69611. * @returns the new matrix
  69612. */
  69613. static Scaling(x: number, y: number, z: number): Matrix;
  69614. /**
  69615. * Creates a scaling matrix and stores it in a given matrix
  69616. * @param x defines the scale factor on X axis
  69617. * @param y defines the scale factor on Y axis
  69618. * @param z defines the scale factor on Z axis
  69619. * @param result defines the target matrix
  69620. */
  69621. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  69622. /**
  69623. * Creates a translation matrix
  69624. * @param x defines the translation on X axis
  69625. * @param y defines the translation on Y axis
  69626. * @param z defines the translationon Z axis
  69627. * @returns the new matrix
  69628. */
  69629. static Translation(x: number, y: number, z: number): Matrix;
  69630. /**
  69631. * Creates a translation matrix and stores it in a given matrix
  69632. * @param x defines the translation on X axis
  69633. * @param y defines the translation on Y axis
  69634. * @param z defines the translationon Z axis
  69635. * @param result defines the target matrix
  69636. */
  69637. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  69638. /**
  69639. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69640. * @param startValue defines the start value
  69641. * @param endValue defines the end value
  69642. * @param gradient defines the gradient factor
  69643. * @returns the new matrix
  69644. */
  69645. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69646. /**
  69647. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  69648. * @param startValue defines the start value
  69649. * @param endValue defines the end value
  69650. * @param gradient defines the gradient factor
  69651. * @param result defines the Matrix object where to store data
  69652. */
  69653. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69654. /**
  69655. * Builds a new matrix whose values are computed by:
  69656. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69657. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69658. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69659. * @param startValue defines the first matrix
  69660. * @param endValue defines the second matrix
  69661. * @param gradient defines the gradient between the two matrices
  69662. * @returns the new matrix
  69663. */
  69664. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  69665. /**
  69666. * Update a matrix to values which are computed by:
  69667. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  69668. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  69669. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  69670. * @param startValue defines the first matrix
  69671. * @param endValue defines the second matrix
  69672. * @param gradient defines the gradient between the two matrices
  69673. * @param result defines the target matrix
  69674. */
  69675. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  69676. /**
  69677. * 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"
  69678. * This function works in left handed mode
  69679. * @param eye defines the final position of the entity
  69680. * @param target defines where the entity should look at
  69681. * @param up defines the up vector for the entity
  69682. * @returns the new matrix
  69683. */
  69684. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69685. /**
  69686. * 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".
  69687. * This function works in left handed mode
  69688. * @param eye defines the final position of the entity
  69689. * @param target defines where the entity should look at
  69690. * @param up defines the up vector for the entity
  69691. * @param result defines the target matrix
  69692. */
  69693. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69694. /**
  69695. * 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"
  69696. * This function works in right handed mode
  69697. * @param eye defines the final position of the entity
  69698. * @param target defines where the entity should look at
  69699. * @param up defines the up vector for the entity
  69700. * @returns the new matrix
  69701. */
  69702. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  69703. /**
  69704. * 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".
  69705. * This function works in right handed mode
  69706. * @param eye defines the final position of the entity
  69707. * @param target defines where the entity should look at
  69708. * @param up defines the up vector for the entity
  69709. * @param result defines the target matrix
  69710. */
  69711. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  69712. /**
  69713. * Create a left-handed orthographic projection matrix
  69714. * @param width defines the viewport width
  69715. * @param height defines the viewport height
  69716. * @param znear defines the near clip plane
  69717. * @param zfar defines the far clip plane
  69718. * @returns a new matrix as a left-handed orthographic projection matrix
  69719. */
  69720. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69721. /**
  69722. * Store a left-handed orthographic projection to a given matrix
  69723. * @param width defines the viewport width
  69724. * @param height defines the viewport height
  69725. * @param znear defines the near clip plane
  69726. * @param zfar defines the far clip plane
  69727. * @param result defines the target matrix
  69728. */
  69729. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  69730. /**
  69731. * Create a left-handed orthographic projection matrix
  69732. * @param left defines the viewport left coordinate
  69733. * @param right defines the viewport right coordinate
  69734. * @param bottom defines the viewport bottom coordinate
  69735. * @param top defines the viewport top coordinate
  69736. * @param znear defines the near clip plane
  69737. * @param zfar defines the far clip plane
  69738. * @returns a new matrix as a left-handed orthographic projection matrix
  69739. */
  69740. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69741. /**
  69742. * Stores a left-handed orthographic projection into a given matrix
  69743. * @param left defines the viewport left coordinate
  69744. * @param right defines the viewport right coordinate
  69745. * @param bottom defines the viewport bottom coordinate
  69746. * @param top defines the viewport top coordinate
  69747. * @param znear defines the near clip plane
  69748. * @param zfar defines the far clip plane
  69749. * @param result defines the target matrix
  69750. */
  69751. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69752. /**
  69753. * Creates a right-handed orthographic projection matrix
  69754. * @param left defines the viewport left coordinate
  69755. * @param right defines the viewport right coordinate
  69756. * @param bottom defines the viewport bottom coordinate
  69757. * @param top defines the viewport top coordinate
  69758. * @param znear defines the near clip plane
  69759. * @param zfar defines the far clip plane
  69760. * @returns a new matrix as a right-handed orthographic projection matrix
  69761. */
  69762. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  69763. /**
  69764. * Stores a right-handed orthographic projection into a given matrix
  69765. * @param left defines the viewport left coordinate
  69766. * @param right defines the viewport right coordinate
  69767. * @param bottom defines the viewport bottom coordinate
  69768. * @param top defines the viewport top coordinate
  69769. * @param znear defines the near clip plane
  69770. * @param zfar defines the far clip plane
  69771. * @param result defines the target matrix
  69772. */
  69773. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  69774. /**
  69775. * Creates a left-handed perspective projection matrix
  69776. * @param width defines the viewport width
  69777. * @param height defines the viewport height
  69778. * @param znear defines the near clip plane
  69779. * @param zfar defines the far clip plane
  69780. * @returns a new matrix as a left-handed perspective projection matrix
  69781. */
  69782. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  69783. /**
  69784. * Creates a left-handed perspective projection matrix
  69785. * @param fov defines the horizontal field of view
  69786. * @param aspect defines the aspect ratio
  69787. * @param znear defines the near clip plane
  69788. * @param zfar defines the far clip plane
  69789. * @returns a new matrix as a left-handed perspective projection matrix
  69790. */
  69791. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69792. /**
  69793. * Stores a left-handed perspective projection into a given matrix
  69794. * @param fov defines the horizontal field of view
  69795. * @param aspect defines the aspect ratio
  69796. * @param znear defines the near clip plane
  69797. * @param zfar defines the far clip plane
  69798. * @param result defines the target matrix
  69799. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69800. */
  69801. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69802. /**
  69803. * Creates a right-handed perspective projection matrix
  69804. * @param fov defines the horizontal field of view
  69805. * @param aspect defines the aspect ratio
  69806. * @param znear defines the near clip plane
  69807. * @param zfar defines the far clip plane
  69808. * @returns a new matrix as a right-handed perspective projection matrix
  69809. */
  69810. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  69811. /**
  69812. * Stores a right-handed perspective projection into a given matrix
  69813. * @param fov defines the horizontal field of view
  69814. * @param aspect defines the aspect ratio
  69815. * @param znear defines the near clip plane
  69816. * @param zfar defines the far clip plane
  69817. * @param result defines the target matrix
  69818. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  69819. */
  69820. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  69821. /**
  69822. * Stores a perspective projection for WebVR info a given matrix
  69823. * @param fov defines the field of view
  69824. * @param znear defines the near clip plane
  69825. * @param zfar defines the far clip plane
  69826. * @param result defines the target matrix
  69827. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  69828. */
  69829. static PerspectiveFovWebVRToRef(fov: {
  69830. upDegrees: number;
  69831. downDegrees: number;
  69832. leftDegrees: number;
  69833. rightDegrees: number;
  69834. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  69835. /**
  69836. * Computes a complete transformation matrix
  69837. * @param viewport defines the viewport to use
  69838. * @param world defines the world matrix
  69839. * @param view defines the view matrix
  69840. * @param projection defines the projection matrix
  69841. * @param zmin defines the near clip plane
  69842. * @param zmax defines the far clip plane
  69843. * @returns the transformation matrix
  69844. */
  69845. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  69846. /**
  69847. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  69848. * @param matrix defines the matrix to use
  69849. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  69850. */
  69851. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  69852. /**
  69853. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  69854. * @param matrix defines the matrix to use
  69855. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  69856. */
  69857. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  69858. /**
  69859. * Compute the transpose of a given matrix
  69860. * @param matrix defines the matrix to transpose
  69861. * @returns the new matrix
  69862. */
  69863. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  69864. /**
  69865. * Compute the transpose of a matrix and store it in a target matrix
  69866. * @param matrix defines the matrix to transpose
  69867. * @param result defines the target matrix
  69868. */
  69869. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  69870. /**
  69871. * Computes a reflection matrix from a plane
  69872. * @param plane defines the reflection plane
  69873. * @returns a new matrix
  69874. */
  69875. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  69876. /**
  69877. * Computes a reflection matrix from a plane
  69878. * @param plane defines the reflection plane
  69879. * @param result defines the target matrix
  69880. */
  69881. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  69882. /**
  69883. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  69884. * @param xaxis defines the value of the 1st axis
  69885. * @param yaxis defines the value of the 2nd axis
  69886. * @param zaxis defines the value of the 3rd axis
  69887. * @param result defines the target matrix
  69888. */
  69889. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  69890. /**
  69891. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  69892. * @param quat defines the quaternion to use
  69893. * @param result defines the target matrix
  69894. */
  69895. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  69896. }
  69897. /**
  69898. * @hidden
  69899. */
  69900. export class TmpVectors {
  69901. static Vector2: Vector2[];
  69902. static Vector3: Vector3[];
  69903. static Vector4: Vector4[];
  69904. static Quaternion: Quaternion[];
  69905. static Matrix: Matrix[];
  69906. }
  69907. }
  69908. declare module BABYLON {
  69909. /** Defines the cross module used constants to avoid circular dependncies */
  69910. export class Constants {
  69911. /** Defines that alpha blending is disabled */
  69912. static readonly ALPHA_DISABLE: number;
  69913. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  69914. static readonly ALPHA_ADD: number;
  69915. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  69916. static readonly ALPHA_COMBINE: number;
  69917. /** Defines that alpha blending to DEST - SRC * DEST */
  69918. static readonly ALPHA_SUBTRACT: number;
  69919. /** Defines that alpha blending to SRC * DEST */
  69920. static readonly ALPHA_MULTIPLY: number;
  69921. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  69922. static readonly ALPHA_MAXIMIZED: number;
  69923. /** Defines that alpha blending to SRC + DEST */
  69924. static readonly ALPHA_ONEONE: number;
  69925. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  69926. static readonly ALPHA_PREMULTIPLIED: number;
  69927. /**
  69928. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  69929. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  69930. */
  69931. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  69932. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  69933. static readonly ALPHA_INTERPOLATE: number;
  69934. /**
  69935. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  69936. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  69937. */
  69938. static readonly ALPHA_SCREENMODE: number;
  69939. /**
  69940. * Defines that alpha blending to SRC + DST
  69941. * Alpha will be set to SRC ALPHA + DST ALPHA
  69942. */
  69943. static readonly ALPHA_ONEONE_ONEONE: number;
  69944. /**
  69945. * Defines that alpha blending to SRC * DST ALPHA + DST
  69946. * Alpha will be set to 0
  69947. */
  69948. static readonly ALPHA_ALPHATOCOLOR: number;
  69949. /**
  69950. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  69951. */
  69952. static readonly ALPHA_REVERSEONEMINUS: number;
  69953. /**
  69954. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  69955. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  69956. */
  69957. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  69958. /**
  69959. * Defines that alpha blending to SRC + DST
  69960. * Alpha will be set to SRC ALPHA
  69961. */
  69962. static readonly ALPHA_ONEONE_ONEZERO: number;
  69963. /** Defines that alpha blending equation a SUM */
  69964. static readonly ALPHA_EQUATION_ADD: number;
  69965. /** Defines that alpha blending equation a SUBSTRACTION */
  69966. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  69967. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  69968. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  69969. /** Defines that alpha blending equation a MAX operation */
  69970. static readonly ALPHA_EQUATION_MAX: number;
  69971. /** Defines that alpha blending equation a MIN operation */
  69972. static readonly ALPHA_EQUATION_MIN: number;
  69973. /**
  69974. * Defines that alpha blending equation a DARKEN operation:
  69975. * It takes the min of the src and sums the alpha channels.
  69976. */
  69977. static readonly ALPHA_EQUATION_DARKEN: number;
  69978. /** Defines that the ressource is not delayed*/
  69979. static readonly DELAYLOADSTATE_NONE: number;
  69980. /** Defines that the ressource was successfully delay loaded */
  69981. static readonly DELAYLOADSTATE_LOADED: number;
  69982. /** Defines that the ressource is currently delay loading */
  69983. static readonly DELAYLOADSTATE_LOADING: number;
  69984. /** Defines that the ressource is delayed and has not started loading */
  69985. static readonly DELAYLOADSTATE_NOTLOADED: number;
  69986. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  69987. static readonly NEVER: number;
  69988. /** 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 */
  69989. static readonly ALWAYS: number;
  69990. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  69991. static readonly LESS: number;
  69992. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  69993. static readonly EQUAL: number;
  69994. /** 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 */
  69995. static readonly LEQUAL: number;
  69996. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  69997. static readonly GREATER: number;
  69998. /** 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 */
  69999. static readonly GEQUAL: number;
  70000. /** 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 */
  70001. static readonly NOTEQUAL: number;
  70002. /** Passed to stencilOperation to specify that stencil value must be kept */
  70003. static readonly KEEP: number;
  70004. /** Passed to stencilOperation to specify that stencil value must be replaced */
  70005. static readonly REPLACE: number;
  70006. /** Passed to stencilOperation to specify that stencil value must be incremented */
  70007. static readonly INCR: number;
  70008. /** Passed to stencilOperation to specify that stencil value must be decremented */
  70009. static readonly DECR: number;
  70010. /** Passed to stencilOperation to specify that stencil value must be inverted */
  70011. static readonly INVERT: number;
  70012. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  70013. static readonly INCR_WRAP: number;
  70014. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  70015. static readonly DECR_WRAP: number;
  70016. /** Texture is not repeating outside of 0..1 UVs */
  70017. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  70018. /** Texture is repeating outside of 0..1 UVs */
  70019. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  70020. /** Texture is repeating and mirrored */
  70021. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  70022. /** ALPHA */
  70023. static readonly TEXTUREFORMAT_ALPHA: number;
  70024. /** LUMINANCE */
  70025. static readonly TEXTUREFORMAT_LUMINANCE: number;
  70026. /** LUMINANCE_ALPHA */
  70027. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  70028. /** RGB */
  70029. static readonly TEXTUREFORMAT_RGB: number;
  70030. /** RGBA */
  70031. static readonly TEXTUREFORMAT_RGBA: number;
  70032. /** RED */
  70033. static readonly TEXTUREFORMAT_RED: number;
  70034. /** RED (2nd reference) */
  70035. static readonly TEXTUREFORMAT_R: number;
  70036. /** RG */
  70037. static readonly TEXTUREFORMAT_RG: number;
  70038. /** RED_INTEGER */
  70039. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  70040. /** RED_INTEGER (2nd reference) */
  70041. static readonly TEXTUREFORMAT_R_INTEGER: number;
  70042. /** RG_INTEGER */
  70043. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  70044. /** RGB_INTEGER */
  70045. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  70046. /** RGBA_INTEGER */
  70047. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  70048. /** UNSIGNED_BYTE */
  70049. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  70050. /** UNSIGNED_BYTE (2nd reference) */
  70051. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  70052. /** FLOAT */
  70053. static readonly TEXTURETYPE_FLOAT: number;
  70054. /** HALF_FLOAT */
  70055. static readonly TEXTURETYPE_HALF_FLOAT: number;
  70056. /** BYTE */
  70057. static readonly TEXTURETYPE_BYTE: number;
  70058. /** SHORT */
  70059. static readonly TEXTURETYPE_SHORT: number;
  70060. /** UNSIGNED_SHORT */
  70061. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  70062. /** INT */
  70063. static readonly TEXTURETYPE_INT: number;
  70064. /** UNSIGNED_INT */
  70065. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  70066. /** UNSIGNED_SHORT_4_4_4_4 */
  70067. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  70068. /** UNSIGNED_SHORT_5_5_5_1 */
  70069. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  70070. /** UNSIGNED_SHORT_5_6_5 */
  70071. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  70072. /** UNSIGNED_INT_2_10_10_10_REV */
  70073. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  70074. /** UNSIGNED_INT_24_8 */
  70075. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  70076. /** UNSIGNED_INT_10F_11F_11F_REV */
  70077. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  70078. /** UNSIGNED_INT_5_9_9_9_REV */
  70079. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  70080. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  70081. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70082. /** nearest is mag = nearest and min = nearest and mip = linear */
  70083. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  70084. /** Bilinear is mag = linear and min = linear and mip = nearest */
  70085. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  70086. /** Trilinear is mag = linear and min = linear and mip = linear */
  70087. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  70088. /** nearest is mag = nearest and min = nearest and mip = linear */
  70089. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  70090. /** Bilinear is mag = linear and min = linear and mip = nearest */
  70091. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  70092. /** Trilinear is mag = linear and min = linear and mip = linear */
  70093. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  70094. /** mag = nearest and min = nearest and mip = nearest */
  70095. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  70096. /** mag = nearest and min = linear and mip = nearest */
  70097. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  70098. /** mag = nearest and min = linear and mip = linear */
  70099. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  70100. /** mag = nearest and min = linear and mip = none */
  70101. static readonly TEXTURE_NEAREST_LINEAR: number;
  70102. /** mag = nearest and min = nearest and mip = none */
  70103. static readonly TEXTURE_NEAREST_NEAREST: number;
  70104. /** mag = linear and min = nearest and mip = nearest */
  70105. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  70106. /** mag = linear and min = nearest and mip = linear */
  70107. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  70108. /** mag = linear and min = linear and mip = none */
  70109. static readonly TEXTURE_LINEAR_LINEAR: number;
  70110. /** mag = linear and min = nearest and mip = none */
  70111. static readonly TEXTURE_LINEAR_NEAREST: number;
  70112. /** Explicit coordinates mode */
  70113. static readonly TEXTURE_EXPLICIT_MODE: number;
  70114. /** Spherical coordinates mode */
  70115. static readonly TEXTURE_SPHERICAL_MODE: number;
  70116. /** Planar coordinates mode */
  70117. static readonly TEXTURE_PLANAR_MODE: number;
  70118. /** Cubic coordinates mode */
  70119. static readonly TEXTURE_CUBIC_MODE: number;
  70120. /** Projection coordinates mode */
  70121. static readonly TEXTURE_PROJECTION_MODE: number;
  70122. /** Skybox coordinates mode */
  70123. static readonly TEXTURE_SKYBOX_MODE: number;
  70124. /** Inverse Cubic coordinates mode */
  70125. static readonly TEXTURE_INVCUBIC_MODE: number;
  70126. /** Equirectangular coordinates mode */
  70127. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  70128. /** Equirectangular Fixed coordinates mode */
  70129. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  70130. /** Equirectangular Fixed Mirrored coordinates mode */
  70131. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  70132. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  70133. static readonly SCALEMODE_FLOOR: number;
  70134. /** Defines that texture rescaling will look for the nearest power of 2 size */
  70135. static readonly SCALEMODE_NEAREST: number;
  70136. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  70137. static readonly SCALEMODE_CEILING: number;
  70138. /**
  70139. * The dirty texture flag value
  70140. */
  70141. static readonly MATERIAL_TextureDirtyFlag: number;
  70142. /**
  70143. * The dirty light flag value
  70144. */
  70145. static readonly MATERIAL_LightDirtyFlag: number;
  70146. /**
  70147. * The dirty fresnel flag value
  70148. */
  70149. static readonly MATERIAL_FresnelDirtyFlag: number;
  70150. /**
  70151. * The dirty attribute flag value
  70152. */
  70153. static readonly MATERIAL_AttributesDirtyFlag: number;
  70154. /**
  70155. * The dirty misc flag value
  70156. */
  70157. static readonly MATERIAL_MiscDirtyFlag: number;
  70158. /**
  70159. * The all dirty flag value
  70160. */
  70161. static readonly MATERIAL_AllDirtyFlag: number;
  70162. /**
  70163. * Returns the triangle fill mode
  70164. */
  70165. static readonly MATERIAL_TriangleFillMode: number;
  70166. /**
  70167. * Returns the wireframe mode
  70168. */
  70169. static readonly MATERIAL_WireFrameFillMode: number;
  70170. /**
  70171. * Returns the point fill mode
  70172. */
  70173. static readonly MATERIAL_PointFillMode: number;
  70174. /**
  70175. * Returns the point list draw mode
  70176. */
  70177. static readonly MATERIAL_PointListDrawMode: number;
  70178. /**
  70179. * Returns the line list draw mode
  70180. */
  70181. static readonly MATERIAL_LineListDrawMode: number;
  70182. /**
  70183. * Returns the line loop draw mode
  70184. */
  70185. static readonly MATERIAL_LineLoopDrawMode: number;
  70186. /**
  70187. * Returns the line strip draw mode
  70188. */
  70189. static readonly MATERIAL_LineStripDrawMode: number;
  70190. /**
  70191. * Returns the triangle strip draw mode
  70192. */
  70193. static readonly MATERIAL_TriangleStripDrawMode: number;
  70194. /**
  70195. * Returns the triangle fan draw mode
  70196. */
  70197. static readonly MATERIAL_TriangleFanDrawMode: number;
  70198. /**
  70199. * Stores the clock-wise side orientation
  70200. */
  70201. static readonly MATERIAL_ClockWiseSideOrientation: number;
  70202. /**
  70203. * Stores the counter clock-wise side orientation
  70204. */
  70205. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  70206. /**
  70207. * Nothing
  70208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70209. */
  70210. static readonly ACTION_NothingTrigger: number;
  70211. /**
  70212. * On pick
  70213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70214. */
  70215. static readonly ACTION_OnPickTrigger: number;
  70216. /**
  70217. * On left pick
  70218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70219. */
  70220. static readonly ACTION_OnLeftPickTrigger: number;
  70221. /**
  70222. * On right pick
  70223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70224. */
  70225. static readonly ACTION_OnRightPickTrigger: number;
  70226. /**
  70227. * On center pick
  70228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70229. */
  70230. static readonly ACTION_OnCenterPickTrigger: number;
  70231. /**
  70232. * On pick down
  70233. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70234. */
  70235. static readonly ACTION_OnPickDownTrigger: number;
  70236. /**
  70237. * On double pick
  70238. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70239. */
  70240. static readonly ACTION_OnDoublePickTrigger: number;
  70241. /**
  70242. * On pick up
  70243. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70244. */
  70245. static readonly ACTION_OnPickUpTrigger: number;
  70246. /**
  70247. * On pick out.
  70248. * This trigger will only be raised if you also declared a OnPickDown
  70249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70250. */
  70251. static readonly ACTION_OnPickOutTrigger: number;
  70252. /**
  70253. * On long press
  70254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70255. */
  70256. static readonly ACTION_OnLongPressTrigger: number;
  70257. /**
  70258. * On pointer over
  70259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70260. */
  70261. static readonly ACTION_OnPointerOverTrigger: number;
  70262. /**
  70263. * On pointer out
  70264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70265. */
  70266. static readonly ACTION_OnPointerOutTrigger: number;
  70267. /**
  70268. * On every frame
  70269. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70270. */
  70271. static readonly ACTION_OnEveryFrameTrigger: number;
  70272. /**
  70273. * On intersection enter
  70274. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70275. */
  70276. static readonly ACTION_OnIntersectionEnterTrigger: number;
  70277. /**
  70278. * On intersection exit
  70279. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70280. */
  70281. static readonly ACTION_OnIntersectionExitTrigger: number;
  70282. /**
  70283. * On key down
  70284. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70285. */
  70286. static readonly ACTION_OnKeyDownTrigger: number;
  70287. /**
  70288. * On key up
  70289. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70290. */
  70291. static readonly ACTION_OnKeyUpTrigger: number;
  70292. /**
  70293. * Billboard mode will only apply to Y axis
  70294. */
  70295. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  70296. /**
  70297. * Billboard mode will apply to all axes
  70298. */
  70299. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  70300. /**
  70301. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  70302. */
  70303. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  70304. /**
  70305. * Gets or sets base Assets URL
  70306. */
  70307. static PARTICLES_BaseAssetsUrl: string;
  70308. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  70309. * Test order :
  70310. * Is the bounding sphere outside the frustum ?
  70311. * If not, are the bounding box vertices outside the frustum ?
  70312. * It not, then the cullable object is in the frustum.
  70313. */
  70314. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  70315. /** Culling strategy : Bounding Sphere Only.
  70316. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  70317. * It's also less accurate than the standard because some not visible objects can still be selected.
  70318. * Test : is the bounding sphere outside the frustum ?
  70319. * If not, then the cullable object is in the frustum.
  70320. */
  70321. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  70322. /** Culling strategy : Optimistic Inclusion.
  70323. * This in an inclusion test first, then the standard exclusion test.
  70324. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  70325. * 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.
  70326. * Anyway, it's as accurate as the standard strategy.
  70327. * Test :
  70328. * Is the cullable object bounding sphere center in the frustum ?
  70329. * If not, apply the default culling strategy.
  70330. */
  70331. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  70332. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  70333. * This in an inclusion test first, then the bounding sphere only exclusion test.
  70334. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  70335. * 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.
  70336. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  70337. * Test :
  70338. * Is the cullable object bounding sphere center in the frustum ?
  70339. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  70340. */
  70341. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  70342. /**
  70343. * No logging while loading
  70344. */
  70345. static readonly SCENELOADER_NO_LOGGING: number;
  70346. /**
  70347. * Minimal logging while loading
  70348. */
  70349. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  70350. /**
  70351. * Summary logging while loading
  70352. */
  70353. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  70354. /**
  70355. * Detailled logging while loading
  70356. */
  70357. static readonly SCENELOADER_DETAILED_LOGGING: number;
  70358. }
  70359. }
  70360. declare module BABYLON {
  70361. /**
  70362. * Class used to store and describe the pipeline context associated with an effect
  70363. */
  70364. export interface IPipelineContext {
  70365. /**
  70366. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  70367. */
  70368. isAsync: boolean;
  70369. /**
  70370. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  70371. */
  70372. isReady: boolean;
  70373. /** @hidden */
  70374. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  70375. }
  70376. }
  70377. declare module BABYLON {
  70378. /** @hidden */
  70379. export interface IShaderProcessor {
  70380. attributeProcessor?: (attribute: string) => string;
  70381. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  70382. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  70383. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  70384. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  70385. lineProcessor?: (line: string, isFragment: boolean) => string;
  70386. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70387. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  70388. }
  70389. }
  70390. declare module BABYLON {
  70391. /** @hidden */
  70392. export interface ProcessingOptions {
  70393. defines: string[];
  70394. indexParameters: any;
  70395. isFragment: boolean;
  70396. shouldUseHighPrecisionShader: boolean;
  70397. supportsUniformBuffers: boolean;
  70398. shadersRepository: string;
  70399. includesShadersStore: {
  70400. [key: string]: string;
  70401. };
  70402. processor?: IShaderProcessor;
  70403. version: string;
  70404. platformName: string;
  70405. lookForClosingBracketForUniformBuffer?: boolean;
  70406. }
  70407. }
  70408. declare module BABYLON {
  70409. /**
  70410. * Helper to manipulate strings
  70411. */
  70412. export class StringTools {
  70413. /**
  70414. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  70415. * @param str Source string
  70416. * @param suffix Suffix to search for in the source string
  70417. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70418. */
  70419. static EndsWith(str: string, suffix: string): boolean;
  70420. /**
  70421. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  70422. * @param str Source string
  70423. * @param suffix Suffix to search for in the source string
  70424. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  70425. */
  70426. static StartsWith(str: string, suffix: string): boolean;
  70427. }
  70428. }
  70429. declare module BABYLON {
  70430. /** @hidden */
  70431. export class ShaderCodeNode {
  70432. line: string;
  70433. children: ShaderCodeNode[];
  70434. additionalDefineKey?: string;
  70435. additionalDefineValue?: string;
  70436. isValid(preprocessors: {
  70437. [key: string]: string;
  70438. }): boolean;
  70439. process(preprocessors: {
  70440. [key: string]: string;
  70441. }, options: ProcessingOptions): string;
  70442. }
  70443. }
  70444. declare module BABYLON {
  70445. /** @hidden */
  70446. export class ShaderCodeCursor {
  70447. private _lines;
  70448. lineIndex: number;
  70449. readonly currentLine: string;
  70450. readonly canRead: boolean;
  70451. lines: string[];
  70452. }
  70453. }
  70454. declare module BABYLON {
  70455. /** @hidden */
  70456. export class ShaderCodeConditionNode extends ShaderCodeNode {
  70457. process(preprocessors: {
  70458. [key: string]: string;
  70459. }, options: ProcessingOptions): string;
  70460. }
  70461. }
  70462. declare module BABYLON {
  70463. /** @hidden */
  70464. export class ShaderDefineExpression {
  70465. isTrue(preprocessors: {
  70466. [key: string]: string;
  70467. }): boolean;
  70468. }
  70469. }
  70470. declare module BABYLON {
  70471. /** @hidden */
  70472. export class ShaderCodeTestNode extends ShaderCodeNode {
  70473. testExpression: ShaderDefineExpression;
  70474. isValid(preprocessors: {
  70475. [key: string]: string;
  70476. }): boolean;
  70477. }
  70478. }
  70479. declare module BABYLON {
  70480. /** @hidden */
  70481. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  70482. define: string;
  70483. not: boolean;
  70484. constructor(define: string, not?: boolean);
  70485. isTrue(preprocessors: {
  70486. [key: string]: string;
  70487. }): boolean;
  70488. }
  70489. }
  70490. declare module BABYLON {
  70491. /** @hidden */
  70492. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  70493. leftOperand: ShaderDefineExpression;
  70494. rightOperand: ShaderDefineExpression;
  70495. isTrue(preprocessors: {
  70496. [key: string]: string;
  70497. }): boolean;
  70498. }
  70499. }
  70500. declare module BABYLON {
  70501. /** @hidden */
  70502. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  70503. leftOperand: ShaderDefineExpression;
  70504. rightOperand: ShaderDefineExpression;
  70505. isTrue(preprocessors: {
  70506. [key: string]: string;
  70507. }): boolean;
  70508. }
  70509. }
  70510. declare module BABYLON {
  70511. /** @hidden */
  70512. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  70513. define: string;
  70514. operand: string;
  70515. testValue: string;
  70516. constructor(define: string, operand: string, testValue: string);
  70517. isTrue(preprocessors: {
  70518. [key: string]: string;
  70519. }): boolean;
  70520. }
  70521. }
  70522. declare module BABYLON {
  70523. /**
  70524. * @ignore
  70525. * Application error to support additional information when loading a file
  70526. */
  70527. export class LoadFileError extends Error {
  70528. /** defines the optional web request */
  70529. request?: WebRequest | undefined;
  70530. private static _setPrototypeOf;
  70531. /**
  70532. * Creates a new LoadFileError
  70533. * @param message defines the message of the error
  70534. * @param request defines the optional web request
  70535. */
  70536. constructor(message: string,
  70537. /** defines the optional web request */
  70538. request?: WebRequest | undefined);
  70539. }
  70540. }
  70541. declare module BABYLON {
  70542. /**
  70543. * Class used to enable access to offline support
  70544. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70545. */
  70546. export interface IOfflineProvider {
  70547. /**
  70548. * Gets a boolean indicating if scene must be saved in the database
  70549. */
  70550. enableSceneOffline: boolean;
  70551. /**
  70552. * Gets a boolean indicating if textures must be saved in the database
  70553. */
  70554. enableTexturesOffline: boolean;
  70555. /**
  70556. * Open the offline support and make it available
  70557. * @param successCallback defines the callback to call on success
  70558. * @param errorCallback defines the callback to call on error
  70559. */
  70560. open(successCallback: () => void, errorCallback: () => void): void;
  70561. /**
  70562. * Loads an image from the offline support
  70563. * @param url defines the url to load from
  70564. * @param image defines the target DOM image
  70565. */
  70566. loadImage(url: string, image: HTMLImageElement): void;
  70567. /**
  70568. * Loads a file from offline support
  70569. * @param url defines the URL to load from
  70570. * @param sceneLoaded defines a callback to call on success
  70571. * @param progressCallBack defines a callback to call when progress changed
  70572. * @param errorCallback defines a callback to call on error
  70573. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  70574. */
  70575. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  70576. }
  70577. }
  70578. declare module BABYLON {
  70579. /**
  70580. * Class used to help managing file picking and drag'n'drop
  70581. * File Storage
  70582. */
  70583. export class FilesInputStore {
  70584. /**
  70585. * List of files ready to be loaded
  70586. */
  70587. static FilesToLoad: {
  70588. [key: string]: File;
  70589. };
  70590. }
  70591. }
  70592. declare module BABYLON {
  70593. /**
  70594. * Class used to define a retry strategy when error happens while loading assets
  70595. */
  70596. export class RetryStrategy {
  70597. /**
  70598. * Function used to defines an exponential back off strategy
  70599. * @param maxRetries defines the maximum number of retries (3 by default)
  70600. * @param baseInterval defines the interval between retries
  70601. * @returns the strategy function to use
  70602. */
  70603. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  70604. }
  70605. }
  70606. declare module BABYLON {
  70607. /**
  70608. * @hidden
  70609. */
  70610. export class FileTools {
  70611. /**
  70612. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  70613. */
  70614. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  70615. /**
  70616. * Gets or sets the base URL to use to load assets
  70617. */
  70618. static BaseUrl: string;
  70619. /**
  70620. * Default behaviour for cors in the application.
  70621. * It can be a string if the expected behavior is identical in the entire app.
  70622. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  70623. */
  70624. static CorsBehavior: string | ((url: string | string[]) => string);
  70625. /**
  70626. * Gets or sets a function used to pre-process url before using them to load assets
  70627. */
  70628. static PreprocessUrl: (url: string) => string;
  70629. /**
  70630. * Removes unwanted characters from an url
  70631. * @param url defines the url to clean
  70632. * @returns the cleaned url
  70633. */
  70634. private static _CleanUrl;
  70635. /**
  70636. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  70637. * @param url define the url we are trying
  70638. * @param element define the dom element where to configure the cors policy
  70639. */
  70640. static SetCorsBehavior(url: string | string[], element: {
  70641. crossOrigin: string | null;
  70642. }): void;
  70643. /**
  70644. * Loads an image as an HTMLImageElement.
  70645. * @param input url string, ArrayBuffer, or Blob to load
  70646. * @param onLoad callback called when the image successfully loads
  70647. * @param onError callback called when the image fails to load
  70648. * @param offlineProvider offline provider for caching
  70649. * @returns the HTMLImageElement of the loaded image
  70650. */
  70651. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  70652. /**
  70653. * Loads a file
  70654. * @param fileToLoad defines the file to load
  70655. * @param callback defines the callback to call when data is loaded
  70656. * @param progressCallBack defines the callback to call during loading process
  70657. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  70658. * @returns a file request object
  70659. */
  70660. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  70661. /**
  70662. * Loads a file
  70663. * @param url url string, ArrayBuffer, or Blob to load
  70664. * @param onSuccess callback called when the file successfully loads
  70665. * @param onProgress callback called while file is loading (if the server supports this mode)
  70666. * @param offlineProvider defines the offline provider for caching
  70667. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  70668. * @param onError callback called when the file fails to load
  70669. * @returns a file request object
  70670. */
  70671. 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;
  70672. /**
  70673. * Checks if the loaded document was accessed via `file:`-Protocol.
  70674. * @returns boolean
  70675. */
  70676. static IsFileURL(): boolean;
  70677. }
  70678. }
  70679. declare module BABYLON {
  70680. /** @hidden */
  70681. export class ShaderProcessor {
  70682. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  70683. private static _ProcessPrecision;
  70684. private static _ExtractOperation;
  70685. private static _BuildSubExpression;
  70686. private static _BuildExpression;
  70687. private static _MoveCursorWithinIf;
  70688. private static _MoveCursor;
  70689. private static _EvaluatePreProcessors;
  70690. private static _PreparePreProcessors;
  70691. private static _ProcessShaderConversion;
  70692. private static _ProcessIncludes;
  70693. }
  70694. }
  70695. declare module BABYLON {
  70696. /**
  70697. * Class used to hold a RBG color
  70698. */
  70699. export class Color3 {
  70700. /**
  70701. * Defines the red component (between 0 and 1, default is 0)
  70702. */
  70703. r: number;
  70704. /**
  70705. * Defines the green component (between 0 and 1, default is 0)
  70706. */
  70707. g: number;
  70708. /**
  70709. * Defines the blue component (between 0 and 1, default is 0)
  70710. */
  70711. b: number;
  70712. /**
  70713. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  70714. * @param r defines the red component (between 0 and 1, default is 0)
  70715. * @param g defines the green component (between 0 and 1, default is 0)
  70716. * @param b defines the blue component (between 0 and 1, default is 0)
  70717. */
  70718. constructor(
  70719. /**
  70720. * Defines the red component (between 0 and 1, default is 0)
  70721. */
  70722. r?: number,
  70723. /**
  70724. * Defines the green component (between 0 and 1, default is 0)
  70725. */
  70726. g?: number,
  70727. /**
  70728. * Defines the blue component (between 0 and 1, default is 0)
  70729. */
  70730. b?: number);
  70731. /**
  70732. * Creates a string with the Color3 current values
  70733. * @returns the string representation of the Color3 object
  70734. */
  70735. toString(): string;
  70736. /**
  70737. * Returns the string "Color3"
  70738. * @returns "Color3"
  70739. */
  70740. getClassName(): string;
  70741. /**
  70742. * Compute the Color3 hash code
  70743. * @returns an unique number that can be used to hash Color3 objects
  70744. */
  70745. getHashCode(): number;
  70746. /**
  70747. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  70748. * @param array defines the array where to store the r,g,b components
  70749. * @param index defines an optional index in the target array to define where to start storing values
  70750. * @returns the current Color3 object
  70751. */
  70752. toArray(array: FloatArray, index?: number): Color3;
  70753. /**
  70754. * Returns a new Color4 object from the current Color3 and the given alpha
  70755. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  70756. * @returns a new Color4 object
  70757. */
  70758. toColor4(alpha?: number): Color4;
  70759. /**
  70760. * Returns a new array populated with 3 numeric elements : red, green and blue values
  70761. * @returns the new array
  70762. */
  70763. asArray(): number[];
  70764. /**
  70765. * Returns the luminance value
  70766. * @returns a float value
  70767. */
  70768. toLuminance(): number;
  70769. /**
  70770. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  70771. * @param otherColor defines the second operand
  70772. * @returns the new Color3 object
  70773. */
  70774. multiply(otherColor: DeepImmutable<Color3>): Color3;
  70775. /**
  70776. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  70777. * @param otherColor defines the second operand
  70778. * @param result defines the Color3 object where to store the result
  70779. * @returns the current Color3
  70780. */
  70781. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70782. /**
  70783. * Determines equality between Color3 objects
  70784. * @param otherColor defines the second operand
  70785. * @returns true if the rgb values are equal to the given ones
  70786. */
  70787. equals(otherColor: DeepImmutable<Color3>): boolean;
  70788. /**
  70789. * Determines equality between the current Color3 object and a set of r,b,g values
  70790. * @param r defines the red component to check
  70791. * @param g defines the green component to check
  70792. * @param b defines the blue component to check
  70793. * @returns true if the rgb values are equal to the given ones
  70794. */
  70795. equalsFloats(r: number, g: number, b: number): boolean;
  70796. /**
  70797. * Multiplies in place each rgb value by scale
  70798. * @param scale defines the scaling factor
  70799. * @returns the updated Color3
  70800. */
  70801. scale(scale: number): Color3;
  70802. /**
  70803. * Multiplies the rgb values by scale and stores the result into "result"
  70804. * @param scale defines the scaling factor
  70805. * @param result defines the Color3 object where to store the result
  70806. * @returns the unmodified current Color3
  70807. */
  70808. scaleToRef(scale: number, result: Color3): Color3;
  70809. /**
  70810. * Scale the current Color3 values by a factor and add the result to a given Color3
  70811. * @param scale defines the scale factor
  70812. * @param result defines color to store the result into
  70813. * @returns the unmodified current Color3
  70814. */
  70815. scaleAndAddToRef(scale: number, result: Color3): Color3;
  70816. /**
  70817. * Clamps the rgb values by the min and max values and stores the result into "result"
  70818. * @param min defines minimum clamping value (default is 0)
  70819. * @param max defines maximum clamping value (default is 1)
  70820. * @param result defines color to store the result into
  70821. * @returns the original Color3
  70822. */
  70823. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  70824. /**
  70825. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70826. * @param otherColor defines the second operand
  70827. * @returns the new Color3
  70828. */
  70829. add(otherColor: DeepImmutable<Color3>): Color3;
  70830. /**
  70831. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70832. * @param otherColor defines the second operand
  70833. * @param result defines Color3 object to store the result into
  70834. * @returns the unmodified current Color3
  70835. */
  70836. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70837. /**
  70838. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70839. * @param otherColor defines the second operand
  70840. * @returns the new Color3
  70841. */
  70842. subtract(otherColor: DeepImmutable<Color3>): Color3;
  70843. /**
  70844. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70845. * @param otherColor defines the second operand
  70846. * @param result defines Color3 object to store the result into
  70847. * @returns the unmodified current Color3
  70848. */
  70849. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70850. /**
  70851. * Copy the current object
  70852. * @returns a new Color3 copied the current one
  70853. */
  70854. clone(): Color3;
  70855. /**
  70856. * Copies the rgb values from the source in the current Color3
  70857. * @param source defines the source Color3 object
  70858. * @returns the updated Color3 object
  70859. */
  70860. copyFrom(source: DeepImmutable<Color3>): Color3;
  70861. /**
  70862. * Updates the Color3 rgb values from the given floats
  70863. * @param r defines the red component to read from
  70864. * @param g defines the green component to read from
  70865. * @param b defines the blue component to read from
  70866. * @returns the current Color3 object
  70867. */
  70868. copyFromFloats(r: number, g: number, b: number): Color3;
  70869. /**
  70870. * Updates the Color3 rgb values from the given floats
  70871. * @param r defines the red component to read from
  70872. * @param g defines the green component to read from
  70873. * @param b defines the blue component to read from
  70874. * @returns the current Color3 object
  70875. */
  70876. set(r: number, g: number, b: number): Color3;
  70877. /**
  70878. * Compute the Color3 hexadecimal code as a string
  70879. * @returns a string containing the hexadecimal representation of the Color3 object
  70880. */
  70881. toHexString(): string;
  70882. /**
  70883. * Computes a new Color3 converted from the current one to linear space
  70884. * @returns a new Color3 object
  70885. */
  70886. toLinearSpace(): Color3;
  70887. /**
  70888. * Converts current color in rgb space to HSV values
  70889. * @returns a new color3 representing the HSV values
  70890. */
  70891. toHSV(): Color3;
  70892. /**
  70893. * Converts current color in rgb space to HSV values
  70894. * @param result defines the Color3 where to store the HSV values
  70895. */
  70896. toHSVToRef(result: Color3): void;
  70897. /**
  70898. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70899. * @param convertedColor defines the Color3 object where to store the linear space version
  70900. * @returns the unmodified Color3
  70901. */
  70902. toLinearSpaceToRef(convertedColor: Color3): Color3;
  70903. /**
  70904. * Computes a new Color3 converted from the current one to gamma space
  70905. * @returns a new Color3 object
  70906. */
  70907. toGammaSpace(): Color3;
  70908. /**
  70909. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70910. * @param convertedColor defines the Color3 object where to store the gamma space version
  70911. * @returns the unmodified Color3
  70912. */
  70913. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70914. private static _BlackReadOnly;
  70915. /**
  70916. * Convert Hue, saturation and value to a Color3 (RGB)
  70917. * @param hue defines the hue
  70918. * @param saturation defines the saturation
  70919. * @param value defines the value
  70920. * @param result defines the Color3 where to store the RGB values
  70921. */
  70922. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70923. /**
  70924. * Creates a new Color3 from the string containing valid hexadecimal values
  70925. * @param hex defines a string containing valid hexadecimal values
  70926. * @returns a new Color3 object
  70927. */
  70928. static FromHexString(hex: string): Color3;
  70929. /**
  70930. * Creates a new Color3 from the starting index of the given array
  70931. * @param array defines the source array
  70932. * @param offset defines an offset in the source array
  70933. * @returns a new Color3 object
  70934. */
  70935. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70936. /**
  70937. * Creates a new Color3 from integer values (< 256)
  70938. * @param r defines the red component to read from (value between 0 and 255)
  70939. * @param g defines the green component to read from (value between 0 and 255)
  70940. * @param b defines the blue component to read from (value between 0 and 255)
  70941. * @returns a new Color3 object
  70942. */
  70943. static FromInts(r: number, g: number, b: number): Color3;
  70944. /**
  70945. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70946. * @param start defines the start Color3 value
  70947. * @param end defines the end Color3 value
  70948. * @param amount defines the gradient value between start and end
  70949. * @returns a new Color3 object
  70950. */
  70951. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70952. /**
  70953. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70954. * @param left defines the start value
  70955. * @param right defines the end value
  70956. * @param amount defines the gradient factor
  70957. * @param result defines the Color3 object where to store the result
  70958. */
  70959. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70960. /**
  70961. * Returns a Color3 value containing a red color
  70962. * @returns a new Color3 object
  70963. */
  70964. static Red(): Color3;
  70965. /**
  70966. * Returns a Color3 value containing a green color
  70967. * @returns a new Color3 object
  70968. */
  70969. static Green(): Color3;
  70970. /**
  70971. * Returns a Color3 value containing a blue color
  70972. * @returns a new Color3 object
  70973. */
  70974. static Blue(): Color3;
  70975. /**
  70976. * Returns a Color3 value containing a black color
  70977. * @returns a new Color3 object
  70978. */
  70979. static Black(): Color3;
  70980. /**
  70981. * Gets a Color3 value containing a black color that must not be updated
  70982. */
  70983. static readonly BlackReadOnly: DeepImmutable<Color3>;
  70984. /**
  70985. * Returns a Color3 value containing a white color
  70986. * @returns a new Color3 object
  70987. */
  70988. static White(): Color3;
  70989. /**
  70990. * Returns a Color3 value containing a purple color
  70991. * @returns a new Color3 object
  70992. */
  70993. static Purple(): Color3;
  70994. /**
  70995. * Returns a Color3 value containing a magenta color
  70996. * @returns a new Color3 object
  70997. */
  70998. static Magenta(): Color3;
  70999. /**
  71000. * Returns a Color3 value containing a yellow color
  71001. * @returns a new Color3 object
  71002. */
  71003. static Yellow(): Color3;
  71004. /**
  71005. * Returns a Color3 value containing a gray color
  71006. * @returns a new Color3 object
  71007. */
  71008. static Gray(): Color3;
  71009. /**
  71010. * Returns a Color3 value containing a teal color
  71011. * @returns a new Color3 object
  71012. */
  71013. static Teal(): Color3;
  71014. /**
  71015. * Returns a Color3 value containing a random color
  71016. * @returns a new Color3 object
  71017. */
  71018. static Random(): Color3;
  71019. }
  71020. /**
  71021. * Class used to hold a RBGA color
  71022. */
  71023. export class Color4 {
  71024. /**
  71025. * Defines the red component (between 0 and 1, default is 0)
  71026. */
  71027. r: number;
  71028. /**
  71029. * Defines the green component (between 0 and 1, default is 0)
  71030. */
  71031. g: number;
  71032. /**
  71033. * Defines the blue component (between 0 and 1, default is 0)
  71034. */
  71035. b: number;
  71036. /**
  71037. * Defines the alpha component (between 0 and 1, default is 1)
  71038. */
  71039. a: number;
  71040. /**
  71041. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  71042. * @param r defines the red component (between 0 and 1, default is 0)
  71043. * @param g defines the green component (between 0 and 1, default is 0)
  71044. * @param b defines the blue component (between 0 and 1, default is 0)
  71045. * @param a defines the alpha component (between 0 and 1, default is 1)
  71046. */
  71047. constructor(
  71048. /**
  71049. * Defines the red component (between 0 and 1, default is 0)
  71050. */
  71051. r?: number,
  71052. /**
  71053. * Defines the green component (between 0 and 1, default is 0)
  71054. */
  71055. g?: number,
  71056. /**
  71057. * Defines the blue component (between 0 and 1, default is 0)
  71058. */
  71059. b?: number,
  71060. /**
  71061. * Defines the alpha component (between 0 and 1, default is 1)
  71062. */
  71063. a?: number);
  71064. /**
  71065. * Adds in place the given Color4 values to the current Color4 object
  71066. * @param right defines the second operand
  71067. * @returns the current updated Color4 object
  71068. */
  71069. addInPlace(right: DeepImmutable<Color4>): Color4;
  71070. /**
  71071. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  71072. * @returns the new array
  71073. */
  71074. asArray(): number[];
  71075. /**
  71076. * Stores from the starting index in the given array the Color4 successive values
  71077. * @param array defines the array where to store the r,g,b components
  71078. * @param index defines an optional index in the target array to define where to start storing values
  71079. * @returns the current Color4 object
  71080. */
  71081. toArray(array: number[], index?: number): Color4;
  71082. /**
  71083. * Determines equality between Color4 objects
  71084. * @param otherColor defines the second operand
  71085. * @returns true if the rgba values are equal to the given ones
  71086. */
  71087. equals(otherColor: DeepImmutable<Color4>): boolean;
  71088. /**
  71089. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  71090. * @param right defines the second operand
  71091. * @returns a new Color4 object
  71092. */
  71093. add(right: DeepImmutable<Color4>): Color4;
  71094. /**
  71095. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  71096. * @param right defines the second operand
  71097. * @returns a new Color4 object
  71098. */
  71099. subtract(right: DeepImmutable<Color4>): Color4;
  71100. /**
  71101. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  71102. * @param right defines the second operand
  71103. * @param result defines the Color4 object where to store the result
  71104. * @returns the current Color4 object
  71105. */
  71106. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  71107. /**
  71108. * Creates a new Color4 with the current Color4 values multiplied by scale
  71109. * @param scale defines the scaling factor to apply
  71110. * @returns a new Color4 object
  71111. */
  71112. scale(scale: number): Color4;
  71113. /**
  71114. * Multiplies the current Color4 values by scale and stores the result in "result"
  71115. * @param scale defines the scaling factor to apply
  71116. * @param result defines the Color4 object where to store the result
  71117. * @returns the current unmodified Color4
  71118. */
  71119. scaleToRef(scale: number, result: Color4): Color4;
  71120. /**
  71121. * Scale the current Color4 values by a factor and add the result to a given Color4
  71122. * @param scale defines the scale factor
  71123. * @param result defines the Color4 object where to store the result
  71124. * @returns the unmodified current Color4
  71125. */
  71126. scaleAndAddToRef(scale: number, result: Color4): Color4;
  71127. /**
  71128. * Clamps the rgb values by the min and max values and stores the result into "result"
  71129. * @param min defines minimum clamping value (default is 0)
  71130. * @param max defines maximum clamping value (default is 1)
  71131. * @param result defines color to store the result into.
  71132. * @returns the cuurent Color4
  71133. */
  71134. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  71135. /**
  71136. * Multipy an Color4 value by another and return a new Color4 object
  71137. * @param color defines the Color4 value to multiply by
  71138. * @returns a new Color4 object
  71139. */
  71140. multiply(color: Color4): Color4;
  71141. /**
  71142. * Multipy a Color4 value by another and push the result in a reference value
  71143. * @param color defines the Color4 value to multiply by
  71144. * @param result defines the Color4 to fill the result in
  71145. * @returns the result Color4
  71146. */
  71147. multiplyToRef(color: Color4, result: Color4): Color4;
  71148. /**
  71149. * Creates a string with the Color4 current values
  71150. * @returns the string representation of the Color4 object
  71151. */
  71152. toString(): string;
  71153. /**
  71154. * Returns the string "Color4"
  71155. * @returns "Color4"
  71156. */
  71157. getClassName(): string;
  71158. /**
  71159. * Compute the Color4 hash code
  71160. * @returns an unique number that can be used to hash Color4 objects
  71161. */
  71162. getHashCode(): number;
  71163. /**
  71164. * Creates a new Color4 copied from the current one
  71165. * @returns a new Color4 object
  71166. */
  71167. clone(): Color4;
  71168. /**
  71169. * Copies the given Color4 values into the current one
  71170. * @param source defines the source Color4 object
  71171. * @returns the current updated Color4 object
  71172. */
  71173. copyFrom(source: Color4): Color4;
  71174. /**
  71175. * Copies the given float values into the current one
  71176. * @param r defines the red component to read from
  71177. * @param g defines the green component to read from
  71178. * @param b defines the blue component to read from
  71179. * @param a defines the alpha component to read from
  71180. * @returns the current updated Color4 object
  71181. */
  71182. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  71183. /**
  71184. * Copies the given float values into the current one
  71185. * @param r defines the red component to read from
  71186. * @param g defines the green component to read from
  71187. * @param b defines the blue component to read from
  71188. * @param a defines the alpha component to read from
  71189. * @returns the current updated Color4 object
  71190. */
  71191. set(r: number, g: number, b: number, a: number): Color4;
  71192. /**
  71193. * Compute the Color4 hexadecimal code as a string
  71194. * @returns a string containing the hexadecimal representation of the Color4 object
  71195. */
  71196. toHexString(): string;
  71197. /**
  71198. * Computes a new Color4 converted from the current one to linear space
  71199. * @returns a new Color4 object
  71200. */
  71201. toLinearSpace(): Color4;
  71202. /**
  71203. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  71204. * @param convertedColor defines the Color4 object where to store the linear space version
  71205. * @returns the unmodified Color4
  71206. */
  71207. toLinearSpaceToRef(convertedColor: Color4): Color4;
  71208. /**
  71209. * Computes a new Color4 converted from the current one to gamma space
  71210. * @returns a new Color4 object
  71211. */
  71212. toGammaSpace(): Color4;
  71213. /**
  71214. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  71215. * @param convertedColor defines the Color4 object where to store the gamma space version
  71216. * @returns the unmodified Color4
  71217. */
  71218. toGammaSpaceToRef(convertedColor: Color4): Color4;
  71219. /**
  71220. * Creates a new Color4 from the string containing valid hexadecimal values
  71221. * @param hex defines a string containing valid hexadecimal values
  71222. * @returns a new Color4 object
  71223. */
  71224. static FromHexString(hex: string): Color4;
  71225. /**
  71226. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71227. * @param left defines the start value
  71228. * @param right defines the end value
  71229. * @param amount defines the gradient factor
  71230. * @returns a new Color4 object
  71231. */
  71232. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  71233. /**
  71234. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  71235. * @param left defines the start value
  71236. * @param right defines the end value
  71237. * @param amount defines the gradient factor
  71238. * @param result defines the Color4 object where to store data
  71239. */
  71240. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  71241. /**
  71242. * Creates a new Color4 from a Color3 and an alpha value
  71243. * @param color3 defines the source Color3 to read from
  71244. * @param alpha defines the alpha component (1.0 by default)
  71245. * @returns a new Color4 object
  71246. */
  71247. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  71248. /**
  71249. * Creates a new Color4 from the starting index element of the given array
  71250. * @param array defines the source array to read from
  71251. * @param offset defines the offset in the source array
  71252. * @returns a new Color4 object
  71253. */
  71254. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  71255. /**
  71256. * Creates a new Color3 from integer values (< 256)
  71257. * @param r defines the red component to read from (value between 0 and 255)
  71258. * @param g defines the green component to read from (value between 0 and 255)
  71259. * @param b defines the blue component to read from (value between 0 and 255)
  71260. * @param a defines the alpha component to read from (value between 0 and 255)
  71261. * @returns a new Color3 object
  71262. */
  71263. static FromInts(r: number, g: number, b: number, a: number): Color4;
  71264. /**
  71265. * Check the content of a given array and convert it to an array containing RGBA data
  71266. * If the original array was already containing count * 4 values then it is returned directly
  71267. * @param colors defines the array to check
  71268. * @param count defines the number of RGBA data to expect
  71269. * @returns an array containing count * 4 values (RGBA)
  71270. */
  71271. static CheckColors4(colors: number[], count: number): number[];
  71272. }
  71273. /**
  71274. * @hidden
  71275. */
  71276. export class TmpColors {
  71277. static Color3: Color3[];
  71278. static Color4: Color4[];
  71279. }
  71280. }
  71281. declare module BABYLON {
  71282. /**
  71283. * Class representing spherical harmonics coefficients to the 3rd degree
  71284. */
  71285. export class SphericalHarmonics {
  71286. /**
  71287. * Defines whether or not the harmonics have been prescaled for rendering.
  71288. */
  71289. preScaled: boolean;
  71290. /**
  71291. * The l0,0 coefficients of the spherical harmonics
  71292. */
  71293. l00: Vector3;
  71294. /**
  71295. * The l1,-1 coefficients of the spherical harmonics
  71296. */
  71297. l1_1: Vector3;
  71298. /**
  71299. * The l1,0 coefficients of the spherical harmonics
  71300. */
  71301. l10: Vector3;
  71302. /**
  71303. * The l1,1 coefficients of the spherical harmonics
  71304. */
  71305. l11: Vector3;
  71306. /**
  71307. * The l2,-2 coefficients of the spherical harmonics
  71308. */
  71309. l2_2: Vector3;
  71310. /**
  71311. * The l2,-1 coefficients of the spherical harmonics
  71312. */
  71313. l2_1: Vector3;
  71314. /**
  71315. * The l2,0 coefficients of the spherical harmonics
  71316. */
  71317. l20: Vector3;
  71318. /**
  71319. * The l2,1 coefficients of the spherical harmonics
  71320. */
  71321. l21: Vector3;
  71322. /**
  71323. * The l2,2 coefficients of the spherical harmonics
  71324. */
  71325. l22: Vector3;
  71326. /**
  71327. * Adds a light to the spherical harmonics
  71328. * @param direction the direction of the light
  71329. * @param color the color of the light
  71330. * @param deltaSolidAngle the delta solid angle of the light
  71331. */
  71332. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  71333. /**
  71334. * Scales the spherical harmonics by the given amount
  71335. * @param scale the amount to scale
  71336. */
  71337. scaleInPlace(scale: number): void;
  71338. /**
  71339. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  71340. *
  71341. * ```
  71342. * E_lm = A_l * L_lm
  71343. * ```
  71344. *
  71345. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  71346. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  71347. * the scaling factors are given in equation 9.
  71348. */
  71349. convertIncidentRadianceToIrradiance(): void;
  71350. /**
  71351. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  71352. *
  71353. * ```
  71354. * L = (1/pi) * E * rho
  71355. * ```
  71356. *
  71357. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  71358. */
  71359. convertIrradianceToLambertianRadiance(): void;
  71360. /**
  71361. * Integrates the reconstruction coefficients directly in to the SH preventing further
  71362. * required operations at run time.
  71363. *
  71364. * This is simply done by scaling back the SH with Ylm constants parameter.
  71365. * The trigonometric part being applied by the shader at run time.
  71366. */
  71367. preScaleForRendering(): void;
  71368. /**
  71369. * Constructs a spherical harmonics from an array.
  71370. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  71371. * @returns the spherical harmonics
  71372. */
  71373. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  71374. /**
  71375. * Gets the spherical harmonics from polynomial
  71376. * @param polynomial the spherical polynomial
  71377. * @returns the spherical harmonics
  71378. */
  71379. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  71380. }
  71381. /**
  71382. * Class representing spherical polynomial coefficients to the 3rd degree
  71383. */
  71384. export class SphericalPolynomial {
  71385. private _harmonics;
  71386. /**
  71387. * The spherical harmonics used to create the polynomials.
  71388. */
  71389. readonly preScaledHarmonics: SphericalHarmonics;
  71390. /**
  71391. * The x coefficients of the spherical polynomial
  71392. */
  71393. x: Vector3;
  71394. /**
  71395. * The y coefficients of the spherical polynomial
  71396. */
  71397. y: Vector3;
  71398. /**
  71399. * The z coefficients of the spherical polynomial
  71400. */
  71401. z: Vector3;
  71402. /**
  71403. * The xx coefficients of the spherical polynomial
  71404. */
  71405. xx: Vector3;
  71406. /**
  71407. * The yy coefficients of the spherical polynomial
  71408. */
  71409. yy: Vector3;
  71410. /**
  71411. * The zz coefficients of the spherical polynomial
  71412. */
  71413. zz: Vector3;
  71414. /**
  71415. * The xy coefficients of the spherical polynomial
  71416. */
  71417. xy: Vector3;
  71418. /**
  71419. * The yz coefficients of the spherical polynomial
  71420. */
  71421. yz: Vector3;
  71422. /**
  71423. * The zx coefficients of the spherical polynomial
  71424. */
  71425. zx: Vector3;
  71426. /**
  71427. * Adds an ambient color to the spherical polynomial
  71428. * @param color the color to add
  71429. */
  71430. addAmbient(color: Color3): void;
  71431. /**
  71432. * Scales the spherical polynomial by the given amount
  71433. * @param scale the amount to scale
  71434. */
  71435. scaleInPlace(scale: number): void;
  71436. /**
  71437. * Gets the spherical polynomial from harmonics
  71438. * @param harmonics the spherical harmonics
  71439. * @returns the spherical polynomial
  71440. */
  71441. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  71442. /**
  71443. * Constructs a spherical polynomial from an array.
  71444. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  71445. * @returns the spherical polynomial
  71446. */
  71447. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  71448. }
  71449. }
  71450. declare module BABYLON {
  71451. /**
  71452. * Define options used to create a render target texture
  71453. */
  71454. export class RenderTargetCreationOptions {
  71455. /**
  71456. * Specifies is mipmaps must be generated
  71457. */
  71458. generateMipMaps?: boolean;
  71459. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71460. generateDepthBuffer?: boolean;
  71461. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71462. generateStencilBuffer?: boolean;
  71463. /** Defines texture type (int by default) */
  71464. type?: number;
  71465. /** Defines sampling mode (trilinear by default) */
  71466. samplingMode?: number;
  71467. /** Defines format (RGBA by default) */
  71468. format?: number;
  71469. }
  71470. }
  71471. declare module BABYLON {
  71472. /**
  71473. * @hidden
  71474. **/
  71475. export class _AlphaState {
  71476. private _isAlphaBlendDirty;
  71477. private _isBlendFunctionParametersDirty;
  71478. private _isBlendEquationParametersDirty;
  71479. private _isBlendConstantsDirty;
  71480. private _alphaBlend;
  71481. private _blendFunctionParameters;
  71482. private _blendEquationParameters;
  71483. private _blendConstants;
  71484. /**
  71485. * Initializes the state.
  71486. */
  71487. constructor();
  71488. readonly isDirty: boolean;
  71489. alphaBlend: boolean;
  71490. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  71491. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  71492. setAlphaEquationParameters(rgb: number, alpha: number): void;
  71493. reset(): void;
  71494. apply(gl: WebGLRenderingContext): void;
  71495. }
  71496. }
  71497. declare module BABYLON {
  71498. /**
  71499. * @hidden
  71500. **/
  71501. export class _DepthCullingState {
  71502. private _isDepthTestDirty;
  71503. private _isDepthMaskDirty;
  71504. private _isDepthFuncDirty;
  71505. private _isCullFaceDirty;
  71506. private _isCullDirty;
  71507. private _isZOffsetDirty;
  71508. private _isFrontFaceDirty;
  71509. private _depthTest;
  71510. private _depthMask;
  71511. private _depthFunc;
  71512. private _cull;
  71513. private _cullFace;
  71514. private _zOffset;
  71515. private _frontFace;
  71516. /**
  71517. * Initializes the state.
  71518. */
  71519. constructor();
  71520. readonly isDirty: boolean;
  71521. zOffset: number;
  71522. cullFace: Nullable<number>;
  71523. cull: Nullable<boolean>;
  71524. depthFunc: Nullable<number>;
  71525. depthMask: boolean;
  71526. depthTest: boolean;
  71527. frontFace: Nullable<number>;
  71528. reset(): void;
  71529. apply(gl: WebGLRenderingContext): void;
  71530. }
  71531. }
  71532. declare module BABYLON {
  71533. /**
  71534. * @hidden
  71535. **/
  71536. export class _StencilState {
  71537. /** 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 */
  71538. static readonly ALWAYS: number;
  71539. /** Passed to stencilOperation to specify that stencil value must be kept */
  71540. static readonly KEEP: number;
  71541. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71542. static readonly REPLACE: number;
  71543. private _isStencilTestDirty;
  71544. private _isStencilMaskDirty;
  71545. private _isStencilFuncDirty;
  71546. private _isStencilOpDirty;
  71547. private _stencilTest;
  71548. private _stencilMask;
  71549. private _stencilFunc;
  71550. private _stencilFuncRef;
  71551. private _stencilFuncMask;
  71552. private _stencilOpStencilFail;
  71553. private _stencilOpDepthFail;
  71554. private _stencilOpStencilDepthPass;
  71555. readonly isDirty: boolean;
  71556. stencilFunc: number;
  71557. stencilFuncRef: number;
  71558. stencilFuncMask: number;
  71559. stencilOpStencilFail: number;
  71560. stencilOpDepthFail: number;
  71561. stencilOpStencilDepthPass: number;
  71562. stencilMask: number;
  71563. stencilTest: boolean;
  71564. constructor();
  71565. reset(): void;
  71566. apply(gl: WebGLRenderingContext): void;
  71567. }
  71568. }
  71569. declare module BABYLON {
  71570. /**
  71571. * @hidden
  71572. **/
  71573. export class _TimeToken {
  71574. _startTimeQuery: Nullable<WebGLQuery>;
  71575. _endTimeQuery: Nullable<WebGLQuery>;
  71576. _timeElapsedQuery: Nullable<WebGLQuery>;
  71577. _timeElapsedQueryEnded: boolean;
  71578. }
  71579. }
  71580. declare module BABYLON {
  71581. /**
  71582. * Class used to evalaute queries containing `and` and `or` operators
  71583. */
  71584. export class AndOrNotEvaluator {
  71585. /**
  71586. * Evaluate a query
  71587. * @param query defines the query to evaluate
  71588. * @param evaluateCallback defines the callback used to filter result
  71589. * @returns true if the query matches
  71590. */
  71591. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71592. private static _HandleParenthesisContent;
  71593. private static _SimplifyNegation;
  71594. }
  71595. }
  71596. declare module BABYLON {
  71597. /**
  71598. * Class used to store custom tags
  71599. */
  71600. export class Tags {
  71601. /**
  71602. * Adds support for tags on the given object
  71603. * @param obj defines the object to use
  71604. */
  71605. static EnableFor(obj: any): void;
  71606. /**
  71607. * Removes tags support
  71608. * @param obj defines the object to use
  71609. */
  71610. static DisableFor(obj: any): void;
  71611. /**
  71612. * Gets a boolean indicating if the given object has tags
  71613. * @param obj defines the object to use
  71614. * @returns a boolean
  71615. */
  71616. static HasTags(obj: any): boolean;
  71617. /**
  71618. * Gets the tags available on a given object
  71619. * @param obj defines the object to use
  71620. * @param asString defines if the tags must be returned as a string instead of an array of strings
  71621. * @returns the tags
  71622. */
  71623. static GetTags(obj: any, asString?: boolean): any;
  71624. /**
  71625. * Adds tags to an object
  71626. * @param obj defines the object to use
  71627. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  71628. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  71629. */
  71630. static AddTagsTo(obj: any, tagsString: string): void;
  71631. /**
  71632. * @hidden
  71633. */
  71634. static _AddTagTo(obj: any, tag: string): void;
  71635. /**
  71636. * Removes specific tags from a specific object
  71637. * @param obj defines the object to use
  71638. * @param tagsString defines the tags to remove
  71639. */
  71640. static RemoveTagsFrom(obj: any, tagsString: string): void;
  71641. /**
  71642. * @hidden
  71643. */
  71644. static _RemoveTagFrom(obj: any, tag: string): void;
  71645. /**
  71646. * Defines if tags hosted on an object match a given query
  71647. * @param obj defines the object to use
  71648. * @param tagsQuery defines the tag query
  71649. * @returns a boolean
  71650. */
  71651. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  71652. }
  71653. }
  71654. declare module BABYLON {
  71655. /**
  71656. * Defines potential orientation for back face culling
  71657. */
  71658. export enum Orientation {
  71659. /**
  71660. * Clockwise
  71661. */
  71662. CW = 0,
  71663. /** Counter clockwise */
  71664. CCW = 1
  71665. }
  71666. /** Class used to represent a Bezier curve */
  71667. export class BezierCurve {
  71668. /**
  71669. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71670. * @param t defines the time
  71671. * @param x1 defines the left coordinate on X axis
  71672. * @param y1 defines the left coordinate on Y axis
  71673. * @param x2 defines the right coordinate on X axis
  71674. * @param y2 defines the right coordinate on Y axis
  71675. * @returns the interpolated value
  71676. */
  71677. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71678. }
  71679. /**
  71680. * Defines angle representation
  71681. */
  71682. export class Angle {
  71683. private _radians;
  71684. /**
  71685. * Creates an Angle object of "radians" radians (float).
  71686. * @param radians the angle in radians
  71687. */
  71688. constructor(radians: number);
  71689. /**
  71690. * Get value in degrees
  71691. * @returns the Angle value in degrees (float)
  71692. */
  71693. degrees(): number;
  71694. /**
  71695. * Get value in radians
  71696. * @returns the Angle value in radians (float)
  71697. */
  71698. radians(): number;
  71699. /**
  71700. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71701. * @param a defines first vector
  71702. * @param b defines second vector
  71703. * @returns a new Angle
  71704. */
  71705. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71706. /**
  71707. * Gets a new Angle object from the given float in radians
  71708. * @param radians defines the angle value in radians
  71709. * @returns a new Angle
  71710. */
  71711. static FromRadians(radians: number): Angle;
  71712. /**
  71713. * Gets a new Angle object from the given float in degrees
  71714. * @param degrees defines the angle value in degrees
  71715. * @returns a new Angle
  71716. */
  71717. static FromDegrees(degrees: number): Angle;
  71718. }
  71719. /**
  71720. * This represents an arc in a 2d space.
  71721. */
  71722. export class Arc2 {
  71723. /** Defines the start point of the arc */
  71724. startPoint: Vector2;
  71725. /** Defines the mid point of the arc */
  71726. midPoint: Vector2;
  71727. /** Defines the end point of the arc */
  71728. endPoint: Vector2;
  71729. /**
  71730. * Defines the center point of the arc.
  71731. */
  71732. centerPoint: Vector2;
  71733. /**
  71734. * Defines the radius of the arc.
  71735. */
  71736. radius: number;
  71737. /**
  71738. * Defines the angle of the arc (from mid point to end point).
  71739. */
  71740. angle: Angle;
  71741. /**
  71742. * Defines the start angle of the arc (from start point to middle point).
  71743. */
  71744. startAngle: Angle;
  71745. /**
  71746. * Defines the orientation of the arc (clock wise/counter clock wise).
  71747. */
  71748. orientation: Orientation;
  71749. /**
  71750. * Creates an Arc object from the three given points : start, middle and end.
  71751. * @param startPoint Defines the start point of the arc
  71752. * @param midPoint Defines the midlle point of the arc
  71753. * @param endPoint Defines the end point of the arc
  71754. */
  71755. constructor(
  71756. /** Defines the start point of the arc */
  71757. startPoint: Vector2,
  71758. /** Defines the mid point of the arc */
  71759. midPoint: Vector2,
  71760. /** Defines the end point of the arc */
  71761. endPoint: Vector2);
  71762. }
  71763. /**
  71764. * Represents a 2D path made up of multiple 2D points
  71765. */
  71766. export class Path2 {
  71767. private _points;
  71768. private _length;
  71769. /**
  71770. * If the path start and end point are the same
  71771. */
  71772. closed: boolean;
  71773. /**
  71774. * Creates a Path2 object from the starting 2D coordinates x and y.
  71775. * @param x the starting points x value
  71776. * @param y the starting points y value
  71777. */
  71778. constructor(x: number, y: number);
  71779. /**
  71780. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71781. * @param x the added points x value
  71782. * @param y the added points y value
  71783. * @returns the updated Path2.
  71784. */
  71785. addLineTo(x: number, y: number): Path2;
  71786. /**
  71787. * 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.
  71788. * @param midX middle point x value
  71789. * @param midY middle point y value
  71790. * @param endX end point x value
  71791. * @param endY end point y value
  71792. * @param numberOfSegments (default: 36)
  71793. * @returns the updated Path2.
  71794. */
  71795. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71796. /**
  71797. * Closes the Path2.
  71798. * @returns the Path2.
  71799. */
  71800. close(): Path2;
  71801. /**
  71802. * Gets the sum of the distance between each sequential point in the path
  71803. * @returns the Path2 total length (float).
  71804. */
  71805. length(): number;
  71806. /**
  71807. * Gets the points which construct the path
  71808. * @returns the Path2 internal array of points.
  71809. */
  71810. getPoints(): Vector2[];
  71811. /**
  71812. * Retreives the point at the distance aways from the starting point
  71813. * @param normalizedLengthPosition the length along the path to retreive the point from
  71814. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71815. */
  71816. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71817. /**
  71818. * Creates a new path starting from an x and y position
  71819. * @param x starting x value
  71820. * @param y starting y value
  71821. * @returns a new Path2 starting at the coordinates (x, y).
  71822. */
  71823. static StartingAt(x: number, y: number): Path2;
  71824. }
  71825. /**
  71826. * Represents a 3D path made up of multiple 3D points
  71827. */
  71828. export class Path3D {
  71829. /**
  71830. * an array of Vector3, the curve axis of the Path3D
  71831. */
  71832. path: Vector3[];
  71833. private _curve;
  71834. private _distances;
  71835. private _tangents;
  71836. private _normals;
  71837. private _binormals;
  71838. private _raw;
  71839. /**
  71840. * new Path3D(path, normal, raw)
  71841. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71842. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71843. * @param path an array of Vector3, the curve axis of the Path3D
  71844. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71845. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71846. */
  71847. constructor(
  71848. /**
  71849. * an array of Vector3, the curve axis of the Path3D
  71850. */
  71851. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71852. /**
  71853. * Returns the Path3D array of successive Vector3 designing its curve.
  71854. * @returns the Path3D array of successive Vector3 designing its curve.
  71855. */
  71856. getCurve(): Vector3[];
  71857. /**
  71858. * Returns an array populated with tangent vectors on each Path3D curve point.
  71859. * @returns an array populated with tangent vectors on each Path3D curve point.
  71860. */
  71861. getTangents(): Vector3[];
  71862. /**
  71863. * Returns an array populated with normal vectors on each Path3D curve point.
  71864. * @returns an array populated with normal vectors on each Path3D curve point.
  71865. */
  71866. getNormals(): Vector3[];
  71867. /**
  71868. * Returns an array populated with binormal vectors on each Path3D curve point.
  71869. * @returns an array populated with binormal vectors on each Path3D curve point.
  71870. */
  71871. getBinormals(): Vector3[];
  71872. /**
  71873. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71874. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71875. */
  71876. getDistances(): number[];
  71877. /**
  71878. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71879. * @param path path which all values are copied into the curves points
  71880. * @param firstNormal which should be projected onto the curve
  71881. * @returns the same object updated.
  71882. */
  71883. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71884. private _compute;
  71885. private _getFirstNonNullVector;
  71886. private _getLastNonNullVector;
  71887. private _normalVector;
  71888. }
  71889. /**
  71890. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71891. * A Curve3 is designed from a series of successive Vector3.
  71892. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71893. */
  71894. export class Curve3 {
  71895. private _points;
  71896. private _length;
  71897. /**
  71898. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  71899. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  71900. * @param v1 (Vector3) the control point
  71901. * @param v2 (Vector3) the end point of the Quadratic Bezier
  71902. * @param nbPoints (integer) the wanted number of points in the curve
  71903. * @returns the created Curve3
  71904. */
  71905. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71906. /**
  71907. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  71908. * @param v0 (Vector3) the origin point of the Cubic Bezier
  71909. * @param v1 (Vector3) the first control point
  71910. * @param v2 (Vector3) the second control point
  71911. * @param v3 (Vector3) the end point of the Cubic Bezier
  71912. * @param nbPoints (integer) the wanted number of points in the curve
  71913. * @returns the created Curve3
  71914. */
  71915. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71916. /**
  71917. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71918. * @param p1 (Vector3) the origin point of the Hermite Spline
  71919. * @param t1 (Vector3) the tangent vector at the origin point
  71920. * @param p2 (Vector3) the end point of the Hermite Spline
  71921. * @param t2 (Vector3) the tangent vector at the end point
  71922. * @param nbPoints (integer) the wanted number of points in the curve
  71923. * @returns the created Curve3
  71924. */
  71925. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71926. /**
  71927. * Returns a Curve3 object along a CatmullRom Spline curve :
  71928. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71929. * @param nbPoints (integer) the wanted number of points between each curve control points
  71930. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71931. * @returns the created Curve3
  71932. */
  71933. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71934. /**
  71935. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71936. * A Curve3 is designed from a series of successive Vector3.
  71937. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71938. * @param points points which make up the curve
  71939. */
  71940. constructor(points: Vector3[]);
  71941. /**
  71942. * @returns the Curve3 stored array of successive Vector3
  71943. */
  71944. getPoints(): Vector3[];
  71945. /**
  71946. * @returns the computed length (float) of the curve.
  71947. */
  71948. length(): number;
  71949. /**
  71950. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71951. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71952. * curveA and curveB keep unchanged.
  71953. * @param curve the curve to continue from this curve
  71954. * @returns the newly constructed curve
  71955. */
  71956. continue(curve: DeepImmutable<Curve3>): Curve3;
  71957. private _computeLength;
  71958. }
  71959. }
  71960. declare module BABYLON {
  71961. /**
  71962. * This represents the main contract an easing function should follow.
  71963. * Easing functions are used throughout the animation system.
  71964. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71965. */
  71966. export interface IEasingFunction {
  71967. /**
  71968. * Given an input gradient between 0 and 1, this returns the corrseponding value
  71969. * of the easing function.
  71970. * The link below provides some of the most common examples of easing functions.
  71971. * @see https://easings.net/
  71972. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71973. * @returns the corresponding value on the curve defined by the easing function
  71974. */
  71975. ease(gradient: number): number;
  71976. }
  71977. /**
  71978. * Base class used for every default easing function.
  71979. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71980. */
  71981. export class EasingFunction implements IEasingFunction {
  71982. /**
  71983. * Interpolation follows the mathematical formula associated with the easing function.
  71984. */
  71985. static readonly EASINGMODE_EASEIN: number;
  71986. /**
  71987. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  71988. */
  71989. static readonly EASINGMODE_EASEOUT: number;
  71990. /**
  71991. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  71992. */
  71993. static readonly EASINGMODE_EASEINOUT: number;
  71994. private _easingMode;
  71995. /**
  71996. * Sets the easing mode of the current function.
  71997. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71998. */
  71999. setEasingMode(easingMode: number): void;
  72000. /**
  72001. * Gets the current easing mode.
  72002. * @returns the easing mode
  72003. */
  72004. getEasingMode(): number;
  72005. /**
  72006. * @hidden
  72007. */
  72008. easeInCore(gradient: number): number;
  72009. /**
  72010. * Given an input gradient between 0 and 1, this returns the corresponding value
  72011. * of the easing function.
  72012. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72013. * @returns the corresponding value on the curve defined by the easing function
  72014. */
  72015. ease(gradient: number): number;
  72016. }
  72017. /**
  72018. * Easing function with a circle shape (see link below).
  72019. * @see https://easings.net/#easeInCirc
  72020. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72021. */
  72022. export class CircleEase extends EasingFunction implements IEasingFunction {
  72023. /** @hidden */
  72024. easeInCore(gradient: number): number;
  72025. }
  72026. /**
  72027. * Easing function with a ease back shape (see link below).
  72028. * @see https://easings.net/#easeInBack
  72029. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72030. */
  72031. export class BackEase extends EasingFunction implements IEasingFunction {
  72032. /** Defines the amplitude of the function */
  72033. amplitude: number;
  72034. /**
  72035. * Instantiates a back ease easing
  72036. * @see https://easings.net/#easeInBack
  72037. * @param amplitude Defines the amplitude of the function
  72038. */
  72039. constructor(
  72040. /** Defines the amplitude of the function */
  72041. amplitude?: number);
  72042. /** @hidden */
  72043. easeInCore(gradient: number): number;
  72044. }
  72045. /**
  72046. * Easing function with a bouncing shape (see link below).
  72047. * @see https://easings.net/#easeInBounce
  72048. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72049. */
  72050. export class BounceEase extends EasingFunction implements IEasingFunction {
  72051. /** Defines the number of bounces */
  72052. bounces: number;
  72053. /** Defines the amplitude of the bounce */
  72054. bounciness: number;
  72055. /**
  72056. * Instantiates a bounce easing
  72057. * @see https://easings.net/#easeInBounce
  72058. * @param bounces Defines the number of bounces
  72059. * @param bounciness Defines the amplitude of the bounce
  72060. */
  72061. constructor(
  72062. /** Defines the number of bounces */
  72063. bounces?: number,
  72064. /** Defines the amplitude of the bounce */
  72065. bounciness?: number);
  72066. /** @hidden */
  72067. easeInCore(gradient: number): number;
  72068. }
  72069. /**
  72070. * Easing function with a power of 3 shape (see link below).
  72071. * @see https://easings.net/#easeInCubic
  72072. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72073. */
  72074. export class CubicEase extends EasingFunction implements IEasingFunction {
  72075. /** @hidden */
  72076. easeInCore(gradient: number): number;
  72077. }
  72078. /**
  72079. * Easing function with an elastic shape (see link below).
  72080. * @see https://easings.net/#easeInElastic
  72081. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72082. */
  72083. export class ElasticEase extends EasingFunction implements IEasingFunction {
  72084. /** Defines the number of oscillations*/
  72085. oscillations: number;
  72086. /** Defines the amplitude of the oscillations*/
  72087. springiness: number;
  72088. /**
  72089. * Instantiates an elastic easing function
  72090. * @see https://easings.net/#easeInElastic
  72091. * @param oscillations Defines the number of oscillations
  72092. * @param springiness Defines the amplitude of the oscillations
  72093. */
  72094. constructor(
  72095. /** Defines the number of oscillations*/
  72096. oscillations?: number,
  72097. /** Defines the amplitude of the oscillations*/
  72098. springiness?: number);
  72099. /** @hidden */
  72100. easeInCore(gradient: number): number;
  72101. }
  72102. /**
  72103. * Easing function with an exponential shape (see link below).
  72104. * @see https://easings.net/#easeInExpo
  72105. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72106. */
  72107. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72108. /** Defines the exponent of the function */
  72109. exponent: number;
  72110. /**
  72111. * Instantiates an exponential easing function
  72112. * @see https://easings.net/#easeInExpo
  72113. * @param exponent Defines the exponent of the function
  72114. */
  72115. constructor(
  72116. /** Defines the exponent of the function */
  72117. exponent?: number);
  72118. /** @hidden */
  72119. easeInCore(gradient: number): number;
  72120. }
  72121. /**
  72122. * Easing function with a power shape (see link below).
  72123. * @see https://easings.net/#easeInQuad
  72124. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72125. */
  72126. export class PowerEase extends EasingFunction implements IEasingFunction {
  72127. /** Defines the power of the function */
  72128. power: number;
  72129. /**
  72130. * Instantiates an power base easing function
  72131. * @see https://easings.net/#easeInQuad
  72132. * @param power Defines the power of the function
  72133. */
  72134. constructor(
  72135. /** Defines the power of the function */
  72136. power?: number);
  72137. /** @hidden */
  72138. easeInCore(gradient: number): number;
  72139. }
  72140. /**
  72141. * Easing function with a power of 2 shape (see link below).
  72142. * @see https://easings.net/#easeInQuad
  72143. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72144. */
  72145. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72146. /** @hidden */
  72147. easeInCore(gradient: number): number;
  72148. }
  72149. /**
  72150. * Easing function with a power of 4 shape (see link below).
  72151. * @see https://easings.net/#easeInQuart
  72152. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72153. */
  72154. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72155. /** @hidden */
  72156. easeInCore(gradient: number): number;
  72157. }
  72158. /**
  72159. * Easing function with a power of 5 shape (see link below).
  72160. * @see https://easings.net/#easeInQuint
  72161. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72162. */
  72163. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72164. /** @hidden */
  72165. easeInCore(gradient: number): number;
  72166. }
  72167. /**
  72168. * Easing function with a sin shape (see link below).
  72169. * @see https://easings.net/#easeInSine
  72170. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72171. */
  72172. export class SineEase extends EasingFunction implements IEasingFunction {
  72173. /** @hidden */
  72174. easeInCore(gradient: number): number;
  72175. }
  72176. /**
  72177. * Easing function with a bezier shape (see link below).
  72178. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72179. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72180. */
  72181. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72182. /** Defines the x component of the start tangent in the bezier curve */
  72183. x1: number;
  72184. /** Defines the y component of the start tangent in the bezier curve */
  72185. y1: number;
  72186. /** Defines the x component of the end tangent in the bezier curve */
  72187. x2: number;
  72188. /** Defines the y component of the end tangent in the bezier curve */
  72189. y2: number;
  72190. /**
  72191. * Instantiates a bezier function
  72192. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72193. * @param x1 Defines the x component of the start tangent in the bezier curve
  72194. * @param y1 Defines the y component of the start tangent in the bezier curve
  72195. * @param x2 Defines the x component of the end tangent in the bezier curve
  72196. * @param y2 Defines the y component of the end tangent in the bezier curve
  72197. */
  72198. constructor(
  72199. /** Defines the x component of the start tangent in the bezier curve */
  72200. x1?: number,
  72201. /** Defines the y component of the start tangent in the bezier curve */
  72202. y1?: number,
  72203. /** Defines the x component of the end tangent in the bezier curve */
  72204. x2?: number,
  72205. /** Defines the y component of the end tangent in the bezier curve */
  72206. y2?: number);
  72207. /** @hidden */
  72208. easeInCore(gradient: number): number;
  72209. }
  72210. }
  72211. declare module BABYLON {
  72212. /**
  72213. * Defines an interface which represents an animation key frame
  72214. */
  72215. export interface IAnimationKey {
  72216. /**
  72217. * Frame of the key frame
  72218. */
  72219. frame: number;
  72220. /**
  72221. * Value at the specifies key frame
  72222. */
  72223. value: any;
  72224. /**
  72225. * The input tangent for the cubic hermite spline
  72226. */
  72227. inTangent?: any;
  72228. /**
  72229. * The output tangent for the cubic hermite spline
  72230. */
  72231. outTangent?: any;
  72232. /**
  72233. * The animation interpolation type
  72234. */
  72235. interpolation?: AnimationKeyInterpolation;
  72236. }
  72237. /**
  72238. * Enum for the animation key frame interpolation type
  72239. */
  72240. export enum AnimationKeyInterpolation {
  72241. /**
  72242. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72243. */
  72244. STEP = 1
  72245. }
  72246. }
  72247. declare module BABYLON {
  72248. /**
  72249. * Represents the range of an animation
  72250. */
  72251. export class AnimationRange {
  72252. /**The name of the animation range**/
  72253. name: string;
  72254. /**The starting frame of the animation */
  72255. from: number;
  72256. /**The ending frame of the animation*/
  72257. to: number;
  72258. /**
  72259. * Initializes the range of an animation
  72260. * @param name The name of the animation range
  72261. * @param from The starting frame of the animation
  72262. * @param to The ending frame of the animation
  72263. */
  72264. constructor(
  72265. /**The name of the animation range**/
  72266. name: string,
  72267. /**The starting frame of the animation */
  72268. from: number,
  72269. /**The ending frame of the animation*/
  72270. to: number);
  72271. /**
  72272. * Makes a copy of the animation range
  72273. * @returns A copy of the animation range
  72274. */
  72275. clone(): AnimationRange;
  72276. }
  72277. }
  72278. declare module BABYLON {
  72279. /**
  72280. * Composed of a frame, and an action function
  72281. */
  72282. export class AnimationEvent {
  72283. /** The frame for which the event is triggered **/
  72284. frame: number;
  72285. /** The event to perform when triggered **/
  72286. action: (currentFrame: number) => void;
  72287. /** Specifies if the event should be triggered only once**/
  72288. onlyOnce?: boolean | undefined;
  72289. /**
  72290. * Specifies if the animation event is done
  72291. */
  72292. isDone: boolean;
  72293. /**
  72294. * Initializes the animation event
  72295. * @param frame The frame for which the event is triggered
  72296. * @param action The event to perform when triggered
  72297. * @param onlyOnce Specifies if the event should be triggered only once
  72298. */
  72299. constructor(
  72300. /** The frame for which the event is triggered **/
  72301. frame: number,
  72302. /** The event to perform when triggered **/
  72303. action: (currentFrame: number) => void,
  72304. /** Specifies if the event should be triggered only once**/
  72305. onlyOnce?: boolean | undefined);
  72306. /** @hidden */
  72307. _clone(): AnimationEvent;
  72308. }
  72309. }
  72310. declare module BABYLON {
  72311. /**
  72312. * Interface used to define a behavior
  72313. */
  72314. export interface Behavior<T> {
  72315. /** gets or sets behavior's name */
  72316. name: string;
  72317. /**
  72318. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72319. */
  72320. init(): void;
  72321. /**
  72322. * Called when the behavior is attached to a target
  72323. * @param target defines the target where the behavior is attached to
  72324. */
  72325. attach(target: T): void;
  72326. /**
  72327. * Called when the behavior is detached from its target
  72328. */
  72329. detach(): void;
  72330. }
  72331. /**
  72332. * Interface implemented by classes supporting behaviors
  72333. */
  72334. export interface IBehaviorAware<T> {
  72335. /**
  72336. * Attach a behavior
  72337. * @param behavior defines the behavior to attach
  72338. * @returns the current host
  72339. */
  72340. addBehavior(behavior: Behavior<T>): T;
  72341. /**
  72342. * Remove a behavior from the current object
  72343. * @param behavior defines the behavior to detach
  72344. * @returns the current host
  72345. */
  72346. removeBehavior(behavior: Behavior<T>): T;
  72347. /**
  72348. * Gets a behavior using its name to search
  72349. * @param name defines the name to search
  72350. * @returns the behavior or null if not found
  72351. */
  72352. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72353. }
  72354. }
  72355. declare module BABYLON {
  72356. /**
  72357. * Defines an array and its length.
  72358. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72359. */
  72360. export interface ISmartArrayLike<T> {
  72361. /**
  72362. * The data of the array.
  72363. */
  72364. data: Array<T>;
  72365. /**
  72366. * The active length of the array.
  72367. */
  72368. length: number;
  72369. }
  72370. /**
  72371. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72372. */
  72373. export class SmartArray<T> implements ISmartArrayLike<T> {
  72374. /**
  72375. * The full set of data from the array.
  72376. */
  72377. data: Array<T>;
  72378. /**
  72379. * The active length of the array.
  72380. */
  72381. length: number;
  72382. protected _id: number;
  72383. /**
  72384. * Instantiates a Smart Array.
  72385. * @param capacity defines the default capacity of the array.
  72386. */
  72387. constructor(capacity: number);
  72388. /**
  72389. * Pushes a value at the end of the active data.
  72390. * @param value defines the object to push in the array.
  72391. */
  72392. push(value: T): void;
  72393. /**
  72394. * Iterates over the active data and apply the lambda to them.
  72395. * @param func defines the action to apply on each value.
  72396. */
  72397. forEach(func: (content: T) => void): void;
  72398. /**
  72399. * Sorts the full sets of data.
  72400. * @param compareFn defines the comparison function to apply.
  72401. */
  72402. sort(compareFn: (a: T, b: T) => number): void;
  72403. /**
  72404. * Resets the active data to an empty array.
  72405. */
  72406. reset(): void;
  72407. /**
  72408. * Releases all the data from the array as well as the array.
  72409. */
  72410. dispose(): void;
  72411. /**
  72412. * Concats the active data with a given array.
  72413. * @param array defines the data to concatenate with.
  72414. */
  72415. concat(array: any): void;
  72416. /**
  72417. * Returns the position of a value in the active data.
  72418. * @param value defines the value to find the index for
  72419. * @returns the index if found in the active data otherwise -1
  72420. */
  72421. indexOf(value: T): number;
  72422. /**
  72423. * Returns whether an element is part of the active data.
  72424. * @param value defines the value to look for
  72425. * @returns true if found in the active data otherwise false
  72426. */
  72427. contains(value: T): boolean;
  72428. private static _GlobalId;
  72429. }
  72430. /**
  72431. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72432. * The data in this array can only be present once
  72433. */
  72434. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72435. private _duplicateId;
  72436. /**
  72437. * Pushes a value at the end of the active data.
  72438. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72439. * @param value defines the object to push in the array.
  72440. */
  72441. push(value: T): void;
  72442. /**
  72443. * Pushes a value at the end of the active data.
  72444. * If the data is already present, it won t be added again
  72445. * @param value defines the object to push in the array.
  72446. * @returns true if added false if it was already present
  72447. */
  72448. pushNoDuplicate(value: T): boolean;
  72449. /**
  72450. * Resets the active data to an empty array.
  72451. */
  72452. reset(): void;
  72453. /**
  72454. * Concats the active data with a given array.
  72455. * This ensures no dupplicate will be present in the result.
  72456. * @param array defines the data to concatenate with.
  72457. */
  72458. concatWithNoDuplicate(array: any): void;
  72459. }
  72460. }
  72461. declare module BABYLON {
  72462. /**
  72463. * @ignore
  72464. * This is a list of all the different input types that are available in the application.
  72465. * Fo instance: ArcRotateCameraGamepadInput...
  72466. */
  72467. export var CameraInputTypes: {};
  72468. /**
  72469. * This is the contract to implement in order to create a new input class.
  72470. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72471. */
  72472. export interface ICameraInput<TCamera extends Camera> {
  72473. /**
  72474. * Defines the camera the input is attached to.
  72475. */
  72476. camera: Nullable<TCamera>;
  72477. /**
  72478. * Gets the class name of the current intput.
  72479. * @returns the class name
  72480. */
  72481. getClassName(): string;
  72482. /**
  72483. * Get the friendly name associated with the input class.
  72484. * @returns the input friendly name
  72485. */
  72486. getSimpleName(): string;
  72487. /**
  72488. * Attach the input controls to a specific dom element to get the input from.
  72489. * @param element Defines the element the controls should be listened from
  72490. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72491. */
  72492. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72493. /**
  72494. * Detach the current controls from the specified dom element.
  72495. * @param element Defines the element to stop listening the inputs from
  72496. */
  72497. detachControl(element: Nullable<HTMLElement>): void;
  72498. /**
  72499. * Update the current camera state depending on the inputs that have been used this frame.
  72500. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72501. */
  72502. checkInputs?: () => void;
  72503. }
  72504. /**
  72505. * Represents a map of input types to input instance or input index to input instance.
  72506. */
  72507. export interface CameraInputsMap<TCamera extends Camera> {
  72508. /**
  72509. * Accessor to the input by input type.
  72510. */
  72511. [name: string]: ICameraInput<TCamera>;
  72512. /**
  72513. * Accessor to the input by input index.
  72514. */
  72515. [idx: number]: ICameraInput<TCamera>;
  72516. }
  72517. /**
  72518. * This represents the input manager used within a camera.
  72519. * It helps dealing with all the different kind of input attached to a camera.
  72520. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72521. */
  72522. export class CameraInputsManager<TCamera extends Camera> {
  72523. /**
  72524. * Defines the list of inputs attahed to the camera.
  72525. */
  72526. attached: CameraInputsMap<TCamera>;
  72527. /**
  72528. * Defines the dom element the camera is collecting inputs from.
  72529. * This is null if the controls have not been attached.
  72530. */
  72531. attachedElement: Nullable<HTMLElement>;
  72532. /**
  72533. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72534. */
  72535. noPreventDefault: boolean;
  72536. /**
  72537. * Defined the camera the input manager belongs to.
  72538. */
  72539. camera: TCamera;
  72540. /**
  72541. * Update the current camera state depending on the inputs that have been used this frame.
  72542. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72543. */
  72544. checkInputs: () => void;
  72545. /**
  72546. * Instantiate a new Camera Input Manager.
  72547. * @param camera Defines the camera the input manager blongs to
  72548. */
  72549. constructor(camera: TCamera);
  72550. /**
  72551. * Add an input method to a camera
  72552. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72553. * @param input camera input method
  72554. */
  72555. add(input: ICameraInput<TCamera>): void;
  72556. /**
  72557. * Remove a specific input method from a camera
  72558. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72559. * @param inputToRemove camera input method
  72560. */
  72561. remove(inputToRemove: ICameraInput<TCamera>): void;
  72562. /**
  72563. * Remove a specific input type from a camera
  72564. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72565. * @param inputType the type of the input to remove
  72566. */
  72567. removeByType(inputType: string): void;
  72568. private _addCheckInputs;
  72569. /**
  72570. * Attach the input controls to the currently attached dom element to listen the events from.
  72571. * @param input Defines the input to attach
  72572. */
  72573. attachInput(input: ICameraInput<TCamera>): void;
  72574. /**
  72575. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72576. * @param element Defines the dom element to collect the events from
  72577. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72578. */
  72579. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72580. /**
  72581. * Detach the current manager inputs controls from a specific dom element.
  72582. * @param element Defines the dom element to collect the events from
  72583. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72584. */
  72585. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72586. /**
  72587. * Rebuild the dynamic inputCheck function from the current list of
  72588. * defined inputs in the manager.
  72589. */
  72590. rebuildInputCheck(): void;
  72591. /**
  72592. * Remove all attached input methods from a camera
  72593. */
  72594. clear(): void;
  72595. /**
  72596. * Serialize the current input manager attached to a camera.
  72597. * This ensures than once parsed,
  72598. * the input associated to the camera will be identical to the current ones
  72599. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72600. */
  72601. serialize(serializedCamera: any): void;
  72602. /**
  72603. * Parses an input manager serialized JSON to restore the previous list of inputs
  72604. * and states associated to a camera.
  72605. * @param parsedCamera Defines the JSON to parse
  72606. */
  72607. parse(parsedCamera: any): void;
  72608. }
  72609. }
  72610. declare module BABYLON {
  72611. /**
  72612. * @hidden
  72613. */
  72614. export class IntersectionInfo {
  72615. bu: Nullable<number>;
  72616. bv: Nullable<number>;
  72617. distance: number;
  72618. faceId: number;
  72619. subMeshId: number;
  72620. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  72621. }
  72622. }
  72623. declare module BABYLON {
  72624. /**
  72625. * Represens a plane by the equation ax + by + cz + d = 0
  72626. */
  72627. export class Plane {
  72628. private static _TmpMatrix;
  72629. /**
  72630. * Normal of the plane (a,b,c)
  72631. */
  72632. normal: Vector3;
  72633. /**
  72634. * d component of the plane
  72635. */
  72636. d: number;
  72637. /**
  72638. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  72639. * @param a a component of the plane
  72640. * @param b b component of the plane
  72641. * @param c c component of the plane
  72642. * @param d d component of the plane
  72643. */
  72644. constructor(a: number, b: number, c: number, d: number);
  72645. /**
  72646. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  72647. */
  72648. asArray(): number[];
  72649. /**
  72650. * @returns a new plane copied from the current Plane.
  72651. */
  72652. clone(): Plane;
  72653. /**
  72654. * @returns the string "Plane".
  72655. */
  72656. getClassName(): string;
  72657. /**
  72658. * @returns the Plane hash code.
  72659. */
  72660. getHashCode(): number;
  72661. /**
  72662. * Normalize the current Plane in place.
  72663. * @returns the updated Plane.
  72664. */
  72665. normalize(): Plane;
  72666. /**
  72667. * Applies a transformation the plane and returns the result
  72668. * @param transformation the transformation matrix to be applied to the plane
  72669. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  72670. */
  72671. transform(transformation: DeepImmutable<Matrix>): Plane;
  72672. /**
  72673. * Calcualtte the dot product between the point and the plane normal
  72674. * @param point point to calculate the dot product with
  72675. * @returns the dot product (float) of the point coordinates and the plane normal.
  72676. */
  72677. dotCoordinate(point: DeepImmutable<Vector3>): number;
  72678. /**
  72679. * Updates the current Plane from the plane defined by the three given points.
  72680. * @param point1 one of the points used to contruct the plane
  72681. * @param point2 one of the points used to contruct the plane
  72682. * @param point3 one of the points used to contruct the plane
  72683. * @returns the updated Plane.
  72684. */
  72685. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72686. /**
  72687. * Checks if the plane is facing a given direction
  72688. * @param direction the direction to check if the plane is facing
  72689. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  72690. * @returns True is the vector "direction" is the same side than the plane normal.
  72691. */
  72692. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  72693. /**
  72694. * Calculates the distance to a point
  72695. * @param point point to calculate distance to
  72696. * @returns the signed distance (float) from the given point to the Plane.
  72697. */
  72698. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  72699. /**
  72700. * Creates a plane from an array
  72701. * @param array the array to create a plane from
  72702. * @returns a new Plane from the given array.
  72703. */
  72704. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  72705. /**
  72706. * Creates a plane from three points
  72707. * @param point1 point used to create the plane
  72708. * @param point2 point used to create the plane
  72709. * @param point3 point used to create the plane
  72710. * @returns a new Plane defined by the three given points.
  72711. */
  72712. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  72713. /**
  72714. * Creates a plane from an origin point and a normal
  72715. * @param origin origin of the plane to be constructed
  72716. * @param normal normal of the plane to be constructed
  72717. * @returns a new Plane the normal vector to this plane at the given origin point.
  72718. * Note : the vector "normal" is updated because normalized.
  72719. */
  72720. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  72721. /**
  72722. * Calculates the distance from a plane and a point
  72723. * @param origin origin of the plane to be constructed
  72724. * @param normal normal of the plane to be constructed
  72725. * @param point point to calculate distance to
  72726. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  72727. */
  72728. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  72729. }
  72730. }
  72731. declare module BABYLON {
  72732. /**
  72733. * Class used to store bounding sphere information
  72734. */
  72735. export class BoundingSphere {
  72736. /**
  72737. * Gets the center of the bounding sphere in local space
  72738. */
  72739. readonly center: Vector3;
  72740. /**
  72741. * Radius of the bounding sphere in local space
  72742. */
  72743. radius: number;
  72744. /**
  72745. * Gets the center of the bounding sphere in world space
  72746. */
  72747. readonly centerWorld: Vector3;
  72748. /**
  72749. * Radius of the bounding sphere in world space
  72750. */
  72751. radiusWorld: number;
  72752. /**
  72753. * Gets the minimum vector in local space
  72754. */
  72755. readonly minimum: Vector3;
  72756. /**
  72757. * Gets the maximum vector in local space
  72758. */
  72759. readonly maximum: Vector3;
  72760. private _worldMatrix;
  72761. private static readonly TmpVector3;
  72762. /**
  72763. * Creates a new bounding sphere
  72764. * @param min defines the minimum vector (in local space)
  72765. * @param max defines the maximum vector (in local space)
  72766. * @param worldMatrix defines the new world matrix
  72767. */
  72768. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72769. /**
  72770. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  72771. * @param min defines the new minimum vector (in local space)
  72772. * @param max defines the new maximum vector (in local space)
  72773. * @param worldMatrix defines the new world matrix
  72774. */
  72775. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72776. /**
  72777. * Scale the current bounding sphere by applying a scale factor
  72778. * @param factor defines the scale factor to apply
  72779. * @returns the current bounding box
  72780. */
  72781. scale(factor: number): BoundingSphere;
  72782. /**
  72783. * Gets the world matrix of the bounding box
  72784. * @returns a matrix
  72785. */
  72786. getWorldMatrix(): DeepImmutable<Matrix>;
  72787. /** @hidden */
  72788. _update(worldMatrix: DeepImmutable<Matrix>): void;
  72789. /**
  72790. * Tests if the bounding sphere is intersecting the frustum planes
  72791. * @param frustumPlanes defines the frustum planes to test
  72792. * @returns true if there is an intersection
  72793. */
  72794. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72795. /**
  72796. * Tests if the bounding sphere center is in between the frustum planes.
  72797. * Used for optimistic fast inclusion.
  72798. * @param frustumPlanes defines the frustum planes to test
  72799. * @returns true if the sphere center is in between the frustum planes
  72800. */
  72801. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72802. /**
  72803. * Tests if a point is inside the bounding sphere
  72804. * @param point defines the point to test
  72805. * @returns true if the point is inside the bounding sphere
  72806. */
  72807. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72808. /**
  72809. * Checks if two sphere intersct
  72810. * @param sphere0 sphere 0
  72811. * @param sphere1 sphere 1
  72812. * @returns true if the speres intersect
  72813. */
  72814. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  72815. }
  72816. }
  72817. declare module BABYLON {
  72818. /**
  72819. * Class used to store bounding box information
  72820. */
  72821. export class BoundingBox implements ICullable {
  72822. /**
  72823. * Gets the 8 vectors representing the bounding box in local space
  72824. */
  72825. readonly vectors: Vector3[];
  72826. /**
  72827. * Gets the center of the bounding box in local space
  72828. */
  72829. readonly center: Vector3;
  72830. /**
  72831. * Gets the center of the bounding box in world space
  72832. */
  72833. readonly centerWorld: Vector3;
  72834. /**
  72835. * Gets the extend size in local space
  72836. */
  72837. readonly extendSize: Vector3;
  72838. /**
  72839. * Gets the extend size in world space
  72840. */
  72841. readonly extendSizeWorld: Vector3;
  72842. /**
  72843. * Gets the OBB (object bounding box) directions
  72844. */
  72845. readonly directions: Vector3[];
  72846. /**
  72847. * Gets the 8 vectors representing the bounding box in world space
  72848. */
  72849. readonly vectorsWorld: Vector3[];
  72850. /**
  72851. * Gets the minimum vector in world space
  72852. */
  72853. readonly minimumWorld: Vector3;
  72854. /**
  72855. * Gets the maximum vector in world space
  72856. */
  72857. readonly maximumWorld: Vector3;
  72858. /**
  72859. * Gets the minimum vector in local space
  72860. */
  72861. readonly minimum: Vector3;
  72862. /**
  72863. * Gets the maximum vector in local space
  72864. */
  72865. readonly maximum: Vector3;
  72866. private _worldMatrix;
  72867. private static readonly TmpVector3;
  72868. /**
  72869. * @hidden
  72870. */
  72871. _tag: number;
  72872. /**
  72873. * Creates a new bounding box
  72874. * @param min defines the minimum vector (in local space)
  72875. * @param max defines the maximum vector (in local space)
  72876. * @param worldMatrix defines the new world matrix
  72877. */
  72878. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  72879. /**
  72880. * Recreates the entire bounding box from scratch as if we call the constructor in place
  72881. * @param min defines the new minimum vector (in local space)
  72882. * @param max defines the new maximum vector (in local space)
  72883. * @param worldMatrix defines the new world matrix
  72884. */
  72885. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  72886. /**
  72887. * Scale the current bounding box by applying a scale factor
  72888. * @param factor defines the scale factor to apply
  72889. * @returns the current bounding box
  72890. */
  72891. scale(factor: number): BoundingBox;
  72892. /**
  72893. * Gets the world matrix of the bounding box
  72894. * @returns a matrix
  72895. */
  72896. getWorldMatrix(): DeepImmutable<Matrix>;
  72897. /** @hidden */
  72898. _update(world: DeepImmutable<Matrix>): void;
  72899. /**
  72900. * Tests if the bounding box is intersecting the frustum planes
  72901. * @param frustumPlanes defines the frustum planes to test
  72902. * @returns true if there is an intersection
  72903. */
  72904. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72905. /**
  72906. * Tests if the bounding box is entirely inside the frustum planes
  72907. * @param frustumPlanes defines the frustum planes to test
  72908. * @returns true if there is an inclusion
  72909. */
  72910. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72911. /**
  72912. * Tests if a point is inside the bounding box
  72913. * @param point defines the point to test
  72914. * @returns true if the point is inside the bounding box
  72915. */
  72916. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  72917. /**
  72918. * Tests if the bounding box intersects with a bounding sphere
  72919. * @param sphere defines the sphere to test
  72920. * @returns true if there is an intersection
  72921. */
  72922. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  72923. /**
  72924. * Tests if the bounding box intersects with a box defined by a min and max vectors
  72925. * @param min defines the min vector to use
  72926. * @param max defines the max vector to use
  72927. * @returns true if there is an intersection
  72928. */
  72929. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  72930. /**
  72931. * Tests if two bounding boxes are intersections
  72932. * @param box0 defines the first box to test
  72933. * @param box1 defines the second box to test
  72934. * @returns true if there is an intersection
  72935. */
  72936. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  72937. /**
  72938. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  72939. * @param minPoint defines the minimum vector of the bounding box
  72940. * @param maxPoint defines the maximum vector of the bounding box
  72941. * @param sphereCenter defines the sphere center
  72942. * @param sphereRadius defines the sphere radius
  72943. * @returns true if there is an intersection
  72944. */
  72945. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  72946. /**
  72947. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  72948. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72949. * @param frustumPlanes defines the frustum planes to test
  72950. * @return true if there is an inclusion
  72951. */
  72952. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72953. /**
  72954. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  72955. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  72956. * @param frustumPlanes defines the frustum planes to test
  72957. * @return true if there is an intersection
  72958. */
  72959. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  72960. }
  72961. }
  72962. declare module BABYLON {
  72963. /** @hidden */
  72964. export class Collider {
  72965. /** Define if a collision was found */
  72966. collisionFound: boolean;
  72967. /**
  72968. * Define last intersection point in local space
  72969. */
  72970. intersectionPoint: Vector3;
  72971. /**
  72972. * Define last collided mesh
  72973. */
  72974. collidedMesh: Nullable<AbstractMesh>;
  72975. private _collisionPoint;
  72976. private _planeIntersectionPoint;
  72977. private _tempVector;
  72978. private _tempVector2;
  72979. private _tempVector3;
  72980. private _tempVector4;
  72981. private _edge;
  72982. private _baseToVertex;
  72983. private _destinationPoint;
  72984. private _slidePlaneNormal;
  72985. private _displacementVector;
  72986. /** @hidden */
  72987. _radius: Vector3;
  72988. /** @hidden */
  72989. _retry: number;
  72990. private _velocity;
  72991. private _basePoint;
  72992. private _epsilon;
  72993. /** @hidden */
  72994. _velocityWorldLength: number;
  72995. /** @hidden */
  72996. _basePointWorld: Vector3;
  72997. private _velocityWorld;
  72998. private _normalizedVelocity;
  72999. /** @hidden */
  73000. _initialVelocity: Vector3;
  73001. /** @hidden */
  73002. _initialPosition: Vector3;
  73003. private _nearestDistance;
  73004. private _collisionMask;
  73005. collisionMask: number;
  73006. /**
  73007. * Gets the plane normal used to compute the sliding response (in local space)
  73008. */
  73009. readonly slidePlaneNormal: Vector3;
  73010. /** @hidden */
  73011. _initialize(source: Vector3, dir: Vector3, e: number): void;
  73012. /** @hidden */
  73013. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  73014. /** @hidden */
  73015. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  73016. /** @hidden */
  73017. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73018. /** @hidden */
  73019. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73020. /** @hidden */
  73021. _getResponse(pos: Vector3, vel: Vector3): void;
  73022. }
  73023. }
  73024. declare module BABYLON {
  73025. /**
  73026. * Interface for cullable objects
  73027. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  73028. */
  73029. export interface ICullable {
  73030. /**
  73031. * Checks if the object or part of the object is in the frustum
  73032. * @param frustumPlanes Camera near/planes
  73033. * @returns true if the object is in frustum otherwise false
  73034. */
  73035. isInFrustum(frustumPlanes: Plane[]): boolean;
  73036. /**
  73037. * Checks if a cullable object (mesh...) is in the camera frustum
  73038. * Unlike isInFrustum this cheks the full bounding box
  73039. * @param frustumPlanes Camera near/planes
  73040. * @returns true if the object is in frustum otherwise false
  73041. */
  73042. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  73043. }
  73044. /**
  73045. * Info for a bounding data of a mesh
  73046. */
  73047. export class BoundingInfo implements ICullable {
  73048. /**
  73049. * Bounding box for the mesh
  73050. */
  73051. readonly boundingBox: BoundingBox;
  73052. /**
  73053. * Bounding sphere for the mesh
  73054. */
  73055. readonly boundingSphere: BoundingSphere;
  73056. private _isLocked;
  73057. private static readonly TmpVector3;
  73058. /**
  73059. * Constructs bounding info
  73060. * @param minimum min vector of the bounding box/sphere
  73061. * @param maximum max vector of the bounding box/sphere
  73062. * @param worldMatrix defines the new world matrix
  73063. */
  73064. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73065. /**
  73066. * Recreates the entire bounding info from scratch as if we call the constructor in place
  73067. * @param min defines the new minimum vector (in local space)
  73068. * @param max defines the new maximum vector (in local space)
  73069. * @param worldMatrix defines the new world matrix
  73070. */
  73071. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73072. /**
  73073. * min vector of the bounding box/sphere
  73074. */
  73075. readonly minimum: Vector3;
  73076. /**
  73077. * max vector of the bounding box/sphere
  73078. */
  73079. readonly maximum: Vector3;
  73080. /**
  73081. * If the info is locked and won't be updated to avoid perf overhead
  73082. */
  73083. isLocked: boolean;
  73084. /**
  73085. * Updates the bounding sphere and box
  73086. * @param world world matrix to be used to update
  73087. */
  73088. update(world: DeepImmutable<Matrix>): void;
  73089. /**
  73090. * Recreate the bounding info to be centered around a specific point given a specific extend.
  73091. * @param center New center of the bounding info
  73092. * @param extend New extend of the bounding info
  73093. * @returns the current bounding info
  73094. */
  73095. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  73096. /**
  73097. * Scale the current bounding info by applying a scale factor
  73098. * @param factor defines the scale factor to apply
  73099. * @returns the current bounding info
  73100. */
  73101. scale(factor: number): BoundingInfo;
  73102. /**
  73103. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  73104. * @param frustumPlanes defines the frustum to test
  73105. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  73106. * @returns true if the bounding info is in the frustum planes
  73107. */
  73108. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73109. /**
  73110. * Gets the world distance between the min and max points of the bounding box
  73111. */
  73112. readonly diagonalLength: number;
  73113. /**
  73114. * Checks if a cullable object (mesh...) is in the camera frustum
  73115. * Unlike isInFrustum this cheks the full bounding box
  73116. * @param frustumPlanes Camera near/planes
  73117. * @returns true if the object is in frustum otherwise false
  73118. */
  73119. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73120. /** @hidden */
  73121. _checkCollision(collider: Collider): boolean;
  73122. /**
  73123. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73124. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73125. * @param point the point to check intersection with
  73126. * @returns if the point intersects
  73127. */
  73128. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73129. /**
  73130. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73131. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73132. * @param boundingInfo the bounding info to check intersection with
  73133. * @param precise if the intersection should be done using OBB
  73134. * @returns if the bounding info intersects
  73135. */
  73136. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73137. }
  73138. }
  73139. declare module BABYLON {
  73140. /**
  73141. * Extracts minimum and maximum values from a list of indexed positions
  73142. * @param positions defines the positions to use
  73143. * @param indices defines the indices to the positions
  73144. * @param indexStart defines the start index
  73145. * @param indexCount defines the end index
  73146. * @param bias defines bias value to add to the result
  73147. * @return minimum and maximum values
  73148. */
  73149. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73150. minimum: Vector3;
  73151. maximum: Vector3;
  73152. };
  73153. /**
  73154. * Extracts minimum and maximum values from a list of positions
  73155. * @param positions defines the positions to use
  73156. * @param start defines the start index in the positions array
  73157. * @param count defines the number of positions to handle
  73158. * @param bias defines bias value to add to the result
  73159. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73160. * @return minimum and maximum values
  73161. */
  73162. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73163. minimum: Vector3;
  73164. maximum: Vector3;
  73165. };
  73166. }
  73167. declare module BABYLON {
  73168. /**
  73169. * Enum that determines the text-wrapping mode to use.
  73170. */
  73171. export enum InspectableType {
  73172. /**
  73173. * Checkbox for booleans
  73174. */
  73175. Checkbox = 0,
  73176. /**
  73177. * Sliders for numbers
  73178. */
  73179. Slider = 1,
  73180. /**
  73181. * Vector3
  73182. */
  73183. Vector3 = 2,
  73184. /**
  73185. * Quaternions
  73186. */
  73187. Quaternion = 3,
  73188. /**
  73189. * Color3
  73190. */
  73191. Color3 = 4,
  73192. /**
  73193. * String
  73194. */
  73195. String = 5
  73196. }
  73197. /**
  73198. * Interface used to define custom inspectable properties.
  73199. * This interface is used by the inspector to display custom property grids
  73200. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  73201. */
  73202. export interface IInspectable {
  73203. /**
  73204. * Gets the label to display
  73205. */
  73206. label: string;
  73207. /**
  73208. * Gets the name of the property to edit
  73209. */
  73210. propertyName: string;
  73211. /**
  73212. * Gets the type of the editor to use
  73213. */
  73214. type: InspectableType;
  73215. /**
  73216. * Gets the minimum value of the property when using in "slider" mode
  73217. */
  73218. min?: number;
  73219. /**
  73220. * Gets the maximum value of the property when using in "slider" mode
  73221. */
  73222. max?: number;
  73223. /**
  73224. * Gets the setp to use when using in "slider" mode
  73225. */
  73226. step?: number;
  73227. }
  73228. }
  73229. declare module BABYLON {
  73230. /**
  73231. * Class used to provide helper for timing
  73232. */
  73233. export class TimingTools {
  73234. /**
  73235. * Polyfill for setImmediate
  73236. * @param action defines the action to execute after the current execution block
  73237. */
  73238. static SetImmediate(action: () => void): void;
  73239. }
  73240. }
  73241. declare module BABYLON {
  73242. /**
  73243. * Class used to enable instatition of objects by class name
  73244. */
  73245. export class InstantiationTools {
  73246. /**
  73247. * Use this object to register external classes like custom textures or material
  73248. * to allow the laoders to instantiate them
  73249. */
  73250. static RegisteredExternalClasses: {
  73251. [key: string]: Object;
  73252. };
  73253. /**
  73254. * Tries to instantiate a new object from a given class name
  73255. * @param className defines the class name to instantiate
  73256. * @returns the new object or null if the system was not able to do the instantiation
  73257. */
  73258. static Instantiate(className: string): any;
  73259. }
  73260. }
  73261. declare module BABYLON {
  73262. /**
  73263. * This represents the required contract to create a new type of texture loader.
  73264. */
  73265. export interface IInternalTextureLoader {
  73266. /**
  73267. * Defines wether the loader supports cascade loading the different faces.
  73268. */
  73269. supportCascades: boolean;
  73270. /**
  73271. * This returns if the loader support the current file information.
  73272. * @param extension defines the file extension of the file being loaded
  73273. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73274. * @param fallback defines the fallback internal texture if any
  73275. * @param isBase64 defines whether the texture is encoded as a base64
  73276. * @param isBuffer defines whether the texture data are stored as a buffer
  73277. * @returns true if the loader can load the specified file
  73278. */
  73279. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  73280. /**
  73281. * Transform the url before loading if required.
  73282. * @param rootUrl the url of the texture
  73283. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73284. * @returns the transformed texture
  73285. */
  73286. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  73287. /**
  73288. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  73289. * @param rootUrl the url of the texture
  73290. * @param textureFormatInUse defines the current compressed format in use iun the engine
  73291. * @returns the fallback texture
  73292. */
  73293. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  73294. /**
  73295. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  73296. * @param data contains the texture data
  73297. * @param texture defines the BabylonJS internal texture
  73298. * @param createPolynomials will be true if polynomials have been requested
  73299. * @param onLoad defines the callback to trigger once the texture is ready
  73300. * @param onError defines the callback to trigger in case of error
  73301. */
  73302. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  73303. /**
  73304. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  73305. * @param data contains the texture data
  73306. * @param texture defines the BabylonJS internal texture
  73307. * @param callback defines the method to call once ready to upload
  73308. */
  73309. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  73310. }
  73311. }
  73312. declare module BABYLON {
  73313. interface Engine {
  73314. /**
  73315. * Creates a depth stencil cube texture.
  73316. * This is only available in WebGL 2.
  73317. * @param size The size of face edge in the cube texture.
  73318. * @param options The options defining the cube texture.
  73319. * @returns The cube texture
  73320. */
  73321. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  73322. /**
  73323. * Creates a cube texture
  73324. * @param rootUrl defines the url where the files to load is located
  73325. * @param scene defines the current scene
  73326. * @param files defines the list of files to load (1 per face)
  73327. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73328. * @param onLoad defines an optional callback raised when the texture is loaded
  73329. * @param onError defines an optional callback raised if there is an issue to load the texture
  73330. * @param format defines the format of the data
  73331. * @param forcedExtension defines the extension to use to pick the right loader
  73332. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73333. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73334. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73335. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  73336. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  73337. * @returns the cube texture as an InternalTexture
  73338. */
  73339. 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>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  73340. /**
  73341. * Creates a cube texture
  73342. * @param rootUrl defines the url where the files to load is located
  73343. * @param scene defines the current scene
  73344. * @param files defines the list of files to load (1 per face)
  73345. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73346. * @param onLoad defines an optional callback raised when the texture is loaded
  73347. * @param onError defines an optional callback raised if there is an issue to load the texture
  73348. * @param format defines the format of the data
  73349. * @param forcedExtension defines the extension to use to pick the right loader
  73350. * @returns the cube texture as an InternalTexture
  73351. */
  73352. 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;
  73353. /**
  73354. * Creates a cube texture
  73355. * @param rootUrl defines the url where the files to load is located
  73356. * @param scene defines the current scene
  73357. * @param files defines the list of files to load (1 per face)
  73358. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  73359. * @param onLoad defines an optional callback raised when the texture is loaded
  73360. * @param onError defines an optional callback raised if there is an issue to load the texture
  73361. * @param format defines the format of the data
  73362. * @param forcedExtension defines the extension to use to pick the right loader
  73363. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  73364. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73365. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73366. * @returns the cube texture as an InternalTexture
  73367. */
  73368. 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;
  73369. /** @hidden */
  73370. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73371. /** @hidden */
  73372. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73373. /** @hidden */
  73374. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  73375. /** @hidden */
  73376. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  73377. }
  73378. }
  73379. declare module BABYLON {
  73380. /**
  73381. * Class for creating a cube texture
  73382. */
  73383. export class CubeTexture extends BaseTexture {
  73384. private _delayedOnLoad;
  73385. /**
  73386. * The url of the texture
  73387. */
  73388. url: string;
  73389. /**
  73390. * Gets or sets the center of the bounding box associated with the cube texture.
  73391. * It must define where the camera used to render the texture was set
  73392. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73393. */
  73394. boundingBoxPosition: Vector3;
  73395. private _boundingBoxSize;
  73396. /**
  73397. * Gets or sets the size of the bounding box associated with the cube texture
  73398. * When defined, the cubemap will switch to local mode
  73399. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  73400. * @example https://www.babylonjs-playground.com/#RNASML
  73401. */
  73402. /**
  73403. * Returns the bounding box size
  73404. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  73405. */
  73406. boundingBoxSize: Vector3;
  73407. protected _rotationY: number;
  73408. /**
  73409. * Sets texture matrix rotation angle around Y axis in radians.
  73410. */
  73411. /**
  73412. * Gets texture matrix rotation angle around Y axis radians.
  73413. */
  73414. rotationY: number;
  73415. /**
  73416. * Are mip maps generated for this texture or not.
  73417. */
  73418. readonly noMipmap: boolean;
  73419. private _noMipmap;
  73420. private _files;
  73421. private _extensions;
  73422. private _textureMatrix;
  73423. private _format;
  73424. private _createPolynomials;
  73425. /** @hidden */
  73426. _prefiltered: boolean;
  73427. /**
  73428. * Creates a cube texture from an array of image urls
  73429. * @param files defines an array of image urls
  73430. * @param scene defines the hosting scene
  73431. * @param noMipmap specifies if mip maps are not used
  73432. * @returns a cube texture
  73433. */
  73434. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  73435. /**
  73436. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  73437. * @param url defines the url of the prefiltered texture
  73438. * @param scene defines the scene the texture is attached to
  73439. * @param forcedExtension defines the extension of the file if different from the url
  73440. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73441. * @return the prefiltered texture
  73442. */
  73443. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  73444. /**
  73445. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  73446. * as prefiltered data.
  73447. * @param rootUrl defines the url of the texture or the root name of the six images
  73448. * @param scene defines the scene the texture is attached to
  73449. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  73450. * @param noMipmap defines if mipmaps should be created or not
  73451. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  73452. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  73453. * @param onError defines a callback triggered in case of error during load
  73454. * @param format defines the internal format to use for the texture once loaded
  73455. * @param prefiltered defines whether or not the texture is created from prefiltered data
  73456. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  73457. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  73458. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  73459. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  73460. * @return the cube texture
  73461. */
  73462. constructor(rootUrl: string, scene: Scene, 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);
  73463. /**
  73464. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  73465. */
  73466. readonly isPrefiltered: boolean;
  73467. /**
  73468. * Get the current class name of the texture useful for serialization or dynamic coding.
  73469. * @returns "CubeTexture"
  73470. */
  73471. getClassName(): string;
  73472. /**
  73473. * Update the url (and optional buffer) of this texture if url was null during construction.
  73474. * @param url the url of the texture
  73475. * @param forcedExtension defines the extension to use
  73476. * @param onLoad callback called when the texture is loaded (defaults to null)
  73477. */
  73478. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  73479. /**
  73480. * Delays loading of the cube texture
  73481. * @param forcedExtension defines the extension to use
  73482. */
  73483. delayLoad(forcedExtension?: string): void;
  73484. /**
  73485. * Returns the reflection texture matrix
  73486. * @returns the reflection texture matrix
  73487. */
  73488. getReflectionTextureMatrix(): Matrix;
  73489. /**
  73490. * Sets the reflection texture matrix
  73491. * @param value Reflection texture matrix
  73492. */
  73493. setReflectionTextureMatrix(value: Matrix): void;
  73494. /**
  73495. * Parses text to create a cube texture
  73496. * @param parsedTexture define the serialized text to read from
  73497. * @param scene defines the hosting scene
  73498. * @param rootUrl defines the root url of the cube texture
  73499. * @returns a cube texture
  73500. */
  73501. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  73502. /**
  73503. * Makes a clone, or deep copy, of the cube texture
  73504. * @returns a new cube texture
  73505. */
  73506. clone(): CubeTexture;
  73507. }
  73508. }
  73509. declare module BABYLON {
  73510. /**
  73511. * Manages the defines for the Material
  73512. */
  73513. export class MaterialDefines {
  73514. /** @hidden */
  73515. protected _keys: string[];
  73516. private _isDirty;
  73517. /** @hidden */
  73518. _renderId: number;
  73519. /** @hidden */
  73520. _areLightsDirty: boolean;
  73521. /** @hidden */
  73522. _areLightsDisposed: boolean;
  73523. /** @hidden */
  73524. _areAttributesDirty: boolean;
  73525. /** @hidden */
  73526. _areTexturesDirty: boolean;
  73527. /** @hidden */
  73528. _areFresnelDirty: boolean;
  73529. /** @hidden */
  73530. _areMiscDirty: boolean;
  73531. /** @hidden */
  73532. _areImageProcessingDirty: boolean;
  73533. /** @hidden */
  73534. _normals: boolean;
  73535. /** @hidden */
  73536. _uvs: boolean;
  73537. /** @hidden */
  73538. _needNormals: boolean;
  73539. /** @hidden */
  73540. _needUVs: boolean;
  73541. [id: string]: any;
  73542. /**
  73543. * Specifies if the material needs to be re-calculated
  73544. */
  73545. readonly isDirty: boolean;
  73546. /**
  73547. * Marks the material to indicate that it has been re-calculated
  73548. */
  73549. markAsProcessed(): void;
  73550. /**
  73551. * Marks the material to indicate that it needs to be re-calculated
  73552. */
  73553. markAsUnprocessed(): void;
  73554. /**
  73555. * Marks the material to indicate all of its defines need to be re-calculated
  73556. */
  73557. markAllAsDirty(): void;
  73558. /**
  73559. * Marks the material to indicate that image processing needs to be re-calculated
  73560. */
  73561. markAsImageProcessingDirty(): void;
  73562. /**
  73563. * Marks the material to indicate the lights need to be re-calculated
  73564. * @param disposed Defines whether the light is dirty due to dispose or not
  73565. */
  73566. markAsLightDirty(disposed?: boolean): void;
  73567. /**
  73568. * Marks the attribute state as changed
  73569. */
  73570. markAsAttributesDirty(): void;
  73571. /**
  73572. * Marks the texture state as changed
  73573. */
  73574. markAsTexturesDirty(): void;
  73575. /**
  73576. * Marks the fresnel state as changed
  73577. */
  73578. markAsFresnelDirty(): void;
  73579. /**
  73580. * Marks the misc state as changed
  73581. */
  73582. markAsMiscDirty(): void;
  73583. /**
  73584. * Rebuilds the material defines
  73585. */
  73586. rebuild(): void;
  73587. /**
  73588. * Specifies if two material defines are equal
  73589. * @param other - A material define instance to compare to
  73590. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  73591. */
  73592. isEqual(other: MaterialDefines): boolean;
  73593. /**
  73594. * Clones this instance's defines to another instance
  73595. * @param other - material defines to clone values to
  73596. */
  73597. cloneTo(other: MaterialDefines): void;
  73598. /**
  73599. * Resets the material define values
  73600. */
  73601. reset(): void;
  73602. /**
  73603. * Converts the material define values to a string
  73604. * @returns - String of material define information
  73605. */
  73606. toString(): string;
  73607. }
  73608. }
  73609. declare module BABYLON {
  73610. /**
  73611. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  73612. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  73613. * 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;
  73614. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  73615. */
  73616. export class ColorCurves {
  73617. private _dirty;
  73618. private _tempColor;
  73619. private _globalCurve;
  73620. private _highlightsCurve;
  73621. private _midtonesCurve;
  73622. private _shadowsCurve;
  73623. private _positiveCurve;
  73624. private _negativeCurve;
  73625. private _globalHue;
  73626. private _globalDensity;
  73627. private _globalSaturation;
  73628. private _globalExposure;
  73629. /**
  73630. * Gets the global Hue value.
  73631. * 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).
  73632. */
  73633. /**
  73634. * Sets the global Hue value.
  73635. * 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).
  73636. */
  73637. globalHue: number;
  73638. /**
  73639. * Gets the global Density value.
  73640. * 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.
  73641. * Values less than zero provide a filter of opposite hue.
  73642. */
  73643. /**
  73644. * Sets the global Density value.
  73645. * 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.
  73646. * Values less than zero provide a filter of opposite hue.
  73647. */
  73648. globalDensity: number;
  73649. /**
  73650. * Gets the global Saturation value.
  73651. * 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.
  73652. */
  73653. /**
  73654. * Sets the global Saturation value.
  73655. * 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.
  73656. */
  73657. globalSaturation: number;
  73658. /**
  73659. * Gets the global Exposure value.
  73660. * 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.
  73661. */
  73662. /**
  73663. * Sets the global Exposure value.
  73664. * 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.
  73665. */
  73666. globalExposure: number;
  73667. private _highlightsHue;
  73668. private _highlightsDensity;
  73669. private _highlightsSaturation;
  73670. private _highlightsExposure;
  73671. /**
  73672. * Gets the highlights Hue value.
  73673. * 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).
  73674. */
  73675. /**
  73676. * Sets the highlights Hue value.
  73677. * 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).
  73678. */
  73679. highlightsHue: number;
  73680. /**
  73681. * Gets the highlights Density value.
  73682. * 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.
  73683. * Values less than zero provide a filter of opposite hue.
  73684. */
  73685. /**
  73686. * Sets the highlights Density value.
  73687. * 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.
  73688. * Values less than zero provide a filter of opposite hue.
  73689. */
  73690. highlightsDensity: number;
  73691. /**
  73692. * Gets the highlights Saturation value.
  73693. * 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.
  73694. */
  73695. /**
  73696. * Sets the highlights Saturation value.
  73697. * 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.
  73698. */
  73699. highlightsSaturation: number;
  73700. /**
  73701. * Gets the highlights Exposure value.
  73702. * 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.
  73703. */
  73704. /**
  73705. * Sets the highlights Exposure value.
  73706. * 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.
  73707. */
  73708. highlightsExposure: number;
  73709. private _midtonesHue;
  73710. private _midtonesDensity;
  73711. private _midtonesSaturation;
  73712. private _midtonesExposure;
  73713. /**
  73714. * Gets the midtones Hue value.
  73715. * 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).
  73716. */
  73717. /**
  73718. * Sets the midtones Hue value.
  73719. * 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).
  73720. */
  73721. midtonesHue: number;
  73722. /**
  73723. * Gets the midtones Density value.
  73724. * 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.
  73725. * Values less than zero provide a filter of opposite hue.
  73726. */
  73727. /**
  73728. * Sets the midtones Density value.
  73729. * 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.
  73730. * Values less than zero provide a filter of opposite hue.
  73731. */
  73732. midtonesDensity: number;
  73733. /**
  73734. * Gets the midtones Saturation value.
  73735. * 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.
  73736. */
  73737. /**
  73738. * Sets the midtones Saturation value.
  73739. * 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.
  73740. */
  73741. midtonesSaturation: number;
  73742. /**
  73743. * Gets the midtones Exposure value.
  73744. * 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.
  73745. */
  73746. /**
  73747. * Sets the midtones Exposure value.
  73748. * 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.
  73749. */
  73750. midtonesExposure: number;
  73751. private _shadowsHue;
  73752. private _shadowsDensity;
  73753. private _shadowsSaturation;
  73754. private _shadowsExposure;
  73755. /**
  73756. * Gets the shadows Hue value.
  73757. * 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).
  73758. */
  73759. /**
  73760. * Sets the shadows Hue value.
  73761. * 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).
  73762. */
  73763. shadowsHue: number;
  73764. /**
  73765. * Gets the shadows Density value.
  73766. * 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.
  73767. * Values less than zero provide a filter of opposite hue.
  73768. */
  73769. /**
  73770. * Sets the shadows Density value.
  73771. * 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.
  73772. * Values less than zero provide a filter of opposite hue.
  73773. */
  73774. shadowsDensity: number;
  73775. /**
  73776. * Gets the shadows Saturation value.
  73777. * 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.
  73778. */
  73779. /**
  73780. * Sets the shadows Saturation value.
  73781. * 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.
  73782. */
  73783. shadowsSaturation: number;
  73784. /**
  73785. * Gets the shadows Exposure value.
  73786. * 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.
  73787. */
  73788. /**
  73789. * Sets the shadows Exposure value.
  73790. * 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.
  73791. */
  73792. shadowsExposure: number;
  73793. /**
  73794. * Returns the class name
  73795. * @returns The class name
  73796. */
  73797. getClassName(): string;
  73798. /**
  73799. * Binds the color curves to the shader.
  73800. * @param colorCurves The color curve to bind
  73801. * @param effect The effect to bind to
  73802. * @param positiveUniform The positive uniform shader parameter
  73803. * @param neutralUniform The neutral uniform shader parameter
  73804. * @param negativeUniform The negative uniform shader parameter
  73805. */
  73806. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  73807. /**
  73808. * Prepare the list of uniforms associated with the ColorCurves effects.
  73809. * @param uniformsList The list of uniforms used in the effect
  73810. */
  73811. static PrepareUniforms(uniformsList: string[]): void;
  73812. /**
  73813. * Returns color grading data based on a hue, density, saturation and exposure value.
  73814. * @param filterHue The hue of the color filter.
  73815. * @param filterDensity The density of the color filter.
  73816. * @param saturation The saturation.
  73817. * @param exposure The exposure.
  73818. * @param result The result data container.
  73819. */
  73820. private getColorGradingDataToRef;
  73821. /**
  73822. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  73823. * @param value The input slider value in range [-100,100].
  73824. * @returns Adjusted value.
  73825. */
  73826. private static applyColorGradingSliderNonlinear;
  73827. /**
  73828. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  73829. * @param hue The hue (H) input.
  73830. * @param saturation The saturation (S) input.
  73831. * @param brightness The brightness (B) input.
  73832. * @result An RGBA color represented as Vector4.
  73833. */
  73834. private static fromHSBToRef;
  73835. /**
  73836. * Returns a value clamped between min and max
  73837. * @param value The value to clamp
  73838. * @param min The minimum of value
  73839. * @param max The maximum of value
  73840. * @returns The clamped value.
  73841. */
  73842. private static clamp;
  73843. /**
  73844. * Clones the current color curve instance.
  73845. * @return The cloned curves
  73846. */
  73847. clone(): ColorCurves;
  73848. /**
  73849. * Serializes the current color curve instance to a json representation.
  73850. * @return a JSON representation
  73851. */
  73852. serialize(): any;
  73853. /**
  73854. * Parses the color curve from a json representation.
  73855. * @param source the JSON source to parse
  73856. * @return The parsed curves
  73857. */
  73858. static Parse(source: any): ColorCurves;
  73859. }
  73860. }
  73861. declare module BABYLON {
  73862. /**
  73863. * Interface to follow in your material defines to integrate easily the
  73864. * Image proccessing functions.
  73865. * @hidden
  73866. */
  73867. export interface IImageProcessingConfigurationDefines {
  73868. IMAGEPROCESSING: boolean;
  73869. VIGNETTE: boolean;
  73870. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73871. VIGNETTEBLENDMODEOPAQUE: boolean;
  73872. TONEMAPPING: boolean;
  73873. TONEMAPPING_ACES: boolean;
  73874. CONTRAST: boolean;
  73875. EXPOSURE: boolean;
  73876. COLORCURVES: boolean;
  73877. COLORGRADING: boolean;
  73878. COLORGRADING3D: boolean;
  73879. SAMPLER3DGREENDEPTH: boolean;
  73880. SAMPLER3DBGRMAP: boolean;
  73881. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73882. }
  73883. /**
  73884. * @hidden
  73885. */
  73886. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  73887. IMAGEPROCESSING: boolean;
  73888. VIGNETTE: boolean;
  73889. VIGNETTEBLENDMODEMULTIPLY: boolean;
  73890. VIGNETTEBLENDMODEOPAQUE: boolean;
  73891. TONEMAPPING: boolean;
  73892. TONEMAPPING_ACES: boolean;
  73893. CONTRAST: boolean;
  73894. COLORCURVES: boolean;
  73895. COLORGRADING: boolean;
  73896. COLORGRADING3D: boolean;
  73897. SAMPLER3DGREENDEPTH: boolean;
  73898. SAMPLER3DBGRMAP: boolean;
  73899. IMAGEPROCESSINGPOSTPROCESS: boolean;
  73900. EXPOSURE: boolean;
  73901. constructor();
  73902. }
  73903. /**
  73904. * This groups together the common properties used for image processing either in direct forward pass
  73905. * or through post processing effect depending on the use of the image processing pipeline in your scene
  73906. * or not.
  73907. */
  73908. export class ImageProcessingConfiguration {
  73909. /**
  73910. * Default tone mapping applied in BabylonJS.
  73911. */
  73912. static readonly TONEMAPPING_STANDARD: number;
  73913. /**
  73914. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  73915. * to other engines rendering to increase portability.
  73916. */
  73917. static readonly TONEMAPPING_ACES: number;
  73918. /**
  73919. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  73920. */
  73921. colorCurves: Nullable<ColorCurves>;
  73922. private _colorCurvesEnabled;
  73923. /**
  73924. * Gets wether the color curves effect is enabled.
  73925. */
  73926. /**
  73927. * Sets wether the color curves effect is enabled.
  73928. */
  73929. colorCurvesEnabled: boolean;
  73930. private _colorGradingTexture;
  73931. /**
  73932. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73933. */
  73934. /**
  73935. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  73936. */
  73937. colorGradingTexture: Nullable<BaseTexture>;
  73938. private _colorGradingEnabled;
  73939. /**
  73940. * Gets wether the color grading effect is enabled.
  73941. */
  73942. /**
  73943. * Sets wether the color grading effect is enabled.
  73944. */
  73945. colorGradingEnabled: boolean;
  73946. private _colorGradingWithGreenDepth;
  73947. /**
  73948. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  73949. */
  73950. /**
  73951. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  73952. */
  73953. colorGradingWithGreenDepth: boolean;
  73954. private _colorGradingBGR;
  73955. /**
  73956. * Gets wether the color grading texture contains BGR values.
  73957. */
  73958. /**
  73959. * Sets wether the color grading texture contains BGR values.
  73960. */
  73961. colorGradingBGR: boolean;
  73962. /** @hidden */
  73963. _exposure: number;
  73964. /**
  73965. * Gets the Exposure used in the effect.
  73966. */
  73967. /**
  73968. * Sets the Exposure used in the effect.
  73969. */
  73970. exposure: number;
  73971. private _toneMappingEnabled;
  73972. /**
  73973. * Gets wether the tone mapping effect is enabled.
  73974. */
  73975. /**
  73976. * Sets wether the tone mapping effect is enabled.
  73977. */
  73978. toneMappingEnabled: boolean;
  73979. private _toneMappingType;
  73980. /**
  73981. * Gets the type of tone mapping effect.
  73982. */
  73983. /**
  73984. * Sets the type of tone mapping effect used in BabylonJS.
  73985. */
  73986. toneMappingType: number;
  73987. protected _contrast: number;
  73988. /**
  73989. * Gets the contrast used in the effect.
  73990. */
  73991. /**
  73992. * Sets the contrast used in the effect.
  73993. */
  73994. contrast: number;
  73995. /**
  73996. * Vignette stretch size.
  73997. */
  73998. vignetteStretch: number;
  73999. /**
  74000. * Vignette centre X Offset.
  74001. */
  74002. vignetteCentreX: number;
  74003. /**
  74004. * Vignette centre Y Offset.
  74005. */
  74006. vignetteCentreY: number;
  74007. /**
  74008. * Vignette weight or intensity of the vignette effect.
  74009. */
  74010. vignetteWeight: number;
  74011. /**
  74012. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  74013. * if vignetteEnabled is set to true.
  74014. */
  74015. vignetteColor: Color4;
  74016. /**
  74017. * Camera field of view used by the Vignette effect.
  74018. */
  74019. vignetteCameraFov: number;
  74020. private _vignetteBlendMode;
  74021. /**
  74022. * Gets the vignette blend mode allowing different kind of effect.
  74023. */
  74024. /**
  74025. * Sets the vignette blend mode allowing different kind of effect.
  74026. */
  74027. vignetteBlendMode: number;
  74028. private _vignetteEnabled;
  74029. /**
  74030. * Gets wether the vignette effect is enabled.
  74031. */
  74032. /**
  74033. * Sets wether the vignette effect is enabled.
  74034. */
  74035. vignetteEnabled: boolean;
  74036. private _applyByPostProcess;
  74037. /**
  74038. * Gets wether the image processing is applied through a post process or not.
  74039. */
  74040. /**
  74041. * Sets wether the image processing is applied through a post process or not.
  74042. */
  74043. applyByPostProcess: boolean;
  74044. private _isEnabled;
  74045. /**
  74046. * Gets wether the image processing is enabled or not.
  74047. */
  74048. /**
  74049. * Sets wether the image processing is enabled or not.
  74050. */
  74051. isEnabled: boolean;
  74052. /**
  74053. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  74054. */
  74055. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  74056. /**
  74057. * Method called each time the image processing information changes requires to recompile the effect.
  74058. */
  74059. protected _updateParameters(): void;
  74060. /**
  74061. * Gets the current class name.
  74062. * @return "ImageProcessingConfiguration"
  74063. */
  74064. getClassName(): string;
  74065. /**
  74066. * Prepare the list of uniforms associated with the Image Processing effects.
  74067. * @param uniforms The list of uniforms used in the effect
  74068. * @param defines the list of defines currently in use
  74069. */
  74070. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  74071. /**
  74072. * Prepare the list of samplers associated with the Image Processing effects.
  74073. * @param samplersList The list of uniforms used in the effect
  74074. * @param defines the list of defines currently in use
  74075. */
  74076. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  74077. /**
  74078. * Prepare the list of defines associated to the shader.
  74079. * @param defines the list of defines to complete
  74080. * @param forPostProcess Define if we are currently in post process mode or not
  74081. */
  74082. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  74083. /**
  74084. * Returns true if all the image processing information are ready.
  74085. * @returns True if ready, otherwise, false
  74086. */
  74087. isReady(): boolean;
  74088. /**
  74089. * Binds the image processing to the shader.
  74090. * @param effect The effect to bind to
  74091. * @param aspectRatio Define the current aspect ratio of the effect
  74092. */
  74093. bind(effect: Effect, aspectRatio?: number): void;
  74094. /**
  74095. * Clones the current image processing instance.
  74096. * @return The cloned image processing
  74097. */
  74098. clone(): ImageProcessingConfiguration;
  74099. /**
  74100. * Serializes the current image processing instance to a json representation.
  74101. * @return a JSON representation
  74102. */
  74103. serialize(): any;
  74104. /**
  74105. * Parses the image processing from a json representation.
  74106. * @param source the JSON source to parse
  74107. * @return The parsed image processing
  74108. */
  74109. static Parse(source: any): ImageProcessingConfiguration;
  74110. private static _VIGNETTEMODE_MULTIPLY;
  74111. private static _VIGNETTEMODE_OPAQUE;
  74112. /**
  74113. * Used to apply the vignette as a mix with the pixel color.
  74114. */
  74115. static readonly VIGNETTEMODE_MULTIPLY: number;
  74116. /**
  74117. * Used to apply the vignette as a replacement of the pixel color.
  74118. */
  74119. static readonly VIGNETTEMODE_OPAQUE: number;
  74120. }
  74121. }
  74122. declare module BABYLON {
  74123. /** @hidden */
  74124. export var postprocessVertexShader: {
  74125. name: string;
  74126. shader: string;
  74127. };
  74128. }
  74129. declare module BABYLON {
  74130. /** Defines supported spaces */
  74131. export enum Space {
  74132. /** Local (object) space */
  74133. LOCAL = 0,
  74134. /** World space */
  74135. WORLD = 1,
  74136. /** Bone space */
  74137. BONE = 2
  74138. }
  74139. /** Defines the 3 main axes */
  74140. export class Axis {
  74141. /** X axis */
  74142. static X: Vector3;
  74143. /** Y axis */
  74144. static Y: Vector3;
  74145. /** Z axis */
  74146. static Z: Vector3;
  74147. }
  74148. }
  74149. declare module BABYLON {
  74150. /**
  74151. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  74152. * This is the base of the follow, arc rotate cameras and Free camera
  74153. * @see http://doc.babylonjs.com/features/cameras
  74154. */
  74155. export class TargetCamera extends Camera {
  74156. private static _RigCamTransformMatrix;
  74157. private static _TargetTransformMatrix;
  74158. private static _TargetFocalPoint;
  74159. /**
  74160. * Define the current direction the camera is moving to
  74161. */
  74162. cameraDirection: Vector3;
  74163. /**
  74164. * Define the current rotation the camera is rotating to
  74165. */
  74166. cameraRotation: Vector2;
  74167. /**
  74168. * When set, the up vector of the camera will be updated by the rotation of the camera
  74169. */
  74170. updateUpVectorFromRotation: boolean;
  74171. private _tmpQuaternion;
  74172. /**
  74173. * Define the current rotation of the camera
  74174. */
  74175. rotation: Vector3;
  74176. /**
  74177. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  74178. */
  74179. rotationQuaternion: Quaternion;
  74180. /**
  74181. * Define the current speed of the camera
  74182. */
  74183. speed: number;
  74184. /**
  74185. * Add cconstraint to the camera to prevent it to move freely in all directions and
  74186. * around all axis.
  74187. */
  74188. noRotationConstraint: boolean;
  74189. /**
  74190. * Define the current target of the camera as an object or a position.
  74191. */
  74192. lockedTarget: any;
  74193. /** @hidden */
  74194. _currentTarget: Vector3;
  74195. /** @hidden */
  74196. _initialFocalDistance: number;
  74197. /** @hidden */
  74198. _viewMatrix: Matrix;
  74199. /** @hidden */
  74200. _camMatrix: Matrix;
  74201. /** @hidden */
  74202. _cameraTransformMatrix: Matrix;
  74203. /** @hidden */
  74204. _cameraRotationMatrix: Matrix;
  74205. /** @hidden */
  74206. _referencePoint: Vector3;
  74207. /** @hidden */
  74208. _transformedReferencePoint: Vector3;
  74209. protected _globalCurrentTarget: Vector3;
  74210. protected _globalCurrentUpVector: Vector3;
  74211. /** @hidden */
  74212. _reset: () => void;
  74213. private _defaultUp;
  74214. /**
  74215. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  74216. * This is the base of the follow, arc rotate cameras and Free camera
  74217. * @see http://doc.babylonjs.com/features/cameras
  74218. * @param name Defines the name of the camera in the scene
  74219. * @param position Defines the start position of the camera in the scene
  74220. * @param scene Defines the scene the camera belongs to
  74221. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  74222. */
  74223. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  74224. /**
  74225. * Gets the position in front of the camera at a given distance.
  74226. * @param distance The distance from the camera we want the position to be
  74227. * @returns the position
  74228. */
  74229. getFrontPosition(distance: number): Vector3;
  74230. /** @hidden */
  74231. _getLockedTargetPosition(): Nullable<Vector3>;
  74232. private _storedPosition;
  74233. private _storedRotation;
  74234. private _storedRotationQuaternion;
  74235. /**
  74236. * Store current camera state of the camera (fov, position, rotation, etc..)
  74237. * @returns the camera
  74238. */
  74239. storeState(): Camera;
  74240. /**
  74241. * Restored camera state. You must call storeState() first
  74242. * @returns whether it was successful or not
  74243. * @hidden
  74244. */
  74245. _restoreStateValues(): boolean;
  74246. /** @hidden */
  74247. _initCache(): void;
  74248. /** @hidden */
  74249. _updateCache(ignoreParentClass?: boolean): void;
  74250. /** @hidden */
  74251. _isSynchronizedViewMatrix(): boolean;
  74252. /** @hidden */
  74253. _computeLocalCameraSpeed(): number;
  74254. /**
  74255. * Defines the target the camera should look at.
  74256. * @param target Defines the new target as a Vector or a mesh
  74257. */
  74258. setTarget(target: Vector3): void;
  74259. /**
  74260. * Return the current target position of the camera. This value is expressed in local space.
  74261. * @returns the target position
  74262. */
  74263. getTarget(): Vector3;
  74264. /** @hidden */
  74265. _decideIfNeedsToMove(): boolean;
  74266. /** @hidden */
  74267. _updatePosition(): void;
  74268. /** @hidden */
  74269. _checkInputs(): void;
  74270. protected _updateCameraRotationMatrix(): void;
  74271. /**
  74272. * 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)
  74273. * @returns the current camera
  74274. */
  74275. private _rotateUpVectorWithCameraRotationMatrix;
  74276. private _cachedRotationZ;
  74277. private _cachedQuaternionRotationZ;
  74278. /** @hidden */
  74279. _getViewMatrix(): Matrix;
  74280. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  74281. /**
  74282. * @hidden
  74283. */
  74284. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  74285. /**
  74286. * @hidden
  74287. */
  74288. _updateRigCameras(): void;
  74289. private _getRigCamPositionAndTarget;
  74290. /**
  74291. * Gets the current object class name.
  74292. * @return the class name
  74293. */
  74294. getClassName(): string;
  74295. }
  74296. }
  74297. declare module BABYLON {
  74298. /**
  74299. * Gather the list of keyboard event types as constants.
  74300. */
  74301. export class KeyboardEventTypes {
  74302. /**
  74303. * The keydown event is fired when a key becomes active (pressed).
  74304. */
  74305. static readonly KEYDOWN: number;
  74306. /**
  74307. * The keyup event is fired when a key has been released.
  74308. */
  74309. static readonly KEYUP: number;
  74310. }
  74311. /**
  74312. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74313. */
  74314. export class KeyboardInfo {
  74315. /**
  74316. * Defines the type of event (KeyboardEventTypes)
  74317. */
  74318. type: number;
  74319. /**
  74320. * Defines the related dom event
  74321. */
  74322. event: KeyboardEvent;
  74323. /**
  74324. * Instantiates a new keyboard info.
  74325. * This class is used to store keyboard related info for the onKeyboardObservable event.
  74326. * @param type Defines the type of event (KeyboardEventTypes)
  74327. * @param event Defines the related dom event
  74328. */
  74329. constructor(
  74330. /**
  74331. * Defines the type of event (KeyboardEventTypes)
  74332. */
  74333. type: number,
  74334. /**
  74335. * Defines the related dom event
  74336. */
  74337. event: KeyboardEvent);
  74338. }
  74339. /**
  74340. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74341. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  74342. */
  74343. export class KeyboardInfoPre extends KeyboardInfo {
  74344. /**
  74345. * Defines the type of event (KeyboardEventTypes)
  74346. */
  74347. type: number;
  74348. /**
  74349. * Defines the related dom event
  74350. */
  74351. event: KeyboardEvent;
  74352. /**
  74353. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  74354. */
  74355. skipOnPointerObservable: boolean;
  74356. /**
  74357. * Instantiates a new keyboard pre info.
  74358. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  74359. * @param type Defines the type of event (KeyboardEventTypes)
  74360. * @param event Defines the related dom event
  74361. */
  74362. constructor(
  74363. /**
  74364. * Defines the type of event (KeyboardEventTypes)
  74365. */
  74366. type: number,
  74367. /**
  74368. * Defines the related dom event
  74369. */
  74370. event: KeyboardEvent);
  74371. }
  74372. }
  74373. declare module BABYLON {
  74374. /**
  74375. * Manage the keyboard inputs to control the movement of a free camera.
  74376. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74377. */
  74378. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  74379. /**
  74380. * Defines the camera the input is attached to.
  74381. */
  74382. camera: FreeCamera;
  74383. /**
  74384. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  74385. */
  74386. keysUp: number[];
  74387. /**
  74388. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  74389. */
  74390. keysDown: number[];
  74391. /**
  74392. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  74393. */
  74394. keysLeft: number[];
  74395. /**
  74396. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  74397. */
  74398. keysRight: number[];
  74399. private _keys;
  74400. private _onCanvasBlurObserver;
  74401. private _onKeyboardObserver;
  74402. private _engine;
  74403. private _scene;
  74404. /**
  74405. * Attach the input controls to a specific dom element to get the input from.
  74406. * @param element Defines the element the controls should be listened from
  74407. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74408. */
  74409. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74410. /**
  74411. * Detach the current controls from the specified dom element.
  74412. * @param element Defines the element to stop listening the inputs from
  74413. */
  74414. detachControl(element: Nullable<HTMLElement>): void;
  74415. /**
  74416. * Update the current camera state depending on the inputs that have been used this frame.
  74417. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74418. */
  74419. checkInputs(): void;
  74420. /**
  74421. * Gets the class name of the current intput.
  74422. * @returns the class name
  74423. */
  74424. getClassName(): string;
  74425. /** @hidden */
  74426. _onLostFocus(): void;
  74427. /**
  74428. * Get the friendly name associated with the input class.
  74429. * @returns the input friendly name
  74430. */
  74431. getSimpleName(): string;
  74432. }
  74433. }
  74434. declare module BABYLON {
  74435. /**
  74436. * Interface describing all the common properties and methods a shadow light needs to implement.
  74437. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  74438. * as well as binding the different shadow properties to the effects.
  74439. */
  74440. export interface IShadowLight extends Light {
  74441. /**
  74442. * The light id in the scene (used in scene.findLighById for instance)
  74443. */
  74444. id: string;
  74445. /**
  74446. * The position the shdow will be casted from.
  74447. */
  74448. position: Vector3;
  74449. /**
  74450. * In 2d mode (needCube being false), the direction used to cast the shadow.
  74451. */
  74452. direction: Vector3;
  74453. /**
  74454. * The transformed position. Position of the light in world space taking parenting in account.
  74455. */
  74456. transformedPosition: Vector3;
  74457. /**
  74458. * The transformed direction. Direction of the light in world space taking parenting in account.
  74459. */
  74460. transformedDirection: Vector3;
  74461. /**
  74462. * The friendly name of the light in the scene.
  74463. */
  74464. name: string;
  74465. /**
  74466. * Defines the shadow projection clipping minimum z value.
  74467. */
  74468. shadowMinZ: number;
  74469. /**
  74470. * Defines the shadow projection clipping maximum z value.
  74471. */
  74472. shadowMaxZ: number;
  74473. /**
  74474. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74475. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74476. */
  74477. computeTransformedInformation(): boolean;
  74478. /**
  74479. * Gets the scene the light belongs to.
  74480. * @returns The scene
  74481. */
  74482. getScene(): Scene;
  74483. /**
  74484. * Callback defining a custom Projection Matrix Builder.
  74485. * This can be used to override the default projection matrix computation.
  74486. */
  74487. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74488. /**
  74489. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74490. * @param matrix The materix to updated with the projection information
  74491. * @param viewMatrix The transform matrix of the light
  74492. * @param renderList The list of mesh to render in the map
  74493. * @returns The current light
  74494. */
  74495. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74496. /**
  74497. * Gets the current depth scale used in ESM.
  74498. * @returns The scale
  74499. */
  74500. getDepthScale(): number;
  74501. /**
  74502. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74503. * @returns true if a cube texture needs to be use
  74504. */
  74505. needCube(): boolean;
  74506. /**
  74507. * Detects if the projection matrix requires to be recomputed this frame.
  74508. * @returns true if it requires to be recomputed otherwise, false.
  74509. */
  74510. needProjectionMatrixCompute(): boolean;
  74511. /**
  74512. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74513. */
  74514. forceProjectionMatrixCompute(): void;
  74515. /**
  74516. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74517. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74518. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74519. */
  74520. getShadowDirection(faceIndex?: number): Vector3;
  74521. /**
  74522. * Gets the minZ used for shadow according to both the scene and the light.
  74523. * @param activeCamera The camera we are returning the min for
  74524. * @returns the depth min z
  74525. */
  74526. getDepthMinZ(activeCamera: Camera): number;
  74527. /**
  74528. * Gets the maxZ used for shadow according to both the scene and the light.
  74529. * @param activeCamera The camera we are returning the max for
  74530. * @returns the depth max z
  74531. */
  74532. getDepthMaxZ(activeCamera: Camera): number;
  74533. }
  74534. /**
  74535. * Base implementation IShadowLight
  74536. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  74537. */
  74538. export abstract class ShadowLight extends Light implements IShadowLight {
  74539. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  74540. protected _position: Vector3;
  74541. protected _setPosition(value: Vector3): void;
  74542. /**
  74543. * Sets the position the shadow will be casted from. Also use as the light position for both
  74544. * point and spot lights.
  74545. */
  74546. /**
  74547. * Sets the position the shadow will be casted from. Also use as the light position for both
  74548. * point and spot lights.
  74549. */
  74550. position: Vector3;
  74551. protected _direction: Vector3;
  74552. protected _setDirection(value: Vector3): void;
  74553. /**
  74554. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  74555. * Also use as the light direction on spot and directional lights.
  74556. */
  74557. /**
  74558. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  74559. * Also use as the light direction on spot and directional lights.
  74560. */
  74561. direction: Vector3;
  74562. private _shadowMinZ;
  74563. /**
  74564. * Gets the shadow projection clipping minimum z value.
  74565. */
  74566. /**
  74567. * Sets the shadow projection clipping minimum z value.
  74568. */
  74569. shadowMinZ: number;
  74570. private _shadowMaxZ;
  74571. /**
  74572. * Sets the shadow projection clipping maximum z value.
  74573. */
  74574. /**
  74575. * Gets the shadow projection clipping maximum z value.
  74576. */
  74577. shadowMaxZ: number;
  74578. /**
  74579. * Callback defining a custom Projection Matrix Builder.
  74580. * This can be used to override the default projection matrix computation.
  74581. */
  74582. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  74583. /**
  74584. * The transformed position. Position of the light in world space taking parenting in account.
  74585. */
  74586. transformedPosition: Vector3;
  74587. /**
  74588. * The transformed direction. Direction of the light in world space taking parenting in account.
  74589. */
  74590. transformedDirection: Vector3;
  74591. private _needProjectionMatrixCompute;
  74592. /**
  74593. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  74594. * @returns true if the information has been computed, false if it does not need to (no parenting)
  74595. */
  74596. computeTransformedInformation(): boolean;
  74597. /**
  74598. * Return the depth scale used for the shadow map.
  74599. * @returns the depth scale.
  74600. */
  74601. getDepthScale(): number;
  74602. /**
  74603. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  74604. * @param faceIndex The index of the face we are computed the direction to generate shadow
  74605. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  74606. */
  74607. getShadowDirection(faceIndex?: number): Vector3;
  74608. /**
  74609. * Returns the ShadowLight absolute position in the World.
  74610. * @returns the position vector in world space
  74611. */
  74612. getAbsolutePosition(): Vector3;
  74613. /**
  74614. * Sets the ShadowLight direction toward the passed target.
  74615. * @param target The point to target in local space
  74616. * @returns the updated ShadowLight direction
  74617. */
  74618. setDirectionToTarget(target: Vector3): Vector3;
  74619. /**
  74620. * Returns the light rotation in euler definition.
  74621. * @returns the x y z rotation in local space.
  74622. */
  74623. getRotation(): Vector3;
  74624. /**
  74625. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  74626. * @returns true if a cube texture needs to be use
  74627. */
  74628. needCube(): boolean;
  74629. /**
  74630. * Detects if the projection matrix requires to be recomputed this frame.
  74631. * @returns true if it requires to be recomputed otherwise, false.
  74632. */
  74633. needProjectionMatrixCompute(): boolean;
  74634. /**
  74635. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  74636. */
  74637. forceProjectionMatrixCompute(): void;
  74638. /** @hidden */
  74639. _initCache(): void;
  74640. /** @hidden */
  74641. _isSynchronized(): boolean;
  74642. /**
  74643. * Computes the world matrix of the node
  74644. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  74645. * @returns the world matrix
  74646. */
  74647. computeWorldMatrix(force?: boolean): Matrix;
  74648. /**
  74649. * Gets the minZ used for shadow according to both the scene and the light.
  74650. * @param activeCamera The camera we are returning the min for
  74651. * @returns the depth min z
  74652. */
  74653. getDepthMinZ(activeCamera: Camera): number;
  74654. /**
  74655. * Gets the maxZ used for shadow according to both the scene and the light.
  74656. * @param activeCamera The camera we are returning the max for
  74657. * @returns the depth max z
  74658. */
  74659. getDepthMaxZ(activeCamera: Camera): number;
  74660. /**
  74661. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  74662. * @param matrix The materix to updated with the projection information
  74663. * @param viewMatrix The transform matrix of the light
  74664. * @param renderList The list of mesh to render in the map
  74665. * @returns The current light
  74666. */
  74667. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  74668. }
  74669. }
  74670. declare module BABYLON {
  74671. /**
  74672. * "Static Class" containing the most commonly used helper while dealing with material for
  74673. * rendering purpose.
  74674. *
  74675. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  74676. *
  74677. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  74678. */
  74679. export class MaterialHelper {
  74680. /**
  74681. * Bind the current view position to an effect.
  74682. * @param effect The effect to be bound
  74683. * @param scene The scene the eyes position is used from
  74684. */
  74685. static BindEyePosition(effect: Effect, scene: Scene): void;
  74686. /**
  74687. * Helps preparing the defines values about the UVs in used in the effect.
  74688. * UVs are shared as much as we can accross channels in the shaders.
  74689. * @param texture The texture we are preparing the UVs for
  74690. * @param defines The defines to update
  74691. * @param key The channel key "diffuse", "specular"... used in the shader
  74692. */
  74693. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  74694. /**
  74695. * Binds a texture matrix value to its corrsponding uniform
  74696. * @param texture The texture to bind the matrix for
  74697. * @param uniformBuffer The uniform buffer receivin the data
  74698. * @param key The channel key "diffuse", "specular"... used in the shader
  74699. */
  74700. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  74701. /**
  74702. * Gets the current status of the fog (should it be enabled?)
  74703. * @param mesh defines the mesh to evaluate for fog support
  74704. * @param scene defines the hosting scene
  74705. * @returns true if fog must be enabled
  74706. */
  74707. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  74708. /**
  74709. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  74710. * @param mesh defines the current mesh
  74711. * @param scene defines the current scene
  74712. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  74713. * @param pointsCloud defines if point cloud rendering has to be turned on
  74714. * @param fogEnabled defines if fog has to be turned on
  74715. * @param alphaTest defines if alpha testing has to be turned on
  74716. * @param defines defines the current list of defines
  74717. */
  74718. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  74719. /**
  74720. * Helper used to prepare the list of defines associated with frame values for shader compilation
  74721. * @param scene defines the current scene
  74722. * @param engine defines the current engine
  74723. * @param defines specifies the list of active defines
  74724. * @param useInstances defines if instances have to be turned on
  74725. * @param useClipPlane defines if clip plane have to be turned on
  74726. */
  74727. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  74728. /**
  74729. * Prepares the defines for bones
  74730. * @param mesh The mesh containing the geometry data we will draw
  74731. * @param defines The defines to update
  74732. */
  74733. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  74734. /**
  74735. * Prepares the defines for morph targets
  74736. * @param mesh The mesh containing the geometry data we will draw
  74737. * @param defines The defines to update
  74738. */
  74739. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  74740. /**
  74741. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  74742. * @param mesh The mesh containing the geometry data we will draw
  74743. * @param defines The defines to update
  74744. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  74745. * @param useBones Precise whether bones should be used or not (override mesh info)
  74746. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  74747. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  74748. * @returns false if defines are considered not dirty and have not been checked
  74749. */
  74750. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  74751. /**
  74752. * Prepares the defines related to multiview
  74753. * @param scene The scene we are intending to draw
  74754. * @param defines The defines to update
  74755. */
  74756. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  74757. /**
  74758. * Prepares the defines related to the light information passed in parameter
  74759. * @param scene The scene we are intending to draw
  74760. * @param mesh The mesh the effect is compiling for
  74761. * @param light The light the effect is compiling for
  74762. * @param lightIndex The index of the light
  74763. * @param defines The defines to update
  74764. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74765. * @param state Defines the current state regarding what is needed (normals, etc...)
  74766. */
  74767. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  74768. needNormals: boolean;
  74769. needRebuild: boolean;
  74770. shadowEnabled: boolean;
  74771. specularEnabled: boolean;
  74772. lightmapMode: boolean;
  74773. }): void;
  74774. /**
  74775. * Prepares the defines related to the light information passed in parameter
  74776. * @param scene The scene we are intending to draw
  74777. * @param mesh The mesh the effect is compiling for
  74778. * @param defines The defines to update
  74779. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  74780. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  74781. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  74782. * @returns true if normals will be required for the rest of the effect
  74783. */
  74784. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  74785. /**
  74786. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  74787. * @param lightIndex defines the light index
  74788. * @param uniformsList The uniform list
  74789. * @param samplersList The sampler list
  74790. * @param projectedLightTexture defines if projected texture must be used
  74791. * @param uniformBuffersList defines an optional list of uniform buffers
  74792. */
  74793. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  74794. /**
  74795. * Prepares the uniforms and samplers list to be used in the effect
  74796. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  74797. * @param samplersList The sampler list
  74798. * @param defines The defines helping in the list generation
  74799. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  74800. */
  74801. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  74802. /**
  74803. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  74804. * @param defines The defines to update while falling back
  74805. * @param fallbacks The authorized effect fallbacks
  74806. * @param maxSimultaneousLights The maximum number of lights allowed
  74807. * @param rank the current rank of the Effect
  74808. * @returns The newly affected rank
  74809. */
  74810. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  74811. private static _TmpMorphInfluencers;
  74812. /**
  74813. * Prepares the list of attributes required for morph targets according to the effect defines.
  74814. * @param attribs The current list of supported attribs
  74815. * @param mesh The mesh to prepare the morph targets attributes for
  74816. * @param influencers The number of influencers
  74817. */
  74818. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  74819. /**
  74820. * Prepares the list of attributes required for morph targets according to the effect defines.
  74821. * @param attribs The current list of supported attribs
  74822. * @param mesh The mesh to prepare the morph targets attributes for
  74823. * @param defines The current Defines of the effect
  74824. */
  74825. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  74826. /**
  74827. * Prepares the list of attributes required for bones according to the effect defines.
  74828. * @param attribs The current list of supported attribs
  74829. * @param mesh The mesh to prepare the bones attributes for
  74830. * @param defines The current Defines of the effect
  74831. * @param fallbacks The current efffect fallback strategy
  74832. */
  74833. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  74834. /**
  74835. * Check and prepare the list of attributes required for instances according to the effect defines.
  74836. * @param attribs The current list of supported attribs
  74837. * @param defines The current MaterialDefines of the effect
  74838. */
  74839. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  74840. /**
  74841. * Add the list of attributes required for instances to the attribs array.
  74842. * @param attribs The current list of supported attribs
  74843. */
  74844. static PushAttributesForInstances(attribs: string[]): void;
  74845. /**
  74846. * Binds the light shadow information to the effect for the given mesh.
  74847. * @param light The light containing the generator
  74848. * @param scene The scene the lights belongs to
  74849. * @param mesh The mesh we are binding the information to render
  74850. * @param lightIndex The light index in the effect used to render the mesh
  74851. * @param effect The effect we are binding the data to
  74852. */
  74853. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  74854. /**
  74855. * Binds the light information to the effect.
  74856. * @param light The light containing the generator
  74857. * @param effect The effect we are binding the data to
  74858. * @param lightIndex The light index in the effect used to render
  74859. */
  74860. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  74861. /**
  74862. * Binds the lights information from the scene to the effect for the given mesh.
  74863. * @param light Light to bind
  74864. * @param lightIndex Light index
  74865. * @param scene The scene where the light belongs to
  74866. * @param mesh The mesh we are binding the information to render
  74867. * @param effect The effect we are binding the data to
  74868. * @param useSpecular Defines if specular is supported
  74869. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74870. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74871. */
  74872. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74873. /**
  74874. * Binds the lights information from the scene to the effect for the given mesh.
  74875. * @param scene The scene the lights belongs to
  74876. * @param mesh The mesh we are binding the information to render
  74877. * @param effect The effect we are binding the data to
  74878. * @param defines The generated defines for the effect
  74879. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  74880. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  74881. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  74882. */
  74883. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  74884. private static _tempFogColor;
  74885. /**
  74886. * Binds the fog information from the scene to the effect for the given mesh.
  74887. * @param scene The scene the lights belongs to
  74888. * @param mesh The mesh we are binding the information to render
  74889. * @param effect The effect we are binding the data to
  74890. * @param linearSpace Defines if the fog effect is applied in linear space
  74891. */
  74892. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  74893. /**
  74894. * Binds the bones information from the mesh to the effect.
  74895. * @param mesh The mesh we are binding the information to render
  74896. * @param effect The effect we are binding the data to
  74897. */
  74898. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  74899. /**
  74900. * Binds the morph targets information from the mesh to the effect.
  74901. * @param abstractMesh The mesh we are binding the information to render
  74902. * @param effect The effect we are binding the data to
  74903. */
  74904. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  74905. /**
  74906. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  74907. * @param defines The generated defines used in the effect
  74908. * @param effect The effect we are binding the data to
  74909. * @param scene The scene we are willing to render with logarithmic scale for
  74910. */
  74911. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  74912. /**
  74913. * Binds the clip plane information from the scene to the effect.
  74914. * @param scene The scene the clip plane information are extracted from
  74915. * @param effect The effect we are binding the data to
  74916. */
  74917. static BindClipPlane(effect: Effect, scene: Scene): void;
  74918. }
  74919. }
  74920. declare module BABYLON {
  74921. /** @hidden */
  74922. export var packingFunctions: {
  74923. name: string;
  74924. shader: string;
  74925. };
  74926. }
  74927. declare module BABYLON {
  74928. /** @hidden */
  74929. export var shadowMapPixelShader: {
  74930. name: string;
  74931. shader: string;
  74932. };
  74933. }
  74934. declare module BABYLON {
  74935. /** @hidden */
  74936. export var bonesDeclaration: {
  74937. name: string;
  74938. shader: string;
  74939. };
  74940. }
  74941. declare module BABYLON {
  74942. /** @hidden */
  74943. export var morphTargetsVertexGlobalDeclaration: {
  74944. name: string;
  74945. shader: string;
  74946. };
  74947. }
  74948. declare module BABYLON {
  74949. /** @hidden */
  74950. export var morphTargetsVertexDeclaration: {
  74951. name: string;
  74952. shader: string;
  74953. };
  74954. }
  74955. declare module BABYLON {
  74956. /** @hidden */
  74957. export var instancesDeclaration: {
  74958. name: string;
  74959. shader: string;
  74960. };
  74961. }
  74962. declare module BABYLON {
  74963. /** @hidden */
  74964. export var helperFunctions: {
  74965. name: string;
  74966. shader: string;
  74967. };
  74968. }
  74969. declare module BABYLON {
  74970. /** @hidden */
  74971. export var morphTargetsVertex: {
  74972. name: string;
  74973. shader: string;
  74974. };
  74975. }
  74976. declare module BABYLON {
  74977. /** @hidden */
  74978. export var instancesVertex: {
  74979. name: string;
  74980. shader: string;
  74981. };
  74982. }
  74983. declare module BABYLON {
  74984. /** @hidden */
  74985. export var bonesVertex: {
  74986. name: string;
  74987. shader: string;
  74988. };
  74989. }
  74990. declare module BABYLON {
  74991. /** @hidden */
  74992. export var shadowMapVertexShader: {
  74993. name: string;
  74994. shader: string;
  74995. };
  74996. }
  74997. declare module BABYLON {
  74998. /** @hidden */
  74999. export var depthBoxBlurPixelShader: {
  75000. name: string;
  75001. shader: string;
  75002. };
  75003. }
  75004. declare module BABYLON {
  75005. /**
  75006. * Defines the options associated with the creation of a custom shader for a shadow generator.
  75007. */
  75008. export interface ICustomShaderOptions {
  75009. /**
  75010. * Gets or sets the custom shader name to use
  75011. */
  75012. shaderName: string;
  75013. /**
  75014. * The list of attribute names used in the shader
  75015. */
  75016. attributes?: string[];
  75017. /**
  75018. * The list of unifrom names used in the shader
  75019. */
  75020. uniforms?: string[];
  75021. /**
  75022. * The list of sampler names used in the shader
  75023. */
  75024. samplers?: string[];
  75025. /**
  75026. * The list of defines used in the shader
  75027. */
  75028. defines?: string[];
  75029. }
  75030. /**
  75031. * Interface to implement to create a shadow generator compatible with BJS.
  75032. */
  75033. export interface IShadowGenerator {
  75034. /**
  75035. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75036. * @returns The render target texture if present otherwise, null
  75037. */
  75038. getShadowMap(): Nullable<RenderTargetTexture>;
  75039. /**
  75040. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75041. * @returns The render target texture if the shadow map is present otherwise, null
  75042. */
  75043. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75044. /**
  75045. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75046. * @param subMesh The submesh we want to render in the shadow map
  75047. * @param useInstances Defines wether will draw in the map using instances
  75048. * @returns true if ready otherwise, false
  75049. */
  75050. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75051. /**
  75052. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75053. * @param defines Defines of the material we want to update
  75054. * @param lightIndex Index of the light in the enabled light list of the material
  75055. */
  75056. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  75057. /**
  75058. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75059. * defined in the generator but impacting the effect).
  75060. * It implies the unifroms available on the materials are the standard BJS ones.
  75061. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75062. * @param effect The effect we are binfing the information for
  75063. */
  75064. bindShadowLight(lightIndex: string, effect: Effect): void;
  75065. /**
  75066. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  75067. * (eq to shadow prjection matrix * light transform matrix)
  75068. * @returns The transform matrix used to create the shadow map
  75069. */
  75070. getTransformMatrix(): Matrix;
  75071. /**
  75072. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  75073. * Cube and 2D textures for instance.
  75074. */
  75075. recreateShadowMap(): void;
  75076. /**
  75077. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75078. * @param onCompiled Callback triggered at the and of the effects compilation
  75079. * @param options Sets of optional options forcing the compilation with different modes
  75080. */
  75081. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  75082. useInstances: boolean;
  75083. }>): void;
  75084. /**
  75085. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75086. * @param options Sets of optional options forcing the compilation with different modes
  75087. * @returns A promise that resolves when the compilation completes
  75088. */
  75089. forceCompilationAsync(options?: Partial<{
  75090. useInstances: boolean;
  75091. }>): Promise<void>;
  75092. /**
  75093. * Serializes the shadow generator setup to a json object.
  75094. * @returns The serialized JSON object
  75095. */
  75096. serialize(): any;
  75097. /**
  75098. * Disposes the Shadow map and related Textures and effects.
  75099. */
  75100. dispose(): void;
  75101. }
  75102. /**
  75103. * Default implementation IShadowGenerator.
  75104. * This is the main object responsible of generating shadows in the framework.
  75105. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  75106. */
  75107. export class ShadowGenerator implements IShadowGenerator {
  75108. /**
  75109. * Shadow generator mode None: no filtering applied.
  75110. */
  75111. static readonly FILTER_NONE: number;
  75112. /**
  75113. * Shadow generator mode ESM: Exponential Shadow Mapping.
  75114. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75115. */
  75116. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  75117. /**
  75118. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  75119. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  75120. */
  75121. static readonly FILTER_POISSONSAMPLING: number;
  75122. /**
  75123. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  75124. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75125. */
  75126. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  75127. /**
  75128. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  75129. * edge artifacts on steep falloff.
  75130. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75131. */
  75132. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  75133. /**
  75134. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  75135. * edge artifacts on steep falloff.
  75136. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  75137. */
  75138. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  75139. /**
  75140. * Shadow generator mode PCF: Percentage Closer Filtering
  75141. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75142. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  75143. */
  75144. static readonly FILTER_PCF: number;
  75145. /**
  75146. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  75147. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  75148. * Contact Hardening
  75149. */
  75150. static readonly FILTER_PCSS: number;
  75151. /**
  75152. * Reserved for PCF and PCSS
  75153. * Highest Quality.
  75154. *
  75155. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  75156. *
  75157. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  75158. */
  75159. static readonly QUALITY_HIGH: number;
  75160. /**
  75161. * Reserved for PCF and PCSS
  75162. * Good tradeoff for quality/perf cross devices
  75163. *
  75164. * Execute PCF on a 3*3 kernel.
  75165. *
  75166. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  75167. */
  75168. static readonly QUALITY_MEDIUM: number;
  75169. /**
  75170. * Reserved for PCF and PCSS
  75171. * The lowest quality but the fastest.
  75172. *
  75173. * Execute PCF on a 1*1 kernel.
  75174. *
  75175. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  75176. */
  75177. static readonly QUALITY_LOW: number;
  75178. /** Gets or sets the custom shader name to use */
  75179. customShaderOptions: ICustomShaderOptions;
  75180. /**
  75181. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  75182. */
  75183. onBeforeShadowMapRenderObservable: Observable<Effect>;
  75184. /**
  75185. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  75186. */
  75187. onAfterShadowMapRenderObservable: Observable<Effect>;
  75188. /**
  75189. * Observable triggered before a mesh is rendered in the shadow map.
  75190. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  75191. */
  75192. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  75193. /**
  75194. * Observable triggered after a mesh is rendered in the shadow map.
  75195. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  75196. */
  75197. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  75198. private _bias;
  75199. /**
  75200. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  75201. */
  75202. /**
  75203. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  75204. */
  75205. bias: number;
  75206. private _normalBias;
  75207. /**
  75208. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75209. */
  75210. /**
  75211. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  75212. */
  75213. normalBias: number;
  75214. private _blurBoxOffset;
  75215. /**
  75216. * Gets the blur box offset: offset applied during the blur pass.
  75217. * Only useful if useKernelBlur = false
  75218. */
  75219. /**
  75220. * Sets the blur box offset: offset applied during the blur pass.
  75221. * Only useful if useKernelBlur = false
  75222. */
  75223. blurBoxOffset: number;
  75224. private _blurScale;
  75225. /**
  75226. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  75227. * 2 means half of the size.
  75228. */
  75229. /**
  75230. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  75231. * 2 means half of the size.
  75232. */
  75233. blurScale: number;
  75234. private _blurKernel;
  75235. /**
  75236. * Gets the blur kernel: kernel size of the blur pass.
  75237. * Only useful if useKernelBlur = true
  75238. */
  75239. /**
  75240. * Sets the blur kernel: kernel size of the blur pass.
  75241. * Only useful if useKernelBlur = true
  75242. */
  75243. blurKernel: number;
  75244. private _useKernelBlur;
  75245. /**
  75246. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  75247. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75248. */
  75249. /**
  75250. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  75251. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  75252. */
  75253. useKernelBlur: boolean;
  75254. private _depthScale;
  75255. /**
  75256. * Gets the depth scale used in ESM mode.
  75257. */
  75258. /**
  75259. * Sets the depth scale used in ESM mode.
  75260. * This can override the scale stored on the light.
  75261. */
  75262. depthScale: number;
  75263. private _filter;
  75264. /**
  75265. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  75266. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75267. */
  75268. /**
  75269. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  75270. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  75271. */
  75272. filter: number;
  75273. /**
  75274. * Gets if the current filter is set to Poisson Sampling.
  75275. */
  75276. /**
  75277. * Sets the current filter to Poisson Sampling.
  75278. */
  75279. usePoissonSampling: boolean;
  75280. /**
  75281. * Gets if the current filter is set to ESM.
  75282. */
  75283. /**
  75284. * Sets the current filter is to ESM.
  75285. */
  75286. useExponentialShadowMap: boolean;
  75287. /**
  75288. * Gets if the current filter is set to filtered ESM.
  75289. */
  75290. /**
  75291. * Gets if the current filter is set to filtered ESM.
  75292. */
  75293. useBlurExponentialShadowMap: boolean;
  75294. /**
  75295. * Gets if the current filter is set to "close ESM" (using the inverse of the
  75296. * exponential to prevent steep falloff artifacts).
  75297. */
  75298. /**
  75299. * Sets the current filter to "close ESM" (using the inverse of the
  75300. * exponential to prevent steep falloff artifacts).
  75301. */
  75302. useCloseExponentialShadowMap: boolean;
  75303. /**
  75304. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  75305. * exponential to prevent steep falloff artifacts).
  75306. */
  75307. /**
  75308. * Sets the current filter to filtered "close ESM" (using the inverse of the
  75309. * exponential to prevent steep falloff artifacts).
  75310. */
  75311. useBlurCloseExponentialShadowMap: boolean;
  75312. /**
  75313. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  75314. */
  75315. /**
  75316. * Sets the current filter to "PCF" (percentage closer filtering).
  75317. */
  75318. usePercentageCloserFiltering: boolean;
  75319. private _filteringQuality;
  75320. /**
  75321. * Gets the PCF or PCSS Quality.
  75322. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75323. */
  75324. /**
  75325. * Sets the PCF or PCSS Quality.
  75326. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  75327. */
  75328. filteringQuality: number;
  75329. /**
  75330. * Gets if the current filter is set to "PCSS" (contact hardening).
  75331. */
  75332. /**
  75333. * Sets the current filter to "PCSS" (contact hardening).
  75334. */
  75335. useContactHardeningShadow: boolean;
  75336. private _contactHardeningLightSizeUVRatio;
  75337. /**
  75338. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75339. * Using a ratio helps keeping shape stability independently of the map size.
  75340. *
  75341. * It does not account for the light projection as it was having too much
  75342. * instability during the light setup or during light position changes.
  75343. *
  75344. * Only valid if useContactHardeningShadow is true.
  75345. */
  75346. /**
  75347. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  75348. * Using a ratio helps keeping shape stability independently of the map size.
  75349. *
  75350. * It does not account for the light projection as it was having too much
  75351. * instability during the light setup or during light position changes.
  75352. *
  75353. * Only valid if useContactHardeningShadow is true.
  75354. */
  75355. contactHardeningLightSizeUVRatio: number;
  75356. private _darkness;
  75357. /** Gets or sets the actual darkness of a shadow */
  75358. darkness: number;
  75359. /**
  75360. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  75361. * 0 means strongest and 1 would means no shadow.
  75362. * @returns the darkness.
  75363. */
  75364. getDarkness(): number;
  75365. /**
  75366. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  75367. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  75368. * @returns the shadow generator allowing fluent coding.
  75369. */
  75370. setDarkness(darkness: number): ShadowGenerator;
  75371. private _transparencyShadow;
  75372. /** Gets or sets the ability to have transparent shadow */
  75373. transparencyShadow: boolean;
  75374. /**
  75375. * Sets the ability to have transparent shadow (boolean).
  75376. * @param transparent True if transparent else False
  75377. * @returns the shadow generator allowing fluent coding
  75378. */
  75379. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  75380. private _shadowMap;
  75381. private _shadowMap2;
  75382. /**
  75383. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75384. * @returns The render target texture if present otherwise, null
  75385. */
  75386. getShadowMap(): Nullable<RenderTargetTexture>;
  75387. /**
  75388. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75389. * @returns The render target texture if the shadow map is present otherwise, null
  75390. */
  75391. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75392. /**
  75393. * Gets the class name of that object
  75394. * @returns "ShadowGenerator"
  75395. */
  75396. getClassName(): string;
  75397. /**
  75398. * Helper function to add a mesh and its descendants to the list of shadow casters.
  75399. * @param mesh Mesh to add
  75400. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  75401. * @returns the Shadow Generator itself
  75402. */
  75403. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75404. /**
  75405. * Helper function to remove a mesh and its descendants from the list of shadow casters
  75406. * @param mesh Mesh to remove
  75407. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  75408. * @returns the Shadow Generator itself
  75409. */
  75410. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  75411. /**
  75412. * Controls the extent to which the shadows fade out at the edge of the frustum
  75413. * Used only by directionals and spots
  75414. */
  75415. frustumEdgeFalloff: number;
  75416. private _light;
  75417. /**
  75418. * Returns the associated light object.
  75419. * @returns the light generating the shadow
  75420. */
  75421. getLight(): IShadowLight;
  75422. /**
  75423. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  75424. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  75425. * It might on the other hand introduce peter panning.
  75426. */
  75427. forceBackFacesOnly: boolean;
  75428. private _scene;
  75429. private _lightDirection;
  75430. private _effect;
  75431. private _viewMatrix;
  75432. private _projectionMatrix;
  75433. private _transformMatrix;
  75434. private _cachedPosition;
  75435. private _cachedDirection;
  75436. private _cachedDefines;
  75437. private _currentRenderID;
  75438. private _boxBlurPostprocess;
  75439. private _kernelBlurXPostprocess;
  75440. private _kernelBlurYPostprocess;
  75441. private _blurPostProcesses;
  75442. private _mapSize;
  75443. private _currentFaceIndex;
  75444. private _currentFaceIndexCache;
  75445. private _textureType;
  75446. private _defaultTextureMatrix;
  75447. /** @hidden */
  75448. static _SceneComponentInitialization: (scene: Scene) => void;
  75449. /**
  75450. * Creates a ShadowGenerator object.
  75451. * A ShadowGenerator is the required tool to use the shadows.
  75452. * Each light casting shadows needs to use its own ShadowGenerator.
  75453. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  75454. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  75455. * @param light The light object generating the shadows.
  75456. * @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.
  75457. */
  75458. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  75459. private _initializeGenerator;
  75460. private _initializeShadowMap;
  75461. private _initializeBlurRTTAndPostProcesses;
  75462. private _renderForShadowMap;
  75463. private _renderSubMeshForShadowMap;
  75464. private _applyFilterValues;
  75465. /**
  75466. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75467. * @param onCompiled Callback triggered at the and of the effects compilation
  75468. * @param options Sets of optional options forcing the compilation with different modes
  75469. */
  75470. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  75471. useInstances: boolean;
  75472. }>): void;
  75473. /**
  75474. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  75475. * @param options Sets of optional options forcing the compilation with different modes
  75476. * @returns A promise that resolves when the compilation completes
  75477. */
  75478. forceCompilationAsync(options?: Partial<{
  75479. useInstances: boolean;
  75480. }>): Promise<void>;
  75481. /**
  75482. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75483. * @param subMesh The submesh we want to render in the shadow map
  75484. * @param useInstances Defines wether will draw in the map using instances
  75485. * @returns true if ready otherwise, false
  75486. */
  75487. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75488. /**
  75489. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75490. * @param defines Defines of the material we want to update
  75491. * @param lightIndex Index of the light in the enabled light list of the material
  75492. */
  75493. prepareDefines(defines: any, lightIndex: number): void;
  75494. /**
  75495. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75496. * defined in the generator but impacting the effect).
  75497. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75498. * @param effect The effect we are binfing the information for
  75499. */
  75500. bindShadowLight(lightIndex: string, effect: Effect): void;
  75501. /**
  75502. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  75503. * (eq to shadow prjection matrix * light transform matrix)
  75504. * @returns The transform matrix used to create the shadow map
  75505. */
  75506. getTransformMatrix(): Matrix;
  75507. /**
  75508. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  75509. * Cube and 2D textures for instance.
  75510. */
  75511. recreateShadowMap(): void;
  75512. private _disposeBlurPostProcesses;
  75513. private _disposeRTTandPostProcesses;
  75514. /**
  75515. * Disposes the ShadowGenerator.
  75516. * Returns nothing.
  75517. */
  75518. dispose(): void;
  75519. /**
  75520. * Serializes the shadow generator setup to a json object.
  75521. * @returns The serialized JSON object
  75522. */
  75523. serialize(): any;
  75524. /**
  75525. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  75526. * @param parsedShadowGenerator The JSON object to parse
  75527. * @param scene The scene to create the shadow map for
  75528. * @returns The parsed shadow generator
  75529. */
  75530. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  75531. }
  75532. }
  75533. declare module BABYLON {
  75534. /**
  75535. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  75536. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  75537. * 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.
  75538. */
  75539. export abstract class Light extends Node {
  75540. /**
  75541. * Falloff Default: light is falling off following the material specification:
  75542. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  75543. */
  75544. static readonly FALLOFF_DEFAULT: number;
  75545. /**
  75546. * Falloff Physical: light is falling off following the inverse squared distance law.
  75547. */
  75548. static readonly FALLOFF_PHYSICAL: number;
  75549. /**
  75550. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  75551. * to enhance interoperability with other engines.
  75552. */
  75553. static readonly FALLOFF_GLTF: number;
  75554. /**
  75555. * Falloff Standard: light is falling off like in the standard material
  75556. * to enhance interoperability with other materials.
  75557. */
  75558. static readonly FALLOFF_STANDARD: number;
  75559. /**
  75560. * If every light affecting the material is in this lightmapMode,
  75561. * material.lightmapTexture adds or multiplies
  75562. * (depends on material.useLightmapAsShadowmap)
  75563. * after every other light calculations.
  75564. */
  75565. static readonly LIGHTMAP_DEFAULT: number;
  75566. /**
  75567. * material.lightmapTexture as only diffuse lighting from this light
  75568. * adds only specular lighting from this light
  75569. * adds dynamic shadows
  75570. */
  75571. static readonly LIGHTMAP_SPECULAR: number;
  75572. /**
  75573. * material.lightmapTexture as only lighting
  75574. * no light calculation from this light
  75575. * only adds dynamic shadows from this light
  75576. */
  75577. static readonly LIGHTMAP_SHADOWSONLY: number;
  75578. /**
  75579. * Each light type uses the default quantity according to its type:
  75580. * point/spot lights use luminous intensity
  75581. * directional lights use illuminance
  75582. */
  75583. static readonly INTENSITYMODE_AUTOMATIC: number;
  75584. /**
  75585. * lumen (lm)
  75586. */
  75587. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  75588. /**
  75589. * candela (lm/sr)
  75590. */
  75591. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  75592. /**
  75593. * lux (lm/m^2)
  75594. */
  75595. static readonly INTENSITYMODE_ILLUMINANCE: number;
  75596. /**
  75597. * nit (cd/m^2)
  75598. */
  75599. static readonly INTENSITYMODE_LUMINANCE: number;
  75600. /**
  75601. * Light type const id of the point light.
  75602. */
  75603. static readonly LIGHTTYPEID_POINTLIGHT: number;
  75604. /**
  75605. * Light type const id of the directional light.
  75606. */
  75607. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  75608. /**
  75609. * Light type const id of the spot light.
  75610. */
  75611. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  75612. /**
  75613. * Light type const id of the hemispheric light.
  75614. */
  75615. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  75616. /**
  75617. * Diffuse gives the basic color to an object.
  75618. */
  75619. diffuse: Color3;
  75620. /**
  75621. * Specular produces a highlight color on an object.
  75622. * Note: This is note affecting PBR materials.
  75623. */
  75624. specular: Color3;
  75625. /**
  75626. * Defines the falloff type for this light. This lets overrriding how punctual light are
  75627. * falling off base on range or angle.
  75628. * This can be set to any values in Light.FALLOFF_x.
  75629. *
  75630. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  75631. * other types of materials.
  75632. */
  75633. falloffType: number;
  75634. /**
  75635. * Strength of the light.
  75636. * Note: By default it is define in the framework own unit.
  75637. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  75638. */
  75639. intensity: number;
  75640. private _range;
  75641. protected _inverseSquaredRange: number;
  75642. /**
  75643. * Defines how far from the source the light is impacting in scene units.
  75644. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75645. */
  75646. /**
  75647. * Defines how far from the source the light is impacting in scene units.
  75648. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  75649. */
  75650. range: number;
  75651. /**
  75652. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  75653. * of light.
  75654. */
  75655. private _photometricScale;
  75656. private _intensityMode;
  75657. /**
  75658. * Gets the photometric scale used to interpret the intensity.
  75659. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75660. */
  75661. /**
  75662. * Sets the photometric scale used to interpret the intensity.
  75663. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  75664. */
  75665. intensityMode: number;
  75666. private _radius;
  75667. /**
  75668. * Gets the light radius used by PBR Materials to simulate soft area lights.
  75669. */
  75670. /**
  75671. * sets the light radius used by PBR Materials to simulate soft area lights.
  75672. */
  75673. radius: number;
  75674. private _renderPriority;
  75675. /**
  75676. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  75677. * exceeding the number allowed of the materials.
  75678. */
  75679. renderPriority: number;
  75680. private _shadowEnabled;
  75681. /**
  75682. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75683. * the current shadow generator.
  75684. */
  75685. /**
  75686. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  75687. * the current shadow generator.
  75688. */
  75689. shadowEnabled: boolean;
  75690. private _includedOnlyMeshes;
  75691. /**
  75692. * Gets the only meshes impacted by this light.
  75693. */
  75694. /**
  75695. * Sets the only meshes impacted by this light.
  75696. */
  75697. includedOnlyMeshes: AbstractMesh[];
  75698. private _excludedMeshes;
  75699. /**
  75700. * Gets the meshes not impacted by this light.
  75701. */
  75702. /**
  75703. * Sets the meshes not impacted by this light.
  75704. */
  75705. excludedMeshes: AbstractMesh[];
  75706. private _excludeWithLayerMask;
  75707. /**
  75708. * Gets the layer id use to find what meshes are not impacted by the light.
  75709. * Inactive if 0
  75710. */
  75711. /**
  75712. * Sets the layer id use to find what meshes are not impacted by the light.
  75713. * Inactive if 0
  75714. */
  75715. excludeWithLayerMask: number;
  75716. private _includeOnlyWithLayerMask;
  75717. /**
  75718. * Gets the layer id use to find what meshes are impacted by the light.
  75719. * Inactive if 0
  75720. */
  75721. /**
  75722. * Sets the layer id use to find what meshes are impacted by the light.
  75723. * Inactive if 0
  75724. */
  75725. includeOnlyWithLayerMask: number;
  75726. private _lightmapMode;
  75727. /**
  75728. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75729. */
  75730. /**
  75731. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  75732. */
  75733. lightmapMode: number;
  75734. /**
  75735. * Shadow generator associted to the light.
  75736. * @hidden Internal use only.
  75737. */
  75738. _shadowGenerator: Nullable<IShadowGenerator>;
  75739. /**
  75740. * @hidden Internal use only.
  75741. */
  75742. _excludedMeshesIds: string[];
  75743. /**
  75744. * @hidden Internal use only.
  75745. */
  75746. _includedOnlyMeshesIds: string[];
  75747. /**
  75748. * The current light unifom buffer.
  75749. * @hidden Internal use only.
  75750. */
  75751. _uniformBuffer: UniformBuffer;
  75752. /**
  75753. * Creates a Light object in the scene.
  75754. * Documentation : https://doc.babylonjs.com/babylon101/lights
  75755. * @param name The firendly name of the light
  75756. * @param scene The scene the light belongs too
  75757. */
  75758. constructor(name: string, scene: Scene);
  75759. protected abstract _buildUniformLayout(): void;
  75760. /**
  75761. * Sets the passed Effect "effect" with the Light information.
  75762. * @param effect The effect to update
  75763. * @param lightIndex The index of the light in the effect to update
  75764. * @returns The light
  75765. */
  75766. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  75767. /**
  75768. * Sets the passed Effect "effect" with the Light information.
  75769. * @param effect The effect to update
  75770. * @param lightDataUniformName The uniform used to store light data (position or direction)
  75771. * @returns The light
  75772. */
  75773. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  75774. /**
  75775. * Returns the string "Light".
  75776. * @returns the class name
  75777. */
  75778. getClassName(): string;
  75779. /** @hidden */
  75780. readonly _isLight: boolean;
  75781. /**
  75782. * Converts the light information to a readable string for debug purpose.
  75783. * @param fullDetails Supports for multiple levels of logging within scene loading
  75784. * @returns the human readable light info
  75785. */
  75786. toString(fullDetails?: boolean): string;
  75787. /** @hidden */
  75788. protected _syncParentEnabledState(): void;
  75789. /**
  75790. * Set the enabled state of this node.
  75791. * @param value - the new enabled state
  75792. */
  75793. setEnabled(value: boolean): void;
  75794. /**
  75795. * Returns the Light associated shadow generator if any.
  75796. * @return the associated shadow generator.
  75797. */
  75798. getShadowGenerator(): Nullable<IShadowGenerator>;
  75799. /**
  75800. * Returns a Vector3, the absolute light position in the World.
  75801. * @returns the world space position of the light
  75802. */
  75803. getAbsolutePosition(): Vector3;
  75804. /**
  75805. * Specifies if the light will affect the passed mesh.
  75806. * @param mesh The mesh to test against the light
  75807. * @return true the mesh is affected otherwise, false.
  75808. */
  75809. canAffectMesh(mesh: AbstractMesh): boolean;
  75810. /**
  75811. * Sort function to order lights for rendering.
  75812. * @param a First Light object to compare to second.
  75813. * @param b Second Light object to compare first.
  75814. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  75815. */
  75816. static CompareLightsPriority(a: Light, b: Light): number;
  75817. /**
  75818. * Releases resources associated with this node.
  75819. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  75820. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  75821. */
  75822. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75823. /**
  75824. * Returns the light type ID (integer).
  75825. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  75826. */
  75827. getTypeID(): number;
  75828. /**
  75829. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  75830. * @returns the scaled intensity in intensity mode unit
  75831. */
  75832. getScaledIntensity(): number;
  75833. /**
  75834. * Returns a new Light object, named "name", from the current one.
  75835. * @param name The name of the cloned light
  75836. * @returns the new created light
  75837. */
  75838. clone(name: string): Nullable<Light>;
  75839. /**
  75840. * Serializes the current light into a Serialization object.
  75841. * @returns the serialized object.
  75842. */
  75843. serialize(): any;
  75844. /**
  75845. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  75846. * This new light is named "name" and added to the passed scene.
  75847. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  75848. * @param name The friendly name of the light
  75849. * @param scene The scene the new light will belong to
  75850. * @returns the constructor function
  75851. */
  75852. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  75853. /**
  75854. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  75855. * @param parsedLight The JSON representation of the light
  75856. * @param scene The scene to create the parsed light in
  75857. * @returns the created light after parsing
  75858. */
  75859. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  75860. private _hookArrayForExcluded;
  75861. private _hookArrayForIncludedOnly;
  75862. private _resyncMeshes;
  75863. /**
  75864. * Forces the meshes to update their light related information in their rendering used effects
  75865. * @hidden Internal Use Only
  75866. */
  75867. _markMeshesAsLightDirty(): void;
  75868. /**
  75869. * Recomputes the cached photometric scale if needed.
  75870. */
  75871. private _computePhotometricScale;
  75872. /**
  75873. * Returns the Photometric Scale according to the light type and intensity mode.
  75874. */
  75875. private _getPhotometricScale;
  75876. /**
  75877. * Reorder the light in the scene according to their defined priority.
  75878. * @hidden Internal Use Only
  75879. */
  75880. _reorderLightsInScene(): void;
  75881. /**
  75882. * Prepares the list of defines specific to the light type.
  75883. * @param defines the list of defines
  75884. * @param lightIndex defines the index of the light for the effect
  75885. */
  75886. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  75887. }
  75888. }
  75889. declare module BABYLON {
  75890. /**
  75891. * Interface used to define Action
  75892. */
  75893. export interface IAction {
  75894. /**
  75895. * Trigger for the action
  75896. */
  75897. trigger: number;
  75898. /** Options of the trigger */
  75899. triggerOptions: any;
  75900. /**
  75901. * Gets the trigger parameters
  75902. * @returns the trigger parameters
  75903. */
  75904. getTriggerParameter(): any;
  75905. /**
  75906. * Internal only - executes current action event
  75907. * @hidden
  75908. */
  75909. _executeCurrent(evt?: ActionEvent): void;
  75910. /**
  75911. * Serialize placeholder for child classes
  75912. * @param parent of child
  75913. * @returns the serialized object
  75914. */
  75915. serialize(parent: any): any;
  75916. /**
  75917. * Internal only
  75918. * @hidden
  75919. */
  75920. _prepare(): void;
  75921. /**
  75922. * Internal only - manager for action
  75923. * @hidden
  75924. */
  75925. _actionManager: AbstractActionManager;
  75926. /**
  75927. * Adds action to chain of actions, may be a DoNothingAction
  75928. * @param action defines the next action to execute
  75929. * @returns The action passed in
  75930. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75931. */
  75932. then(action: IAction): IAction;
  75933. }
  75934. /**
  75935. * The action to be carried out following a trigger
  75936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  75937. */
  75938. export class Action implements IAction {
  75939. /** the trigger, with or without parameters, for the action */
  75940. triggerOptions: any;
  75941. /**
  75942. * Trigger for the action
  75943. */
  75944. trigger: number;
  75945. /**
  75946. * Internal only - manager for action
  75947. * @hidden
  75948. */
  75949. _actionManager: ActionManager;
  75950. private _nextActiveAction;
  75951. private _child;
  75952. private _condition?;
  75953. private _triggerParameter;
  75954. /**
  75955. * An event triggered prior to action being executed.
  75956. */
  75957. onBeforeExecuteObservable: Observable<Action>;
  75958. /**
  75959. * Creates a new Action
  75960. * @param triggerOptions the trigger, with or without parameters, for the action
  75961. * @param condition an optional determinant of action
  75962. */
  75963. constructor(
  75964. /** the trigger, with or without parameters, for the action */
  75965. triggerOptions: any, condition?: Condition);
  75966. /**
  75967. * Internal only
  75968. * @hidden
  75969. */
  75970. _prepare(): void;
  75971. /**
  75972. * Gets the trigger parameters
  75973. * @returns the trigger parameters
  75974. */
  75975. getTriggerParameter(): any;
  75976. /**
  75977. * Internal only - executes current action event
  75978. * @hidden
  75979. */
  75980. _executeCurrent(evt?: ActionEvent): void;
  75981. /**
  75982. * Execute placeholder for child classes
  75983. * @param evt optional action event
  75984. */
  75985. execute(evt?: ActionEvent): void;
  75986. /**
  75987. * Skips to next active action
  75988. */
  75989. skipToNextActiveAction(): void;
  75990. /**
  75991. * Adds action to chain of actions, may be a DoNothingAction
  75992. * @param action defines the next action to execute
  75993. * @returns The action passed in
  75994. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75995. */
  75996. then(action: Action): Action;
  75997. /**
  75998. * Internal only
  75999. * @hidden
  76000. */
  76001. _getProperty(propertyPath: string): string;
  76002. /**
  76003. * Internal only
  76004. * @hidden
  76005. */
  76006. _getEffectiveTarget(target: any, propertyPath: string): any;
  76007. /**
  76008. * Serialize placeholder for child classes
  76009. * @param parent of child
  76010. * @returns the serialized object
  76011. */
  76012. serialize(parent: any): any;
  76013. /**
  76014. * Internal only called by serialize
  76015. * @hidden
  76016. */
  76017. protected _serialize(serializedAction: any, parent?: any): any;
  76018. /**
  76019. * Internal only
  76020. * @hidden
  76021. */
  76022. static _SerializeValueAsString: (value: any) => string;
  76023. /**
  76024. * Internal only
  76025. * @hidden
  76026. */
  76027. static _GetTargetProperty: (target: Node | Scene) => {
  76028. name: string;
  76029. targetType: string;
  76030. value: string;
  76031. };
  76032. }
  76033. }
  76034. declare module BABYLON {
  76035. /**
  76036. * A Condition applied to an Action
  76037. */
  76038. export class Condition {
  76039. /**
  76040. * Internal only - manager for action
  76041. * @hidden
  76042. */
  76043. _actionManager: ActionManager;
  76044. /**
  76045. * Internal only
  76046. * @hidden
  76047. */
  76048. _evaluationId: number;
  76049. /**
  76050. * Internal only
  76051. * @hidden
  76052. */
  76053. _currentResult: boolean;
  76054. /**
  76055. * Creates a new Condition
  76056. * @param actionManager the manager of the action the condition is applied to
  76057. */
  76058. constructor(actionManager: ActionManager);
  76059. /**
  76060. * Check if the current condition is valid
  76061. * @returns a boolean
  76062. */
  76063. isValid(): boolean;
  76064. /**
  76065. * Internal only
  76066. * @hidden
  76067. */
  76068. _getProperty(propertyPath: string): string;
  76069. /**
  76070. * Internal only
  76071. * @hidden
  76072. */
  76073. _getEffectiveTarget(target: any, propertyPath: string): any;
  76074. /**
  76075. * Serialize placeholder for child classes
  76076. * @returns the serialized object
  76077. */
  76078. serialize(): any;
  76079. /**
  76080. * Internal only
  76081. * @hidden
  76082. */
  76083. protected _serialize(serializedCondition: any): any;
  76084. }
  76085. /**
  76086. * Defines specific conditional operators as extensions of Condition
  76087. */
  76088. export class ValueCondition extends Condition {
  76089. /** path to specify the property of the target the conditional operator uses */
  76090. propertyPath: string;
  76091. /** the value compared by the conditional operator against the current value of the property */
  76092. value: any;
  76093. /** the conditional operator, default ValueCondition.IsEqual */
  76094. operator: number;
  76095. /**
  76096. * Internal only
  76097. * @hidden
  76098. */
  76099. private static _IsEqual;
  76100. /**
  76101. * Internal only
  76102. * @hidden
  76103. */
  76104. private static _IsDifferent;
  76105. /**
  76106. * Internal only
  76107. * @hidden
  76108. */
  76109. private static _IsGreater;
  76110. /**
  76111. * Internal only
  76112. * @hidden
  76113. */
  76114. private static _IsLesser;
  76115. /**
  76116. * returns the number for IsEqual
  76117. */
  76118. static readonly IsEqual: number;
  76119. /**
  76120. * Returns the number for IsDifferent
  76121. */
  76122. static readonly IsDifferent: number;
  76123. /**
  76124. * Returns the number for IsGreater
  76125. */
  76126. static readonly IsGreater: number;
  76127. /**
  76128. * Returns the number for IsLesser
  76129. */
  76130. static readonly IsLesser: number;
  76131. /**
  76132. * Internal only The action manager for the condition
  76133. * @hidden
  76134. */
  76135. _actionManager: ActionManager;
  76136. /**
  76137. * Internal only
  76138. * @hidden
  76139. */
  76140. private _target;
  76141. /**
  76142. * Internal only
  76143. * @hidden
  76144. */
  76145. private _effectiveTarget;
  76146. /**
  76147. * Internal only
  76148. * @hidden
  76149. */
  76150. private _property;
  76151. /**
  76152. * Creates a new ValueCondition
  76153. * @param actionManager manager for the action the condition applies to
  76154. * @param target for the action
  76155. * @param propertyPath path to specify the property of the target the conditional operator uses
  76156. * @param value the value compared by the conditional operator against the current value of the property
  76157. * @param operator the conditional operator, default ValueCondition.IsEqual
  76158. */
  76159. constructor(actionManager: ActionManager, target: any,
  76160. /** path to specify the property of the target the conditional operator uses */
  76161. propertyPath: string,
  76162. /** the value compared by the conditional operator against the current value of the property */
  76163. value: any,
  76164. /** the conditional operator, default ValueCondition.IsEqual */
  76165. operator?: number);
  76166. /**
  76167. * Compares the given value with the property value for the specified conditional operator
  76168. * @returns the result of the comparison
  76169. */
  76170. isValid(): boolean;
  76171. /**
  76172. * Serialize the ValueCondition into a JSON compatible object
  76173. * @returns serialization object
  76174. */
  76175. serialize(): any;
  76176. /**
  76177. * Gets the name of the conditional operator for the ValueCondition
  76178. * @param operator the conditional operator
  76179. * @returns the name
  76180. */
  76181. static GetOperatorName(operator: number): string;
  76182. }
  76183. /**
  76184. * Defines a predicate condition as an extension of Condition
  76185. */
  76186. export class PredicateCondition extends Condition {
  76187. /** defines the predicate function used to validate the condition */
  76188. predicate: () => boolean;
  76189. /**
  76190. * Internal only - manager for action
  76191. * @hidden
  76192. */
  76193. _actionManager: ActionManager;
  76194. /**
  76195. * Creates a new PredicateCondition
  76196. * @param actionManager manager for the action the condition applies to
  76197. * @param predicate defines the predicate function used to validate the condition
  76198. */
  76199. constructor(actionManager: ActionManager,
  76200. /** defines the predicate function used to validate the condition */
  76201. predicate: () => boolean);
  76202. /**
  76203. * @returns the validity of the predicate condition
  76204. */
  76205. isValid(): boolean;
  76206. }
  76207. /**
  76208. * Defines a state condition as an extension of Condition
  76209. */
  76210. export class StateCondition extends Condition {
  76211. /** Value to compare with target state */
  76212. value: string;
  76213. /**
  76214. * Internal only - manager for action
  76215. * @hidden
  76216. */
  76217. _actionManager: ActionManager;
  76218. /**
  76219. * Internal only
  76220. * @hidden
  76221. */
  76222. private _target;
  76223. /**
  76224. * Creates a new StateCondition
  76225. * @param actionManager manager for the action the condition applies to
  76226. * @param target of the condition
  76227. * @param value to compare with target state
  76228. */
  76229. constructor(actionManager: ActionManager, target: any,
  76230. /** Value to compare with target state */
  76231. value: string);
  76232. /**
  76233. * Gets a boolean indicating if the current condition is met
  76234. * @returns the validity of the state
  76235. */
  76236. isValid(): boolean;
  76237. /**
  76238. * Serialize the StateCondition into a JSON compatible object
  76239. * @returns serialization object
  76240. */
  76241. serialize(): any;
  76242. }
  76243. }
  76244. declare module BABYLON {
  76245. /**
  76246. * This defines an action responsible to toggle a boolean once triggered.
  76247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76248. */
  76249. export class SwitchBooleanAction extends Action {
  76250. /**
  76251. * The path to the boolean property in the target object
  76252. */
  76253. propertyPath: string;
  76254. private _target;
  76255. private _effectiveTarget;
  76256. private _property;
  76257. /**
  76258. * Instantiate the action
  76259. * @param triggerOptions defines the trigger options
  76260. * @param target defines the object containing the boolean
  76261. * @param propertyPath defines the path to the boolean property in the target object
  76262. * @param condition defines the trigger related conditions
  76263. */
  76264. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  76265. /** @hidden */
  76266. _prepare(): void;
  76267. /**
  76268. * Execute the action toggle the boolean value.
  76269. */
  76270. execute(): void;
  76271. /**
  76272. * Serializes the actions and its related information.
  76273. * @param parent defines the object to serialize in
  76274. * @returns the serialized object
  76275. */
  76276. serialize(parent: any): any;
  76277. }
  76278. /**
  76279. * This defines an action responsible to set a the state field of the target
  76280. * to a desired value once triggered.
  76281. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76282. */
  76283. export class SetStateAction extends Action {
  76284. /**
  76285. * The value to store in the state field.
  76286. */
  76287. value: string;
  76288. private _target;
  76289. /**
  76290. * Instantiate the action
  76291. * @param triggerOptions defines the trigger options
  76292. * @param target defines the object containing the state property
  76293. * @param value defines the value to store in the state field
  76294. * @param condition defines the trigger related conditions
  76295. */
  76296. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  76297. /**
  76298. * Execute the action and store the value on the target state property.
  76299. */
  76300. execute(): void;
  76301. /**
  76302. * Serializes the actions and its related information.
  76303. * @param parent defines the object to serialize in
  76304. * @returns the serialized object
  76305. */
  76306. serialize(parent: any): any;
  76307. }
  76308. /**
  76309. * This defines an action responsible to set a property of the target
  76310. * to a desired value once triggered.
  76311. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76312. */
  76313. export class SetValueAction extends Action {
  76314. /**
  76315. * The path of the property to set in the target.
  76316. */
  76317. propertyPath: string;
  76318. /**
  76319. * The value to set in the property
  76320. */
  76321. value: any;
  76322. private _target;
  76323. private _effectiveTarget;
  76324. private _property;
  76325. /**
  76326. * Instantiate the action
  76327. * @param triggerOptions defines the trigger options
  76328. * @param target defines the object containing the property
  76329. * @param propertyPath defines the path of the property to set in the target
  76330. * @param value defines the value to set in the property
  76331. * @param condition defines the trigger related conditions
  76332. */
  76333. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76334. /** @hidden */
  76335. _prepare(): void;
  76336. /**
  76337. * Execute the action and set the targetted property to the desired value.
  76338. */
  76339. execute(): void;
  76340. /**
  76341. * Serializes the actions and its related information.
  76342. * @param parent defines the object to serialize in
  76343. * @returns the serialized object
  76344. */
  76345. serialize(parent: any): any;
  76346. }
  76347. /**
  76348. * This defines an action responsible to increment the target value
  76349. * to a desired value once triggered.
  76350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76351. */
  76352. export class IncrementValueAction extends Action {
  76353. /**
  76354. * The path of the property to increment in the target.
  76355. */
  76356. propertyPath: string;
  76357. /**
  76358. * The value we should increment the property by.
  76359. */
  76360. value: any;
  76361. private _target;
  76362. private _effectiveTarget;
  76363. private _property;
  76364. /**
  76365. * Instantiate the action
  76366. * @param triggerOptions defines the trigger options
  76367. * @param target defines the object containing the property
  76368. * @param propertyPath defines the path of the property to increment in the target
  76369. * @param value defines the value value we should increment the property by
  76370. * @param condition defines the trigger related conditions
  76371. */
  76372. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76373. /** @hidden */
  76374. _prepare(): void;
  76375. /**
  76376. * Execute the action and increment the target of the value amount.
  76377. */
  76378. execute(): void;
  76379. /**
  76380. * Serializes the actions and its related information.
  76381. * @param parent defines the object to serialize in
  76382. * @returns the serialized object
  76383. */
  76384. serialize(parent: any): any;
  76385. }
  76386. /**
  76387. * This defines an action responsible to start an animation once triggered.
  76388. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76389. */
  76390. export class PlayAnimationAction extends Action {
  76391. /**
  76392. * Where the animation should start (animation frame)
  76393. */
  76394. from: number;
  76395. /**
  76396. * Where the animation should stop (animation frame)
  76397. */
  76398. to: number;
  76399. /**
  76400. * Define if the animation should loop or stop after the first play.
  76401. */
  76402. loop?: boolean;
  76403. private _target;
  76404. /**
  76405. * Instantiate the action
  76406. * @param triggerOptions defines the trigger options
  76407. * @param target defines the target animation or animation name
  76408. * @param from defines from where the animation should start (animation frame)
  76409. * @param end defines where the animation should stop (animation frame)
  76410. * @param loop defines if the animation should loop or stop after the first play
  76411. * @param condition defines the trigger related conditions
  76412. */
  76413. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  76414. /** @hidden */
  76415. _prepare(): void;
  76416. /**
  76417. * Execute the action and play the animation.
  76418. */
  76419. execute(): void;
  76420. /**
  76421. * Serializes the actions and its related information.
  76422. * @param parent defines the object to serialize in
  76423. * @returns the serialized object
  76424. */
  76425. serialize(parent: any): any;
  76426. }
  76427. /**
  76428. * This defines an action responsible to stop an animation once triggered.
  76429. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76430. */
  76431. export class StopAnimationAction extends Action {
  76432. private _target;
  76433. /**
  76434. * Instantiate the action
  76435. * @param triggerOptions defines the trigger options
  76436. * @param target defines the target animation or animation name
  76437. * @param condition defines the trigger related conditions
  76438. */
  76439. constructor(triggerOptions: any, target: any, condition?: Condition);
  76440. /** @hidden */
  76441. _prepare(): void;
  76442. /**
  76443. * Execute the action and stop the animation.
  76444. */
  76445. execute(): void;
  76446. /**
  76447. * Serializes the actions and its related information.
  76448. * @param parent defines the object to serialize in
  76449. * @returns the serialized object
  76450. */
  76451. serialize(parent: any): any;
  76452. }
  76453. /**
  76454. * This defines an action responsible that does nothing once triggered.
  76455. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76456. */
  76457. export class DoNothingAction extends Action {
  76458. /**
  76459. * Instantiate the action
  76460. * @param triggerOptions defines the trigger options
  76461. * @param condition defines the trigger related conditions
  76462. */
  76463. constructor(triggerOptions?: any, condition?: Condition);
  76464. /**
  76465. * Execute the action and do nothing.
  76466. */
  76467. execute(): void;
  76468. /**
  76469. * Serializes the actions and its related information.
  76470. * @param parent defines the object to serialize in
  76471. * @returns the serialized object
  76472. */
  76473. serialize(parent: any): any;
  76474. }
  76475. /**
  76476. * This defines an action responsible to trigger several actions once triggered.
  76477. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76478. */
  76479. export class CombineAction extends Action {
  76480. /**
  76481. * The list of aggregated animations to run.
  76482. */
  76483. children: Action[];
  76484. /**
  76485. * Instantiate the action
  76486. * @param triggerOptions defines the trigger options
  76487. * @param children defines the list of aggregated animations to run
  76488. * @param condition defines the trigger related conditions
  76489. */
  76490. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  76491. /** @hidden */
  76492. _prepare(): void;
  76493. /**
  76494. * Execute the action and executes all the aggregated actions.
  76495. */
  76496. execute(evt: ActionEvent): void;
  76497. /**
  76498. * Serializes the actions and its related information.
  76499. * @param parent defines the object to serialize in
  76500. * @returns the serialized object
  76501. */
  76502. serialize(parent: any): any;
  76503. }
  76504. /**
  76505. * This defines an action responsible to run code (external event) once triggered.
  76506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76507. */
  76508. export class ExecuteCodeAction extends Action {
  76509. /**
  76510. * The callback function to run.
  76511. */
  76512. func: (evt: ActionEvent) => void;
  76513. /**
  76514. * Instantiate the action
  76515. * @param triggerOptions defines the trigger options
  76516. * @param func defines the callback function to run
  76517. * @param condition defines the trigger related conditions
  76518. */
  76519. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  76520. /**
  76521. * Execute the action and run the attached code.
  76522. */
  76523. execute(evt: ActionEvent): void;
  76524. }
  76525. /**
  76526. * This defines an action responsible to set the parent property of the target once triggered.
  76527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76528. */
  76529. export class SetParentAction extends Action {
  76530. private _parent;
  76531. private _target;
  76532. /**
  76533. * Instantiate the action
  76534. * @param triggerOptions defines the trigger options
  76535. * @param target defines the target containing the parent property
  76536. * @param parent defines from where the animation should start (animation frame)
  76537. * @param condition defines the trigger related conditions
  76538. */
  76539. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  76540. /** @hidden */
  76541. _prepare(): void;
  76542. /**
  76543. * Execute the action and set the parent property.
  76544. */
  76545. execute(): void;
  76546. /**
  76547. * Serializes the actions and its related information.
  76548. * @param parent defines the object to serialize in
  76549. * @returns the serialized object
  76550. */
  76551. serialize(parent: any): any;
  76552. }
  76553. }
  76554. declare module BABYLON {
  76555. /**
  76556. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  76557. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  76558. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76559. */
  76560. export class ActionManager extends AbstractActionManager {
  76561. /**
  76562. * Nothing
  76563. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76564. */
  76565. static readonly NothingTrigger: number;
  76566. /**
  76567. * On pick
  76568. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76569. */
  76570. static readonly OnPickTrigger: number;
  76571. /**
  76572. * On left pick
  76573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76574. */
  76575. static readonly OnLeftPickTrigger: number;
  76576. /**
  76577. * On right pick
  76578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76579. */
  76580. static readonly OnRightPickTrigger: number;
  76581. /**
  76582. * On center pick
  76583. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76584. */
  76585. static readonly OnCenterPickTrigger: number;
  76586. /**
  76587. * On pick down
  76588. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76589. */
  76590. static readonly OnPickDownTrigger: number;
  76591. /**
  76592. * On double pick
  76593. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76594. */
  76595. static readonly OnDoublePickTrigger: number;
  76596. /**
  76597. * On pick up
  76598. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76599. */
  76600. static readonly OnPickUpTrigger: number;
  76601. /**
  76602. * On pick out.
  76603. * This trigger will only be raised if you also declared a OnPickDown
  76604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76605. */
  76606. static readonly OnPickOutTrigger: number;
  76607. /**
  76608. * On long press
  76609. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76610. */
  76611. static readonly OnLongPressTrigger: number;
  76612. /**
  76613. * On pointer over
  76614. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76615. */
  76616. static readonly OnPointerOverTrigger: number;
  76617. /**
  76618. * On pointer out
  76619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76620. */
  76621. static readonly OnPointerOutTrigger: number;
  76622. /**
  76623. * On every frame
  76624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76625. */
  76626. static readonly OnEveryFrameTrigger: number;
  76627. /**
  76628. * On intersection enter
  76629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76630. */
  76631. static readonly OnIntersectionEnterTrigger: number;
  76632. /**
  76633. * On intersection exit
  76634. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76635. */
  76636. static readonly OnIntersectionExitTrigger: number;
  76637. /**
  76638. * On key down
  76639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76640. */
  76641. static readonly OnKeyDownTrigger: number;
  76642. /**
  76643. * On key up
  76644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76645. */
  76646. static readonly OnKeyUpTrigger: number;
  76647. private _scene;
  76648. /**
  76649. * Creates a new action manager
  76650. * @param scene defines the hosting scene
  76651. */
  76652. constructor(scene: Scene);
  76653. /**
  76654. * Releases all associated resources
  76655. */
  76656. dispose(): void;
  76657. /**
  76658. * Gets hosting scene
  76659. * @returns the hosting scene
  76660. */
  76661. getScene(): Scene;
  76662. /**
  76663. * Does this action manager handles actions of any of the given triggers
  76664. * @param triggers defines the triggers to be tested
  76665. * @return a boolean indicating whether one (or more) of the triggers is handled
  76666. */
  76667. hasSpecificTriggers(triggers: number[]): boolean;
  76668. /**
  76669. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  76670. * speed.
  76671. * @param triggerA defines the trigger to be tested
  76672. * @param triggerB defines the trigger to be tested
  76673. * @return a boolean indicating whether one (or more) of the triggers is handled
  76674. */
  76675. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  76676. /**
  76677. * Does this action manager handles actions of a given trigger
  76678. * @param trigger defines the trigger to be tested
  76679. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  76680. * @return whether the trigger is handled
  76681. */
  76682. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  76683. /**
  76684. * Does this action manager has pointer triggers
  76685. */
  76686. readonly hasPointerTriggers: boolean;
  76687. /**
  76688. * Does this action manager has pick triggers
  76689. */
  76690. readonly hasPickTriggers: boolean;
  76691. /**
  76692. * Registers an action to this action manager
  76693. * @param action defines the action to be registered
  76694. * @return the action amended (prepared) after registration
  76695. */
  76696. registerAction(action: IAction): Nullable<IAction>;
  76697. /**
  76698. * Unregisters an action to this action manager
  76699. * @param action defines the action to be unregistered
  76700. * @return a boolean indicating whether the action has been unregistered
  76701. */
  76702. unregisterAction(action: IAction): Boolean;
  76703. /**
  76704. * Process a specific trigger
  76705. * @param trigger defines the trigger to process
  76706. * @param evt defines the event details to be processed
  76707. */
  76708. processTrigger(trigger: number, evt?: IActionEvent): void;
  76709. /** @hidden */
  76710. _getEffectiveTarget(target: any, propertyPath: string): any;
  76711. /** @hidden */
  76712. _getProperty(propertyPath: string): string;
  76713. /**
  76714. * Serialize this manager to a JSON object
  76715. * @param name defines the property name to store this manager
  76716. * @returns a JSON representation of this manager
  76717. */
  76718. serialize(name: string): any;
  76719. /**
  76720. * Creates a new ActionManager from a JSON data
  76721. * @param parsedActions defines the JSON data to read from
  76722. * @param object defines the hosting mesh
  76723. * @param scene defines the hosting scene
  76724. */
  76725. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  76726. /**
  76727. * Get a trigger name by index
  76728. * @param trigger defines the trigger index
  76729. * @returns a trigger name
  76730. */
  76731. static GetTriggerName(trigger: number): string;
  76732. }
  76733. }
  76734. declare module BABYLON {
  76735. /**
  76736. * Class representing a ray with position and direction
  76737. */
  76738. export class Ray {
  76739. /** origin point */
  76740. origin: Vector3;
  76741. /** direction */
  76742. direction: Vector3;
  76743. /** length of the ray */
  76744. length: number;
  76745. private static readonly TmpVector3;
  76746. private _tmpRay;
  76747. /**
  76748. * Creates a new ray
  76749. * @param origin origin point
  76750. * @param direction direction
  76751. * @param length length of the ray
  76752. */
  76753. constructor(
  76754. /** origin point */
  76755. origin: Vector3,
  76756. /** direction */
  76757. direction: Vector3,
  76758. /** length of the ray */
  76759. length?: number);
  76760. /**
  76761. * Checks if the ray intersects a box
  76762. * @param minimum bound of the box
  76763. * @param maximum bound of the box
  76764. * @param intersectionTreshold extra extend to be added to the box in all direction
  76765. * @returns if the box was hit
  76766. */
  76767. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  76768. /**
  76769. * Checks if the ray intersects a box
  76770. * @param box the bounding box to check
  76771. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  76772. * @returns if the box was hit
  76773. */
  76774. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  76775. /**
  76776. * If the ray hits a sphere
  76777. * @param sphere the bounding sphere to check
  76778. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  76779. * @returns true if it hits the sphere
  76780. */
  76781. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  76782. /**
  76783. * If the ray hits a triange
  76784. * @param vertex0 triangle vertex
  76785. * @param vertex1 triangle vertex
  76786. * @param vertex2 triangle vertex
  76787. * @returns intersection information if hit
  76788. */
  76789. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  76790. /**
  76791. * Checks if ray intersects a plane
  76792. * @param plane the plane to check
  76793. * @returns the distance away it was hit
  76794. */
  76795. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  76796. /**
  76797. * Calculate the intercept of a ray on a given axis
  76798. * @param axis to check 'x' | 'y' | 'z'
  76799. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  76800. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  76801. */
  76802. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  76803. /**
  76804. * Checks if ray intersects a mesh
  76805. * @param mesh the mesh to check
  76806. * @param fastCheck if only the bounding box should checked
  76807. * @returns picking info of the intersecton
  76808. */
  76809. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  76810. /**
  76811. * Checks if ray intersects a mesh
  76812. * @param meshes the meshes to check
  76813. * @param fastCheck if only the bounding box should checked
  76814. * @param results array to store result in
  76815. * @returns Array of picking infos
  76816. */
  76817. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  76818. private _comparePickingInfo;
  76819. private static smallnum;
  76820. private static rayl;
  76821. /**
  76822. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  76823. * @param sega the first point of the segment to test the intersection against
  76824. * @param segb the second point of the segment to test the intersection against
  76825. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  76826. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  76827. */
  76828. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  76829. /**
  76830. * Update the ray from viewport position
  76831. * @param x position
  76832. * @param y y position
  76833. * @param viewportWidth viewport width
  76834. * @param viewportHeight viewport height
  76835. * @param world world matrix
  76836. * @param view view matrix
  76837. * @param projection projection matrix
  76838. * @returns this ray updated
  76839. */
  76840. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76841. /**
  76842. * Creates a ray with origin and direction of 0,0,0
  76843. * @returns the new ray
  76844. */
  76845. static Zero(): Ray;
  76846. /**
  76847. * Creates a new ray from screen space and viewport
  76848. * @param x position
  76849. * @param y y position
  76850. * @param viewportWidth viewport width
  76851. * @param viewportHeight viewport height
  76852. * @param world world matrix
  76853. * @param view view matrix
  76854. * @param projection projection matrix
  76855. * @returns new ray
  76856. */
  76857. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  76858. /**
  76859. * 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
  76860. * transformed to the given world matrix.
  76861. * @param origin The origin point
  76862. * @param end The end point
  76863. * @param world a matrix to transform the ray to. Default is the identity matrix.
  76864. * @returns the new ray
  76865. */
  76866. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  76867. /**
  76868. * Transforms a ray by a matrix
  76869. * @param ray ray to transform
  76870. * @param matrix matrix to apply
  76871. * @returns the resulting new ray
  76872. */
  76873. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  76874. /**
  76875. * Transforms a ray by a matrix
  76876. * @param ray ray to transform
  76877. * @param matrix matrix to apply
  76878. * @param result ray to store result in
  76879. */
  76880. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  76881. /**
  76882. * Unproject a ray from screen space to object space
  76883. * @param sourceX defines the screen space x coordinate to use
  76884. * @param sourceY defines the screen space y coordinate to use
  76885. * @param viewportWidth defines the current width of the viewport
  76886. * @param viewportHeight defines the current height of the viewport
  76887. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76888. * @param view defines the view matrix to use
  76889. * @param projection defines the projection matrix to use
  76890. */
  76891. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  76892. }
  76893. /**
  76894. * Type used to define predicate used to select faces when a mesh intersection is detected
  76895. */
  76896. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  76897. interface Scene {
  76898. /** @hidden */
  76899. _tempPickingRay: Nullable<Ray>;
  76900. /** @hidden */
  76901. _cachedRayForTransform: Ray;
  76902. /** @hidden */
  76903. _pickWithRayInverseMatrix: Matrix;
  76904. /** @hidden */
  76905. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  76906. /** @hidden */
  76907. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  76908. }
  76909. }
  76910. declare module BABYLON {
  76911. /**
  76912. * Groups all the scene component constants in one place to ease maintenance.
  76913. * @hidden
  76914. */
  76915. export class SceneComponentConstants {
  76916. static readonly NAME_EFFECTLAYER: string;
  76917. static readonly NAME_LAYER: string;
  76918. static readonly NAME_LENSFLARESYSTEM: string;
  76919. static readonly NAME_BOUNDINGBOXRENDERER: string;
  76920. static readonly NAME_PARTICLESYSTEM: string;
  76921. static readonly NAME_GAMEPAD: string;
  76922. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  76923. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  76924. static readonly NAME_DEPTHRENDERER: string;
  76925. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  76926. static readonly NAME_SPRITE: string;
  76927. static readonly NAME_OUTLINERENDERER: string;
  76928. static readonly NAME_PROCEDURALTEXTURE: string;
  76929. static readonly NAME_SHADOWGENERATOR: string;
  76930. static readonly NAME_OCTREE: string;
  76931. static readonly NAME_PHYSICSENGINE: string;
  76932. static readonly NAME_AUDIO: string;
  76933. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  76934. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76935. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  76936. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  76937. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  76938. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  76939. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  76940. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  76941. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  76942. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  76943. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  76944. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  76945. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  76946. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  76947. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  76948. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  76949. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  76950. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  76951. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  76952. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  76953. static readonly STEP_AFTERRENDER_AUDIO: number;
  76954. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  76955. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  76956. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  76957. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  76958. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  76959. static readonly STEP_POINTERMOVE_SPRITE: number;
  76960. static readonly STEP_POINTERDOWN_SPRITE: number;
  76961. static readonly STEP_POINTERUP_SPRITE: number;
  76962. }
  76963. /**
  76964. * This represents a scene component.
  76965. *
  76966. * This is used to decouple the dependency the scene is having on the different workloads like
  76967. * layers, post processes...
  76968. */
  76969. export interface ISceneComponent {
  76970. /**
  76971. * The name of the component. Each component must have a unique name.
  76972. */
  76973. name: string;
  76974. /**
  76975. * The scene the component belongs to.
  76976. */
  76977. scene: Scene;
  76978. /**
  76979. * Register the component to one instance of a scene.
  76980. */
  76981. register(): void;
  76982. /**
  76983. * Rebuilds the elements related to this component in case of
  76984. * context lost for instance.
  76985. */
  76986. rebuild(): void;
  76987. /**
  76988. * Disposes the component and the associated ressources.
  76989. */
  76990. dispose(): void;
  76991. }
  76992. /**
  76993. * This represents a SERIALIZABLE scene component.
  76994. *
  76995. * This extends Scene Component to add Serialization methods on top.
  76996. */
  76997. export interface ISceneSerializableComponent extends ISceneComponent {
  76998. /**
  76999. * Adds all the elements from the container to the scene
  77000. * @param container the container holding the elements
  77001. */
  77002. addFromContainer(container: AbstractScene): void;
  77003. /**
  77004. * Removes all the elements in the container from the scene
  77005. * @param container contains the elements to remove
  77006. * @param dispose if the removed element should be disposed (default: false)
  77007. */
  77008. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77009. /**
  77010. * Serializes the component data to the specified json object
  77011. * @param serializationObject The object to serialize to
  77012. */
  77013. serialize(serializationObject: any): void;
  77014. }
  77015. /**
  77016. * Strong typing of a Mesh related stage step action
  77017. */
  77018. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  77019. /**
  77020. * Strong typing of a Evaluate Sub Mesh related stage step action
  77021. */
  77022. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  77023. /**
  77024. * Strong typing of a Active Mesh related stage step action
  77025. */
  77026. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  77027. /**
  77028. * Strong typing of a Camera related stage step action
  77029. */
  77030. export type CameraStageAction = (camera: Camera) => void;
  77031. /**
  77032. * Strong typing of a Camera Frame buffer related stage step action
  77033. */
  77034. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  77035. /**
  77036. * Strong typing of a Render Target related stage step action
  77037. */
  77038. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  77039. /**
  77040. * Strong typing of a RenderingGroup related stage step action
  77041. */
  77042. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  77043. /**
  77044. * Strong typing of a Mesh Render related stage step action
  77045. */
  77046. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  77047. /**
  77048. * Strong typing of a simple stage step action
  77049. */
  77050. export type SimpleStageAction = () => void;
  77051. /**
  77052. * Strong typing of a render target action.
  77053. */
  77054. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  77055. /**
  77056. * Strong typing of a pointer move action.
  77057. */
  77058. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  77059. /**
  77060. * Strong typing of a pointer up/down action.
  77061. */
  77062. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  77063. /**
  77064. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  77065. * @hidden
  77066. */
  77067. export class Stage<T extends Function> extends Array<{
  77068. index: number;
  77069. component: ISceneComponent;
  77070. action: T;
  77071. }> {
  77072. /**
  77073. * Hide ctor from the rest of the world.
  77074. * @param items The items to add.
  77075. */
  77076. private constructor();
  77077. /**
  77078. * Creates a new Stage.
  77079. * @returns A new instance of a Stage
  77080. */
  77081. static Create<T extends Function>(): Stage<T>;
  77082. /**
  77083. * Registers a step in an ordered way in the targeted stage.
  77084. * @param index Defines the position to register the step in
  77085. * @param component Defines the component attached to the step
  77086. * @param action Defines the action to launch during the step
  77087. */
  77088. registerStep(index: number, component: ISceneComponent, action: T): void;
  77089. /**
  77090. * Clears all the steps from the stage.
  77091. */
  77092. clear(): void;
  77093. }
  77094. }
  77095. declare module BABYLON {
  77096. interface Scene {
  77097. /** @hidden */
  77098. _pointerOverSprite: Nullable<Sprite>;
  77099. /** @hidden */
  77100. _pickedDownSprite: Nullable<Sprite>;
  77101. /** @hidden */
  77102. _tempSpritePickingRay: Nullable<Ray>;
  77103. /**
  77104. * All of the sprite managers added to this scene
  77105. * @see http://doc.babylonjs.com/babylon101/sprites
  77106. */
  77107. spriteManagers: Array<ISpriteManager>;
  77108. /**
  77109. * An event triggered when sprites rendering is about to start
  77110. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77111. */
  77112. onBeforeSpritesRenderingObservable: Observable<Scene>;
  77113. /**
  77114. * An event triggered when sprites rendering is done
  77115. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  77116. */
  77117. onAfterSpritesRenderingObservable: Observable<Scene>;
  77118. /** @hidden */
  77119. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77120. /** Launch a ray to try to pick a sprite in the scene
  77121. * @param x position on screen
  77122. * @param y position on screen
  77123. * @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
  77124. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77125. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77126. * @returns a PickingInfo
  77127. */
  77128. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77129. /** Use the given ray to pick a sprite in the scene
  77130. * @param ray The ray (in world space) to use to pick meshes
  77131. * @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
  77132. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  77133. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77134. * @returns a PickingInfo
  77135. */
  77136. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  77137. /** @hidden */
  77138. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77139. /** Launch a ray to try to pick sprites in the scene
  77140. * @param x position on screen
  77141. * @param y position on screen
  77142. * @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
  77143. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  77144. * @returns a PickingInfo array
  77145. */
  77146. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77147. /** Use the given ray to pick sprites in the scene
  77148. * @param ray The ray (in world space) to use to pick meshes
  77149. * @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
  77150. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  77151. * @returns a PickingInfo array
  77152. */
  77153. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  77154. /**
  77155. * Force the sprite under the pointer
  77156. * @param sprite defines the sprite to use
  77157. */
  77158. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  77159. /**
  77160. * Gets the sprite under the pointer
  77161. * @returns a Sprite or null if no sprite is under the pointer
  77162. */
  77163. getPointerOverSprite(): Nullable<Sprite>;
  77164. }
  77165. /**
  77166. * Defines the sprite scene component responsible to manage sprites
  77167. * in a given scene.
  77168. */
  77169. export class SpriteSceneComponent implements ISceneComponent {
  77170. /**
  77171. * The component name helpfull to identify the component in the list of scene components.
  77172. */
  77173. readonly name: string;
  77174. /**
  77175. * The scene the component belongs to.
  77176. */
  77177. scene: Scene;
  77178. /** @hidden */
  77179. private _spritePredicate;
  77180. /**
  77181. * Creates a new instance of the component for the given scene
  77182. * @param scene Defines the scene to register the component in
  77183. */
  77184. constructor(scene: Scene);
  77185. /**
  77186. * Registers the component in a given scene
  77187. */
  77188. register(): void;
  77189. /**
  77190. * Rebuilds the elements related to this component in case of
  77191. * context lost for instance.
  77192. */
  77193. rebuild(): void;
  77194. /**
  77195. * Disposes the component and the associated ressources.
  77196. */
  77197. dispose(): void;
  77198. private _pickSpriteButKeepRay;
  77199. private _pointerMove;
  77200. private _pointerDown;
  77201. private _pointerUp;
  77202. }
  77203. }
  77204. declare module BABYLON {
  77205. /** @hidden */
  77206. export var fogFragmentDeclaration: {
  77207. name: string;
  77208. shader: string;
  77209. };
  77210. }
  77211. declare module BABYLON {
  77212. /** @hidden */
  77213. export var fogFragment: {
  77214. name: string;
  77215. shader: string;
  77216. };
  77217. }
  77218. declare module BABYLON {
  77219. /** @hidden */
  77220. export var spritesPixelShader: {
  77221. name: string;
  77222. shader: string;
  77223. };
  77224. }
  77225. declare module BABYLON {
  77226. /** @hidden */
  77227. export var fogVertexDeclaration: {
  77228. name: string;
  77229. shader: string;
  77230. };
  77231. }
  77232. declare module BABYLON {
  77233. /** @hidden */
  77234. export var spritesVertexShader: {
  77235. name: string;
  77236. shader: string;
  77237. };
  77238. }
  77239. declare module BABYLON {
  77240. /**
  77241. * Defines the minimum interface to fullfil in order to be a sprite manager.
  77242. */
  77243. export interface ISpriteManager extends IDisposable {
  77244. /**
  77245. * Restricts the camera to viewing objects with the same layerMask.
  77246. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  77247. */
  77248. layerMask: number;
  77249. /**
  77250. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  77251. */
  77252. isPickable: boolean;
  77253. /**
  77254. * Specifies the rendering group id for this mesh (0 by default)
  77255. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  77256. */
  77257. renderingGroupId: number;
  77258. /**
  77259. * Defines the list of sprites managed by the manager.
  77260. */
  77261. sprites: Array<Sprite>;
  77262. /**
  77263. * Tests the intersection of a sprite with a specific ray.
  77264. * @param ray The ray we are sending to test the collision
  77265. * @param camera The camera space we are sending rays in
  77266. * @param predicate A predicate allowing excluding sprites from the list of object to test
  77267. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  77268. * @returns picking info or null.
  77269. */
  77270. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77271. /**
  77272. * Intersects the sprites with a ray
  77273. * @param ray defines the ray to intersect with
  77274. * @param camera defines the current active camera
  77275. * @param predicate defines a predicate used to select candidate sprites
  77276. * @returns null if no hit or a PickingInfo array
  77277. */
  77278. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77279. /**
  77280. * Renders the list of sprites on screen.
  77281. */
  77282. render(): void;
  77283. }
  77284. /**
  77285. * Class used to manage multiple sprites on the same spritesheet
  77286. * @see http://doc.babylonjs.com/babylon101/sprites
  77287. */
  77288. export class SpriteManager implements ISpriteManager {
  77289. /** defines the manager's name */
  77290. name: string;
  77291. /** Gets the list of sprites */
  77292. sprites: Sprite[];
  77293. /** Gets or sets the rendering group id (0 by default) */
  77294. renderingGroupId: number;
  77295. /** Gets or sets camera layer mask */
  77296. layerMask: number;
  77297. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  77298. fogEnabled: boolean;
  77299. /** Gets or sets a boolean indicating if the sprites are pickable */
  77300. isPickable: boolean;
  77301. /** Defines the default width of a cell in the spritesheet */
  77302. cellWidth: number;
  77303. /** Defines the default height of a cell in the spritesheet */
  77304. cellHeight: number;
  77305. /** Associative array from JSON sprite data file */
  77306. private _cellData;
  77307. /** Array of sprite names from JSON sprite data file */
  77308. private _spriteMap;
  77309. /** True when packed cell data from JSON file is ready*/
  77310. private _packedAndReady;
  77311. /**
  77312. * An event triggered when the manager is disposed.
  77313. */
  77314. onDisposeObservable: Observable<SpriteManager>;
  77315. private _onDisposeObserver;
  77316. /**
  77317. * Callback called when the manager is disposed
  77318. */
  77319. onDispose: () => void;
  77320. private _capacity;
  77321. private _fromPacked;
  77322. private _spriteTexture;
  77323. private _epsilon;
  77324. private _scene;
  77325. private _vertexData;
  77326. private _buffer;
  77327. private _vertexBuffers;
  77328. private _indexBuffer;
  77329. private _effectBase;
  77330. private _effectFog;
  77331. /**
  77332. * Gets or sets the spritesheet texture
  77333. */
  77334. texture: Texture;
  77335. /**
  77336. * Creates a new sprite manager
  77337. * @param name defines the manager's name
  77338. * @param imgUrl defines the sprite sheet url
  77339. * @param capacity defines the maximum allowed number of sprites
  77340. * @param cellSize defines the size of a sprite cell
  77341. * @param scene defines the hosting scene
  77342. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77343. * @param samplingMode defines the smapling mode to use with spritesheet
  77344. * @param fromPacked set to false; do not alter
  77345. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  77346. */
  77347. constructor(
  77348. /** defines the manager's name */
  77349. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  77350. private _makePacked;
  77351. private _appendSpriteVertex;
  77352. /**
  77353. * Intersects the sprites with a ray
  77354. * @param ray defines the ray to intersect with
  77355. * @param camera defines the current active camera
  77356. * @param predicate defines a predicate used to select candidate sprites
  77357. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  77358. * @returns null if no hit or a PickingInfo
  77359. */
  77360. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  77361. /**
  77362. * Intersects the sprites with a ray
  77363. * @param ray defines the ray to intersect with
  77364. * @param camera defines the current active camera
  77365. * @param predicate defines a predicate used to select candidate sprites
  77366. * @returns null if no hit or a PickingInfo array
  77367. */
  77368. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  77369. /**
  77370. * Render all child sprites
  77371. */
  77372. render(): void;
  77373. /**
  77374. * Release associated resources
  77375. */
  77376. dispose(): void;
  77377. }
  77378. }
  77379. declare module BABYLON {
  77380. /**
  77381. * Class used to represent a sprite
  77382. * @see http://doc.babylonjs.com/babylon101/sprites
  77383. */
  77384. export class Sprite {
  77385. /** defines the name */
  77386. name: string;
  77387. /** Gets or sets the current world position */
  77388. position: Vector3;
  77389. /** Gets or sets the main color */
  77390. color: Color4;
  77391. /** Gets or sets the width */
  77392. width: number;
  77393. /** Gets or sets the height */
  77394. height: number;
  77395. /** Gets or sets rotation angle */
  77396. angle: number;
  77397. /** Gets or sets the cell index in the sprite sheet */
  77398. cellIndex: number;
  77399. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  77400. cellRef: string;
  77401. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  77402. invertU: number;
  77403. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  77404. invertV: number;
  77405. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  77406. disposeWhenFinishedAnimating: boolean;
  77407. /** Gets the list of attached animations */
  77408. animations: Animation[];
  77409. /** Gets or sets a boolean indicating if the sprite can be picked */
  77410. isPickable: boolean;
  77411. /**
  77412. * Gets or sets the associated action manager
  77413. */
  77414. actionManager: Nullable<ActionManager>;
  77415. private _animationStarted;
  77416. private _loopAnimation;
  77417. private _fromIndex;
  77418. private _toIndex;
  77419. private _delay;
  77420. private _direction;
  77421. private _manager;
  77422. private _time;
  77423. private _onAnimationEnd;
  77424. /**
  77425. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  77426. */
  77427. isVisible: boolean;
  77428. /**
  77429. * Gets or sets the sprite size
  77430. */
  77431. size: number;
  77432. /**
  77433. * Creates a new Sprite
  77434. * @param name defines the name
  77435. * @param manager defines the manager
  77436. */
  77437. constructor(
  77438. /** defines the name */
  77439. name: string, manager: ISpriteManager);
  77440. /**
  77441. * Starts an animation
  77442. * @param from defines the initial key
  77443. * @param to defines the end key
  77444. * @param loop defines if the animation must loop
  77445. * @param delay defines the start delay (in ms)
  77446. * @param onAnimationEnd defines a callback to call when animation ends
  77447. */
  77448. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  77449. /** Stops current animation (if any) */
  77450. stopAnimation(): void;
  77451. /** @hidden */
  77452. _animate(deltaTime: number): void;
  77453. /** Release associated resources */
  77454. dispose(): void;
  77455. }
  77456. }
  77457. declare module BABYLON {
  77458. /**
  77459. * Information about the result of picking within a scene
  77460. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  77461. */
  77462. export class PickingInfo {
  77463. /** @hidden */
  77464. _pickingUnavailable: boolean;
  77465. /**
  77466. * If the pick collided with an object
  77467. */
  77468. hit: boolean;
  77469. /**
  77470. * Distance away where the pick collided
  77471. */
  77472. distance: number;
  77473. /**
  77474. * The location of pick collision
  77475. */
  77476. pickedPoint: Nullable<Vector3>;
  77477. /**
  77478. * The mesh corresponding the the pick collision
  77479. */
  77480. pickedMesh: Nullable<AbstractMesh>;
  77481. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  77482. bu: number;
  77483. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  77484. bv: number;
  77485. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  77486. faceId: number;
  77487. /** Id of the the submesh that was picked */
  77488. subMeshId: number;
  77489. /** If a sprite was picked, this will be the sprite the pick collided with */
  77490. pickedSprite: Nullable<Sprite>;
  77491. /**
  77492. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  77493. */
  77494. originMesh: Nullable<AbstractMesh>;
  77495. /**
  77496. * The ray that was used to perform the picking.
  77497. */
  77498. ray: Nullable<Ray>;
  77499. /**
  77500. * Gets the normal correspodning to the face the pick collided with
  77501. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  77502. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  77503. * @returns The normal correspodning to the face the pick collided with
  77504. */
  77505. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  77506. /**
  77507. * Gets the texture coordinates of where the pick occured
  77508. * @returns the vector containing the coordnates of the texture
  77509. */
  77510. getTextureCoordinates(): Nullable<Vector2>;
  77511. }
  77512. }
  77513. declare module BABYLON {
  77514. /**
  77515. * Gather the list of pointer event types as constants.
  77516. */
  77517. export class PointerEventTypes {
  77518. /**
  77519. * 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.
  77520. */
  77521. static readonly POINTERDOWN: number;
  77522. /**
  77523. * The pointerup event is fired when a pointer is no longer active.
  77524. */
  77525. static readonly POINTERUP: number;
  77526. /**
  77527. * The pointermove event is fired when a pointer changes coordinates.
  77528. */
  77529. static readonly POINTERMOVE: number;
  77530. /**
  77531. * The pointerwheel event is fired when a mouse wheel has been rotated.
  77532. */
  77533. static readonly POINTERWHEEL: number;
  77534. /**
  77535. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  77536. */
  77537. static readonly POINTERPICK: number;
  77538. /**
  77539. * The pointertap event is fired when a the object has been touched and released without drag.
  77540. */
  77541. static readonly POINTERTAP: number;
  77542. /**
  77543. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  77544. */
  77545. static readonly POINTERDOUBLETAP: number;
  77546. }
  77547. /**
  77548. * Base class of pointer info types.
  77549. */
  77550. export class PointerInfoBase {
  77551. /**
  77552. * Defines the type of event (PointerEventTypes)
  77553. */
  77554. type: number;
  77555. /**
  77556. * Defines the related dom event
  77557. */
  77558. event: PointerEvent | MouseWheelEvent;
  77559. /**
  77560. * Instantiates the base class of pointers info.
  77561. * @param type Defines the type of event (PointerEventTypes)
  77562. * @param event Defines the related dom event
  77563. */
  77564. constructor(
  77565. /**
  77566. * Defines the type of event (PointerEventTypes)
  77567. */
  77568. type: number,
  77569. /**
  77570. * Defines the related dom event
  77571. */
  77572. event: PointerEvent | MouseWheelEvent);
  77573. }
  77574. /**
  77575. * This class is used to store pointer related info for the onPrePointerObservable event.
  77576. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  77577. */
  77578. export class PointerInfoPre extends PointerInfoBase {
  77579. /**
  77580. * Ray from a pointer if availible (eg. 6dof controller)
  77581. */
  77582. ray: Nullable<Ray>;
  77583. /**
  77584. * Defines the local position of the pointer on the canvas.
  77585. */
  77586. localPosition: Vector2;
  77587. /**
  77588. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  77589. */
  77590. skipOnPointerObservable: boolean;
  77591. /**
  77592. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  77593. * @param type Defines the type of event (PointerEventTypes)
  77594. * @param event Defines the related dom event
  77595. * @param localX Defines the local x coordinates of the pointer when the event occured
  77596. * @param localY Defines the local y coordinates of the pointer when the event occured
  77597. */
  77598. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  77599. }
  77600. /**
  77601. * This type contains all the data related to a pointer event in Babylon.js.
  77602. * 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.
  77603. */
  77604. export class PointerInfo extends PointerInfoBase {
  77605. /**
  77606. * Defines the picking info associated to the info (if any)\
  77607. */
  77608. pickInfo: Nullable<PickingInfo>;
  77609. /**
  77610. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  77611. * @param type Defines the type of event (PointerEventTypes)
  77612. * @param event Defines the related dom event
  77613. * @param pickInfo Defines the picking info associated to the info (if any)\
  77614. */
  77615. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  77616. /**
  77617. * Defines the picking info associated to the info (if any)\
  77618. */
  77619. pickInfo: Nullable<PickingInfo>);
  77620. }
  77621. /**
  77622. * Data relating to a touch event on the screen.
  77623. */
  77624. export interface PointerTouch {
  77625. /**
  77626. * X coordinate of touch.
  77627. */
  77628. x: number;
  77629. /**
  77630. * Y coordinate of touch.
  77631. */
  77632. y: number;
  77633. /**
  77634. * Id of touch. Unique for each finger.
  77635. */
  77636. pointerId: number;
  77637. /**
  77638. * Event type passed from DOM.
  77639. */
  77640. type: any;
  77641. }
  77642. }
  77643. declare module BABYLON {
  77644. /**
  77645. * Manage the mouse inputs to control the movement of a free camera.
  77646. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77647. */
  77648. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  77649. /**
  77650. * Define if touch is enabled in the mouse input
  77651. */
  77652. touchEnabled: boolean;
  77653. /**
  77654. * Defines the camera the input is attached to.
  77655. */
  77656. camera: FreeCamera;
  77657. /**
  77658. * Defines the buttons associated with the input to handle camera move.
  77659. */
  77660. buttons: number[];
  77661. /**
  77662. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  77663. */
  77664. angularSensibility: number;
  77665. private _pointerInput;
  77666. private _onMouseMove;
  77667. private _observer;
  77668. private previousPosition;
  77669. /**
  77670. * Observable for when a pointer move event occurs containing the move offset
  77671. */
  77672. onPointerMovedObservable: Observable<{
  77673. offsetX: number;
  77674. offsetY: number;
  77675. }>;
  77676. /**
  77677. * @hidden
  77678. * If the camera should be rotated automatically based on pointer movement
  77679. */
  77680. _allowCameraRotation: boolean;
  77681. /**
  77682. * Manage the mouse inputs to control the movement of a free camera.
  77683. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77684. * @param touchEnabled Defines if touch is enabled or not
  77685. */
  77686. constructor(
  77687. /**
  77688. * Define if touch is enabled in the mouse input
  77689. */
  77690. touchEnabled?: boolean);
  77691. /**
  77692. * Attach the input controls to a specific dom element to get the input from.
  77693. * @param element Defines the element the controls should be listened from
  77694. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77695. */
  77696. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77697. /**
  77698. * Called on JS contextmenu event.
  77699. * Override this method to provide functionality.
  77700. */
  77701. protected onContextMenu(evt: PointerEvent): void;
  77702. /**
  77703. * Detach the current controls from the specified dom element.
  77704. * @param element Defines the element to stop listening the inputs from
  77705. */
  77706. detachControl(element: Nullable<HTMLElement>): void;
  77707. /**
  77708. * Gets the class name of the current intput.
  77709. * @returns the class name
  77710. */
  77711. getClassName(): string;
  77712. /**
  77713. * Get the friendly name associated with the input class.
  77714. * @returns the input friendly name
  77715. */
  77716. getSimpleName(): string;
  77717. }
  77718. }
  77719. declare module BABYLON {
  77720. /**
  77721. * Manage the touch inputs to control the movement of a free camera.
  77722. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77723. */
  77724. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  77725. /**
  77726. * Defines the camera the input is attached to.
  77727. */
  77728. camera: FreeCamera;
  77729. /**
  77730. * Defines the touch sensibility for rotation.
  77731. * The higher the faster.
  77732. */
  77733. touchAngularSensibility: number;
  77734. /**
  77735. * Defines the touch sensibility for move.
  77736. * The higher the faster.
  77737. */
  77738. touchMoveSensibility: number;
  77739. private _offsetX;
  77740. private _offsetY;
  77741. private _pointerPressed;
  77742. private _pointerInput;
  77743. private _observer;
  77744. private _onLostFocus;
  77745. /**
  77746. * Attach the input controls to a specific dom element to get the input from.
  77747. * @param element Defines the element the controls should be listened from
  77748. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77749. */
  77750. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77751. /**
  77752. * Detach the current controls from the specified dom element.
  77753. * @param element Defines the element to stop listening the inputs from
  77754. */
  77755. detachControl(element: Nullable<HTMLElement>): void;
  77756. /**
  77757. * Update the current camera state depending on the inputs that have been used this frame.
  77758. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77759. */
  77760. checkInputs(): void;
  77761. /**
  77762. * Gets the class name of the current intput.
  77763. * @returns the class name
  77764. */
  77765. getClassName(): string;
  77766. /**
  77767. * Get the friendly name associated with the input class.
  77768. * @returns the input friendly name
  77769. */
  77770. getSimpleName(): string;
  77771. }
  77772. }
  77773. declare module BABYLON {
  77774. /**
  77775. * Default Inputs manager for the FreeCamera.
  77776. * It groups all the default supported inputs for ease of use.
  77777. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77778. */
  77779. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  77780. /**
  77781. * @hidden
  77782. */
  77783. _mouseInput: Nullable<FreeCameraMouseInput>;
  77784. /**
  77785. * Instantiates a new FreeCameraInputsManager.
  77786. * @param camera Defines the camera the inputs belong to
  77787. */
  77788. constructor(camera: FreeCamera);
  77789. /**
  77790. * Add keyboard input support to the input manager.
  77791. * @returns the current input manager
  77792. */
  77793. addKeyboard(): FreeCameraInputsManager;
  77794. /**
  77795. * Add mouse input support to the input manager.
  77796. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  77797. * @returns the current input manager
  77798. */
  77799. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  77800. /**
  77801. * Removes the mouse input support from the manager
  77802. * @returns the current input manager
  77803. */
  77804. removeMouse(): FreeCameraInputsManager;
  77805. /**
  77806. * Add touch input support to the input manager.
  77807. * @returns the current input manager
  77808. */
  77809. addTouch(): FreeCameraInputsManager;
  77810. /**
  77811. * Remove all attached input methods from a camera
  77812. */
  77813. clear(): void;
  77814. }
  77815. }
  77816. declare module BABYLON {
  77817. /**
  77818. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77819. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  77820. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77821. */
  77822. export class FreeCamera extends TargetCamera {
  77823. /**
  77824. * Define the collision ellipsoid of the camera.
  77825. * This is helpful to simulate a camera body like the player body around the camera
  77826. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  77827. */
  77828. ellipsoid: Vector3;
  77829. /**
  77830. * Define an offset for the position of the ellipsoid around the camera.
  77831. * This can be helpful to determine the center of the body near the gravity center of the body
  77832. * instead of its head.
  77833. */
  77834. ellipsoidOffset: Vector3;
  77835. /**
  77836. * Enable or disable collisions of the camera with the rest of the scene objects.
  77837. */
  77838. checkCollisions: boolean;
  77839. /**
  77840. * Enable or disable gravity on the camera.
  77841. */
  77842. applyGravity: boolean;
  77843. /**
  77844. * Define the input manager associated to the camera.
  77845. */
  77846. inputs: FreeCameraInputsManager;
  77847. /**
  77848. * Gets the input sensibility for a mouse input. (default is 2000.0)
  77849. * Higher values reduce sensitivity.
  77850. */
  77851. /**
  77852. * Sets the input sensibility for a mouse input. (default is 2000.0)
  77853. * Higher values reduce sensitivity.
  77854. */
  77855. angularSensibility: number;
  77856. /**
  77857. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  77858. */
  77859. keysUp: number[];
  77860. /**
  77861. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  77862. */
  77863. keysDown: number[];
  77864. /**
  77865. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  77866. */
  77867. keysLeft: number[];
  77868. /**
  77869. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  77870. */
  77871. keysRight: number[];
  77872. /**
  77873. * Event raised when the camera collide with a mesh in the scene.
  77874. */
  77875. onCollide: (collidedMesh: AbstractMesh) => void;
  77876. private _collider;
  77877. private _needMoveForGravity;
  77878. private _oldPosition;
  77879. private _diffPosition;
  77880. private _newPosition;
  77881. /** @hidden */
  77882. _localDirection: Vector3;
  77883. /** @hidden */
  77884. _transformedDirection: Vector3;
  77885. /**
  77886. * Instantiates a Free Camera.
  77887. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  77888. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  77889. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  77890. * @param name Define the name of the camera in the scene
  77891. * @param position Define the start position of the camera in the scene
  77892. * @param scene Define the scene the camera belongs to
  77893. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  77894. */
  77895. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  77896. /**
  77897. * Attached controls to the current camera.
  77898. * @param element Defines the element the controls should be listened from
  77899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77900. */
  77901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77902. /**
  77903. * Detach the current controls from the camera.
  77904. * The camera will stop reacting to inputs.
  77905. * @param element Defines the element to stop listening the inputs from
  77906. */
  77907. detachControl(element: HTMLElement): void;
  77908. private _collisionMask;
  77909. /**
  77910. * Define a collision mask to limit the list of object the camera can collide with
  77911. */
  77912. collisionMask: number;
  77913. /** @hidden */
  77914. _collideWithWorld(displacement: Vector3): void;
  77915. private _onCollisionPositionChange;
  77916. /** @hidden */
  77917. _checkInputs(): void;
  77918. /** @hidden */
  77919. _decideIfNeedsToMove(): boolean;
  77920. /** @hidden */
  77921. _updatePosition(): void;
  77922. /**
  77923. * Destroy the camera and release the current resources hold by it.
  77924. */
  77925. dispose(): void;
  77926. /**
  77927. * Gets the current object class name.
  77928. * @return the class name
  77929. */
  77930. getClassName(): string;
  77931. }
  77932. }
  77933. declare module BABYLON {
  77934. /**
  77935. * Represents a gamepad control stick position
  77936. */
  77937. export class StickValues {
  77938. /**
  77939. * The x component of the control stick
  77940. */
  77941. x: number;
  77942. /**
  77943. * The y component of the control stick
  77944. */
  77945. y: number;
  77946. /**
  77947. * Initializes the gamepad x and y control stick values
  77948. * @param x The x component of the gamepad control stick value
  77949. * @param y The y component of the gamepad control stick value
  77950. */
  77951. constructor(
  77952. /**
  77953. * The x component of the control stick
  77954. */
  77955. x: number,
  77956. /**
  77957. * The y component of the control stick
  77958. */
  77959. y: number);
  77960. }
  77961. /**
  77962. * An interface which manages callbacks for gamepad button changes
  77963. */
  77964. export interface GamepadButtonChanges {
  77965. /**
  77966. * Called when a gamepad has been changed
  77967. */
  77968. changed: boolean;
  77969. /**
  77970. * Called when a gamepad press event has been triggered
  77971. */
  77972. pressChanged: boolean;
  77973. /**
  77974. * Called when a touch event has been triggered
  77975. */
  77976. touchChanged: boolean;
  77977. /**
  77978. * Called when a value has changed
  77979. */
  77980. valueChanged: boolean;
  77981. }
  77982. /**
  77983. * Represents a gamepad
  77984. */
  77985. export class Gamepad {
  77986. /**
  77987. * The id of the gamepad
  77988. */
  77989. id: string;
  77990. /**
  77991. * The index of the gamepad
  77992. */
  77993. index: number;
  77994. /**
  77995. * The browser gamepad
  77996. */
  77997. browserGamepad: any;
  77998. /**
  77999. * Specifies what type of gamepad this represents
  78000. */
  78001. type: number;
  78002. private _leftStick;
  78003. private _rightStick;
  78004. /** @hidden */
  78005. _isConnected: boolean;
  78006. private _leftStickAxisX;
  78007. private _leftStickAxisY;
  78008. private _rightStickAxisX;
  78009. private _rightStickAxisY;
  78010. /**
  78011. * Triggered when the left control stick has been changed
  78012. */
  78013. private _onleftstickchanged;
  78014. /**
  78015. * Triggered when the right control stick has been changed
  78016. */
  78017. private _onrightstickchanged;
  78018. /**
  78019. * Represents a gamepad controller
  78020. */
  78021. static GAMEPAD: number;
  78022. /**
  78023. * Represents a generic controller
  78024. */
  78025. static GENERIC: number;
  78026. /**
  78027. * Represents an XBox controller
  78028. */
  78029. static XBOX: number;
  78030. /**
  78031. * Represents a pose-enabled controller
  78032. */
  78033. static POSE_ENABLED: number;
  78034. /**
  78035. * Represents an Dual Shock controller
  78036. */
  78037. static DUALSHOCK: number;
  78038. /**
  78039. * Specifies whether the left control stick should be Y-inverted
  78040. */
  78041. protected _invertLeftStickY: boolean;
  78042. /**
  78043. * Specifies if the gamepad has been connected
  78044. */
  78045. readonly isConnected: boolean;
  78046. /**
  78047. * Initializes the gamepad
  78048. * @param id The id of the gamepad
  78049. * @param index The index of the gamepad
  78050. * @param browserGamepad The browser gamepad
  78051. * @param leftStickX The x component of the left joystick
  78052. * @param leftStickY The y component of the left joystick
  78053. * @param rightStickX The x component of the right joystick
  78054. * @param rightStickY The y component of the right joystick
  78055. */
  78056. constructor(
  78057. /**
  78058. * The id of the gamepad
  78059. */
  78060. id: string,
  78061. /**
  78062. * The index of the gamepad
  78063. */
  78064. index: number,
  78065. /**
  78066. * The browser gamepad
  78067. */
  78068. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  78069. /**
  78070. * Callback triggered when the left joystick has changed
  78071. * @param callback
  78072. */
  78073. onleftstickchanged(callback: (values: StickValues) => void): void;
  78074. /**
  78075. * Callback triggered when the right joystick has changed
  78076. * @param callback
  78077. */
  78078. onrightstickchanged(callback: (values: StickValues) => void): void;
  78079. /**
  78080. * Gets the left joystick
  78081. */
  78082. /**
  78083. * Sets the left joystick values
  78084. */
  78085. leftStick: StickValues;
  78086. /**
  78087. * Gets the right joystick
  78088. */
  78089. /**
  78090. * Sets the right joystick value
  78091. */
  78092. rightStick: StickValues;
  78093. /**
  78094. * Updates the gamepad joystick positions
  78095. */
  78096. update(): void;
  78097. /**
  78098. * Disposes the gamepad
  78099. */
  78100. dispose(): void;
  78101. }
  78102. /**
  78103. * Represents a generic gamepad
  78104. */
  78105. export class GenericPad extends Gamepad {
  78106. private _buttons;
  78107. private _onbuttondown;
  78108. private _onbuttonup;
  78109. /**
  78110. * Observable triggered when a button has been pressed
  78111. */
  78112. onButtonDownObservable: Observable<number>;
  78113. /**
  78114. * Observable triggered when a button has been released
  78115. */
  78116. onButtonUpObservable: Observable<number>;
  78117. /**
  78118. * Callback triggered when a button has been pressed
  78119. * @param callback Called when a button has been pressed
  78120. */
  78121. onbuttondown(callback: (buttonPressed: number) => void): void;
  78122. /**
  78123. * Callback triggered when a button has been released
  78124. * @param callback Called when a button has been released
  78125. */
  78126. onbuttonup(callback: (buttonReleased: number) => void): void;
  78127. /**
  78128. * Initializes the generic gamepad
  78129. * @param id The id of the generic gamepad
  78130. * @param index The index of the generic gamepad
  78131. * @param browserGamepad The browser gamepad
  78132. */
  78133. constructor(id: string, index: number, browserGamepad: any);
  78134. private _setButtonValue;
  78135. /**
  78136. * Updates the generic gamepad
  78137. */
  78138. update(): void;
  78139. /**
  78140. * Disposes the generic gamepad
  78141. */
  78142. dispose(): void;
  78143. }
  78144. }
  78145. declare module BABYLON {
  78146. interface Engine {
  78147. /**
  78148. * Creates a raw texture
  78149. * @param data defines the data to store in the texture
  78150. * @param width defines the width of the texture
  78151. * @param height defines the height of the texture
  78152. * @param format defines the format of the data
  78153. * @param generateMipMaps defines if the engine should generate the mip levels
  78154. * @param invertY defines if data must be stored with Y axis inverted
  78155. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78156. * @param compression defines the compression used (null by default)
  78157. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78158. * @returns the raw texture inside an InternalTexture
  78159. */
  78160. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  78161. /**
  78162. * Update a raw texture
  78163. * @param texture defines the texture to update
  78164. * @param data defines the data to store in the texture
  78165. * @param format defines the format of the data
  78166. * @param invertY defines if data must be stored with Y axis inverted
  78167. */
  78168. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78169. /**
  78170. * Update a raw texture
  78171. * @param texture defines the texture to update
  78172. * @param data defines the data to store in the texture
  78173. * @param format defines the format of the data
  78174. * @param invertY defines if data must be stored with Y axis inverted
  78175. * @param compression defines the compression used (null by default)
  78176. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78177. */
  78178. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  78179. /**
  78180. * Creates a new raw cube texture
  78181. * @param data defines the array of data to use to create each face
  78182. * @param size defines the size of the textures
  78183. * @param format defines the format of the data
  78184. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78185. * @param generateMipMaps defines if the engine should generate the mip levels
  78186. * @param invertY defines if data must be stored with Y axis inverted
  78187. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78188. * @param compression defines the compression used (null by default)
  78189. * @returns the cube texture as an InternalTexture
  78190. */
  78191. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  78192. /**
  78193. * Update a raw cube texture
  78194. * @param texture defines the texture to udpdate
  78195. * @param data defines the data to store
  78196. * @param format defines the data format
  78197. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78198. * @param invertY defines if data must be stored with Y axis inverted
  78199. */
  78200. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  78201. /**
  78202. * Update a raw cube texture
  78203. * @param texture defines the texture to udpdate
  78204. * @param data defines the data to store
  78205. * @param format defines the data format
  78206. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78207. * @param invertY defines if data must be stored with Y axis inverted
  78208. * @param compression defines the compression used (null by default)
  78209. */
  78210. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  78211. /**
  78212. * Update a raw cube texture
  78213. * @param texture defines the texture to udpdate
  78214. * @param data defines the data to store
  78215. * @param format defines the data format
  78216. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  78217. * @param invertY defines if data must be stored with Y axis inverted
  78218. * @param compression defines the compression used (null by default)
  78219. * @param level defines which level of the texture to update
  78220. */
  78221. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  78222. /**
  78223. * Creates a new raw cube texture from a specified url
  78224. * @param url defines the url where the data is located
  78225. * @param scene defines the current scene
  78226. * @param size defines the size of the textures
  78227. * @param format defines the format of the data
  78228. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78229. * @param noMipmap defines if the engine should avoid generating the mip levels
  78230. * @param callback defines a callback used to extract texture data from loaded data
  78231. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78232. * @param onLoad defines a callback called when texture is loaded
  78233. * @param onError defines a callback called if there is an error
  78234. * @returns the cube texture as an InternalTexture
  78235. */
  78236. createRawCubeTextureFromUrl(url: string, scene: 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;
  78237. /**
  78238. * Creates a new raw cube texture from a specified url
  78239. * @param url defines the url where the data is located
  78240. * @param scene defines the current scene
  78241. * @param size defines the size of the textures
  78242. * @param format defines the format of the data
  78243. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  78244. * @param noMipmap defines if the engine should avoid generating the mip levels
  78245. * @param callback defines a callback used to extract texture data from loaded data
  78246. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  78247. * @param onLoad defines a callback called when texture is loaded
  78248. * @param onError defines a callback called if there is an error
  78249. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78250. * @param invertY defines if data must be stored with Y axis inverted
  78251. * @returns the cube texture as an InternalTexture
  78252. */
  78253. createRawCubeTextureFromUrl(url: string, scene: 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;
  78254. /**
  78255. * Creates a new raw 3D texture
  78256. * @param data defines the data used to create the texture
  78257. * @param width defines the width of the texture
  78258. * @param height defines the height of the texture
  78259. * @param depth defines the depth of the texture
  78260. * @param format defines the format of the texture
  78261. * @param generateMipMaps defines if the engine must generate mip levels
  78262. * @param invertY defines if data must be stored with Y axis inverted
  78263. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  78264. * @param compression defines the compressed used (can be null)
  78265. * @param textureType defines the compressed used (can be null)
  78266. * @returns a new raw 3D texture (stored in an InternalTexture)
  78267. */
  78268. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  78269. /**
  78270. * Update a raw 3D texture
  78271. * @param texture defines the texture to update
  78272. * @param data defines the data to store
  78273. * @param format defines the data format
  78274. * @param invertY defines if data must be stored with Y axis inverted
  78275. */
  78276. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  78277. /**
  78278. * Update a raw 3D texture
  78279. * @param texture defines the texture to update
  78280. * @param data defines the data to store
  78281. * @param format defines the data format
  78282. * @param invertY defines if data must be stored with Y axis inverted
  78283. * @param compression defines the used compression (can be null)
  78284. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  78285. */
  78286. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  78287. }
  78288. }
  78289. declare module BABYLON {
  78290. /**
  78291. * Raw texture can help creating a texture directly from an array of data.
  78292. * This can be super useful if you either get the data from an uncompressed source or
  78293. * if you wish to create your texture pixel by pixel.
  78294. */
  78295. export class RawTexture extends Texture {
  78296. /**
  78297. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78298. */
  78299. format: number;
  78300. private _engine;
  78301. /**
  78302. * Instantiates a new RawTexture.
  78303. * Raw texture can help creating a texture directly from an array of data.
  78304. * This can be super useful if you either get the data from an uncompressed source or
  78305. * if you wish to create your texture pixel by pixel.
  78306. * @param data define the array of data to use to create the texture
  78307. * @param width define the width of the texture
  78308. * @param height define the height of the texture
  78309. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78310. * @param scene define the scene the texture belongs to
  78311. * @param generateMipMaps define whether mip maps should be generated or not
  78312. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78313. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78314. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78315. */
  78316. constructor(data: ArrayBufferView, width: number, height: number,
  78317. /**
  78318. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  78319. */
  78320. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  78321. /**
  78322. * Updates the texture underlying data.
  78323. * @param data Define the new data of the texture
  78324. */
  78325. update(data: ArrayBufferView): void;
  78326. /**
  78327. * Creates a luminance texture from some data.
  78328. * @param data Define the texture data
  78329. * @param width Define the width of the texture
  78330. * @param height Define the height of the texture
  78331. * @param scene Define the scene the texture belongs to
  78332. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78333. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78334. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78335. * @returns the luminance texture
  78336. */
  78337. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78338. /**
  78339. * Creates a luminance alpha texture from some data.
  78340. * @param data Define the texture data
  78341. * @param width Define the width of the texture
  78342. * @param height Define the height of the texture
  78343. * @param scene Define the scene the texture belongs to
  78344. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78345. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78346. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78347. * @returns the luminance alpha texture
  78348. */
  78349. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78350. /**
  78351. * Creates an alpha texture from some data.
  78352. * @param data Define the texture data
  78353. * @param width Define the width of the texture
  78354. * @param height Define the height of the texture
  78355. * @param scene Define the scene the texture belongs to
  78356. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78357. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78358. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78359. * @returns the alpha texture
  78360. */
  78361. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  78362. /**
  78363. * Creates a RGB texture from some data.
  78364. * @param data Define the texture data
  78365. * @param width Define the width of the texture
  78366. * @param height Define the height of the texture
  78367. * @param scene Define the scene the texture belongs to
  78368. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78369. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78370. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78371. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78372. * @returns the RGB alpha texture
  78373. */
  78374. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78375. /**
  78376. * Creates a RGBA texture from some data.
  78377. * @param data Define the texture data
  78378. * @param width Define the width of the texture
  78379. * @param height Define the height of the texture
  78380. * @param scene Define the scene the texture belongs to
  78381. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78382. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78383. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78384. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78385. * @returns the RGBA texture
  78386. */
  78387. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78388. /**
  78389. * Creates a R texture from some data.
  78390. * @param data Define the texture data
  78391. * @param width Define the width of the texture
  78392. * @param height Define the height of the texture
  78393. * @param scene Define the scene the texture belongs to
  78394. * @param generateMipMaps Define whether or not to create mip maps for the texture
  78395. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  78396. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  78397. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  78398. * @returns the R texture
  78399. */
  78400. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  78401. }
  78402. }
  78403. declare module BABYLON {
  78404. /**
  78405. * Interface for the size containing width and height
  78406. */
  78407. export interface ISize {
  78408. /**
  78409. * Width
  78410. */
  78411. width: number;
  78412. /**
  78413. * Heighht
  78414. */
  78415. height: number;
  78416. }
  78417. /**
  78418. * Size containing widht and height
  78419. */
  78420. export class Size implements ISize {
  78421. /**
  78422. * Width
  78423. */
  78424. width: number;
  78425. /**
  78426. * Height
  78427. */
  78428. height: number;
  78429. /**
  78430. * Creates a Size object from the given width and height (floats).
  78431. * @param width width of the new size
  78432. * @param height height of the new size
  78433. */
  78434. constructor(width: number, height: number);
  78435. /**
  78436. * Returns a string with the Size width and height
  78437. * @returns a string with the Size width and height
  78438. */
  78439. toString(): string;
  78440. /**
  78441. * "Size"
  78442. * @returns the string "Size"
  78443. */
  78444. getClassName(): string;
  78445. /**
  78446. * Returns the Size hash code.
  78447. * @returns a hash code for a unique width and height
  78448. */
  78449. getHashCode(): number;
  78450. /**
  78451. * Updates the current size from the given one.
  78452. * @param src the given size
  78453. */
  78454. copyFrom(src: Size): void;
  78455. /**
  78456. * Updates in place the current Size from the given floats.
  78457. * @param width width of the new size
  78458. * @param height height of the new size
  78459. * @returns the updated Size.
  78460. */
  78461. copyFromFloats(width: number, height: number): Size;
  78462. /**
  78463. * Updates in place the current Size from the given floats.
  78464. * @param width width to set
  78465. * @param height height to set
  78466. * @returns the updated Size.
  78467. */
  78468. set(width: number, height: number): Size;
  78469. /**
  78470. * Multiplies the width and height by numbers
  78471. * @param w factor to multiple the width by
  78472. * @param h factor to multiple the height by
  78473. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  78474. */
  78475. multiplyByFloats(w: number, h: number): Size;
  78476. /**
  78477. * Clones the size
  78478. * @returns a new Size copied from the given one.
  78479. */
  78480. clone(): Size;
  78481. /**
  78482. * True if the current Size and the given one width and height are strictly equal.
  78483. * @param other the other size to compare against
  78484. * @returns True if the current Size and the given one width and height are strictly equal.
  78485. */
  78486. equals(other: Size): boolean;
  78487. /**
  78488. * The surface of the Size : width * height (float).
  78489. */
  78490. readonly surface: number;
  78491. /**
  78492. * Create a new size of zero
  78493. * @returns a new Size set to (0.0, 0.0)
  78494. */
  78495. static Zero(): Size;
  78496. /**
  78497. * Sums the width and height of two sizes
  78498. * @param otherSize size to add to this size
  78499. * @returns a new Size set as the addition result of the current Size and the given one.
  78500. */
  78501. add(otherSize: Size): Size;
  78502. /**
  78503. * Subtracts the width and height of two
  78504. * @param otherSize size to subtract to this size
  78505. * @returns a new Size set as the subtraction result of the given one from the current Size.
  78506. */
  78507. subtract(otherSize: Size): Size;
  78508. /**
  78509. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  78510. * @param start starting size to lerp between
  78511. * @param end end size to lerp between
  78512. * @param amount amount to lerp between the start and end values
  78513. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  78514. */
  78515. static Lerp(start: Size, end: Size, amount: number): Size;
  78516. }
  78517. }
  78518. declare module BABYLON {
  78519. /**
  78520. * Defines a runtime animation
  78521. */
  78522. export class RuntimeAnimation {
  78523. private _events;
  78524. /**
  78525. * The current frame of the runtime animation
  78526. */
  78527. private _currentFrame;
  78528. /**
  78529. * The animation used by the runtime animation
  78530. */
  78531. private _animation;
  78532. /**
  78533. * The target of the runtime animation
  78534. */
  78535. private _target;
  78536. /**
  78537. * The initiating animatable
  78538. */
  78539. private _host;
  78540. /**
  78541. * The original value of the runtime animation
  78542. */
  78543. private _originalValue;
  78544. /**
  78545. * The original blend value of the runtime animation
  78546. */
  78547. private _originalBlendValue;
  78548. /**
  78549. * The offsets cache of the runtime animation
  78550. */
  78551. private _offsetsCache;
  78552. /**
  78553. * The high limits cache of the runtime animation
  78554. */
  78555. private _highLimitsCache;
  78556. /**
  78557. * Specifies if the runtime animation has been stopped
  78558. */
  78559. private _stopped;
  78560. /**
  78561. * The blending factor of the runtime animation
  78562. */
  78563. private _blendingFactor;
  78564. /**
  78565. * The BabylonJS scene
  78566. */
  78567. private _scene;
  78568. /**
  78569. * The current value of the runtime animation
  78570. */
  78571. private _currentValue;
  78572. /** @hidden */
  78573. _animationState: _IAnimationState;
  78574. /**
  78575. * The active target of the runtime animation
  78576. */
  78577. private _activeTargets;
  78578. private _currentActiveTarget;
  78579. private _directTarget;
  78580. /**
  78581. * The target path of the runtime animation
  78582. */
  78583. private _targetPath;
  78584. /**
  78585. * The weight of the runtime animation
  78586. */
  78587. private _weight;
  78588. /**
  78589. * The ratio offset of the runtime animation
  78590. */
  78591. private _ratioOffset;
  78592. /**
  78593. * The previous delay of the runtime animation
  78594. */
  78595. private _previousDelay;
  78596. /**
  78597. * The previous ratio of the runtime animation
  78598. */
  78599. private _previousRatio;
  78600. private _enableBlending;
  78601. private _keys;
  78602. private _minFrame;
  78603. private _maxFrame;
  78604. private _minValue;
  78605. private _maxValue;
  78606. private _targetIsArray;
  78607. /**
  78608. * Gets the current frame of the runtime animation
  78609. */
  78610. readonly currentFrame: number;
  78611. /**
  78612. * Gets the weight of the runtime animation
  78613. */
  78614. readonly weight: number;
  78615. /**
  78616. * Gets the current value of the runtime animation
  78617. */
  78618. readonly currentValue: any;
  78619. /**
  78620. * Gets the target path of the runtime animation
  78621. */
  78622. readonly targetPath: string;
  78623. /**
  78624. * Gets the actual target of the runtime animation
  78625. */
  78626. readonly target: any;
  78627. /** @hidden */
  78628. _onLoop: () => void;
  78629. /**
  78630. * Create a new RuntimeAnimation object
  78631. * @param target defines the target of the animation
  78632. * @param animation defines the source animation object
  78633. * @param scene defines the hosting scene
  78634. * @param host defines the initiating Animatable
  78635. */
  78636. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78637. private _preparePath;
  78638. /**
  78639. * Gets the animation from the runtime animation
  78640. */
  78641. readonly animation: Animation;
  78642. /**
  78643. * Resets the runtime animation to the beginning
  78644. * @param restoreOriginal defines whether to restore the target property to the original value
  78645. */
  78646. reset(restoreOriginal?: boolean): void;
  78647. /**
  78648. * Specifies if the runtime animation is stopped
  78649. * @returns Boolean specifying if the runtime animation is stopped
  78650. */
  78651. isStopped(): boolean;
  78652. /**
  78653. * Disposes of the runtime animation
  78654. */
  78655. dispose(): void;
  78656. /**
  78657. * Apply the interpolated value to the target
  78658. * @param currentValue defines the value computed by the animation
  78659. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78660. */
  78661. setValue(currentValue: any, weight: number): void;
  78662. private _getOriginalValues;
  78663. private _setValue;
  78664. /**
  78665. * Gets the loop pmode of the runtime animation
  78666. * @returns Loop Mode
  78667. */
  78668. private _getCorrectLoopMode;
  78669. /**
  78670. * Move the current animation to a given frame
  78671. * @param frame defines the frame to move to
  78672. */
  78673. goToFrame(frame: number): void;
  78674. /**
  78675. * @hidden Internal use only
  78676. */
  78677. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78678. /**
  78679. * Execute the current animation
  78680. * @param delay defines the delay to add to the current frame
  78681. * @param from defines the lower bound of the animation range
  78682. * @param to defines the upper bound of the animation range
  78683. * @param loop defines if the current animation must loop
  78684. * @param speedRatio defines the current speed ratio
  78685. * @param weight defines the weight of the animation (default is -1 so no weight)
  78686. * @param onLoop optional callback called when animation loops
  78687. * @returns a boolean indicating if the animation is running
  78688. */
  78689. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78690. }
  78691. }
  78692. declare module BABYLON {
  78693. /**
  78694. * Class used to store an actual running animation
  78695. */
  78696. export class Animatable {
  78697. /** defines the target object */
  78698. target: any;
  78699. /** defines the starting frame number (default is 0) */
  78700. fromFrame: number;
  78701. /** defines the ending frame number (default is 100) */
  78702. toFrame: number;
  78703. /** defines if the animation must loop (default is false) */
  78704. loopAnimation: boolean;
  78705. /** defines a callback to call when animation ends if it is not looping */
  78706. onAnimationEnd?: (() => void) | null | undefined;
  78707. /** defines a callback to call when animation loops */
  78708. onAnimationLoop?: (() => void) | null | undefined;
  78709. private _localDelayOffset;
  78710. private _pausedDelay;
  78711. private _runtimeAnimations;
  78712. private _paused;
  78713. private _scene;
  78714. private _speedRatio;
  78715. private _weight;
  78716. private _syncRoot;
  78717. /**
  78718. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78719. * This will only apply for non looping animation (default is true)
  78720. */
  78721. disposeOnEnd: boolean;
  78722. /**
  78723. * Gets a boolean indicating if the animation has started
  78724. */
  78725. animationStarted: boolean;
  78726. /**
  78727. * Observer raised when the animation ends
  78728. */
  78729. onAnimationEndObservable: Observable<Animatable>;
  78730. /**
  78731. * Observer raised when the animation loops
  78732. */
  78733. onAnimationLoopObservable: Observable<Animatable>;
  78734. /**
  78735. * Gets the root Animatable used to synchronize and normalize animations
  78736. */
  78737. readonly syncRoot: Nullable<Animatable>;
  78738. /**
  78739. * Gets the current frame of the first RuntimeAnimation
  78740. * Used to synchronize Animatables
  78741. */
  78742. readonly masterFrame: number;
  78743. /**
  78744. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78745. */
  78746. weight: number;
  78747. /**
  78748. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78749. */
  78750. speedRatio: number;
  78751. /**
  78752. * Creates a new Animatable
  78753. * @param scene defines the hosting scene
  78754. * @param target defines the target object
  78755. * @param fromFrame defines the starting frame number (default is 0)
  78756. * @param toFrame defines the ending frame number (default is 100)
  78757. * @param loopAnimation defines if the animation must loop (default is false)
  78758. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78759. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78760. * @param animations defines a group of animation to add to the new Animatable
  78761. * @param onAnimationLoop defines a callback to call when animation loops
  78762. */
  78763. constructor(scene: Scene,
  78764. /** defines the target object */
  78765. target: any,
  78766. /** defines the starting frame number (default is 0) */
  78767. fromFrame?: number,
  78768. /** defines the ending frame number (default is 100) */
  78769. toFrame?: number,
  78770. /** defines if the animation must loop (default is false) */
  78771. loopAnimation?: boolean, speedRatio?: number,
  78772. /** defines a callback to call when animation ends if it is not looping */
  78773. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78774. /** defines a callback to call when animation loops */
  78775. onAnimationLoop?: (() => void) | null | undefined);
  78776. /**
  78777. * Synchronize and normalize current Animatable with a source Animatable
  78778. * This is useful when using animation weights and when animations are not of the same length
  78779. * @param root defines the root Animatable to synchronize with
  78780. * @returns the current Animatable
  78781. */
  78782. syncWith(root: Animatable): Animatable;
  78783. /**
  78784. * Gets the list of runtime animations
  78785. * @returns an array of RuntimeAnimation
  78786. */
  78787. getAnimations(): RuntimeAnimation[];
  78788. /**
  78789. * Adds more animations to the current animatable
  78790. * @param target defines the target of the animations
  78791. * @param animations defines the new animations to add
  78792. */
  78793. appendAnimations(target: any, animations: Animation[]): void;
  78794. /**
  78795. * Gets the source animation for a specific property
  78796. * @param property defines the propertyu to look for
  78797. * @returns null or the source animation for the given property
  78798. */
  78799. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78800. /**
  78801. * Gets the runtime animation for a specific property
  78802. * @param property defines the propertyu to look for
  78803. * @returns null or the runtime animation for the given property
  78804. */
  78805. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78806. /**
  78807. * Resets the animatable to its original state
  78808. */
  78809. reset(): void;
  78810. /**
  78811. * Allows the animatable to blend with current running animations
  78812. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78813. * @param blendingSpeed defines the blending speed to use
  78814. */
  78815. enableBlending(blendingSpeed: number): void;
  78816. /**
  78817. * Disable animation blending
  78818. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78819. */
  78820. disableBlending(): void;
  78821. /**
  78822. * Jump directly to a given frame
  78823. * @param frame defines the frame to jump to
  78824. */
  78825. goToFrame(frame: number): void;
  78826. /**
  78827. * Pause the animation
  78828. */
  78829. pause(): void;
  78830. /**
  78831. * Restart the animation
  78832. */
  78833. restart(): void;
  78834. private _raiseOnAnimationEnd;
  78835. /**
  78836. * Stop and delete the current animation
  78837. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78838. * @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)
  78839. */
  78840. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78841. /**
  78842. * Wait asynchronously for the animation to end
  78843. * @returns a promise which will be fullfilled when the animation ends
  78844. */
  78845. waitAsync(): Promise<Animatable>;
  78846. /** @hidden */
  78847. _animate(delay: number): boolean;
  78848. }
  78849. interface Scene {
  78850. /** @hidden */
  78851. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78852. /** @hidden */
  78853. _processLateAnimationBindingsForMatrices(holder: {
  78854. totalWeight: number;
  78855. animations: RuntimeAnimation[];
  78856. originalValue: Matrix;
  78857. }): any;
  78858. /** @hidden */
  78859. _processLateAnimationBindingsForQuaternions(holder: {
  78860. totalWeight: number;
  78861. animations: RuntimeAnimation[];
  78862. originalValue: Quaternion;
  78863. }, refQuaternion: Quaternion): Quaternion;
  78864. /** @hidden */
  78865. _processLateAnimationBindings(): void;
  78866. /**
  78867. * Will start the animation sequence of a given target
  78868. * @param target defines the target
  78869. * @param from defines from which frame should animation start
  78870. * @param to defines until which frame should animation run.
  78871. * @param weight defines the weight to apply to the animation (1.0 by default)
  78872. * @param loop defines if the animation loops
  78873. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78874. * @param onAnimationEnd defines the function to be executed when the animation ends
  78875. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78876. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78877. * @param onAnimationLoop defines the callback to call when an animation loops
  78878. * @returns the animatable object created for this animation
  78879. */
  78880. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78881. /**
  78882. * Will start the animation sequence of a given target
  78883. * @param target defines the target
  78884. * @param from defines from which frame should animation start
  78885. * @param to defines until which frame should animation run.
  78886. * @param loop defines if the animation loops
  78887. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78888. * @param onAnimationEnd defines the function to be executed when the animation ends
  78889. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78890. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78891. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78892. * @param onAnimationLoop defines the callback to call when an animation loops
  78893. * @returns the animatable object created for this animation
  78894. */
  78895. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78896. /**
  78897. * Will start the animation sequence of a given target and its hierarchy
  78898. * @param target defines the target
  78899. * @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.
  78900. * @param from defines from which frame should animation start
  78901. * @param to defines until which frame should animation run.
  78902. * @param loop defines if the animation loops
  78903. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78904. * @param onAnimationEnd defines the function to be executed when the animation ends
  78905. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78906. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78907. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78908. * @param onAnimationLoop defines the callback to call when an animation loops
  78909. * @returns the list of created animatables
  78910. */
  78911. 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): Animatable[];
  78912. /**
  78913. * Begin a new animation on a given node
  78914. * @param target defines the target where the animation will take place
  78915. * @param animations defines the list of animations to start
  78916. * @param from defines the initial value
  78917. * @param to defines the final value
  78918. * @param loop defines if you want animation to loop (off by default)
  78919. * @param speedRatio defines the speed ratio to apply to all animations
  78920. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78921. * @param onAnimationLoop defines the callback to call when an animation loops
  78922. * @returns the list of created animatables
  78923. */
  78924. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78925. /**
  78926. * Begin a new animation on a given node and its hierarchy
  78927. * @param target defines the root node where the animation will take place
  78928. * @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.
  78929. * @param animations defines the list of animations to start
  78930. * @param from defines the initial value
  78931. * @param to defines the final value
  78932. * @param loop defines if you want animation to loop (off by default)
  78933. * @param speedRatio defines the speed ratio to apply to all animations
  78934. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78935. * @param onAnimationLoop defines the callback to call when an animation loops
  78936. * @returns the list of animatables created for all nodes
  78937. */
  78938. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78939. /**
  78940. * Gets the animatable associated with a specific target
  78941. * @param target defines the target of the animatable
  78942. * @returns the required animatable if found
  78943. */
  78944. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78945. /**
  78946. * Gets all animatables associated with a given target
  78947. * @param target defines the target to look animatables for
  78948. * @returns an array of Animatables
  78949. */
  78950. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78951. /**
  78952. * Stops and removes all animations that have been applied to the scene
  78953. */
  78954. stopAllAnimations(): void;
  78955. }
  78956. interface Bone {
  78957. /**
  78958. * Copy an animation range from another bone
  78959. * @param source defines the source bone
  78960. * @param rangeName defines the range name to copy
  78961. * @param frameOffset defines the frame offset
  78962. * @param rescaleAsRequired defines if rescaling must be applied if required
  78963. * @param skelDimensionsRatio defines the scaling ratio
  78964. * @returns true if operation was successful
  78965. */
  78966. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78967. }
  78968. }
  78969. declare module BABYLON {
  78970. /**
  78971. * Class used to override all child animations of a given target
  78972. */
  78973. export class AnimationPropertiesOverride {
  78974. /**
  78975. * Gets or sets a value indicating if animation blending must be used
  78976. */
  78977. enableBlending: boolean;
  78978. /**
  78979. * Gets or sets the blending speed to use when enableBlending is true
  78980. */
  78981. blendingSpeed: number;
  78982. /**
  78983. * Gets or sets the default loop mode to use
  78984. */
  78985. loopMode: number;
  78986. }
  78987. }
  78988. declare module BABYLON {
  78989. /**
  78990. * Class used to handle skinning animations
  78991. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78992. */
  78993. export class Skeleton implements IAnimatable {
  78994. /** defines the skeleton name */
  78995. name: string;
  78996. /** defines the skeleton Id */
  78997. id: string;
  78998. /**
  78999. * Defines the list of child bones
  79000. */
  79001. bones: Bone[];
  79002. /**
  79003. * Defines an estimate of the dimension of the skeleton at rest
  79004. */
  79005. dimensionsAtRest: Vector3;
  79006. /**
  79007. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79008. */
  79009. needInitialSkinMatrix: boolean;
  79010. /**
  79011. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79012. */
  79013. overrideMesh: Nullable<AbstractMesh>;
  79014. /**
  79015. * Gets the list of animations attached to this skeleton
  79016. */
  79017. animations: Array<Animation>;
  79018. private _scene;
  79019. private _isDirty;
  79020. private _transformMatrices;
  79021. private _transformMatrixTexture;
  79022. private _meshesWithPoseMatrix;
  79023. private _animatables;
  79024. private _identity;
  79025. private _synchronizedWithMesh;
  79026. private _ranges;
  79027. private _lastAbsoluteTransformsUpdateId;
  79028. private _canUseTextureForBones;
  79029. private _uniqueId;
  79030. /** @hidden */
  79031. _numBonesWithLinkedTransformNode: number;
  79032. /** @hidden */
  79033. _hasWaitingData: Nullable<boolean>;
  79034. /**
  79035. * Specifies if the skeleton should be serialized
  79036. */
  79037. doNotSerialize: boolean;
  79038. private _useTextureToStoreBoneMatrices;
  79039. /**
  79040. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79041. * Please note that this option is not available if the hardware does not support it
  79042. */
  79043. useTextureToStoreBoneMatrices: boolean;
  79044. private _animationPropertiesOverride;
  79045. /**
  79046. * Gets or sets the animation properties override
  79047. */
  79048. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79049. /**
  79050. * List of inspectable custom properties (used by the Inspector)
  79051. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79052. */
  79053. inspectableCustomProperties: IInspectable[];
  79054. /**
  79055. * An observable triggered before computing the skeleton's matrices
  79056. */
  79057. onBeforeComputeObservable: Observable<Skeleton>;
  79058. /**
  79059. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79060. */
  79061. readonly isUsingTextureForMatrices: boolean;
  79062. /**
  79063. * Gets the unique ID of this skeleton
  79064. */
  79065. readonly uniqueId: number;
  79066. /**
  79067. * Creates a new skeleton
  79068. * @param name defines the skeleton name
  79069. * @param id defines the skeleton Id
  79070. * @param scene defines the hosting scene
  79071. */
  79072. constructor(
  79073. /** defines the skeleton name */
  79074. name: string,
  79075. /** defines the skeleton Id */
  79076. id: string, scene: Scene);
  79077. /**
  79078. * Gets the current object class name.
  79079. * @return the class name
  79080. */
  79081. getClassName(): string;
  79082. /**
  79083. * Returns an array containing the root bones
  79084. * @returns an array containing the root bones
  79085. */
  79086. getChildren(): Array<Bone>;
  79087. /**
  79088. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79089. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79090. * @returns a Float32Array containing matrices data
  79091. */
  79092. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79093. /**
  79094. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79095. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79096. * @returns a raw texture containing the data
  79097. */
  79098. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  79099. /**
  79100. * Gets the current hosting scene
  79101. * @returns a scene object
  79102. */
  79103. getScene(): Scene;
  79104. /**
  79105. * Gets a string representing the current skeleton data
  79106. * @param fullDetails defines a boolean indicating if we want a verbose version
  79107. * @returns a string representing the current skeleton data
  79108. */
  79109. toString(fullDetails?: boolean): string;
  79110. /**
  79111. * Get bone's index searching by name
  79112. * @param name defines bone's name to search for
  79113. * @return the indice of the bone. Returns -1 if not found
  79114. */
  79115. getBoneIndexByName(name: string): number;
  79116. /**
  79117. * Creater a new animation range
  79118. * @param name defines the name of the range
  79119. * @param from defines the start key
  79120. * @param to defines the end key
  79121. */
  79122. createAnimationRange(name: string, from: number, to: number): void;
  79123. /**
  79124. * Delete a specific animation range
  79125. * @param name defines the name of the range
  79126. * @param deleteFrames defines if frames must be removed as well
  79127. */
  79128. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79129. /**
  79130. * Gets a specific animation range
  79131. * @param name defines the name of the range to look for
  79132. * @returns the requested animation range or null if not found
  79133. */
  79134. getAnimationRange(name: string): Nullable<AnimationRange>;
  79135. /**
  79136. * Gets the list of all animation ranges defined on this skeleton
  79137. * @returns an array
  79138. */
  79139. getAnimationRanges(): Nullable<AnimationRange>[];
  79140. /**
  79141. * Copy animation range from a source skeleton.
  79142. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79143. * @param source defines the source skeleton
  79144. * @param name defines the name of the range to copy
  79145. * @param rescaleAsRequired defines if rescaling must be applied if required
  79146. * @returns true if operation was successful
  79147. */
  79148. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79149. /**
  79150. * Forces the skeleton to go to rest pose
  79151. */
  79152. returnToRest(): void;
  79153. private _getHighestAnimationFrame;
  79154. /**
  79155. * Begin a specific animation range
  79156. * @param name defines the name of the range to start
  79157. * @param loop defines if looping must be turned on (false by default)
  79158. * @param speedRatio defines the speed ratio to apply (1 by default)
  79159. * @param onAnimationEnd defines a callback which will be called when animation will end
  79160. * @returns a new animatable
  79161. */
  79162. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79163. /** @hidden */
  79164. _markAsDirty(): void;
  79165. /** @hidden */
  79166. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79167. /** @hidden */
  79168. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79169. private _computeTransformMatrices;
  79170. /**
  79171. * Build all resources required to render a skeleton
  79172. */
  79173. prepare(): void;
  79174. /**
  79175. * Gets the list of animatables currently running for this skeleton
  79176. * @returns an array of animatables
  79177. */
  79178. getAnimatables(): IAnimatable[];
  79179. /**
  79180. * Clone the current skeleton
  79181. * @param name defines the name of the new skeleton
  79182. * @param id defines the id of the new skeleton
  79183. * @returns the new skeleton
  79184. */
  79185. clone(name: string, id: string): Skeleton;
  79186. /**
  79187. * Enable animation blending for this skeleton
  79188. * @param blendingSpeed defines the blending speed to apply
  79189. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79190. */
  79191. enableBlending(blendingSpeed?: number): void;
  79192. /**
  79193. * Releases all resources associated with the current skeleton
  79194. */
  79195. dispose(): void;
  79196. /**
  79197. * Serialize the skeleton in a JSON object
  79198. * @returns a JSON object
  79199. */
  79200. serialize(): any;
  79201. /**
  79202. * Creates a new skeleton from serialized data
  79203. * @param parsedSkeleton defines the serialized data
  79204. * @param scene defines the hosting scene
  79205. * @returns a new skeleton
  79206. */
  79207. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79208. /**
  79209. * Compute all node absolute transforms
  79210. * @param forceUpdate defines if computation must be done even if cache is up to date
  79211. */
  79212. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79213. /**
  79214. * Gets the root pose matrix
  79215. * @returns a matrix
  79216. */
  79217. getPoseMatrix(): Nullable<Matrix>;
  79218. /**
  79219. * Sorts bones per internal index
  79220. */
  79221. sortBones(): void;
  79222. private _sortBones;
  79223. }
  79224. }
  79225. declare module BABYLON {
  79226. /**
  79227. * Class used to store bone information
  79228. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79229. */
  79230. export class Bone extends Node {
  79231. /**
  79232. * defines the bone name
  79233. */
  79234. name: string;
  79235. private static _tmpVecs;
  79236. private static _tmpQuat;
  79237. private static _tmpMats;
  79238. /**
  79239. * Gets the list of child bones
  79240. */
  79241. children: Bone[];
  79242. /** Gets the animations associated with this bone */
  79243. animations: Animation[];
  79244. /**
  79245. * Gets or sets bone length
  79246. */
  79247. length: number;
  79248. /**
  79249. * @hidden Internal only
  79250. * Set this value to map this bone to a different index in the transform matrices
  79251. * Set this value to -1 to exclude the bone from the transform matrices
  79252. */
  79253. _index: Nullable<number>;
  79254. private _skeleton;
  79255. private _localMatrix;
  79256. private _restPose;
  79257. private _baseMatrix;
  79258. private _absoluteTransform;
  79259. private _invertedAbsoluteTransform;
  79260. private _parent;
  79261. private _scalingDeterminant;
  79262. private _worldTransform;
  79263. private _localScaling;
  79264. private _localRotation;
  79265. private _localPosition;
  79266. private _needToDecompose;
  79267. private _needToCompose;
  79268. /** @hidden */
  79269. _linkedTransformNode: Nullable<TransformNode>;
  79270. /** @hidden */
  79271. _waitingTransformNodeId: Nullable<string>;
  79272. /** @hidden */
  79273. /** @hidden */
  79274. _matrix: Matrix;
  79275. /**
  79276. * Create a new bone
  79277. * @param name defines the bone name
  79278. * @param skeleton defines the parent skeleton
  79279. * @param parentBone defines the parent (can be null if the bone is the root)
  79280. * @param localMatrix defines the local matrix
  79281. * @param restPose defines the rest pose matrix
  79282. * @param baseMatrix defines the base matrix
  79283. * @param index defines index of the bone in the hiearchy
  79284. */
  79285. constructor(
  79286. /**
  79287. * defines the bone name
  79288. */
  79289. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  79290. /**
  79291. * Gets the current object class name.
  79292. * @return the class name
  79293. */
  79294. getClassName(): string;
  79295. /**
  79296. * Gets the parent skeleton
  79297. * @returns a skeleton
  79298. */
  79299. getSkeleton(): Skeleton;
  79300. /**
  79301. * Gets parent bone
  79302. * @returns a bone or null if the bone is the root of the bone hierarchy
  79303. */
  79304. getParent(): Nullable<Bone>;
  79305. /**
  79306. * Returns an array containing the root bones
  79307. * @returns an array containing the root bones
  79308. */
  79309. getChildren(): Array<Bone>;
  79310. /**
  79311. * Sets the parent bone
  79312. * @param parent defines the parent (can be null if the bone is the root)
  79313. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79314. */
  79315. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  79316. /**
  79317. * Gets the local matrix
  79318. * @returns a matrix
  79319. */
  79320. getLocalMatrix(): Matrix;
  79321. /**
  79322. * Gets the base matrix (initial matrix which remains unchanged)
  79323. * @returns a matrix
  79324. */
  79325. getBaseMatrix(): Matrix;
  79326. /**
  79327. * Gets the rest pose matrix
  79328. * @returns a matrix
  79329. */
  79330. getRestPose(): Matrix;
  79331. /**
  79332. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  79333. */
  79334. getWorldMatrix(): Matrix;
  79335. /**
  79336. * Sets the local matrix to rest pose matrix
  79337. */
  79338. returnToRest(): void;
  79339. /**
  79340. * Gets the inverse of the absolute transform matrix.
  79341. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  79342. * @returns a matrix
  79343. */
  79344. getInvertedAbsoluteTransform(): Matrix;
  79345. /**
  79346. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  79347. * @returns a matrix
  79348. */
  79349. getAbsoluteTransform(): Matrix;
  79350. /**
  79351. * Links with the given transform node.
  79352. * The local matrix of this bone is copied from the transform node every frame.
  79353. * @param transformNode defines the transform node to link to
  79354. */
  79355. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  79356. /**
  79357. * Gets the node used to drive the bone's transformation
  79358. * @returns a transform node or null
  79359. */
  79360. getTransformNode(): Nullable<TransformNode>;
  79361. /** Gets or sets current position (in local space) */
  79362. position: Vector3;
  79363. /** Gets or sets current rotation (in local space) */
  79364. rotation: Vector3;
  79365. /** Gets or sets current rotation quaternion (in local space) */
  79366. rotationQuaternion: Quaternion;
  79367. /** Gets or sets current scaling (in local space) */
  79368. scaling: Vector3;
  79369. /**
  79370. * Gets the animation properties override
  79371. */
  79372. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79373. private _decompose;
  79374. private _compose;
  79375. /**
  79376. * Update the base and local matrices
  79377. * @param matrix defines the new base or local matrix
  79378. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79379. * @param updateLocalMatrix defines if the local matrix should be updated
  79380. */
  79381. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  79382. /** @hidden */
  79383. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  79384. /**
  79385. * Flag the bone as dirty (Forcing it to update everything)
  79386. */
  79387. markAsDirty(): void;
  79388. /** @hidden */
  79389. _markAsDirtyAndCompose(): void;
  79390. private _markAsDirtyAndDecompose;
  79391. /**
  79392. * Translate the bone in local or world space
  79393. * @param vec The amount to translate the bone
  79394. * @param space The space that the translation is in
  79395. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79396. */
  79397. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79398. /**
  79399. * Set the postion of the bone in local or world space
  79400. * @param position The position to set the bone
  79401. * @param space The space that the position is in
  79402. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79403. */
  79404. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79405. /**
  79406. * Set the absolute position of the bone (world space)
  79407. * @param position The position to set the bone
  79408. * @param mesh The mesh that this bone is attached to
  79409. */
  79410. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  79411. /**
  79412. * Scale the bone on the x, y and z axes (in local space)
  79413. * @param x The amount to scale the bone on the x axis
  79414. * @param y The amount to scale the bone on the y axis
  79415. * @param z The amount to scale the bone on the z axis
  79416. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  79417. */
  79418. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  79419. /**
  79420. * Set the bone scaling in local space
  79421. * @param scale defines the scaling vector
  79422. */
  79423. setScale(scale: Vector3): void;
  79424. /**
  79425. * Gets the current scaling in local space
  79426. * @returns the current scaling vector
  79427. */
  79428. getScale(): Vector3;
  79429. /**
  79430. * Gets the current scaling in local space and stores it in a target vector
  79431. * @param result defines the target vector
  79432. */
  79433. getScaleToRef(result: Vector3): void;
  79434. /**
  79435. * Set the yaw, pitch, and roll of the bone in local or world space
  79436. * @param yaw The rotation of the bone on the y axis
  79437. * @param pitch The rotation of the bone on the x axis
  79438. * @param roll The rotation of the bone on the z axis
  79439. * @param space The space that the axes of rotation are in
  79440. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79441. */
  79442. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  79443. /**
  79444. * Add a rotation to the bone on an axis in local or world space
  79445. * @param axis The axis to rotate the bone on
  79446. * @param amount The amount to rotate the bone
  79447. * @param space The space that the axis is in
  79448. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79449. */
  79450. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  79451. /**
  79452. * Set the rotation of the bone to a particular axis angle in local or world space
  79453. * @param axis The axis to rotate the bone on
  79454. * @param angle The angle that the bone should be rotated to
  79455. * @param space The space that the axis is in
  79456. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79457. */
  79458. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  79459. /**
  79460. * Set the euler rotation of the bone in local of world space
  79461. * @param rotation The euler rotation that the bone should be set to
  79462. * @param space The space that the rotation is in
  79463. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79464. */
  79465. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79466. /**
  79467. * Set the quaternion rotation of the bone in local of world space
  79468. * @param quat The quaternion rotation that the bone should be set to
  79469. * @param space The space that the rotation is in
  79470. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79471. */
  79472. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  79473. /**
  79474. * Set the rotation matrix of the bone in local of world space
  79475. * @param rotMat The rotation matrix that the bone should be set to
  79476. * @param space The space that the rotation is in
  79477. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79478. */
  79479. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  79480. private _rotateWithMatrix;
  79481. private _getNegativeRotationToRef;
  79482. /**
  79483. * Get the position of the bone in local or world space
  79484. * @param space The space that the returned position is in
  79485. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79486. * @returns The position of the bone
  79487. */
  79488. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79489. /**
  79490. * Copy the position of the bone to a vector3 in local or world space
  79491. * @param space The space that the returned position is in
  79492. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79493. * @param result The vector3 to copy the position to
  79494. */
  79495. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  79496. /**
  79497. * Get the absolute position of the bone (world space)
  79498. * @param mesh The mesh that this bone is attached to
  79499. * @returns The absolute position of the bone
  79500. */
  79501. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  79502. /**
  79503. * Copy the absolute position of the bone (world space) to the result param
  79504. * @param mesh The mesh that this bone is attached to
  79505. * @param result The vector3 to copy the absolute position to
  79506. */
  79507. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  79508. /**
  79509. * Compute the absolute transforms of this bone and its children
  79510. */
  79511. computeAbsoluteTransforms(): void;
  79512. /**
  79513. * Get the world direction from an axis that is in the local space of the bone
  79514. * @param localAxis The local direction that is used to compute the world direction
  79515. * @param mesh The mesh that this bone is attached to
  79516. * @returns The world direction
  79517. */
  79518. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79519. /**
  79520. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  79521. * @param localAxis The local direction that is used to compute the world direction
  79522. * @param mesh The mesh that this bone is attached to
  79523. * @param result The vector3 that the world direction will be copied to
  79524. */
  79525. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79526. /**
  79527. * Get the euler rotation of the bone in local or world space
  79528. * @param space The space that the rotation should be in
  79529. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79530. * @returns The euler rotation
  79531. */
  79532. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  79533. /**
  79534. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  79535. * @param space The space that the rotation should be in
  79536. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79537. * @param result The vector3 that the rotation should be copied to
  79538. */
  79539. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79540. /**
  79541. * Get the quaternion rotation of the bone in either local or world space
  79542. * @param space The space that the rotation should be in
  79543. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79544. * @returns The quaternion rotation
  79545. */
  79546. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  79547. /**
  79548. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  79549. * @param space The space that the rotation should be in
  79550. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79551. * @param result The quaternion that the rotation should be copied to
  79552. */
  79553. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  79554. /**
  79555. * Get the rotation matrix of the bone in local or world space
  79556. * @param space The space that the rotation should be in
  79557. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79558. * @returns The rotation matrix
  79559. */
  79560. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  79561. /**
  79562. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  79563. * @param space The space that the rotation should be in
  79564. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79565. * @param result The quaternion that the rotation should be copied to
  79566. */
  79567. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  79568. /**
  79569. * Get the world position of a point that is in the local space of the bone
  79570. * @param position The local position
  79571. * @param mesh The mesh that this bone is attached to
  79572. * @returns The world position
  79573. */
  79574. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79575. /**
  79576. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  79577. * @param position The local position
  79578. * @param mesh The mesh that this bone is attached to
  79579. * @param result The vector3 that the world position should be copied to
  79580. */
  79581. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79582. /**
  79583. * Get the local position of a point that is in world space
  79584. * @param position The world position
  79585. * @param mesh The mesh that this bone is attached to
  79586. * @returns The local position
  79587. */
  79588. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  79589. /**
  79590. * Get the local position of a point that is in world space and copy it to the result param
  79591. * @param position The world position
  79592. * @param mesh The mesh that this bone is attached to
  79593. * @param result The vector3 that the local position should be copied to
  79594. */
  79595. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  79596. }
  79597. }
  79598. declare module BABYLON {
  79599. /**
  79600. * 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.
  79601. * @see https://doc.babylonjs.com/how_to/transformnode
  79602. */
  79603. export class TransformNode extends Node {
  79604. /**
  79605. * Object will not rotate to face the camera
  79606. */
  79607. static BILLBOARDMODE_NONE: number;
  79608. /**
  79609. * Object will rotate to face the camera but only on the x axis
  79610. */
  79611. static BILLBOARDMODE_X: number;
  79612. /**
  79613. * Object will rotate to face the camera but only on the y axis
  79614. */
  79615. static BILLBOARDMODE_Y: number;
  79616. /**
  79617. * Object will rotate to face the camera but only on the z axis
  79618. */
  79619. static BILLBOARDMODE_Z: number;
  79620. /**
  79621. * Object will rotate to face the camera
  79622. */
  79623. static BILLBOARDMODE_ALL: number;
  79624. /**
  79625. * Object will rotate to face the camera's position instead of orientation
  79626. */
  79627. static BILLBOARDMODE_USE_POSITION: number;
  79628. private _forward;
  79629. private _forwardInverted;
  79630. private _up;
  79631. private _right;
  79632. private _rightInverted;
  79633. private _position;
  79634. private _rotation;
  79635. private _rotationQuaternion;
  79636. protected _scaling: Vector3;
  79637. protected _isDirty: boolean;
  79638. private _transformToBoneReferal;
  79639. private _isAbsoluteSynced;
  79640. private _billboardMode;
  79641. /**
  79642. * Gets or sets the billboard mode. Default is 0.
  79643. *
  79644. * | Value | Type | Description |
  79645. * | --- | --- | --- |
  79646. * | 0 | BILLBOARDMODE_NONE | |
  79647. * | 1 | BILLBOARDMODE_X | |
  79648. * | 2 | BILLBOARDMODE_Y | |
  79649. * | 4 | BILLBOARDMODE_Z | |
  79650. * | 7 | BILLBOARDMODE_ALL | |
  79651. *
  79652. */
  79653. billboardMode: number;
  79654. private _preserveParentRotationForBillboard;
  79655. /**
  79656. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  79657. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  79658. */
  79659. preserveParentRotationForBillboard: boolean;
  79660. /**
  79661. * 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
  79662. */
  79663. scalingDeterminant: number;
  79664. private _infiniteDistance;
  79665. /**
  79666. * Gets or sets the distance of the object to max, often used by skybox
  79667. */
  79668. infiniteDistance: boolean;
  79669. /**
  79670. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  79671. * By default the system will update normals to compensate
  79672. */
  79673. ignoreNonUniformScaling: boolean;
  79674. /**
  79675. * 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
  79676. */
  79677. reIntegrateRotationIntoRotationQuaternion: boolean;
  79678. /** @hidden */
  79679. _poseMatrix: Nullable<Matrix>;
  79680. /** @hidden */
  79681. _localMatrix: Matrix;
  79682. private _usePivotMatrix;
  79683. private _absolutePosition;
  79684. private _absoluteScaling;
  79685. private _absoluteRotationQuaternion;
  79686. private _pivotMatrix;
  79687. private _pivotMatrixInverse;
  79688. protected _postMultiplyPivotMatrix: boolean;
  79689. protected _isWorldMatrixFrozen: boolean;
  79690. /** @hidden */
  79691. _indexInSceneTransformNodesArray: number;
  79692. /**
  79693. * An event triggered after the world matrix is updated
  79694. */
  79695. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  79696. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  79697. /**
  79698. * Gets a string identifying the name of the class
  79699. * @returns "TransformNode" string
  79700. */
  79701. getClassName(): string;
  79702. /**
  79703. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  79704. */
  79705. position: Vector3;
  79706. /**
  79707. * 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)).
  79708. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  79709. */
  79710. rotation: Vector3;
  79711. /**
  79712. * 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)).
  79713. */
  79714. scaling: Vector3;
  79715. /**
  79716. * 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).
  79717. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  79718. */
  79719. rotationQuaternion: Nullable<Quaternion>;
  79720. /**
  79721. * The forward direction of that transform in world space.
  79722. */
  79723. readonly forward: Vector3;
  79724. /**
  79725. * The up direction of that transform in world space.
  79726. */
  79727. readonly up: Vector3;
  79728. /**
  79729. * The right direction of that transform in world space.
  79730. */
  79731. readonly right: Vector3;
  79732. /**
  79733. * Copies the parameter passed Matrix into the mesh Pose matrix.
  79734. * @param matrix the matrix to copy the pose from
  79735. * @returns this TransformNode.
  79736. */
  79737. updatePoseMatrix(matrix: Matrix): TransformNode;
  79738. /**
  79739. * Returns the mesh Pose matrix.
  79740. * @returns the pose matrix
  79741. */
  79742. getPoseMatrix(): Matrix;
  79743. /** @hidden */
  79744. _isSynchronized(): boolean;
  79745. /** @hidden */
  79746. _initCache(): void;
  79747. /**
  79748. * Flag the transform node as dirty (Forcing it to update everything)
  79749. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  79750. * @returns this transform node
  79751. */
  79752. markAsDirty(property: string): TransformNode;
  79753. /**
  79754. * Returns the current mesh absolute position.
  79755. * Returns a Vector3.
  79756. */
  79757. readonly absolutePosition: Vector3;
  79758. /**
  79759. * Returns the current mesh absolute scaling.
  79760. * Returns a Vector3.
  79761. */
  79762. readonly absoluteScaling: Vector3;
  79763. /**
  79764. * Returns the current mesh absolute rotation.
  79765. * Returns a Quaternion.
  79766. */
  79767. readonly absoluteRotationQuaternion: Quaternion;
  79768. /**
  79769. * Sets a new matrix to apply before all other transformation
  79770. * @param matrix defines the transform matrix
  79771. * @returns the current TransformNode
  79772. */
  79773. setPreTransformMatrix(matrix: Matrix): TransformNode;
  79774. /**
  79775. * Sets a new pivot matrix to the current node
  79776. * @param matrix defines the new pivot matrix to use
  79777. * @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
  79778. * @returns the current TransformNode
  79779. */
  79780. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  79781. /**
  79782. * Returns the mesh pivot matrix.
  79783. * Default : Identity.
  79784. * @returns the matrix
  79785. */
  79786. getPivotMatrix(): Matrix;
  79787. /**
  79788. * Instantiate (when possible) or clone that node with its hierarchy
  79789. * @param newParent defines the new parent to use for the instance (or clone)
  79790. * @returns an instance (or a clone) of the current node with its hiearchy
  79791. */
  79792. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  79793. /**
  79794. * Prevents the World matrix to be computed any longer
  79795. * @param newWorldMatrix defines an optional matrix to use as world matrix
  79796. * @returns the TransformNode.
  79797. */
  79798. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  79799. /**
  79800. * Allows back the World matrix computation.
  79801. * @returns the TransformNode.
  79802. */
  79803. unfreezeWorldMatrix(): this;
  79804. /**
  79805. * True if the World matrix has been frozen.
  79806. */
  79807. readonly isWorldMatrixFrozen: boolean;
  79808. /**
  79809. * Retuns the mesh absolute position in the World.
  79810. * @returns a Vector3.
  79811. */
  79812. getAbsolutePosition(): Vector3;
  79813. /**
  79814. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  79815. * @param absolutePosition the absolute position to set
  79816. * @returns the TransformNode.
  79817. */
  79818. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79819. /**
  79820. * Sets the mesh position in its local space.
  79821. * @param vector3 the position to set in localspace
  79822. * @returns the TransformNode.
  79823. */
  79824. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  79825. /**
  79826. * Returns the mesh position in the local space from the current World matrix values.
  79827. * @returns a new Vector3.
  79828. */
  79829. getPositionExpressedInLocalSpace(): Vector3;
  79830. /**
  79831. * Translates the mesh along the passed Vector3 in its local space.
  79832. * @param vector3 the distance to translate in localspace
  79833. * @returns the TransformNode.
  79834. */
  79835. locallyTranslate(vector3: Vector3): TransformNode;
  79836. private static _lookAtVectorCache;
  79837. /**
  79838. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  79839. * @param targetPoint the position (must be in same space as current mesh) to look at
  79840. * @param yawCor optional yaw (y-axis) correction in radians
  79841. * @param pitchCor optional pitch (x-axis) correction in radians
  79842. * @param rollCor optional roll (z-axis) correction in radians
  79843. * @param space the choosen space of the target
  79844. * @returns the TransformNode.
  79845. */
  79846. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  79847. /**
  79848. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79849. * This Vector3 is expressed in the World space.
  79850. * @param localAxis axis to rotate
  79851. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  79852. */
  79853. getDirection(localAxis: Vector3): Vector3;
  79854. /**
  79855. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  79856. * localAxis is expressed in the mesh local space.
  79857. * result is computed in the Wordl space from the mesh World matrix.
  79858. * @param localAxis axis to rotate
  79859. * @param result the resulting transformnode
  79860. * @returns this TransformNode.
  79861. */
  79862. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  79863. /**
  79864. * Sets this transform node rotation to the given local axis.
  79865. * @param localAxis the axis in local space
  79866. * @param yawCor optional yaw (y-axis) correction in radians
  79867. * @param pitchCor optional pitch (x-axis) correction in radians
  79868. * @param rollCor optional roll (z-axis) correction in radians
  79869. * @returns this TransformNode
  79870. */
  79871. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  79872. /**
  79873. * Sets a new pivot point to the current node
  79874. * @param point defines the new pivot point to use
  79875. * @param space defines if the point is in world or local space (local by default)
  79876. * @returns the current TransformNode
  79877. */
  79878. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  79879. /**
  79880. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  79881. * @returns the pivot point
  79882. */
  79883. getPivotPoint(): Vector3;
  79884. /**
  79885. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  79886. * @param result the vector3 to store the result
  79887. * @returns this TransformNode.
  79888. */
  79889. getPivotPointToRef(result: Vector3): TransformNode;
  79890. /**
  79891. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  79892. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  79893. */
  79894. getAbsolutePivotPoint(): Vector3;
  79895. /**
  79896. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  79897. * @param result vector3 to store the result
  79898. * @returns this TransformNode.
  79899. */
  79900. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  79901. /**
  79902. * Defines the passed node as the parent of the current node.
  79903. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  79904. * @see https://doc.babylonjs.com/how_to/parenting
  79905. * @param node the node ot set as the parent
  79906. * @returns this TransformNode.
  79907. */
  79908. setParent(node: Nullable<Node>): TransformNode;
  79909. private _nonUniformScaling;
  79910. /**
  79911. * True if the scaling property of this object is non uniform eg. (1,2,1)
  79912. */
  79913. readonly nonUniformScaling: boolean;
  79914. /** @hidden */
  79915. _updateNonUniformScalingState(value: boolean): boolean;
  79916. /**
  79917. * Attach the current TransformNode to another TransformNode associated with a bone
  79918. * @param bone Bone affecting the TransformNode
  79919. * @param affectedTransformNode TransformNode associated with the bone
  79920. * @returns this object
  79921. */
  79922. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  79923. /**
  79924. * Detach the transform node if its associated with a bone
  79925. * @returns this object
  79926. */
  79927. detachFromBone(): TransformNode;
  79928. private static _rotationAxisCache;
  79929. /**
  79930. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  79931. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79932. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79933. * The passed axis is also normalized.
  79934. * @param axis the axis to rotate around
  79935. * @param amount the amount to rotate in radians
  79936. * @param space Space to rotate in (Default: local)
  79937. * @returns the TransformNode.
  79938. */
  79939. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79940. /**
  79941. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  79942. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  79943. * The passed axis is also normalized. .
  79944. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  79945. * @param point the point to rotate around
  79946. * @param axis the axis to rotate around
  79947. * @param amount the amount to rotate in radians
  79948. * @returns the TransformNode
  79949. */
  79950. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  79951. /**
  79952. * Translates the mesh along the axis vector for the passed distance in the given space.
  79953. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  79954. * @param axis the axis to translate in
  79955. * @param distance the distance to translate
  79956. * @param space Space to rotate in (Default: local)
  79957. * @returns the TransformNode.
  79958. */
  79959. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79960. /**
  79961. * Adds a rotation step to the mesh current rotation.
  79962. * x, y, z are Euler angles expressed in radians.
  79963. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  79964. * This means this rotation is made in the mesh local space only.
  79965. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  79966. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  79967. * ```javascript
  79968. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  79969. * ```
  79970. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  79971. * 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.
  79972. * @param x Rotation to add
  79973. * @param y Rotation to add
  79974. * @param z Rotation to add
  79975. * @returns the TransformNode.
  79976. */
  79977. addRotation(x: number, y: number, z: number): TransformNode;
  79978. /**
  79979. * @hidden
  79980. */
  79981. protected _getEffectiveParent(): Nullable<Node>;
  79982. /**
  79983. * Computes the world matrix of the node
  79984. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79985. * @returns the world matrix
  79986. */
  79987. computeWorldMatrix(force?: boolean): Matrix;
  79988. protected _afterComputeWorldMatrix(): void;
  79989. /**
  79990. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  79991. * @param func callback function to add
  79992. *
  79993. * @returns the TransformNode.
  79994. */
  79995. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  79996. /**
  79997. * Removes a registered callback function.
  79998. * @param func callback function to remove
  79999. * @returns the TransformNode.
  80000. */
  80001. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80002. /**
  80003. * Gets the position of the current mesh in camera space
  80004. * @param camera defines the camera to use
  80005. * @returns a position
  80006. */
  80007. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  80008. /**
  80009. * Returns the distance from the mesh to the active camera
  80010. * @param camera defines the camera to use
  80011. * @returns the distance
  80012. */
  80013. getDistanceToCamera(camera?: Nullable<Camera>): number;
  80014. /**
  80015. * Clone the current transform node
  80016. * @param name Name of the new clone
  80017. * @param newParent New parent for the clone
  80018. * @param doNotCloneChildren Do not clone children hierarchy
  80019. * @returns the new transform node
  80020. */
  80021. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  80022. /**
  80023. * Serializes the objects information.
  80024. * @param currentSerializationObject defines the object to serialize in
  80025. * @returns the serialized object
  80026. */
  80027. serialize(currentSerializationObject?: any): any;
  80028. /**
  80029. * Returns a new TransformNode object parsed from the source provided.
  80030. * @param parsedTransformNode is the source.
  80031. * @param scene the scne the object belongs to
  80032. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  80033. * @returns a new TransformNode object parsed from the source provided.
  80034. */
  80035. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  80036. /**
  80037. * Get all child-transformNodes of this node
  80038. * @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
  80039. * @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
  80040. * @returns an array of TransformNode
  80041. */
  80042. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  80043. /**
  80044. * Releases resources associated with this transform node.
  80045. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80046. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80047. */
  80048. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80049. /**
  80050. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  80051. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  80052. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  80053. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  80054. * @returns the current mesh
  80055. */
  80056. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  80057. private _syncAbsoluteScalingAndRotation;
  80058. }
  80059. }
  80060. declare module BABYLON {
  80061. /**
  80062. * Defines the types of pose enabled controllers that are supported
  80063. */
  80064. export enum PoseEnabledControllerType {
  80065. /**
  80066. * HTC Vive
  80067. */
  80068. VIVE = 0,
  80069. /**
  80070. * Oculus Rift
  80071. */
  80072. OCULUS = 1,
  80073. /**
  80074. * Windows mixed reality
  80075. */
  80076. WINDOWS = 2,
  80077. /**
  80078. * Samsung gear VR
  80079. */
  80080. GEAR_VR = 3,
  80081. /**
  80082. * Google Daydream
  80083. */
  80084. DAYDREAM = 4,
  80085. /**
  80086. * Generic
  80087. */
  80088. GENERIC = 5
  80089. }
  80090. /**
  80091. * Defines the MutableGamepadButton interface for the state of a gamepad button
  80092. */
  80093. export interface MutableGamepadButton {
  80094. /**
  80095. * Value of the button/trigger
  80096. */
  80097. value: number;
  80098. /**
  80099. * If the button/trigger is currently touched
  80100. */
  80101. touched: boolean;
  80102. /**
  80103. * If the button/trigger is currently pressed
  80104. */
  80105. pressed: boolean;
  80106. }
  80107. /**
  80108. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  80109. * @hidden
  80110. */
  80111. export interface ExtendedGamepadButton extends GamepadButton {
  80112. /**
  80113. * If the button/trigger is currently pressed
  80114. */
  80115. readonly pressed: boolean;
  80116. /**
  80117. * If the button/trigger is currently touched
  80118. */
  80119. readonly touched: boolean;
  80120. /**
  80121. * Value of the button/trigger
  80122. */
  80123. readonly value: number;
  80124. }
  80125. /** @hidden */
  80126. export interface _GamePadFactory {
  80127. /**
  80128. * Returns wether or not the current gamepad can be created for this type of controller.
  80129. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80130. * @returns true if it can be created, otherwise false
  80131. */
  80132. canCreate(gamepadInfo: any): boolean;
  80133. /**
  80134. * Creates a new instance of the Gamepad.
  80135. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  80136. * @returns the new gamepad instance
  80137. */
  80138. create(gamepadInfo: any): Gamepad;
  80139. }
  80140. /**
  80141. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80142. */
  80143. export class PoseEnabledControllerHelper {
  80144. /** @hidden */
  80145. static _ControllerFactories: _GamePadFactory[];
  80146. /** @hidden */
  80147. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  80148. /**
  80149. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  80150. * @param vrGamepad the gamepad to initialized
  80151. * @returns a vr controller of the type the gamepad identified as
  80152. */
  80153. static InitiateController(vrGamepad: any): Gamepad;
  80154. }
  80155. /**
  80156. * Defines the PoseEnabledController object that contains state of a vr capable controller
  80157. */
  80158. export class PoseEnabledController extends Gamepad implements PoseControlled {
  80159. /**
  80160. * If the controller is used in a webXR session
  80161. */
  80162. isXR: boolean;
  80163. private _deviceRoomPosition;
  80164. private _deviceRoomRotationQuaternion;
  80165. /**
  80166. * The device position in babylon space
  80167. */
  80168. devicePosition: Vector3;
  80169. /**
  80170. * The device rotation in babylon space
  80171. */
  80172. deviceRotationQuaternion: Quaternion;
  80173. /**
  80174. * The scale factor of the device in babylon space
  80175. */
  80176. deviceScaleFactor: number;
  80177. /**
  80178. * (Likely devicePosition should be used instead) The device position in its room space
  80179. */
  80180. position: Vector3;
  80181. /**
  80182. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  80183. */
  80184. rotationQuaternion: Quaternion;
  80185. /**
  80186. * The type of controller (Eg. Windows mixed reality)
  80187. */
  80188. controllerType: PoseEnabledControllerType;
  80189. protected _calculatedPosition: Vector3;
  80190. private _calculatedRotation;
  80191. /**
  80192. * The raw pose from the device
  80193. */
  80194. rawPose: DevicePose;
  80195. private _trackPosition;
  80196. private _maxRotationDistFromHeadset;
  80197. private _draggedRoomRotation;
  80198. /**
  80199. * @hidden
  80200. */
  80201. _disableTrackPosition(fixedPosition: Vector3): void;
  80202. /**
  80203. * Internal, the mesh attached to the controller
  80204. * @hidden
  80205. */
  80206. _mesh: Nullable<AbstractMesh>;
  80207. private _poseControlledCamera;
  80208. private _leftHandSystemQuaternion;
  80209. /**
  80210. * Internal, matrix used to convert room space to babylon space
  80211. * @hidden
  80212. */
  80213. _deviceToWorld: Matrix;
  80214. /**
  80215. * Node to be used when casting a ray from the controller
  80216. * @hidden
  80217. */
  80218. _pointingPoseNode: Nullable<TransformNode>;
  80219. /**
  80220. * Name of the child mesh that can be used to cast a ray from the controller
  80221. */
  80222. static readonly POINTING_POSE: string;
  80223. /**
  80224. * Creates a new PoseEnabledController from a gamepad
  80225. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  80226. */
  80227. constructor(browserGamepad: any);
  80228. private _workingMatrix;
  80229. /**
  80230. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  80231. */
  80232. update(): void;
  80233. /**
  80234. * Updates only the pose device and mesh without doing any button event checking
  80235. */
  80236. protected _updatePoseAndMesh(): void;
  80237. /**
  80238. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  80239. * @param poseData raw pose fromthe device
  80240. */
  80241. updateFromDevice(poseData: DevicePose): void;
  80242. /**
  80243. * @hidden
  80244. */
  80245. _meshAttachedObservable: Observable<AbstractMesh>;
  80246. /**
  80247. * Attaches a mesh to the controller
  80248. * @param mesh the mesh to be attached
  80249. */
  80250. attachToMesh(mesh: AbstractMesh): void;
  80251. /**
  80252. * Attaches the controllers mesh to a camera
  80253. * @param camera the camera the mesh should be attached to
  80254. */
  80255. attachToPoseControlledCamera(camera: TargetCamera): void;
  80256. /**
  80257. * Disposes of the controller
  80258. */
  80259. dispose(): void;
  80260. /**
  80261. * The mesh that is attached to the controller
  80262. */
  80263. readonly mesh: Nullable<AbstractMesh>;
  80264. /**
  80265. * Gets the ray of the controller in the direction the controller is pointing
  80266. * @param length the length the resulting ray should be
  80267. * @returns a ray in the direction the controller is pointing
  80268. */
  80269. getForwardRay(length?: number): Ray;
  80270. }
  80271. }
  80272. declare module BABYLON {
  80273. /**
  80274. * Defines the WebVRController object that represents controllers tracked in 3D space
  80275. */
  80276. export abstract class WebVRController extends PoseEnabledController {
  80277. /**
  80278. * Internal, the default controller model for the controller
  80279. */
  80280. protected _defaultModel: AbstractMesh;
  80281. /**
  80282. * Fired when the trigger state has changed
  80283. */
  80284. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  80285. /**
  80286. * Fired when the main button state has changed
  80287. */
  80288. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80289. /**
  80290. * Fired when the secondary button state has changed
  80291. */
  80292. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  80293. /**
  80294. * Fired when the pad state has changed
  80295. */
  80296. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  80297. /**
  80298. * Fired when controllers stick values have changed
  80299. */
  80300. onPadValuesChangedObservable: Observable<StickValues>;
  80301. /**
  80302. * Array of button availible on the controller
  80303. */
  80304. protected _buttons: Array<MutableGamepadButton>;
  80305. private _onButtonStateChange;
  80306. /**
  80307. * Fired when a controller button's state has changed
  80308. * @param callback the callback containing the button that was modified
  80309. */
  80310. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  80311. /**
  80312. * X and Y axis corresponding to the controllers joystick
  80313. */
  80314. pad: StickValues;
  80315. /**
  80316. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  80317. */
  80318. hand: string;
  80319. /**
  80320. * The default controller model for the controller
  80321. */
  80322. readonly defaultModel: AbstractMesh;
  80323. /**
  80324. * Creates a new WebVRController from a gamepad
  80325. * @param vrGamepad the gamepad that the WebVRController should be created from
  80326. */
  80327. constructor(vrGamepad: any);
  80328. /**
  80329. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  80330. */
  80331. update(): void;
  80332. /**
  80333. * Function to be called when a button is modified
  80334. */
  80335. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  80336. /**
  80337. * Loads a mesh and attaches it to the controller
  80338. * @param scene the scene the mesh should be added to
  80339. * @param meshLoaded callback for when the mesh has been loaded
  80340. */
  80341. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  80342. private _setButtonValue;
  80343. private _changes;
  80344. private _checkChanges;
  80345. /**
  80346. * Disposes of th webVRCOntroller
  80347. */
  80348. dispose(): void;
  80349. }
  80350. }
  80351. declare module BABYLON {
  80352. /**
  80353. * The HemisphericLight simulates the ambient environment light,
  80354. * so the passed direction is the light reflection direction, not the incoming direction.
  80355. */
  80356. export class HemisphericLight extends Light {
  80357. /**
  80358. * The groundColor is the light in the opposite direction to the one specified during creation.
  80359. * 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.
  80360. */
  80361. groundColor: Color3;
  80362. /**
  80363. * The light reflection direction, not the incoming direction.
  80364. */
  80365. direction: Vector3;
  80366. /**
  80367. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  80368. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  80369. * The HemisphericLight can't cast shadows.
  80370. * Documentation : https://doc.babylonjs.com/babylon101/lights
  80371. * @param name The friendly name of the light
  80372. * @param direction The direction of the light reflection
  80373. * @param scene The scene the light belongs to
  80374. */
  80375. constructor(name: string, direction: Vector3, scene: Scene);
  80376. protected _buildUniformLayout(): void;
  80377. /**
  80378. * Returns the string "HemisphericLight".
  80379. * @return The class name
  80380. */
  80381. getClassName(): string;
  80382. /**
  80383. * Sets the HemisphericLight direction towards the passed target (Vector3).
  80384. * Returns the updated direction.
  80385. * @param target The target the direction should point to
  80386. * @return The computed direction
  80387. */
  80388. setDirectionToTarget(target: Vector3): Vector3;
  80389. /**
  80390. * Returns the shadow generator associated to the light.
  80391. * @returns Always null for hemispheric lights because it does not support shadows.
  80392. */
  80393. getShadowGenerator(): Nullable<IShadowGenerator>;
  80394. /**
  80395. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  80396. * @param effect The effect to update
  80397. * @param lightIndex The index of the light in the effect to update
  80398. * @returns The hemispheric light
  80399. */
  80400. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  80401. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  80402. /**
  80403. * Computes the world matrix of the node
  80404. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80405. * @param useWasUpdatedFlag defines a reserved property
  80406. * @returns the world matrix
  80407. */
  80408. computeWorldMatrix(): Matrix;
  80409. /**
  80410. * Returns the integer 3.
  80411. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  80412. */
  80413. getTypeID(): number;
  80414. /**
  80415. * Prepares the list of defines specific to the light type.
  80416. * @param defines the list of defines
  80417. * @param lightIndex defines the index of the light for the effect
  80418. */
  80419. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80420. }
  80421. }
  80422. declare module BABYLON {
  80423. /** @hidden */
  80424. export var vrMultiviewToSingleviewPixelShader: {
  80425. name: string;
  80426. shader: string;
  80427. };
  80428. }
  80429. declare module BABYLON {
  80430. /**
  80431. * Renders to multiple views with a single draw call
  80432. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80433. */
  80434. export class MultiviewRenderTarget extends RenderTargetTexture {
  80435. /**
  80436. * Creates a multiview render target
  80437. * @param scene scene used with the render target
  80438. * @param size the size of the render target (used for each view)
  80439. */
  80440. constructor(scene: Scene, size?: number | {
  80441. width: number;
  80442. height: number;
  80443. } | {
  80444. ratio: number;
  80445. });
  80446. /**
  80447. * @hidden
  80448. * @param faceIndex the face index, if its a cube texture
  80449. */
  80450. _bindFrameBuffer(faceIndex?: number): void;
  80451. /**
  80452. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80453. * @returns the view count
  80454. */
  80455. getViewCount(): number;
  80456. }
  80457. }
  80458. declare module BABYLON {
  80459. /**
  80460. * Represents a camera frustum
  80461. */
  80462. export class Frustum {
  80463. /**
  80464. * Gets the planes representing the frustum
  80465. * @param transform matrix to be applied to the returned planes
  80466. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  80467. */
  80468. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  80469. /**
  80470. * Gets the near frustum plane transformed by the transform matrix
  80471. * @param transform transformation matrix to be applied to the resulting frustum plane
  80472. * @param frustumPlane the resuling frustum plane
  80473. */
  80474. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80475. /**
  80476. * Gets the far frustum plane transformed by the transform matrix
  80477. * @param transform transformation matrix to be applied to the resulting frustum plane
  80478. * @param frustumPlane the resuling frustum plane
  80479. */
  80480. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80481. /**
  80482. * Gets the left frustum plane transformed by the transform matrix
  80483. * @param transform transformation matrix to be applied to the resulting frustum plane
  80484. * @param frustumPlane the resuling frustum plane
  80485. */
  80486. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80487. /**
  80488. * Gets the right frustum plane transformed by the transform matrix
  80489. * @param transform transformation matrix to be applied to the resulting frustum plane
  80490. * @param frustumPlane the resuling frustum plane
  80491. */
  80492. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80493. /**
  80494. * Gets the top frustum plane transformed by the transform matrix
  80495. * @param transform transformation matrix to be applied to the resulting frustum plane
  80496. * @param frustumPlane the resuling frustum plane
  80497. */
  80498. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80499. /**
  80500. * Gets the bottom frustum plane transformed by the transform matrix
  80501. * @param transform transformation matrix to be applied to the resulting frustum plane
  80502. * @param frustumPlane the resuling frustum plane
  80503. */
  80504. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  80505. /**
  80506. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  80507. * @param transform transformation matrix to be applied to the resulting frustum planes
  80508. * @param frustumPlanes the resuling frustum planes
  80509. */
  80510. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  80511. }
  80512. }
  80513. declare module BABYLON {
  80514. interface Engine {
  80515. /**
  80516. * Creates a new multiview render target
  80517. * @param width defines the width of the texture
  80518. * @param height defines the height of the texture
  80519. * @returns the created multiview texture
  80520. */
  80521. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80522. /**
  80523. * Binds a multiview framebuffer to be drawn to
  80524. * @param multiviewTexture texture to bind
  80525. */
  80526. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80527. }
  80528. interface Camera {
  80529. /**
  80530. * @hidden
  80531. * 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)
  80532. */
  80533. _useMultiviewToSingleView: boolean;
  80534. /**
  80535. * @hidden
  80536. * 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)
  80537. */
  80538. _multiviewTexture: Nullable<RenderTargetTexture>;
  80539. /**
  80540. * @hidden
  80541. * ensures the multiview texture of the camera exists and has the specified width/height
  80542. * @param width height to set on the multiview texture
  80543. * @param height width to set on the multiview texture
  80544. */
  80545. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80546. }
  80547. interface Scene {
  80548. /** @hidden */
  80549. _transformMatrixR: Matrix;
  80550. /** @hidden */
  80551. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80552. /** @hidden */
  80553. _createMultiviewUbo(): void;
  80554. /** @hidden */
  80555. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80556. /** @hidden */
  80557. _renderMultiviewToSingleView(camera: Camera): void;
  80558. }
  80559. }
  80560. declare module BABYLON {
  80561. /**
  80562. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80563. * This will not be used for webXR as it supports displaying texture arrays directly
  80564. */
  80565. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80566. /**
  80567. * Initializes a VRMultiviewToSingleview
  80568. * @param name name of the post process
  80569. * @param camera camera to be applied to
  80570. * @param scaleFactor scaling factor to the size of the output texture
  80571. */
  80572. constructor(name: string, camera: Camera, scaleFactor: number);
  80573. }
  80574. }
  80575. declare module BABYLON {
  80576. interface Engine {
  80577. /** @hidden */
  80578. _vrDisplay: any;
  80579. /** @hidden */
  80580. _vrSupported: boolean;
  80581. /** @hidden */
  80582. _oldSize: Size;
  80583. /** @hidden */
  80584. _oldHardwareScaleFactor: number;
  80585. /** @hidden */
  80586. _vrExclusivePointerMode: boolean;
  80587. /** @hidden */
  80588. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80589. /** @hidden */
  80590. _onVRDisplayPointerRestricted: () => void;
  80591. /** @hidden */
  80592. _onVRDisplayPointerUnrestricted: () => void;
  80593. /** @hidden */
  80594. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80595. /** @hidden */
  80596. _onVrDisplayDisconnect: Nullable<() => void>;
  80597. /** @hidden */
  80598. _onVrDisplayPresentChange: Nullable<() => void>;
  80599. /**
  80600. * Observable signaled when VR display mode changes
  80601. */
  80602. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80603. /**
  80604. * Observable signaled when VR request present is complete
  80605. */
  80606. onVRRequestPresentComplete: Observable<boolean>;
  80607. /**
  80608. * Observable signaled when VR request present starts
  80609. */
  80610. onVRRequestPresentStart: Observable<Engine>;
  80611. /**
  80612. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80613. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80614. */
  80615. isInVRExclusivePointerMode: boolean;
  80616. /**
  80617. * Gets a boolean indicating if a webVR device was detected
  80618. * @returns true if a webVR device was detected
  80619. */
  80620. isVRDevicePresent(): boolean;
  80621. /**
  80622. * Gets the current webVR device
  80623. * @returns the current webVR device (or null)
  80624. */
  80625. getVRDevice(): any;
  80626. /**
  80627. * Initializes a webVR display and starts listening to display change events
  80628. * The onVRDisplayChangedObservable will be notified upon these changes
  80629. * @returns A promise containing a VRDisplay and if vr is supported
  80630. */
  80631. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80632. /** @hidden */
  80633. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80634. /**
  80635. * Call this function to switch to webVR mode
  80636. * Will do nothing if webVR is not supported or if there is no webVR device
  80637. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80638. */
  80639. enableVR(): void;
  80640. /** @hidden */
  80641. _onVRFullScreenTriggered(): void;
  80642. }
  80643. }
  80644. declare module BABYLON {
  80645. /**
  80646. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80647. * IMPORTANT!! The data is right-hand data.
  80648. * @export
  80649. * @interface DevicePose
  80650. */
  80651. export interface DevicePose {
  80652. /**
  80653. * The position of the device, values in array are [x,y,z].
  80654. */
  80655. readonly position: Nullable<Float32Array>;
  80656. /**
  80657. * The linearVelocity of the device, values in array are [x,y,z].
  80658. */
  80659. readonly linearVelocity: Nullable<Float32Array>;
  80660. /**
  80661. * The linearAcceleration of the device, values in array are [x,y,z].
  80662. */
  80663. readonly linearAcceleration: Nullable<Float32Array>;
  80664. /**
  80665. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80666. */
  80667. readonly orientation: Nullable<Float32Array>;
  80668. /**
  80669. * The angularVelocity of the device, values in array are [x,y,z].
  80670. */
  80671. readonly angularVelocity: Nullable<Float32Array>;
  80672. /**
  80673. * The angularAcceleration of the device, values in array are [x,y,z].
  80674. */
  80675. readonly angularAcceleration: Nullable<Float32Array>;
  80676. }
  80677. /**
  80678. * Interface representing a pose controlled object in Babylon.
  80679. * A pose controlled object has both regular pose values as well as pose values
  80680. * from an external device such as a VR head mounted display
  80681. */
  80682. export interface PoseControlled {
  80683. /**
  80684. * The position of the object in babylon space.
  80685. */
  80686. position: Vector3;
  80687. /**
  80688. * The rotation quaternion of the object in babylon space.
  80689. */
  80690. rotationQuaternion: Quaternion;
  80691. /**
  80692. * The position of the device in babylon space.
  80693. */
  80694. devicePosition?: Vector3;
  80695. /**
  80696. * The rotation quaternion of the device in babylon space.
  80697. */
  80698. deviceRotationQuaternion: Quaternion;
  80699. /**
  80700. * The raw pose coming from the device.
  80701. */
  80702. rawPose: Nullable<DevicePose>;
  80703. /**
  80704. * The scale of the device to be used when translating from device space to babylon space.
  80705. */
  80706. deviceScaleFactor: number;
  80707. /**
  80708. * Updates the poseControlled values based on the input device pose.
  80709. * @param poseData the pose data to update the object with
  80710. */
  80711. updateFromDevice(poseData: DevicePose): void;
  80712. }
  80713. /**
  80714. * Set of options to customize the webVRCamera
  80715. */
  80716. export interface WebVROptions {
  80717. /**
  80718. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80719. */
  80720. trackPosition?: boolean;
  80721. /**
  80722. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80723. */
  80724. positionScale?: number;
  80725. /**
  80726. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80727. */
  80728. displayName?: string;
  80729. /**
  80730. * Should the native controller meshes be initialized. (default: true)
  80731. */
  80732. controllerMeshes?: boolean;
  80733. /**
  80734. * Creating a default HemiLight only on controllers. (default: true)
  80735. */
  80736. defaultLightingOnControllers?: boolean;
  80737. /**
  80738. * If you don't want to use the default VR button of the helper. (default: false)
  80739. */
  80740. useCustomVRButton?: boolean;
  80741. /**
  80742. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80743. */
  80744. customVRButton?: HTMLButtonElement;
  80745. /**
  80746. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80747. */
  80748. rayLength?: number;
  80749. /**
  80750. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80751. */
  80752. defaultHeight?: number;
  80753. /**
  80754. * If multiview should be used if availible (default: false)
  80755. */
  80756. useMultiview?: boolean;
  80757. }
  80758. /**
  80759. * This represents a WebVR camera.
  80760. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80761. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80762. */
  80763. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80764. private webVROptions;
  80765. /**
  80766. * @hidden
  80767. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80768. */
  80769. _vrDevice: any;
  80770. /**
  80771. * The rawPose of the vrDevice.
  80772. */
  80773. rawPose: Nullable<DevicePose>;
  80774. private _onVREnabled;
  80775. private _specsVersion;
  80776. private _attached;
  80777. private _frameData;
  80778. protected _descendants: Array<Node>;
  80779. private _deviceRoomPosition;
  80780. /** @hidden */
  80781. _deviceRoomRotationQuaternion: Quaternion;
  80782. private _standingMatrix;
  80783. /**
  80784. * Represents device position in babylon space.
  80785. */
  80786. devicePosition: Vector3;
  80787. /**
  80788. * Represents device rotation in babylon space.
  80789. */
  80790. deviceRotationQuaternion: Quaternion;
  80791. /**
  80792. * The scale of the device to be used when translating from device space to babylon space.
  80793. */
  80794. deviceScaleFactor: number;
  80795. private _deviceToWorld;
  80796. private _worldToDevice;
  80797. /**
  80798. * References to the webVR controllers for the vrDevice.
  80799. */
  80800. controllers: Array<WebVRController>;
  80801. /**
  80802. * Emits an event when a controller is attached.
  80803. */
  80804. onControllersAttachedObservable: Observable<WebVRController[]>;
  80805. /**
  80806. * Emits an event when a controller's mesh has been loaded;
  80807. */
  80808. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80809. /**
  80810. * Emits an event when the HMD's pose has been updated.
  80811. */
  80812. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80813. private _poseSet;
  80814. /**
  80815. * If the rig cameras be used as parent instead of this camera.
  80816. */
  80817. rigParenting: boolean;
  80818. private _lightOnControllers;
  80819. private _defaultHeight?;
  80820. /**
  80821. * Instantiates a WebVRFreeCamera.
  80822. * @param name The name of the WebVRFreeCamera
  80823. * @param position The starting anchor position for the camera
  80824. * @param scene The scene the camera belongs to
  80825. * @param webVROptions a set of customizable options for the webVRCamera
  80826. */
  80827. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80828. /**
  80829. * Gets the device distance from the ground in meters.
  80830. * @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.
  80831. */
  80832. deviceDistanceToRoomGround(): number;
  80833. /**
  80834. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80835. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80836. */
  80837. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80838. /**
  80839. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80840. * @returns A promise with a boolean set to if the standing matrix is supported.
  80841. */
  80842. useStandingMatrixAsync(): Promise<boolean>;
  80843. /**
  80844. * Disposes the camera
  80845. */
  80846. dispose(): void;
  80847. /**
  80848. * Gets a vrController by name.
  80849. * @param name The name of the controller to retreive
  80850. * @returns the controller matching the name specified or null if not found
  80851. */
  80852. getControllerByName(name: string): Nullable<WebVRController>;
  80853. private _leftController;
  80854. /**
  80855. * The controller corresponding to the users left hand.
  80856. */
  80857. readonly leftController: Nullable<WebVRController>;
  80858. private _rightController;
  80859. /**
  80860. * The controller corresponding to the users right hand.
  80861. */
  80862. readonly rightController: Nullable<WebVRController>;
  80863. /**
  80864. * Casts a ray forward from the vrCamera's gaze.
  80865. * @param length Length of the ray (default: 100)
  80866. * @returns the ray corresponding to the gaze
  80867. */
  80868. getForwardRay(length?: number): Ray;
  80869. /**
  80870. * @hidden
  80871. * Updates the camera based on device's frame data
  80872. */
  80873. _checkInputs(): void;
  80874. /**
  80875. * Updates the poseControlled values based on the input device pose.
  80876. * @param poseData Pose coming from the device
  80877. */
  80878. updateFromDevice(poseData: DevicePose): void;
  80879. private _htmlElementAttached;
  80880. private _detachIfAttached;
  80881. /**
  80882. * WebVR's attach control will start broadcasting frames to the device.
  80883. * Note that in certain browsers (chrome for example) this function must be called
  80884. * within a user-interaction callback. Example:
  80885. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80886. *
  80887. * @param element html element to attach the vrDevice to
  80888. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80889. */
  80890. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80891. /**
  80892. * Detaches the camera from the html element and disables VR
  80893. *
  80894. * @param element html element to detach from
  80895. */
  80896. detachControl(element: HTMLElement): void;
  80897. /**
  80898. * @returns the name of this class
  80899. */
  80900. getClassName(): string;
  80901. /**
  80902. * Calls resetPose on the vrDisplay
  80903. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80904. */
  80905. resetToCurrentRotation(): void;
  80906. /**
  80907. * @hidden
  80908. * Updates the rig cameras (left and right eye)
  80909. */
  80910. _updateRigCameras(): void;
  80911. private _workingVector;
  80912. private _oneVector;
  80913. private _workingMatrix;
  80914. private updateCacheCalled;
  80915. private _correctPositionIfNotTrackPosition;
  80916. /**
  80917. * @hidden
  80918. * Updates the cached values of the camera
  80919. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80920. */
  80921. _updateCache(ignoreParentClass?: boolean): void;
  80922. /**
  80923. * @hidden
  80924. * Get current device position in babylon world
  80925. */
  80926. _computeDevicePosition(): void;
  80927. /**
  80928. * Updates the current device position and rotation in the babylon world
  80929. */
  80930. update(): void;
  80931. /**
  80932. * @hidden
  80933. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80934. * @returns an identity matrix
  80935. */
  80936. _getViewMatrix(): Matrix;
  80937. private _tmpMatrix;
  80938. /**
  80939. * This function is called by the two RIG cameras.
  80940. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80941. * @hidden
  80942. */
  80943. _getWebVRViewMatrix(): Matrix;
  80944. /** @hidden */
  80945. _getWebVRProjectionMatrix(): Matrix;
  80946. private _onGamepadConnectedObserver;
  80947. private _onGamepadDisconnectedObserver;
  80948. private _updateCacheWhenTrackingDisabledObserver;
  80949. /**
  80950. * Initializes the controllers and their meshes
  80951. */
  80952. initControllers(): void;
  80953. }
  80954. }
  80955. declare module BABYLON {
  80956. /**
  80957. * Size options for a post process
  80958. */
  80959. export type PostProcessOptions = {
  80960. width: number;
  80961. height: number;
  80962. };
  80963. /**
  80964. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80965. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80966. */
  80967. export class PostProcess {
  80968. /** Name of the PostProcess. */
  80969. name: string;
  80970. /**
  80971. * Gets or sets the unique id of the post process
  80972. */
  80973. uniqueId: number;
  80974. /**
  80975. * Width of the texture to apply the post process on
  80976. */
  80977. width: number;
  80978. /**
  80979. * Height of the texture to apply the post process on
  80980. */
  80981. height: number;
  80982. /**
  80983. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80984. * @hidden
  80985. */
  80986. _outputTexture: Nullable<InternalTexture>;
  80987. /**
  80988. * Sampling mode used by the shader
  80989. * See https://doc.babylonjs.com/classes/3.1/texture
  80990. */
  80991. renderTargetSamplingMode: number;
  80992. /**
  80993. * Clear color to use when screen clearing
  80994. */
  80995. clearColor: Color4;
  80996. /**
  80997. * If the buffer needs to be cleared before applying the post process. (default: true)
  80998. * Should be set to false if shader will overwrite all previous pixels.
  80999. */
  81000. autoClear: boolean;
  81001. /**
  81002. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  81003. */
  81004. alphaMode: number;
  81005. /**
  81006. * Sets the setAlphaBlendConstants of the babylon engine
  81007. */
  81008. alphaConstants: Color4;
  81009. /**
  81010. * Animations to be used for the post processing
  81011. */
  81012. animations: Animation[];
  81013. /**
  81014. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  81015. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  81016. */
  81017. enablePixelPerfectMode: boolean;
  81018. /**
  81019. * Force the postprocess to be applied without taking in account viewport
  81020. */
  81021. forceFullscreenViewport: boolean;
  81022. /**
  81023. * List of inspectable custom properties (used by the Inspector)
  81024. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81025. */
  81026. inspectableCustomProperties: IInspectable[];
  81027. /**
  81028. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  81029. *
  81030. * | Value | Type | Description |
  81031. * | ----- | ----------------------------------- | ----------- |
  81032. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  81033. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  81034. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  81035. *
  81036. */
  81037. scaleMode: number;
  81038. /**
  81039. * Force textures to be a power of two (default: false)
  81040. */
  81041. alwaysForcePOT: boolean;
  81042. private _samples;
  81043. /**
  81044. * Number of sample textures (default: 1)
  81045. */
  81046. samples: number;
  81047. /**
  81048. * Modify the scale of the post process to be the same as the viewport (default: false)
  81049. */
  81050. adaptScaleToCurrentViewport: boolean;
  81051. private _camera;
  81052. private _scene;
  81053. private _engine;
  81054. private _options;
  81055. private _reusable;
  81056. private _textureType;
  81057. /**
  81058. * Smart array of input and output textures for the post process.
  81059. * @hidden
  81060. */
  81061. _textures: SmartArray<InternalTexture>;
  81062. /**
  81063. * The index in _textures that corresponds to the output texture.
  81064. * @hidden
  81065. */
  81066. _currentRenderTextureInd: number;
  81067. private _effect;
  81068. private _samplers;
  81069. private _fragmentUrl;
  81070. private _vertexUrl;
  81071. private _parameters;
  81072. private _scaleRatio;
  81073. protected _indexParameters: any;
  81074. private _shareOutputWithPostProcess;
  81075. private _texelSize;
  81076. private _forcedOutputTexture;
  81077. /**
  81078. * Returns the fragment url or shader name used in the post process.
  81079. * @returns the fragment url or name in the shader store.
  81080. */
  81081. getEffectName(): string;
  81082. /**
  81083. * An event triggered when the postprocess is activated.
  81084. */
  81085. onActivateObservable: Observable<Camera>;
  81086. private _onActivateObserver;
  81087. /**
  81088. * A function that is added to the onActivateObservable
  81089. */
  81090. onActivate: Nullable<(camera: Camera) => void>;
  81091. /**
  81092. * An event triggered when the postprocess changes its size.
  81093. */
  81094. onSizeChangedObservable: Observable<PostProcess>;
  81095. private _onSizeChangedObserver;
  81096. /**
  81097. * A function that is added to the onSizeChangedObservable
  81098. */
  81099. onSizeChanged: (postProcess: PostProcess) => void;
  81100. /**
  81101. * An event triggered when the postprocess applies its effect.
  81102. */
  81103. onApplyObservable: Observable<Effect>;
  81104. private _onApplyObserver;
  81105. /**
  81106. * A function that is added to the onApplyObservable
  81107. */
  81108. onApply: (effect: Effect) => void;
  81109. /**
  81110. * An event triggered before rendering the postprocess
  81111. */
  81112. onBeforeRenderObservable: Observable<Effect>;
  81113. private _onBeforeRenderObserver;
  81114. /**
  81115. * A function that is added to the onBeforeRenderObservable
  81116. */
  81117. onBeforeRender: (effect: Effect) => void;
  81118. /**
  81119. * An event triggered after rendering the postprocess
  81120. */
  81121. onAfterRenderObservable: Observable<Effect>;
  81122. private _onAfterRenderObserver;
  81123. /**
  81124. * A function that is added to the onAfterRenderObservable
  81125. */
  81126. onAfterRender: (efect: Effect) => void;
  81127. /**
  81128. * 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
  81129. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  81130. */
  81131. inputTexture: InternalTexture;
  81132. /**
  81133. * Gets the camera which post process is applied to.
  81134. * @returns The camera the post process is applied to.
  81135. */
  81136. getCamera(): Camera;
  81137. /**
  81138. * Gets the texel size of the postprocess.
  81139. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  81140. */
  81141. readonly texelSize: Vector2;
  81142. /**
  81143. * Creates a new instance PostProcess
  81144. * @param name The name of the PostProcess.
  81145. * @param fragmentUrl The url of the fragment shader to be used.
  81146. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  81147. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  81148. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81149. * @param camera The camera to apply the render pass to.
  81150. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81151. * @param engine The engine which the post process will be applied. (default: current engine)
  81152. * @param reusable If the post process can be reused on the same frame. (default: false)
  81153. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  81154. * @param textureType Type of textures used when performing the post process. (default: 0)
  81155. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  81156. * @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
  81157. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  81158. */
  81159. constructor(
  81160. /** Name of the PostProcess. */
  81161. 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);
  81162. /**
  81163. * Gets a string idenfifying the name of the class
  81164. * @returns "PostProcess" string
  81165. */
  81166. getClassName(): string;
  81167. /**
  81168. * Gets the engine which this post process belongs to.
  81169. * @returns The engine the post process was enabled with.
  81170. */
  81171. getEngine(): Engine;
  81172. /**
  81173. * The effect that is created when initializing the post process.
  81174. * @returns The created effect corresponding the the postprocess.
  81175. */
  81176. getEffect(): Effect;
  81177. /**
  81178. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  81179. * @param postProcess The post process to share the output with.
  81180. * @returns This post process.
  81181. */
  81182. shareOutputWith(postProcess: PostProcess): PostProcess;
  81183. /**
  81184. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  81185. * This should be called if the post process that shares output with this post process is disabled/disposed.
  81186. */
  81187. useOwnOutput(): void;
  81188. /**
  81189. * Updates the effect with the current post process compile time values and recompiles the shader.
  81190. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81191. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81192. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81193. * @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
  81194. * @param onCompiled Called when the shader has been compiled.
  81195. * @param onError Called if there is an error when compiling a shader.
  81196. */
  81197. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81198. /**
  81199. * The post process is reusable if it can be used multiple times within one frame.
  81200. * @returns If the post process is reusable
  81201. */
  81202. isReusable(): boolean;
  81203. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  81204. markTextureDirty(): void;
  81205. /**
  81206. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  81207. * 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.
  81208. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  81209. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  81210. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  81211. * @returns The target texture that was bound to be written to.
  81212. */
  81213. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  81214. /**
  81215. * If the post process is supported.
  81216. */
  81217. readonly isSupported: boolean;
  81218. /**
  81219. * The aspect ratio of the output texture.
  81220. */
  81221. readonly aspectRatio: number;
  81222. /**
  81223. * Get a value indicating if the post-process is ready to be used
  81224. * @returns true if the post-process is ready (shader is compiled)
  81225. */
  81226. isReady(): boolean;
  81227. /**
  81228. * Binds all textures and uniforms to the shader, this will be run on every pass.
  81229. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  81230. */
  81231. apply(): Nullable<Effect>;
  81232. private _disposeTextures;
  81233. /**
  81234. * Disposes the post process.
  81235. * @param camera The camera to dispose the post process on.
  81236. */
  81237. dispose(camera?: Camera): void;
  81238. }
  81239. }
  81240. declare module BABYLON {
  81241. /** @hidden */
  81242. export var kernelBlurVaryingDeclaration: {
  81243. name: string;
  81244. shader: string;
  81245. };
  81246. }
  81247. declare module BABYLON {
  81248. /** @hidden */
  81249. export var kernelBlurFragment: {
  81250. name: string;
  81251. shader: string;
  81252. };
  81253. }
  81254. declare module BABYLON {
  81255. /** @hidden */
  81256. export var kernelBlurFragment2: {
  81257. name: string;
  81258. shader: string;
  81259. };
  81260. }
  81261. declare module BABYLON {
  81262. /** @hidden */
  81263. export var kernelBlurPixelShader: {
  81264. name: string;
  81265. shader: string;
  81266. };
  81267. }
  81268. declare module BABYLON {
  81269. /** @hidden */
  81270. export var kernelBlurVertex: {
  81271. name: string;
  81272. shader: string;
  81273. };
  81274. }
  81275. declare module BABYLON {
  81276. /** @hidden */
  81277. export var kernelBlurVertexShader: {
  81278. name: string;
  81279. shader: string;
  81280. };
  81281. }
  81282. declare module BABYLON {
  81283. /**
  81284. * The Blur Post Process which blurs an image based on a kernel and direction.
  81285. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  81286. */
  81287. export class BlurPostProcess extends PostProcess {
  81288. /** The direction in which to blur the image. */
  81289. direction: Vector2;
  81290. private blockCompilation;
  81291. protected _kernel: number;
  81292. protected _idealKernel: number;
  81293. protected _packedFloat: boolean;
  81294. private _staticDefines;
  81295. /**
  81296. * Sets the length in pixels of the blur sample region
  81297. */
  81298. /**
  81299. * Gets the length in pixels of the blur sample region
  81300. */
  81301. kernel: number;
  81302. /**
  81303. * Sets wether or not the blur needs to unpack/repack floats
  81304. */
  81305. /**
  81306. * Gets wether or not the blur is unpacking/repacking floats
  81307. */
  81308. packedFloat: boolean;
  81309. /**
  81310. * Creates a new instance BlurPostProcess
  81311. * @param name The name of the effect.
  81312. * @param direction The direction in which to blur the image.
  81313. * @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.
  81314. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  81315. * @param camera The camera to apply the render pass to.
  81316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  81317. * @param engine The engine which the post process will be applied. (default: current engine)
  81318. * @param reusable If the post process can be reused on the same frame. (default: false)
  81319. * @param textureType Type of textures used when performing the post process. (default: 0)
  81320. * @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)
  81321. */
  81322. constructor(name: string,
  81323. /** The direction in which to blur the image. */
  81324. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  81325. /**
  81326. * Updates the effect with the current post process compile time values and recompiles the shader.
  81327. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  81328. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  81329. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  81330. * @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
  81331. * @param onCompiled Called when the shader has been compiled.
  81332. * @param onError Called if there is an error when compiling a shader.
  81333. */
  81334. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81335. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  81336. /**
  81337. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  81338. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  81339. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  81340. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  81341. * The gaps between physical kernels are compensated for in the weighting of the samples
  81342. * @param idealKernel Ideal blur kernel.
  81343. * @return Nearest best kernel.
  81344. */
  81345. protected _nearestBestKernel(idealKernel: number): number;
  81346. /**
  81347. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  81348. * @param x The point on the Gaussian distribution to sample.
  81349. * @return the value of the Gaussian function at x.
  81350. */
  81351. protected _gaussianWeight(x: number): number;
  81352. /**
  81353. * Generates a string that can be used as a floating point number in GLSL.
  81354. * @param x Value to print.
  81355. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  81356. * @return GLSL float string.
  81357. */
  81358. protected _glslFloat(x: number, decimalFigures?: number): string;
  81359. }
  81360. }
  81361. declare module BABYLON {
  81362. /**
  81363. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81364. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81365. * You can then easily use it as a reflectionTexture on a flat surface.
  81366. * In case the surface is not a plane, please consider relying on reflection probes.
  81367. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81368. */
  81369. export class MirrorTexture extends RenderTargetTexture {
  81370. private scene;
  81371. /**
  81372. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  81373. * 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.
  81374. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81375. */
  81376. mirrorPlane: Plane;
  81377. /**
  81378. * Define the blur ratio used to blur the reflection if needed.
  81379. */
  81380. blurRatio: number;
  81381. /**
  81382. * Define the adaptive blur kernel used to blur the reflection if needed.
  81383. * This will autocompute the closest best match for the `blurKernel`
  81384. */
  81385. adaptiveBlurKernel: number;
  81386. /**
  81387. * Define the blur kernel used to blur the reflection if needed.
  81388. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81389. */
  81390. blurKernel: number;
  81391. /**
  81392. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  81393. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81394. */
  81395. blurKernelX: number;
  81396. /**
  81397. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  81398. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  81399. */
  81400. blurKernelY: number;
  81401. private _autoComputeBlurKernel;
  81402. protected _onRatioRescale(): void;
  81403. private _updateGammaSpace;
  81404. private _imageProcessingConfigChangeObserver;
  81405. private _transformMatrix;
  81406. private _mirrorMatrix;
  81407. private _savedViewMatrix;
  81408. private _blurX;
  81409. private _blurY;
  81410. private _adaptiveBlurKernel;
  81411. private _blurKernelX;
  81412. private _blurKernelY;
  81413. private _blurRatio;
  81414. /**
  81415. * Instantiates a Mirror Texture.
  81416. * Mirror texture can be used to simulate the view from a mirror in a scene.
  81417. * It will dynamically be rendered every frame to adapt to the camera point of view.
  81418. * You can then easily use it as a reflectionTexture on a flat surface.
  81419. * In case the surface is not a plane, please consider relying on reflection probes.
  81420. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  81421. * @param name
  81422. * @param size
  81423. * @param scene
  81424. * @param generateMipMaps
  81425. * @param type
  81426. * @param samplingMode
  81427. * @param generateDepthBuffer
  81428. */
  81429. constructor(name: string, size: number | {
  81430. width: number;
  81431. height: number;
  81432. } | {
  81433. ratio: number;
  81434. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  81435. private _preparePostProcesses;
  81436. /**
  81437. * Clone the mirror texture.
  81438. * @returns the cloned texture
  81439. */
  81440. clone(): MirrorTexture;
  81441. /**
  81442. * Serialize the texture to a JSON representation you could use in Parse later on
  81443. * @returns the serialized JSON representation
  81444. */
  81445. serialize(): any;
  81446. /**
  81447. * Dispose the texture and release its associated resources.
  81448. */
  81449. dispose(): void;
  81450. }
  81451. }
  81452. declare module BABYLON {
  81453. /**
  81454. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81455. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81456. */
  81457. export class Texture extends BaseTexture {
  81458. /**
  81459. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  81460. */
  81461. static SerializeBuffers: boolean;
  81462. /** @hidden */
  81463. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  81464. /** @hidden */
  81465. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  81466. /** @hidden */
  81467. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  81468. /** nearest is mag = nearest and min = nearest and mip = linear */
  81469. static readonly NEAREST_SAMPLINGMODE: number;
  81470. /** nearest is mag = nearest and min = nearest and mip = linear */
  81471. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  81472. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81473. static readonly BILINEAR_SAMPLINGMODE: number;
  81474. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81475. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  81476. /** Trilinear is mag = linear and min = linear and mip = linear */
  81477. static readonly TRILINEAR_SAMPLINGMODE: number;
  81478. /** Trilinear is mag = linear and min = linear and mip = linear */
  81479. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81480. /** mag = nearest and min = nearest and mip = nearest */
  81481. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81482. /** mag = nearest and min = linear and mip = nearest */
  81483. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81484. /** mag = nearest and min = linear and mip = linear */
  81485. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81486. /** mag = nearest and min = linear and mip = none */
  81487. static readonly NEAREST_LINEAR: number;
  81488. /** mag = nearest and min = nearest and mip = none */
  81489. static readonly NEAREST_NEAREST: number;
  81490. /** mag = linear and min = nearest and mip = nearest */
  81491. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81492. /** mag = linear and min = nearest and mip = linear */
  81493. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81494. /** mag = linear and min = linear and mip = none */
  81495. static readonly LINEAR_LINEAR: number;
  81496. /** mag = linear and min = nearest and mip = none */
  81497. static readonly LINEAR_NEAREST: number;
  81498. /** Explicit coordinates mode */
  81499. static readonly EXPLICIT_MODE: number;
  81500. /** Spherical coordinates mode */
  81501. static readonly SPHERICAL_MODE: number;
  81502. /** Planar coordinates mode */
  81503. static readonly PLANAR_MODE: number;
  81504. /** Cubic coordinates mode */
  81505. static readonly CUBIC_MODE: number;
  81506. /** Projection coordinates mode */
  81507. static readonly PROJECTION_MODE: number;
  81508. /** Inverse Cubic coordinates mode */
  81509. static readonly SKYBOX_MODE: number;
  81510. /** Inverse Cubic coordinates mode */
  81511. static readonly INVCUBIC_MODE: number;
  81512. /** Equirectangular coordinates mode */
  81513. static readonly EQUIRECTANGULAR_MODE: number;
  81514. /** Equirectangular Fixed coordinates mode */
  81515. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81516. /** Equirectangular Fixed Mirrored coordinates mode */
  81517. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81518. /** Texture is not repeating outside of 0..1 UVs */
  81519. static readonly CLAMP_ADDRESSMODE: number;
  81520. /** Texture is repeating outside of 0..1 UVs */
  81521. static readonly WRAP_ADDRESSMODE: number;
  81522. /** Texture is repeating and mirrored */
  81523. static readonly MIRROR_ADDRESSMODE: number;
  81524. /**
  81525. * 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
  81526. */
  81527. static UseSerializedUrlIfAny: boolean;
  81528. /**
  81529. * Define the url of the texture.
  81530. */
  81531. url: Nullable<string>;
  81532. /**
  81533. * Define an offset on the texture to offset the u coordinates of the UVs
  81534. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81535. */
  81536. uOffset: number;
  81537. /**
  81538. * Define an offset on the texture to offset the v coordinates of the UVs
  81539. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81540. */
  81541. vOffset: number;
  81542. /**
  81543. * Define an offset on the texture to scale the u coordinates of the UVs
  81544. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81545. */
  81546. uScale: number;
  81547. /**
  81548. * Define an offset on the texture to scale the v coordinates of the UVs
  81549. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81550. */
  81551. vScale: number;
  81552. /**
  81553. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81554. * @see http://doc.babylonjs.com/how_to/more_materials
  81555. */
  81556. uAng: number;
  81557. /**
  81558. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81559. * @see http://doc.babylonjs.com/how_to/more_materials
  81560. */
  81561. vAng: number;
  81562. /**
  81563. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81564. * @see http://doc.babylonjs.com/how_to/more_materials
  81565. */
  81566. wAng: number;
  81567. /**
  81568. * Defines the center of rotation (U)
  81569. */
  81570. uRotationCenter: number;
  81571. /**
  81572. * Defines the center of rotation (V)
  81573. */
  81574. vRotationCenter: number;
  81575. /**
  81576. * Defines the center of rotation (W)
  81577. */
  81578. wRotationCenter: number;
  81579. /**
  81580. * Are mip maps generated for this texture or not.
  81581. */
  81582. readonly noMipmap: boolean;
  81583. /**
  81584. * List of inspectable custom properties (used by the Inspector)
  81585. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81586. */
  81587. inspectableCustomProperties: Nullable<IInspectable[]>;
  81588. private _noMipmap;
  81589. /** @hidden */
  81590. _invertY: boolean;
  81591. private _rowGenerationMatrix;
  81592. private _cachedTextureMatrix;
  81593. private _projectionModeMatrix;
  81594. private _t0;
  81595. private _t1;
  81596. private _t2;
  81597. private _cachedUOffset;
  81598. private _cachedVOffset;
  81599. private _cachedUScale;
  81600. private _cachedVScale;
  81601. private _cachedUAng;
  81602. private _cachedVAng;
  81603. private _cachedWAng;
  81604. private _cachedProjectionMatrixId;
  81605. private _cachedCoordinatesMode;
  81606. /** @hidden */
  81607. protected _initialSamplingMode: number;
  81608. /** @hidden */
  81609. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  81610. private _deleteBuffer;
  81611. protected _format: Nullable<number>;
  81612. private _delayedOnLoad;
  81613. private _delayedOnError;
  81614. /**
  81615. * Observable triggered once the texture has been loaded.
  81616. */
  81617. onLoadObservable: Observable<Texture>;
  81618. protected _isBlocking: boolean;
  81619. /**
  81620. * Is the texture preventing material to render while loading.
  81621. * If false, a default texture will be used instead of the loading one during the preparation step.
  81622. */
  81623. isBlocking: boolean;
  81624. /**
  81625. * Get the current sampling mode associated with the texture.
  81626. */
  81627. readonly samplingMode: number;
  81628. /**
  81629. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81630. */
  81631. readonly invertY: boolean;
  81632. /**
  81633. * Instantiates a new texture.
  81634. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81635. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81636. * @param url define the url of the picture to load as a texture
  81637. * @param scene define the scene or engine the texture will belong to
  81638. * @param noMipmap define if the texture will require mip maps or not
  81639. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81640. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81641. * @param onLoad define a callback triggered when the texture has been loaded
  81642. * @param onError define a callback triggered when an error occurred during the loading session
  81643. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81644. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81645. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81646. */
  81647. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  81648. /**
  81649. * Update the url (and optional buffer) of this texture if url was null during construction.
  81650. * @param url the url of the texture
  81651. * @param buffer the buffer of the texture (defaults to null)
  81652. * @param onLoad callback called when the texture is loaded (defaults to null)
  81653. */
  81654. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81655. /**
  81656. * Finish the loading sequence of a texture flagged as delayed load.
  81657. * @hidden
  81658. */
  81659. delayLoad(): void;
  81660. private _prepareRowForTextureGeneration;
  81661. /**
  81662. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81663. * @returns the transform matrix of the texture.
  81664. */
  81665. getTextureMatrix(): Matrix;
  81666. /**
  81667. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81668. * @returns The reflection texture transform
  81669. */
  81670. getReflectionTextureMatrix(): Matrix;
  81671. /**
  81672. * Clones the texture.
  81673. * @returns the cloned texture
  81674. */
  81675. clone(): Texture;
  81676. /**
  81677. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81678. * @returns The JSON representation of the texture
  81679. */
  81680. serialize(): any;
  81681. /**
  81682. * Get the current class name of the texture useful for serialization or dynamic coding.
  81683. * @returns "Texture"
  81684. */
  81685. getClassName(): string;
  81686. /**
  81687. * Dispose the texture and release its associated resources.
  81688. */
  81689. dispose(): void;
  81690. /**
  81691. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81692. * @param parsedTexture Define the JSON representation of the texture
  81693. * @param scene Define the scene the parsed texture should be instantiated in
  81694. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81695. * @returns The parsed texture if successful
  81696. */
  81697. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81698. /**
  81699. * Creates a texture from its base 64 representation.
  81700. * @param data Define the base64 payload without the data: prefix
  81701. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81702. * @param scene Define the scene the texture should belong to
  81703. * @param noMipmap Forces the texture to not create mip map information if true
  81704. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81705. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81706. * @param onLoad define a callback triggered when the texture has been loaded
  81707. * @param onError define a callback triggered when an error occurred during the loading session
  81708. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81709. * @returns the created texture
  81710. */
  81711. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81712. /**
  81713. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81714. * @param data Define the base64 payload without the data: prefix
  81715. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81716. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81717. * @param scene Define the scene the texture should belong to
  81718. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81719. * @param noMipmap Forces the texture to not create mip map information if true
  81720. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81721. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81722. * @param onLoad define a callback triggered when the texture has been loaded
  81723. * @param onError define a callback triggered when an error occurred during the loading session
  81724. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81725. * @returns the created texture
  81726. */
  81727. 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;
  81728. }
  81729. }
  81730. declare module BABYLON {
  81731. /**
  81732. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81733. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81734. */
  81735. export class PostProcessManager {
  81736. private _scene;
  81737. private _indexBuffer;
  81738. private _vertexBuffers;
  81739. /**
  81740. * Creates a new instance PostProcess
  81741. * @param scene The scene that the post process is associated with.
  81742. */
  81743. constructor(scene: Scene);
  81744. private _prepareBuffers;
  81745. private _buildIndexBuffer;
  81746. /**
  81747. * Rebuilds the vertex buffers of the manager.
  81748. * @hidden
  81749. */
  81750. _rebuild(): void;
  81751. /**
  81752. * Prepares a frame to be run through a post process.
  81753. * @param sourceTexture The input texture to the post procesess. (default: null)
  81754. * @param postProcesses An array of post processes to be run. (default: null)
  81755. * @returns True if the post processes were able to be run.
  81756. * @hidden
  81757. */
  81758. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81759. /**
  81760. * Manually render a set of post processes to a texture.
  81761. * @param postProcesses An array of post processes to be run.
  81762. * @param targetTexture The target texture to render to.
  81763. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81764. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81765. * @param lodLevel defines which lod of the texture to render to
  81766. */
  81767. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81768. /**
  81769. * Finalize the result of the output of the postprocesses.
  81770. * @param doNotPresent If true the result will not be displayed to the screen.
  81771. * @param targetTexture The target texture to render to.
  81772. * @param faceIndex The index of the face to bind the target texture to.
  81773. * @param postProcesses The array of post processes to render.
  81774. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81775. * @hidden
  81776. */
  81777. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81778. /**
  81779. * Disposes of the post process manager.
  81780. */
  81781. dispose(): void;
  81782. }
  81783. }
  81784. declare module BABYLON {
  81785. /** Interface used by value gradients (color, factor, ...) */
  81786. export interface IValueGradient {
  81787. /**
  81788. * Gets or sets the gradient value (between 0 and 1)
  81789. */
  81790. gradient: number;
  81791. }
  81792. /** Class used to store color4 gradient */
  81793. export class ColorGradient implements IValueGradient {
  81794. /**
  81795. * Gets or sets the gradient value (between 0 and 1)
  81796. */
  81797. gradient: number;
  81798. /**
  81799. * Gets or sets first associated color
  81800. */
  81801. color1: Color4;
  81802. /**
  81803. * Gets or sets second associated color
  81804. */
  81805. color2?: Color4;
  81806. /**
  81807. * Will get a color picked randomly between color1 and color2.
  81808. * If color2 is undefined then color1 will be used
  81809. * @param result defines the target Color4 to store the result in
  81810. */
  81811. getColorToRef(result: Color4): void;
  81812. }
  81813. /** Class used to store color 3 gradient */
  81814. export class Color3Gradient implements IValueGradient {
  81815. /**
  81816. * Gets or sets the gradient value (between 0 and 1)
  81817. */
  81818. gradient: number;
  81819. /**
  81820. * Gets or sets the associated color
  81821. */
  81822. color: Color3;
  81823. }
  81824. /** Class used to store factor gradient */
  81825. export class FactorGradient implements IValueGradient {
  81826. /**
  81827. * Gets or sets the gradient value (between 0 and 1)
  81828. */
  81829. gradient: number;
  81830. /**
  81831. * Gets or sets first associated factor
  81832. */
  81833. factor1: number;
  81834. /**
  81835. * Gets or sets second associated factor
  81836. */
  81837. factor2?: number;
  81838. /**
  81839. * Will get a number picked randomly between factor1 and factor2.
  81840. * If factor2 is undefined then factor1 will be used
  81841. * @returns the picked number
  81842. */
  81843. getFactor(): number;
  81844. }
  81845. /**
  81846. * Helper used to simplify some generic gradient tasks
  81847. */
  81848. export class GradientHelper {
  81849. /**
  81850. * Gets the current gradient from an array of IValueGradient
  81851. * @param ratio defines the current ratio to get
  81852. * @param gradients defines the array of IValueGradient
  81853. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  81854. */
  81855. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  81856. }
  81857. }
  81858. declare module BABYLON {
  81859. /**
  81860. * A class extending Texture allowing drawing on a texture
  81861. * @see http://doc.babylonjs.com/how_to/dynamictexture
  81862. */
  81863. export class DynamicTexture extends Texture {
  81864. private _generateMipMaps;
  81865. private _canvas;
  81866. private _context;
  81867. private _engine;
  81868. /**
  81869. * Creates a DynamicTexture
  81870. * @param name defines the name of the texture
  81871. * @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
  81872. * @param scene defines the scene where you want the texture
  81873. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  81874. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  81875. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  81876. */
  81877. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  81878. /**
  81879. * Get the current class name of the texture useful for serialization or dynamic coding.
  81880. * @returns "DynamicTexture"
  81881. */
  81882. getClassName(): string;
  81883. /**
  81884. * Gets the current state of canRescale
  81885. */
  81886. readonly canRescale: boolean;
  81887. private _recreate;
  81888. /**
  81889. * Scales the texture
  81890. * @param ratio the scale factor to apply to both width and height
  81891. */
  81892. scale(ratio: number): void;
  81893. /**
  81894. * Resizes the texture
  81895. * @param width the new width
  81896. * @param height the new height
  81897. */
  81898. scaleTo(width: number, height: number): void;
  81899. /**
  81900. * Gets the context of the canvas used by the texture
  81901. * @returns the canvas context of the dynamic texture
  81902. */
  81903. getContext(): CanvasRenderingContext2D;
  81904. /**
  81905. * Clears the texture
  81906. */
  81907. clear(): void;
  81908. /**
  81909. * Updates the texture
  81910. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  81911. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  81912. */
  81913. update(invertY?: boolean, premulAlpha?: boolean): void;
  81914. /**
  81915. * Draws text onto the texture
  81916. * @param text defines the text to be drawn
  81917. * @param x defines the placement of the text from the left
  81918. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  81919. * @param font defines the font to be used with font-style, font-size, font-name
  81920. * @param color defines the color used for the text
  81921. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  81922. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  81923. * @param update defines whether texture is immediately update (default is true)
  81924. */
  81925. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  81926. /**
  81927. * Clones the texture
  81928. * @returns the clone of the texture.
  81929. */
  81930. clone(): DynamicTexture;
  81931. /**
  81932. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  81933. * @returns a serialized dynamic texture object
  81934. */
  81935. serialize(): any;
  81936. /** @hidden */
  81937. _rebuild(): void;
  81938. }
  81939. }
  81940. declare module BABYLON {
  81941. interface AbstractScene {
  81942. /**
  81943. * The list of procedural textures added to the scene
  81944. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81945. */
  81946. proceduralTextures: Array<ProceduralTexture>;
  81947. }
  81948. /**
  81949. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81950. * in a given scene.
  81951. */
  81952. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81953. /**
  81954. * The component name helpfull to identify the component in the list of scene components.
  81955. */
  81956. readonly name: string;
  81957. /**
  81958. * The scene the component belongs to.
  81959. */
  81960. scene: Scene;
  81961. /**
  81962. * Creates a new instance of the component for the given scene
  81963. * @param scene Defines the scene to register the component in
  81964. */
  81965. constructor(scene: Scene);
  81966. /**
  81967. * Registers the component in a given scene
  81968. */
  81969. register(): void;
  81970. /**
  81971. * Rebuilds the elements related to this component in case of
  81972. * context lost for instance.
  81973. */
  81974. rebuild(): void;
  81975. /**
  81976. * Disposes the component and the associated ressources.
  81977. */
  81978. dispose(): void;
  81979. private _beforeClear;
  81980. }
  81981. }
  81982. declare module BABYLON {
  81983. interface Engine {
  81984. /**
  81985. * Creates a new render target cube texture
  81986. * @param size defines the size of the texture
  81987. * @param options defines the options used to create the texture
  81988. * @returns a new render target cube texture stored in an InternalTexture
  81989. */
  81990. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81991. }
  81992. }
  81993. declare module BABYLON {
  81994. /** @hidden */
  81995. export var proceduralVertexShader: {
  81996. name: string;
  81997. shader: string;
  81998. };
  81999. }
  82000. declare module BABYLON {
  82001. /**
  82002. * 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.
  82003. * This is the base class of any Procedural texture and contains most of the shareable code.
  82004. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82005. */
  82006. export class ProceduralTexture extends Texture {
  82007. isCube: boolean;
  82008. /**
  82009. * Define if the texture is enabled or not (disabled texture will not render)
  82010. */
  82011. isEnabled: boolean;
  82012. /**
  82013. * Define if the texture must be cleared before rendering (default is true)
  82014. */
  82015. autoClear: boolean;
  82016. /**
  82017. * Callback called when the texture is generated
  82018. */
  82019. onGenerated: () => void;
  82020. /**
  82021. * Event raised when the texture is generated
  82022. */
  82023. onGeneratedObservable: Observable<ProceduralTexture>;
  82024. /** @hidden */
  82025. _generateMipMaps: boolean;
  82026. /** @hidden **/
  82027. _effect: Effect;
  82028. /** @hidden */
  82029. _textures: {
  82030. [key: string]: Texture;
  82031. };
  82032. private _size;
  82033. private _currentRefreshId;
  82034. private _refreshRate;
  82035. private _vertexBuffers;
  82036. private _indexBuffer;
  82037. private _uniforms;
  82038. private _samplers;
  82039. private _fragment;
  82040. private _floats;
  82041. private _ints;
  82042. private _floatsArrays;
  82043. private _colors3;
  82044. private _colors4;
  82045. private _vectors2;
  82046. private _vectors3;
  82047. private _matrices;
  82048. private _fallbackTexture;
  82049. private _fallbackTextureUsed;
  82050. private _engine;
  82051. private _cachedDefines;
  82052. private _contentUpdateId;
  82053. private _contentData;
  82054. /**
  82055. * Instantiates a new procedural texture.
  82056. * 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.
  82057. * This is the base class of any Procedural texture and contains most of the shareable code.
  82058. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82059. * @param name Define the name of the texture
  82060. * @param size Define the size of the texture to create
  82061. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  82062. * @param scene Define the scene the texture belongs to
  82063. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  82064. * @param generateMipMaps Define if the texture should creates mip maps or not
  82065. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  82066. */
  82067. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  82068. /**
  82069. * The effect that is created when initializing the post process.
  82070. * @returns The created effect corresponding the the postprocess.
  82071. */
  82072. getEffect(): Effect;
  82073. /**
  82074. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  82075. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  82076. */
  82077. getContent(): Nullable<ArrayBufferView>;
  82078. private _createIndexBuffer;
  82079. /** @hidden */
  82080. _rebuild(): void;
  82081. /**
  82082. * Resets the texture in order to recreate its associated resources.
  82083. * This can be called in case of context loss
  82084. */
  82085. reset(): void;
  82086. protected _getDefines(): string;
  82087. /**
  82088. * Is the texture ready to be used ? (rendered at least once)
  82089. * @returns true if ready, otherwise, false.
  82090. */
  82091. isReady(): boolean;
  82092. /**
  82093. * Resets the refresh counter of the texture and start bak from scratch.
  82094. * Could be useful to regenerate the texture if it is setup to render only once.
  82095. */
  82096. resetRefreshCounter(): void;
  82097. /**
  82098. * Set the fragment shader to use in order to render the texture.
  82099. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  82100. */
  82101. setFragment(fragment: any): void;
  82102. /**
  82103. * Define the refresh rate of the texture or the rendering frequency.
  82104. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  82105. */
  82106. refreshRate: number;
  82107. /** @hidden */
  82108. _shouldRender(): boolean;
  82109. /**
  82110. * Get the size the texture is rendering at.
  82111. * @returns the size (texture is always squared)
  82112. */
  82113. getRenderSize(): number;
  82114. /**
  82115. * Resize the texture to new value.
  82116. * @param size Define the new size the texture should have
  82117. * @param generateMipMaps Define whether the new texture should create mip maps
  82118. */
  82119. resize(size: number, generateMipMaps: boolean): void;
  82120. private _checkUniform;
  82121. /**
  82122. * Set a texture in the shader program used to render.
  82123. * @param name Define the name of the uniform samplers as defined in the shader
  82124. * @param texture Define the texture to bind to this sampler
  82125. * @return the texture itself allowing "fluent" like uniform updates
  82126. */
  82127. setTexture(name: string, texture: Texture): ProceduralTexture;
  82128. /**
  82129. * Set a float in the shader.
  82130. * @param name Define the name of the uniform as defined in the shader
  82131. * @param value Define the value to give to the uniform
  82132. * @return the texture itself allowing "fluent" like uniform updates
  82133. */
  82134. setFloat(name: string, value: number): ProceduralTexture;
  82135. /**
  82136. * Set a int in the shader.
  82137. * @param name Define the name of the uniform as defined in the shader
  82138. * @param value Define the value to give to the uniform
  82139. * @return the texture itself allowing "fluent" like uniform updates
  82140. */
  82141. setInt(name: string, value: number): ProceduralTexture;
  82142. /**
  82143. * Set an array of floats in the shader.
  82144. * @param name Define the name of the uniform as defined in the shader
  82145. * @param value Define the value to give to the uniform
  82146. * @return the texture itself allowing "fluent" like uniform updates
  82147. */
  82148. setFloats(name: string, value: number[]): ProceduralTexture;
  82149. /**
  82150. * Set a vec3 in the shader from a Color3.
  82151. * @param name Define the name of the uniform as defined in the shader
  82152. * @param value Define the value to give to the uniform
  82153. * @return the texture itself allowing "fluent" like uniform updates
  82154. */
  82155. setColor3(name: string, value: Color3): ProceduralTexture;
  82156. /**
  82157. * Set a vec4 in the shader from a Color4.
  82158. * @param name Define the name of the uniform as defined in the shader
  82159. * @param value Define the value to give to the uniform
  82160. * @return the texture itself allowing "fluent" like uniform updates
  82161. */
  82162. setColor4(name: string, value: Color4): ProceduralTexture;
  82163. /**
  82164. * Set a vec2 in the shader from a Vector2.
  82165. * @param name Define the name of the uniform as defined in the shader
  82166. * @param value Define the value to give to the uniform
  82167. * @return the texture itself allowing "fluent" like uniform updates
  82168. */
  82169. setVector2(name: string, value: Vector2): ProceduralTexture;
  82170. /**
  82171. * Set a vec3 in the shader from a Vector3.
  82172. * @param name Define the name of the uniform as defined in the shader
  82173. * @param value Define the value to give to the uniform
  82174. * @return the texture itself allowing "fluent" like uniform updates
  82175. */
  82176. setVector3(name: string, value: Vector3): ProceduralTexture;
  82177. /**
  82178. * Set a mat4 in the shader from a MAtrix.
  82179. * @param name Define the name of the uniform as defined in the shader
  82180. * @param value Define the value to give to the uniform
  82181. * @return the texture itself allowing "fluent" like uniform updates
  82182. */
  82183. setMatrix(name: string, value: Matrix): ProceduralTexture;
  82184. /**
  82185. * Render the texture to its associated render target.
  82186. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  82187. */
  82188. render(useCameraPostProcess?: boolean): void;
  82189. /**
  82190. * Clone the texture.
  82191. * @returns the cloned texture
  82192. */
  82193. clone(): ProceduralTexture;
  82194. /**
  82195. * Dispose the texture and release its asoociated resources.
  82196. */
  82197. dispose(): void;
  82198. }
  82199. }
  82200. declare module BABYLON {
  82201. /**
  82202. * This represents the base class for particle system in Babylon.
  82203. * 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.
  82204. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82205. * @example https://doc.babylonjs.com/babylon101/particles
  82206. */
  82207. export class BaseParticleSystem {
  82208. /**
  82209. * Source color is added to the destination color without alpha affecting the result
  82210. */
  82211. static BLENDMODE_ONEONE: number;
  82212. /**
  82213. * Blend current color and particle color using particle’s alpha
  82214. */
  82215. static BLENDMODE_STANDARD: number;
  82216. /**
  82217. * Add current color and particle color multiplied by particle’s alpha
  82218. */
  82219. static BLENDMODE_ADD: number;
  82220. /**
  82221. * Multiply current color with particle color
  82222. */
  82223. static BLENDMODE_MULTIPLY: number;
  82224. /**
  82225. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  82226. */
  82227. static BLENDMODE_MULTIPLYADD: number;
  82228. /**
  82229. * List of animations used by the particle system.
  82230. */
  82231. animations: Animation[];
  82232. /**
  82233. * The id of the Particle system.
  82234. */
  82235. id: string;
  82236. /**
  82237. * The friendly name of the Particle system.
  82238. */
  82239. name: string;
  82240. /**
  82241. * The rendering group used by the Particle system to chose when to render.
  82242. */
  82243. renderingGroupId: number;
  82244. /**
  82245. * The emitter represents the Mesh or position we are attaching the particle system to.
  82246. */
  82247. emitter: Nullable<AbstractMesh | Vector3>;
  82248. /**
  82249. * The maximum number of particles to emit per frame
  82250. */
  82251. emitRate: number;
  82252. /**
  82253. * If you want to launch only a few particles at once, that can be done, as well.
  82254. */
  82255. manualEmitCount: number;
  82256. /**
  82257. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  82258. */
  82259. updateSpeed: number;
  82260. /**
  82261. * The amount of time the particle system is running (depends of the overall update speed).
  82262. */
  82263. targetStopDuration: number;
  82264. /**
  82265. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  82266. */
  82267. disposeOnStop: boolean;
  82268. /**
  82269. * Minimum power of emitting particles.
  82270. */
  82271. minEmitPower: number;
  82272. /**
  82273. * Maximum power of emitting particles.
  82274. */
  82275. maxEmitPower: number;
  82276. /**
  82277. * Minimum life time of emitting particles.
  82278. */
  82279. minLifeTime: number;
  82280. /**
  82281. * Maximum life time of emitting particles.
  82282. */
  82283. maxLifeTime: number;
  82284. /**
  82285. * Minimum Size of emitting particles.
  82286. */
  82287. minSize: number;
  82288. /**
  82289. * Maximum Size of emitting particles.
  82290. */
  82291. maxSize: number;
  82292. /**
  82293. * Minimum scale of emitting particles on X axis.
  82294. */
  82295. minScaleX: number;
  82296. /**
  82297. * Maximum scale of emitting particles on X axis.
  82298. */
  82299. maxScaleX: number;
  82300. /**
  82301. * Minimum scale of emitting particles on Y axis.
  82302. */
  82303. minScaleY: number;
  82304. /**
  82305. * Maximum scale of emitting particles on Y axis.
  82306. */
  82307. maxScaleY: number;
  82308. /**
  82309. * Gets or sets the minimal initial rotation in radians.
  82310. */
  82311. minInitialRotation: number;
  82312. /**
  82313. * Gets or sets the maximal initial rotation in radians.
  82314. */
  82315. maxInitialRotation: number;
  82316. /**
  82317. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  82318. */
  82319. minAngularSpeed: number;
  82320. /**
  82321. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  82322. */
  82323. maxAngularSpeed: number;
  82324. /**
  82325. * The texture used to render each particle. (this can be a spritesheet)
  82326. */
  82327. particleTexture: Nullable<Texture>;
  82328. /**
  82329. * The layer mask we are rendering the particles through.
  82330. */
  82331. layerMask: number;
  82332. /**
  82333. * This can help using your own shader to render the particle system.
  82334. * The according effect will be created
  82335. */
  82336. customShader: any;
  82337. /**
  82338. * By default particle system starts as soon as they are created. This prevents the
  82339. * automatic start to happen and let you decide when to start emitting particles.
  82340. */
  82341. preventAutoStart: boolean;
  82342. private _noiseTexture;
  82343. /**
  82344. * Gets or sets a texture used to add random noise to particle positions
  82345. */
  82346. noiseTexture: Nullable<ProceduralTexture>;
  82347. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  82348. noiseStrength: Vector3;
  82349. /**
  82350. * Callback triggered when the particle animation is ending.
  82351. */
  82352. onAnimationEnd: Nullable<() => void>;
  82353. /**
  82354. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  82355. */
  82356. blendMode: number;
  82357. /**
  82358. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  82359. * to override the particles.
  82360. */
  82361. forceDepthWrite: boolean;
  82362. /** 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 */
  82363. preWarmCycles: number;
  82364. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  82365. preWarmStepOffset: number;
  82366. /**
  82367. * 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)
  82368. */
  82369. spriteCellChangeSpeed: number;
  82370. /**
  82371. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  82372. */
  82373. startSpriteCellID: number;
  82374. /**
  82375. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  82376. */
  82377. endSpriteCellID: number;
  82378. /**
  82379. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  82380. */
  82381. spriteCellWidth: number;
  82382. /**
  82383. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  82384. */
  82385. spriteCellHeight: number;
  82386. /**
  82387. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  82388. */
  82389. spriteRandomStartCell: boolean;
  82390. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  82391. translationPivot: Vector2;
  82392. /** @hidden */
  82393. protected _isAnimationSheetEnabled: boolean;
  82394. /**
  82395. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  82396. */
  82397. beginAnimationOnStart: boolean;
  82398. /**
  82399. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  82400. */
  82401. beginAnimationFrom: number;
  82402. /**
  82403. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  82404. */
  82405. beginAnimationTo: number;
  82406. /**
  82407. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  82408. */
  82409. beginAnimationLoop: boolean;
  82410. /**
  82411. * Gets or sets a world offset applied to all particles
  82412. */
  82413. worldOffset: Vector3;
  82414. /**
  82415. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  82416. */
  82417. isAnimationSheetEnabled: boolean;
  82418. /**
  82419. * Get hosting scene
  82420. * @returns the scene
  82421. */
  82422. getScene(): Scene;
  82423. /**
  82424. * You can use gravity if you want to give an orientation to your particles.
  82425. */
  82426. gravity: Vector3;
  82427. protected _colorGradients: Nullable<Array<ColorGradient>>;
  82428. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  82429. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  82430. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  82431. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  82432. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  82433. protected _dragGradients: Nullable<Array<FactorGradient>>;
  82434. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  82435. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  82436. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  82437. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  82438. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  82439. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  82440. /**
  82441. * Defines the delay in milliseconds before starting the system (0 by default)
  82442. */
  82443. startDelay: number;
  82444. /**
  82445. * Gets the current list of drag gradients.
  82446. * You must use addDragGradient and removeDragGradient to udpate this list
  82447. * @returns the list of drag gradients
  82448. */
  82449. getDragGradients(): Nullable<Array<FactorGradient>>;
  82450. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  82451. limitVelocityDamping: number;
  82452. /**
  82453. * Gets the current list of limit velocity gradients.
  82454. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82455. * @returns the list of limit velocity gradients
  82456. */
  82457. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82458. /**
  82459. * Gets the current list of color gradients.
  82460. * You must use addColorGradient and removeColorGradient to udpate this list
  82461. * @returns the list of color gradients
  82462. */
  82463. getColorGradients(): Nullable<Array<ColorGradient>>;
  82464. /**
  82465. * Gets the current list of size gradients.
  82466. * You must use addSizeGradient and removeSizeGradient to udpate this list
  82467. * @returns the list of size gradients
  82468. */
  82469. getSizeGradients(): Nullable<Array<FactorGradient>>;
  82470. /**
  82471. * Gets the current list of color remap gradients.
  82472. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82473. * @returns the list of color remap gradients
  82474. */
  82475. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82476. /**
  82477. * Gets the current list of alpha remap gradients.
  82478. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82479. * @returns the list of alpha remap gradients
  82480. */
  82481. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82482. /**
  82483. * Gets the current list of life time gradients.
  82484. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82485. * @returns the list of life time gradients
  82486. */
  82487. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82488. /**
  82489. * Gets the current list of angular speed gradients.
  82490. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  82491. * @returns the list of angular speed gradients
  82492. */
  82493. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  82494. /**
  82495. * Gets the current list of velocity gradients.
  82496. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82497. * @returns the list of velocity gradients
  82498. */
  82499. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82500. /**
  82501. * Gets the current list of start size gradients.
  82502. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82503. * @returns the list of start size gradients
  82504. */
  82505. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82506. /**
  82507. * Gets the current list of emit rate gradients.
  82508. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82509. * @returns the list of emit rate gradients
  82510. */
  82511. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82512. /**
  82513. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82514. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82515. */
  82516. direction1: Vector3;
  82517. /**
  82518. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82519. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82520. */
  82521. direction2: Vector3;
  82522. /**
  82523. * 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.
  82524. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82525. */
  82526. minEmitBox: Vector3;
  82527. /**
  82528. * 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.
  82529. * This only works when particleEmitterTyps is a BoxParticleEmitter
  82530. */
  82531. maxEmitBox: Vector3;
  82532. /**
  82533. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82534. */
  82535. color1: Color4;
  82536. /**
  82537. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  82538. */
  82539. color2: Color4;
  82540. /**
  82541. * Color the particle will have at the end of its lifetime
  82542. */
  82543. colorDead: Color4;
  82544. /**
  82545. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  82546. */
  82547. textureMask: Color4;
  82548. /**
  82549. * The particle emitter type defines the emitter used by the particle system.
  82550. * It can be for example box, sphere, or cone...
  82551. */
  82552. particleEmitterType: IParticleEmitterType;
  82553. /** @hidden */
  82554. _isSubEmitter: boolean;
  82555. /**
  82556. * Gets or sets the billboard mode to use when isBillboardBased = true.
  82557. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  82558. */
  82559. billboardMode: number;
  82560. protected _isBillboardBased: boolean;
  82561. /**
  82562. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  82563. */
  82564. isBillboardBased: boolean;
  82565. /**
  82566. * The scene the particle system belongs to.
  82567. */
  82568. protected _scene: Scene;
  82569. /**
  82570. * Local cache of defines for image processing.
  82571. */
  82572. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  82573. /**
  82574. * Default configuration related to image processing available in the standard Material.
  82575. */
  82576. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  82577. /**
  82578. * Gets the image processing configuration used either in this material.
  82579. */
  82580. /**
  82581. * Sets the Default image processing configuration used either in the this material.
  82582. *
  82583. * If sets to null, the scene one is in use.
  82584. */
  82585. imageProcessingConfiguration: ImageProcessingConfiguration;
  82586. /**
  82587. * Attaches a new image processing configuration to the Standard Material.
  82588. * @param configuration
  82589. */
  82590. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  82591. /** @hidden */
  82592. protected _reset(): void;
  82593. /** @hidden */
  82594. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  82595. /**
  82596. * Instantiates a particle system.
  82597. * 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.
  82598. * @param name The name of the particle system
  82599. */
  82600. constructor(name: string);
  82601. /**
  82602. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82603. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82604. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82605. * @returns the emitter
  82606. */
  82607. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82608. /**
  82609. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82610. * @param radius The radius of the hemisphere to emit from
  82611. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82612. * @returns the emitter
  82613. */
  82614. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  82615. /**
  82616. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82617. * @param radius The radius of the sphere to emit from
  82618. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82619. * @returns the emitter
  82620. */
  82621. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  82622. /**
  82623. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82624. * @param radius The radius of the sphere to emit from
  82625. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82626. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82627. * @returns the emitter
  82628. */
  82629. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  82630. /**
  82631. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82632. * @param radius The radius of the emission cylinder
  82633. * @param height The height of the emission cylinder
  82634. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82635. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82636. * @returns the emitter
  82637. */
  82638. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82639. /**
  82640. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82641. * @param radius The radius of the cylinder to emit from
  82642. * @param height The height of the emission cylinder
  82643. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82644. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82645. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82646. * @returns the emitter
  82647. */
  82648. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82649. /**
  82650. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82651. * @param radius The radius of the cone to emit from
  82652. * @param angle The base angle of the cone
  82653. * @returns the emitter
  82654. */
  82655. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82656. /**
  82657. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82658. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82659. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82660. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82661. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82662. * @returns the emitter
  82663. */
  82664. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82665. }
  82666. }
  82667. declare module BABYLON {
  82668. /**
  82669. * Type of sub emitter
  82670. */
  82671. export enum SubEmitterType {
  82672. /**
  82673. * Attached to the particle over it's lifetime
  82674. */
  82675. ATTACHED = 0,
  82676. /**
  82677. * Created when the particle dies
  82678. */
  82679. END = 1
  82680. }
  82681. /**
  82682. * Sub emitter class used to emit particles from an existing particle
  82683. */
  82684. export class SubEmitter {
  82685. /**
  82686. * the particle system to be used by the sub emitter
  82687. */
  82688. particleSystem: ParticleSystem;
  82689. /**
  82690. * Type of the submitter (Default: END)
  82691. */
  82692. type: SubEmitterType;
  82693. /**
  82694. * 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)
  82695. * Note: This only is supported when using an emitter of type Mesh
  82696. */
  82697. inheritDirection: boolean;
  82698. /**
  82699. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82700. */
  82701. inheritedVelocityAmount: number;
  82702. /**
  82703. * Creates a sub emitter
  82704. * @param particleSystem the particle system to be used by the sub emitter
  82705. */
  82706. constructor(
  82707. /**
  82708. * the particle system to be used by the sub emitter
  82709. */
  82710. particleSystem: ParticleSystem);
  82711. /**
  82712. * Clones the sub emitter
  82713. * @returns the cloned sub emitter
  82714. */
  82715. clone(): SubEmitter;
  82716. /**
  82717. * Serialize current object to a JSON object
  82718. * @returns the serialized object
  82719. */
  82720. serialize(): any;
  82721. /** @hidden */
  82722. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82723. /**
  82724. * Creates a new SubEmitter from a serialized JSON version
  82725. * @param serializationObject defines the JSON object to read from
  82726. * @param scene defines the hosting scene
  82727. * @param rootUrl defines the rootUrl for data loading
  82728. * @returns a new SubEmitter
  82729. */
  82730. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82731. /** Release associated resources */
  82732. dispose(): void;
  82733. }
  82734. }
  82735. declare module BABYLON {
  82736. /** @hidden */
  82737. export var clipPlaneFragmentDeclaration: {
  82738. name: string;
  82739. shader: string;
  82740. };
  82741. }
  82742. declare module BABYLON {
  82743. /** @hidden */
  82744. export var imageProcessingDeclaration: {
  82745. name: string;
  82746. shader: string;
  82747. };
  82748. }
  82749. declare module BABYLON {
  82750. /** @hidden */
  82751. export var imageProcessingFunctions: {
  82752. name: string;
  82753. shader: string;
  82754. };
  82755. }
  82756. declare module BABYLON {
  82757. /** @hidden */
  82758. export var clipPlaneFragment: {
  82759. name: string;
  82760. shader: string;
  82761. };
  82762. }
  82763. declare module BABYLON {
  82764. /** @hidden */
  82765. export var particlesPixelShader: {
  82766. name: string;
  82767. shader: string;
  82768. };
  82769. }
  82770. declare module BABYLON {
  82771. /** @hidden */
  82772. export var clipPlaneVertexDeclaration: {
  82773. name: string;
  82774. shader: string;
  82775. };
  82776. }
  82777. declare module BABYLON {
  82778. /** @hidden */
  82779. export var clipPlaneVertex: {
  82780. name: string;
  82781. shader: string;
  82782. };
  82783. }
  82784. declare module BABYLON {
  82785. /** @hidden */
  82786. export var particlesVertexShader: {
  82787. name: string;
  82788. shader: string;
  82789. };
  82790. }
  82791. declare module BABYLON {
  82792. /**
  82793. * This represents a particle system in Babylon.
  82794. * 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.
  82795. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82796. * @example https://doc.babylonjs.com/babylon101/particles
  82797. */
  82798. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82799. /**
  82800. * Billboard mode will only apply to Y axis
  82801. */
  82802. static readonly BILLBOARDMODE_Y: number;
  82803. /**
  82804. * Billboard mode will apply to all axes
  82805. */
  82806. static readonly BILLBOARDMODE_ALL: number;
  82807. /**
  82808. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82809. */
  82810. static readonly BILLBOARDMODE_STRETCHED: number;
  82811. /**
  82812. * This function can be defined to provide custom update for active particles.
  82813. * This function will be called instead of regular update (age, position, color, etc.).
  82814. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82815. */
  82816. updateFunction: (particles: Particle[]) => void;
  82817. private _emitterWorldMatrix;
  82818. /**
  82819. * This function can be defined to specify initial direction for every new particle.
  82820. * It by default use the emitterType defined function
  82821. */
  82822. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82823. /**
  82824. * This function can be defined to specify initial position for every new particle.
  82825. * It by default use the emitterType defined function
  82826. */
  82827. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82828. /**
  82829. * @hidden
  82830. */
  82831. _inheritedVelocityOffset: Vector3;
  82832. /**
  82833. * An event triggered when the system is disposed
  82834. */
  82835. onDisposeObservable: Observable<ParticleSystem>;
  82836. private _onDisposeObserver;
  82837. /**
  82838. * Sets a callback that will be triggered when the system is disposed
  82839. */
  82840. onDispose: () => void;
  82841. private _particles;
  82842. private _epsilon;
  82843. private _capacity;
  82844. private _stockParticles;
  82845. private _newPartsExcess;
  82846. private _vertexData;
  82847. private _vertexBuffer;
  82848. private _vertexBuffers;
  82849. private _spriteBuffer;
  82850. private _indexBuffer;
  82851. private _effect;
  82852. private _customEffect;
  82853. private _cachedDefines;
  82854. private _scaledColorStep;
  82855. private _colorDiff;
  82856. private _scaledDirection;
  82857. private _scaledGravity;
  82858. private _currentRenderId;
  82859. private _alive;
  82860. private _useInstancing;
  82861. private _started;
  82862. private _stopped;
  82863. private _actualFrame;
  82864. private _scaledUpdateSpeed;
  82865. private _vertexBufferSize;
  82866. /** @hidden */
  82867. _currentEmitRateGradient: Nullable<FactorGradient>;
  82868. /** @hidden */
  82869. _currentEmitRate1: number;
  82870. /** @hidden */
  82871. _currentEmitRate2: number;
  82872. /** @hidden */
  82873. _currentStartSizeGradient: Nullable<FactorGradient>;
  82874. /** @hidden */
  82875. _currentStartSize1: number;
  82876. /** @hidden */
  82877. _currentStartSize2: number;
  82878. private readonly _rawTextureWidth;
  82879. private _rampGradientsTexture;
  82880. private _useRampGradients;
  82881. /** Gets or sets a boolean indicating that ramp gradients must be used
  82882. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82883. */
  82884. useRampGradients: boolean;
  82885. /**
  82886. * 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.
  82887. * 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: [])
  82888. */
  82889. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82890. private _subEmitters;
  82891. /**
  82892. * @hidden
  82893. * If the particle systems emitter should be disposed when the particle system is disposed
  82894. */
  82895. _disposeEmitterOnDispose: boolean;
  82896. /**
  82897. * The current active Sub-systems, this property is used by the root particle system only.
  82898. */
  82899. activeSubSystems: Array<ParticleSystem>;
  82900. private _rootParticleSystem;
  82901. /**
  82902. * Gets the current list of active particles
  82903. */
  82904. readonly particles: Particle[];
  82905. /**
  82906. * Returns the string "ParticleSystem"
  82907. * @returns a string containing the class name
  82908. */
  82909. getClassName(): string;
  82910. /**
  82911. * Instantiates a particle system.
  82912. * 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.
  82913. * @param name The name of the particle system
  82914. * @param capacity The max number of particles alive at the same time
  82915. * @param scene The scene the particle system belongs to
  82916. * @param customEffect a custom effect used to change the way particles are rendered by default
  82917. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82918. * @param epsilon Offset used to render the particles
  82919. */
  82920. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82921. private _addFactorGradient;
  82922. private _removeFactorGradient;
  82923. /**
  82924. * Adds a new life time gradient
  82925. * @param gradient defines the gradient to use (between 0 and 1)
  82926. * @param factor defines the life time factor to affect to the specified gradient
  82927. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82928. * @returns the current particle system
  82929. */
  82930. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82931. /**
  82932. * Remove a specific life time gradient
  82933. * @param gradient defines the gradient to remove
  82934. * @returns the current particle system
  82935. */
  82936. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82937. /**
  82938. * Adds a new size gradient
  82939. * @param gradient defines the gradient to use (between 0 and 1)
  82940. * @param factor defines the size factor to affect to the specified gradient
  82941. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82942. * @returns the current particle system
  82943. */
  82944. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82945. /**
  82946. * Remove a specific size gradient
  82947. * @param gradient defines the gradient to remove
  82948. * @returns the current particle system
  82949. */
  82950. removeSizeGradient(gradient: number): IParticleSystem;
  82951. /**
  82952. * Adds a new color remap gradient
  82953. * @param gradient defines the gradient to use (between 0 and 1)
  82954. * @param min defines the color remap minimal range
  82955. * @param max defines the color remap maximal range
  82956. * @returns the current particle system
  82957. */
  82958. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82959. /**
  82960. * Remove a specific color remap gradient
  82961. * @param gradient defines the gradient to remove
  82962. * @returns the current particle system
  82963. */
  82964. removeColorRemapGradient(gradient: number): IParticleSystem;
  82965. /**
  82966. * Adds a new alpha remap gradient
  82967. * @param gradient defines the gradient to use (between 0 and 1)
  82968. * @param min defines the alpha remap minimal range
  82969. * @param max defines the alpha remap maximal range
  82970. * @returns the current particle system
  82971. */
  82972. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82973. /**
  82974. * Remove a specific alpha remap gradient
  82975. * @param gradient defines the gradient to remove
  82976. * @returns the current particle system
  82977. */
  82978. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82979. /**
  82980. * Adds a new angular speed gradient
  82981. * @param gradient defines the gradient to use (between 0 and 1)
  82982. * @param factor defines the angular speed to affect to the specified gradient
  82983. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82984. * @returns the current particle system
  82985. */
  82986. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82987. /**
  82988. * Remove a specific angular speed gradient
  82989. * @param gradient defines the gradient to remove
  82990. * @returns the current particle system
  82991. */
  82992. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82993. /**
  82994. * Adds a new velocity gradient
  82995. * @param gradient defines the gradient to use (between 0 and 1)
  82996. * @param factor defines the velocity to affect to the specified gradient
  82997. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82998. * @returns the current particle system
  82999. */
  83000. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83001. /**
  83002. * Remove a specific velocity gradient
  83003. * @param gradient defines the gradient to remove
  83004. * @returns the current particle system
  83005. */
  83006. removeVelocityGradient(gradient: number): IParticleSystem;
  83007. /**
  83008. * Adds a new limit velocity gradient
  83009. * @param gradient defines the gradient to use (between 0 and 1)
  83010. * @param factor defines the limit velocity value to affect to the specified gradient
  83011. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83012. * @returns the current particle system
  83013. */
  83014. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83015. /**
  83016. * Remove a specific limit velocity gradient
  83017. * @param gradient defines the gradient to remove
  83018. * @returns the current particle system
  83019. */
  83020. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83021. /**
  83022. * Adds a new drag gradient
  83023. * @param gradient defines the gradient to use (between 0 and 1)
  83024. * @param factor defines the drag value to affect to the specified gradient
  83025. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83026. * @returns the current particle system
  83027. */
  83028. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83029. /**
  83030. * Remove a specific drag gradient
  83031. * @param gradient defines the gradient to remove
  83032. * @returns the current particle system
  83033. */
  83034. removeDragGradient(gradient: number): IParticleSystem;
  83035. /**
  83036. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83037. * @param gradient defines the gradient to use (between 0 and 1)
  83038. * @param factor defines the emit rate value to affect to the specified gradient
  83039. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83040. * @returns the current particle system
  83041. */
  83042. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83043. /**
  83044. * Remove a specific emit rate gradient
  83045. * @param gradient defines the gradient to remove
  83046. * @returns the current particle system
  83047. */
  83048. removeEmitRateGradient(gradient: number): IParticleSystem;
  83049. /**
  83050. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  83051. * @param gradient defines the gradient to use (between 0 and 1)
  83052. * @param factor defines the start size value to affect to the specified gradient
  83053. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83054. * @returns the current particle system
  83055. */
  83056. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83057. /**
  83058. * Remove a specific start size gradient
  83059. * @param gradient defines the gradient to remove
  83060. * @returns the current particle system
  83061. */
  83062. removeStartSizeGradient(gradient: number): IParticleSystem;
  83063. private _createRampGradientTexture;
  83064. /**
  83065. * Gets the current list of ramp gradients.
  83066. * You must use addRampGradient and removeRampGradient to udpate this list
  83067. * @returns the list of ramp gradients
  83068. */
  83069. getRampGradients(): Nullable<Array<Color3Gradient>>;
  83070. /**
  83071. * Adds a new ramp gradient used to remap particle colors
  83072. * @param gradient defines the gradient to use (between 0 and 1)
  83073. * @param color defines the color to affect to the specified gradient
  83074. * @returns the current particle system
  83075. */
  83076. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  83077. /**
  83078. * Remove a specific ramp gradient
  83079. * @param gradient defines the gradient to remove
  83080. * @returns the current particle system
  83081. */
  83082. removeRampGradient(gradient: number): ParticleSystem;
  83083. /**
  83084. * Adds a new color gradient
  83085. * @param gradient defines the gradient to use (between 0 and 1)
  83086. * @param color1 defines the color to affect to the specified gradient
  83087. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83088. * @returns this particle system
  83089. */
  83090. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83091. /**
  83092. * Remove a specific color gradient
  83093. * @param gradient defines the gradient to remove
  83094. * @returns this particle system
  83095. */
  83096. removeColorGradient(gradient: number): IParticleSystem;
  83097. private _fetchR;
  83098. protected _reset(): void;
  83099. private _resetEffect;
  83100. private _createVertexBuffers;
  83101. private _createIndexBuffer;
  83102. /**
  83103. * Gets the maximum number of particles active at the same time.
  83104. * @returns The max number of active particles.
  83105. */
  83106. getCapacity(): number;
  83107. /**
  83108. * Gets whether there are still active particles in the system.
  83109. * @returns True if it is alive, otherwise false.
  83110. */
  83111. isAlive(): boolean;
  83112. /**
  83113. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83114. * @returns True if it has been started, otherwise false.
  83115. */
  83116. isStarted(): boolean;
  83117. private _prepareSubEmitterInternalArray;
  83118. /**
  83119. * Starts the particle system and begins to emit
  83120. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  83121. */
  83122. start(delay?: number): void;
  83123. /**
  83124. * Stops the particle system.
  83125. * @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.
  83126. */
  83127. stop(stopSubEmitters?: boolean): void;
  83128. /**
  83129. * Remove all active particles
  83130. */
  83131. reset(): void;
  83132. /**
  83133. * @hidden (for internal use only)
  83134. */
  83135. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  83136. /**
  83137. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  83138. * Its lifetime will start back at 0.
  83139. */
  83140. recycleParticle: (particle: Particle) => void;
  83141. private _stopSubEmitters;
  83142. private _createParticle;
  83143. private _removeFromRoot;
  83144. private _emitFromParticle;
  83145. private _update;
  83146. /** @hidden */
  83147. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  83148. /** @hidden */
  83149. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  83150. /** @hidden */
  83151. private _getEffect;
  83152. /**
  83153. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  83154. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  83155. */
  83156. animate(preWarmOnly?: boolean): void;
  83157. private _appendParticleVertices;
  83158. /**
  83159. * Rebuilds the particle system.
  83160. */
  83161. rebuild(): void;
  83162. /**
  83163. * Is this system ready to be used/rendered
  83164. * @return true if the system is ready
  83165. */
  83166. isReady(): boolean;
  83167. private _render;
  83168. /**
  83169. * Renders the particle system in its current state.
  83170. * @returns the current number of particles
  83171. */
  83172. render(): number;
  83173. /**
  83174. * Disposes the particle system and free the associated resources
  83175. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83176. */
  83177. dispose(disposeTexture?: boolean): void;
  83178. /**
  83179. * Clones the particle system.
  83180. * @param name The name of the cloned object
  83181. * @param newEmitter The new emitter to use
  83182. * @returns the cloned particle system
  83183. */
  83184. clone(name: string, newEmitter: any): ParticleSystem;
  83185. /**
  83186. * Serializes the particle system to a JSON object.
  83187. * @returns the JSON object
  83188. */
  83189. serialize(): any;
  83190. /** @hidden */
  83191. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  83192. /** @hidden */
  83193. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  83194. /**
  83195. * Parses a JSON object to create a particle system.
  83196. * @param parsedParticleSystem The JSON object to parse
  83197. * @param scene The scene to create the particle system in
  83198. * @param rootUrl The root url to use to load external dependencies like texture
  83199. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  83200. * @returns the Parsed particle system
  83201. */
  83202. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  83203. }
  83204. }
  83205. declare module BABYLON {
  83206. /**
  83207. * A particle represents one of the element emitted by a particle system.
  83208. * This is mainly define by its coordinates, direction, velocity and age.
  83209. */
  83210. export class Particle {
  83211. /**
  83212. * The particle system the particle belongs to.
  83213. */
  83214. particleSystem: ParticleSystem;
  83215. private static _Count;
  83216. /**
  83217. * Unique ID of the particle
  83218. */
  83219. id: number;
  83220. /**
  83221. * The world position of the particle in the scene.
  83222. */
  83223. position: Vector3;
  83224. /**
  83225. * The world direction of the particle in the scene.
  83226. */
  83227. direction: Vector3;
  83228. /**
  83229. * The color of the particle.
  83230. */
  83231. color: Color4;
  83232. /**
  83233. * The color change of the particle per step.
  83234. */
  83235. colorStep: Color4;
  83236. /**
  83237. * Defines how long will the life of the particle be.
  83238. */
  83239. lifeTime: number;
  83240. /**
  83241. * The current age of the particle.
  83242. */
  83243. age: number;
  83244. /**
  83245. * The current size of the particle.
  83246. */
  83247. size: number;
  83248. /**
  83249. * The current scale of the particle.
  83250. */
  83251. scale: Vector2;
  83252. /**
  83253. * The current angle of the particle.
  83254. */
  83255. angle: number;
  83256. /**
  83257. * Defines how fast is the angle changing.
  83258. */
  83259. angularSpeed: number;
  83260. /**
  83261. * Defines the cell index used by the particle to be rendered from a sprite.
  83262. */
  83263. cellIndex: number;
  83264. /**
  83265. * The information required to support color remapping
  83266. */
  83267. remapData: Vector4;
  83268. /** @hidden */
  83269. _randomCellOffset?: number;
  83270. /** @hidden */
  83271. _initialDirection: Nullable<Vector3>;
  83272. /** @hidden */
  83273. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  83274. /** @hidden */
  83275. _initialStartSpriteCellID: number;
  83276. /** @hidden */
  83277. _initialEndSpriteCellID: number;
  83278. /** @hidden */
  83279. _currentColorGradient: Nullable<ColorGradient>;
  83280. /** @hidden */
  83281. _currentColor1: Color4;
  83282. /** @hidden */
  83283. _currentColor2: Color4;
  83284. /** @hidden */
  83285. _currentSizeGradient: Nullable<FactorGradient>;
  83286. /** @hidden */
  83287. _currentSize1: number;
  83288. /** @hidden */
  83289. _currentSize2: number;
  83290. /** @hidden */
  83291. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  83292. /** @hidden */
  83293. _currentAngularSpeed1: number;
  83294. /** @hidden */
  83295. _currentAngularSpeed2: number;
  83296. /** @hidden */
  83297. _currentVelocityGradient: Nullable<FactorGradient>;
  83298. /** @hidden */
  83299. _currentVelocity1: number;
  83300. /** @hidden */
  83301. _currentVelocity2: number;
  83302. /** @hidden */
  83303. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  83304. /** @hidden */
  83305. _currentLimitVelocity1: number;
  83306. /** @hidden */
  83307. _currentLimitVelocity2: number;
  83308. /** @hidden */
  83309. _currentDragGradient: Nullable<FactorGradient>;
  83310. /** @hidden */
  83311. _currentDrag1: number;
  83312. /** @hidden */
  83313. _currentDrag2: number;
  83314. /** @hidden */
  83315. _randomNoiseCoordinates1: Vector3;
  83316. /** @hidden */
  83317. _randomNoiseCoordinates2: Vector3;
  83318. /**
  83319. * Creates a new instance Particle
  83320. * @param particleSystem the particle system the particle belongs to
  83321. */
  83322. constructor(
  83323. /**
  83324. * The particle system the particle belongs to.
  83325. */
  83326. particleSystem: ParticleSystem);
  83327. private updateCellInfoFromSystem;
  83328. /**
  83329. * Defines how the sprite cell index is updated for the particle
  83330. */
  83331. updateCellIndex(): void;
  83332. /** @hidden */
  83333. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  83334. /** @hidden */
  83335. _inheritParticleInfoToSubEmitters(): void;
  83336. /** @hidden */
  83337. _reset(): void;
  83338. /**
  83339. * Copy the properties of particle to another one.
  83340. * @param other the particle to copy the information to.
  83341. */
  83342. copyTo(other: Particle): void;
  83343. }
  83344. }
  83345. declare module BABYLON {
  83346. /**
  83347. * Particle emitter represents a volume emitting particles.
  83348. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  83349. */
  83350. export interface IParticleEmitterType {
  83351. /**
  83352. * Called by the particle System when the direction is computed for the created particle.
  83353. * @param worldMatrix is the world matrix of the particle system
  83354. * @param directionToUpdate is the direction vector to update with the result
  83355. * @param particle is the particle we are computed the direction for
  83356. */
  83357. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83358. /**
  83359. * Called by the particle System when the position is computed for the created particle.
  83360. * @param worldMatrix is the world matrix of the particle system
  83361. * @param positionToUpdate is the position vector to update with the result
  83362. * @param particle is the particle we are computed the position for
  83363. */
  83364. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83365. /**
  83366. * Clones the current emitter and returns a copy of it
  83367. * @returns the new emitter
  83368. */
  83369. clone(): IParticleEmitterType;
  83370. /**
  83371. * Called by the GPUParticleSystem to setup the update shader
  83372. * @param effect defines the update shader
  83373. */
  83374. applyToShader(effect: Effect): void;
  83375. /**
  83376. * Returns a string to use to update the GPU particles update shader
  83377. * @returns the effect defines string
  83378. */
  83379. getEffectDefines(): string;
  83380. /**
  83381. * Returns a string representing the class name
  83382. * @returns a string containing the class name
  83383. */
  83384. getClassName(): string;
  83385. /**
  83386. * Serializes the particle system to a JSON object.
  83387. * @returns the JSON object
  83388. */
  83389. serialize(): any;
  83390. /**
  83391. * Parse properties from a JSON object
  83392. * @param serializationObject defines the JSON object
  83393. */
  83394. parse(serializationObject: any): void;
  83395. }
  83396. }
  83397. declare module BABYLON {
  83398. /**
  83399. * Particle emitter emitting particles from the inside of a box.
  83400. * It emits the particles randomly between 2 given directions.
  83401. */
  83402. export class BoxParticleEmitter implements IParticleEmitterType {
  83403. /**
  83404. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83405. */
  83406. direction1: Vector3;
  83407. /**
  83408. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83409. */
  83410. direction2: Vector3;
  83411. /**
  83412. * 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.
  83413. */
  83414. minEmitBox: Vector3;
  83415. /**
  83416. * 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.
  83417. */
  83418. maxEmitBox: Vector3;
  83419. /**
  83420. * Creates a new instance BoxParticleEmitter
  83421. */
  83422. constructor();
  83423. /**
  83424. * Called by the particle System when the direction is computed for the created particle.
  83425. * @param worldMatrix is the world matrix of the particle system
  83426. * @param directionToUpdate is the direction vector to update with the result
  83427. * @param particle is the particle we are computed the direction for
  83428. */
  83429. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83430. /**
  83431. * Called by the particle System when the position is computed for the created particle.
  83432. * @param worldMatrix is the world matrix of the particle system
  83433. * @param positionToUpdate is the position vector to update with the result
  83434. * @param particle is the particle we are computed the position for
  83435. */
  83436. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83437. /**
  83438. * Clones the current emitter and returns a copy of it
  83439. * @returns the new emitter
  83440. */
  83441. clone(): BoxParticleEmitter;
  83442. /**
  83443. * Called by the GPUParticleSystem to setup the update shader
  83444. * @param effect defines the update shader
  83445. */
  83446. applyToShader(effect: Effect): void;
  83447. /**
  83448. * Returns a string to use to update the GPU particles update shader
  83449. * @returns a string containng the defines string
  83450. */
  83451. getEffectDefines(): string;
  83452. /**
  83453. * Returns the string "BoxParticleEmitter"
  83454. * @returns a string containing the class name
  83455. */
  83456. getClassName(): string;
  83457. /**
  83458. * Serializes the particle system to a JSON object.
  83459. * @returns the JSON object
  83460. */
  83461. serialize(): any;
  83462. /**
  83463. * Parse properties from a JSON object
  83464. * @param serializationObject defines the JSON object
  83465. */
  83466. parse(serializationObject: any): void;
  83467. }
  83468. }
  83469. declare module BABYLON {
  83470. /**
  83471. * Particle emitter emitting particles from the inside of a cone.
  83472. * It emits the particles alongside the cone volume from the base to the particle.
  83473. * The emission direction might be randomized.
  83474. */
  83475. export class ConeParticleEmitter implements IParticleEmitterType {
  83476. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83477. directionRandomizer: number;
  83478. private _radius;
  83479. private _angle;
  83480. private _height;
  83481. /**
  83482. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  83483. */
  83484. radiusRange: number;
  83485. /**
  83486. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  83487. */
  83488. heightRange: number;
  83489. /**
  83490. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  83491. */
  83492. emitFromSpawnPointOnly: boolean;
  83493. /**
  83494. * Gets or sets the radius of the emission cone
  83495. */
  83496. radius: number;
  83497. /**
  83498. * Gets or sets the angle of the emission cone
  83499. */
  83500. angle: number;
  83501. private _buildHeight;
  83502. /**
  83503. * Creates a new instance ConeParticleEmitter
  83504. * @param radius the radius of the emission cone (1 by default)
  83505. * @param angle the cone base angle (PI by default)
  83506. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  83507. */
  83508. constructor(radius?: number, angle?: number,
  83509. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  83510. directionRandomizer?: number);
  83511. /**
  83512. * Called by the particle System when the direction is computed for the created particle.
  83513. * @param worldMatrix is the world matrix of the particle system
  83514. * @param directionToUpdate is the direction vector to update with the result
  83515. * @param particle is the particle we are computed the direction for
  83516. */
  83517. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83518. /**
  83519. * Called by the particle System when the position is computed for the created particle.
  83520. * @param worldMatrix is the world matrix of the particle system
  83521. * @param positionToUpdate is the position vector to update with the result
  83522. * @param particle is the particle we are computed the position for
  83523. */
  83524. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83525. /**
  83526. * Clones the current emitter and returns a copy of it
  83527. * @returns the new emitter
  83528. */
  83529. clone(): ConeParticleEmitter;
  83530. /**
  83531. * Called by the GPUParticleSystem to setup the update shader
  83532. * @param effect defines the update shader
  83533. */
  83534. applyToShader(effect: Effect): void;
  83535. /**
  83536. * Returns a string to use to update the GPU particles update shader
  83537. * @returns a string containng the defines string
  83538. */
  83539. getEffectDefines(): string;
  83540. /**
  83541. * Returns the string "ConeParticleEmitter"
  83542. * @returns a string containing the class name
  83543. */
  83544. getClassName(): string;
  83545. /**
  83546. * Serializes the particle system to a JSON object.
  83547. * @returns the JSON object
  83548. */
  83549. serialize(): any;
  83550. /**
  83551. * Parse properties from a JSON object
  83552. * @param serializationObject defines the JSON object
  83553. */
  83554. parse(serializationObject: any): void;
  83555. }
  83556. }
  83557. declare module BABYLON {
  83558. /**
  83559. * Particle emitter emitting particles from the inside of a cylinder.
  83560. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  83561. */
  83562. export class CylinderParticleEmitter implements IParticleEmitterType {
  83563. /**
  83564. * The radius of the emission cylinder.
  83565. */
  83566. radius: number;
  83567. /**
  83568. * The height of the emission cylinder.
  83569. */
  83570. height: number;
  83571. /**
  83572. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83573. */
  83574. radiusRange: number;
  83575. /**
  83576. * How much to randomize the particle direction [0-1].
  83577. */
  83578. directionRandomizer: number;
  83579. /**
  83580. * Creates a new instance CylinderParticleEmitter
  83581. * @param radius the radius of the emission cylinder (1 by default)
  83582. * @param height the height of the emission cylinder (1 by default)
  83583. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83584. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83585. */
  83586. constructor(
  83587. /**
  83588. * The radius of the emission cylinder.
  83589. */
  83590. radius?: number,
  83591. /**
  83592. * The height of the emission cylinder.
  83593. */
  83594. height?: number,
  83595. /**
  83596. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83597. */
  83598. radiusRange?: number,
  83599. /**
  83600. * How much to randomize the particle direction [0-1].
  83601. */
  83602. directionRandomizer?: number);
  83603. /**
  83604. * Called by the particle System when the direction is computed for the created particle.
  83605. * @param worldMatrix is the world matrix of the particle system
  83606. * @param directionToUpdate is the direction vector to update with the result
  83607. * @param particle is the particle we are computed the direction for
  83608. */
  83609. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83610. /**
  83611. * Called by the particle System when the position is computed for the created particle.
  83612. * @param worldMatrix is the world matrix of the particle system
  83613. * @param positionToUpdate is the position vector to update with the result
  83614. * @param particle is the particle we are computed the position for
  83615. */
  83616. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83617. /**
  83618. * Clones the current emitter and returns a copy of it
  83619. * @returns the new emitter
  83620. */
  83621. clone(): CylinderParticleEmitter;
  83622. /**
  83623. * Called by the GPUParticleSystem to setup the update shader
  83624. * @param effect defines the update shader
  83625. */
  83626. applyToShader(effect: Effect): void;
  83627. /**
  83628. * Returns a string to use to update the GPU particles update shader
  83629. * @returns a string containng the defines string
  83630. */
  83631. getEffectDefines(): string;
  83632. /**
  83633. * Returns the string "CylinderParticleEmitter"
  83634. * @returns a string containing the class name
  83635. */
  83636. getClassName(): string;
  83637. /**
  83638. * Serializes the particle system to a JSON object.
  83639. * @returns the JSON object
  83640. */
  83641. serialize(): any;
  83642. /**
  83643. * Parse properties from a JSON object
  83644. * @param serializationObject defines the JSON object
  83645. */
  83646. parse(serializationObject: any): void;
  83647. }
  83648. /**
  83649. * Particle emitter emitting particles from the inside of a cylinder.
  83650. * It emits the particles randomly between two vectors.
  83651. */
  83652. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  83653. /**
  83654. * The min limit of the emission direction.
  83655. */
  83656. direction1: Vector3;
  83657. /**
  83658. * The max limit of the emission direction.
  83659. */
  83660. direction2: Vector3;
  83661. /**
  83662. * Creates a new instance CylinderDirectedParticleEmitter
  83663. * @param radius the radius of the emission cylinder (1 by default)
  83664. * @param height the height of the emission cylinder (1 by default)
  83665. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83666. * @param direction1 the min limit of the emission direction (up vector by default)
  83667. * @param direction2 the max limit of the emission direction (up vector by default)
  83668. */
  83669. constructor(radius?: number, height?: number, radiusRange?: number,
  83670. /**
  83671. * The min limit of the emission direction.
  83672. */
  83673. direction1?: Vector3,
  83674. /**
  83675. * The max limit of the emission direction.
  83676. */
  83677. direction2?: Vector3);
  83678. /**
  83679. * Called by the particle System when the direction is computed for the created particle.
  83680. * @param worldMatrix is the world matrix of the particle system
  83681. * @param directionToUpdate is the direction vector to update with the result
  83682. * @param particle is the particle we are computed the direction for
  83683. */
  83684. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83685. /**
  83686. * Clones the current emitter and returns a copy of it
  83687. * @returns the new emitter
  83688. */
  83689. clone(): CylinderDirectedParticleEmitter;
  83690. /**
  83691. * Called by the GPUParticleSystem to setup the update shader
  83692. * @param effect defines the update shader
  83693. */
  83694. applyToShader(effect: Effect): void;
  83695. /**
  83696. * Returns a string to use to update the GPU particles update shader
  83697. * @returns a string containng the defines string
  83698. */
  83699. getEffectDefines(): string;
  83700. /**
  83701. * Returns the string "CylinderDirectedParticleEmitter"
  83702. * @returns a string containing the class name
  83703. */
  83704. getClassName(): string;
  83705. /**
  83706. * Serializes the particle system to a JSON object.
  83707. * @returns the JSON object
  83708. */
  83709. serialize(): any;
  83710. /**
  83711. * Parse properties from a JSON object
  83712. * @param serializationObject defines the JSON object
  83713. */
  83714. parse(serializationObject: any): void;
  83715. }
  83716. }
  83717. declare module BABYLON {
  83718. /**
  83719. * Particle emitter emitting particles from the inside of a hemisphere.
  83720. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83721. */
  83722. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83723. /**
  83724. * The radius of the emission hemisphere.
  83725. */
  83726. radius: number;
  83727. /**
  83728. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83729. */
  83730. radiusRange: number;
  83731. /**
  83732. * How much to randomize the particle direction [0-1].
  83733. */
  83734. directionRandomizer: number;
  83735. /**
  83736. * Creates a new instance HemisphericParticleEmitter
  83737. * @param radius the radius of the emission hemisphere (1 by default)
  83738. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83739. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83740. */
  83741. constructor(
  83742. /**
  83743. * The radius of the emission hemisphere.
  83744. */
  83745. radius?: number,
  83746. /**
  83747. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83748. */
  83749. radiusRange?: number,
  83750. /**
  83751. * How much to randomize the particle direction [0-1].
  83752. */
  83753. directionRandomizer?: number);
  83754. /**
  83755. * Called by the particle System when the direction is computed for the created particle.
  83756. * @param worldMatrix is the world matrix of the particle system
  83757. * @param directionToUpdate is the direction vector to update with the result
  83758. * @param particle is the particle we are computed the direction for
  83759. */
  83760. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83761. /**
  83762. * Called by the particle System when the position is computed for the created particle.
  83763. * @param worldMatrix is the world matrix of the particle system
  83764. * @param positionToUpdate is the position vector to update with the result
  83765. * @param particle is the particle we are computed the position for
  83766. */
  83767. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83768. /**
  83769. * Clones the current emitter and returns a copy of it
  83770. * @returns the new emitter
  83771. */
  83772. clone(): HemisphericParticleEmitter;
  83773. /**
  83774. * Called by the GPUParticleSystem to setup the update shader
  83775. * @param effect defines the update shader
  83776. */
  83777. applyToShader(effect: Effect): void;
  83778. /**
  83779. * Returns a string to use to update the GPU particles update shader
  83780. * @returns a string containng the defines string
  83781. */
  83782. getEffectDefines(): string;
  83783. /**
  83784. * Returns the string "HemisphericParticleEmitter"
  83785. * @returns a string containing the class name
  83786. */
  83787. getClassName(): string;
  83788. /**
  83789. * Serializes the particle system to a JSON object.
  83790. * @returns the JSON object
  83791. */
  83792. serialize(): any;
  83793. /**
  83794. * Parse properties from a JSON object
  83795. * @param serializationObject defines the JSON object
  83796. */
  83797. parse(serializationObject: any): void;
  83798. }
  83799. }
  83800. declare module BABYLON {
  83801. /**
  83802. * Particle emitter emitting particles from a point.
  83803. * It emits the particles randomly between 2 given directions.
  83804. */
  83805. export class PointParticleEmitter implements IParticleEmitterType {
  83806. /**
  83807. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83808. */
  83809. direction1: Vector3;
  83810. /**
  83811. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83812. */
  83813. direction2: Vector3;
  83814. /**
  83815. * Creates a new instance PointParticleEmitter
  83816. */
  83817. constructor();
  83818. /**
  83819. * Called by the particle System when the direction is computed for the created particle.
  83820. * @param worldMatrix is the world matrix of the particle system
  83821. * @param directionToUpdate is the direction vector to update with the result
  83822. * @param particle is the particle we are computed the direction for
  83823. */
  83824. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83825. /**
  83826. * Called by the particle System when the position is computed for the created particle.
  83827. * @param worldMatrix is the world matrix of the particle system
  83828. * @param positionToUpdate is the position vector to update with the result
  83829. * @param particle is the particle we are computed the position for
  83830. */
  83831. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83832. /**
  83833. * Clones the current emitter and returns a copy of it
  83834. * @returns the new emitter
  83835. */
  83836. clone(): PointParticleEmitter;
  83837. /**
  83838. * Called by the GPUParticleSystem to setup the update shader
  83839. * @param effect defines the update shader
  83840. */
  83841. applyToShader(effect: Effect): void;
  83842. /**
  83843. * Returns a string to use to update the GPU particles update shader
  83844. * @returns a string containng the defines string
  83845. */
  83846. getEffectDefines(): string;
  83847. /**
  83848. * Returns the string "PointParticleEmitter"
  83849. * @returns a string containing the class name
  83850. */
  83851. getClassName(): string;
  83852. /**
  83853. * Serializes the particle system to a JSON object.
  83854. * @returns the JSON object
  83855. */
  83856. serialize(): any;
  83857. /**
  83858. * Parse properties from a JSON object
  83859. * @param serializationObject defines the JSON object
  83860. */
  83861. parse(serializationObject: any): void;
  83862. }
  83863. }
  83864. declare module BABYLON {
  83865. /**
  83866. * Particle emitter emitting particles from the inside of a sphere.
  83867. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83868. */
  83869. export class SphereParticleEmitter implements IParticleEmitterType {
  83870. /**
  83871. * The radius of the emission sphere.
  83872. */
  83873. radius: number;
  83874. /**
  83875. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83876. */
  83877. radiusRange: number;
  83878. /**
  83879. * How much to randomize the particle direction [0-1].
  83880. */
  83881. directionRandomizer: number;
  83882. /**
  83883. * Creates a new instance SphereParticleEmitter
  83884. * @param radius the radius of the emission sphere (1 by default)
  83885. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83886. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83887. */
  83888. constructor(
  83889. /**
  83890. * The radius of the emission sphere.
  83891. */
  83892. radius?: number,
  83893. /**
  83894. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83895. */
  83896. radiusRange?: number,
  83897. /**
  83898. * How much to randomize the particle direction [0-1].
  83899. */
  83900. directionRandomizer?: number);
  83901. /**
  83902. * Called by the particle System when the direction is computed for the created particle.
  83903. * @param worldMatrix is the world matrix of the particle system
  83904. * @param directionToUpdate is the direction vector to update with the result
  83905. * @param particle is the particle we are computed the direction for
  83906. */
  83907. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83908. /**
  83909. * Called by the particle System when the position is computed for the created particle.
  83910. * @param worldMatrix is the world matrix of the particle system
  83911. * @param positionToUpdate is the position vector to update with the result
  83912. * @param particle is the particle we are computed the position for
  83913. */
  83914. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83915. /**
  83916. * Clones the current emitter and returns a copy of it
  83917. * @returns the new emitter
  83918. */
  83919. clone(): SphereParticleEmitter;
  83920. /**
  83921. * Called by the GPUParticleSystem to setup the update shader
  83922. * @param effect defines the update shader
  83923. */
  83924. applyToShader(effect: Effect): void;
  83925. /**
  83926. * Returns a string to use to update the GPU particles update shader
  83927. * @returns a string containng the defines string
  83928. */
  83929. getEffectDefines(): string;
  83930. /**
  83931. * Returns the string "SphereParticleEmitter"
  83932. * @returns a string containing the class name
  83933. */
  83934. getClassName(): string;
  83935. /**
  83936. * Serializes the particle system to a JSON object.
  83937. * @returns the JSON object
  83938. */
  83939. serialize(): any;
  83940. /**
  83941. * Parse properties from a JSON object
  83942. * @param serializationObject defines the JSON object
  83943. */
  83944. parse(serializationObject: any): void;
  83945. }
  83946. /**
  83947. * Particle emitter emitting particles from the inside of a sphere.
  83948. * It emits the particles randomly between two vectors.
  83949. */
  83950. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83951. /**
  83952. * The min limit of the emission direction.
  83953. */
  83954. direction1: Vector3;
  83955. /**
  83956. * The max limit of the emission direction.
  83957. */
  83958. direction2: Vector3;
  83959. /**
  83960. * Creates a new instance SphereDirectedParticleEmitter
  83961. * @param radius the radius of the emission sphere (1 by default)
  83962. * @param direction1 the min limit of the emission direction (up vector by default)
  83963. * @param direction2 the max limit of the emission direction (up vector by default)
  83964. */
  83965. constructor(radius?: number,
  83966. /**
  83967. * The min limit of the emission direction.
  83968. */
  83969. direction1?: Vector3,
  83970. /**
  83971. * The max limit of the emission direction.
  83972. */
  83973. direction2?: Vector3);
  83974. /**
  83975. * Called by the particle System when the direction is computed for the created particle.
  83976. * @param worldMatrix is the world matrix of the particle system
  83977. * @param directionToUpdate is the direction vector to update with the result
  83978. * @param particle is the particle we are computed the direction for
  83979. */
  83980. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83981. /**
  83982. * Clones the current emitter and returns a copy of it
  83983. * @returns the new emitter
  83984. */
  83985. clone(): SphereDirectedParticleEmitter;
  83986. /**
  83987. * Called by the GPUParticleSystem to setup the update shader
  83988. * @param effect defines the update shader
  83989. */
  83990. applyToShader(effect: Effect): void;
  83991. /**
  83992. * Returns a string to use to update the GPU particles update shader
  83993. * @returns a string containng the defines string
  83994. */
  83995. getEffectDefines(): string;
  83996. /**
  83997. * Returns the string "SphereDirectedParticleEmitter"
  83998. * @returns a string containing the class name
  83999. */
  84000. getClassName(): string;
  84001. /**
  84002. * Serializes the particle system to a JSON object.
  84003. * @returns the JSON object
  84004. */
  84005. serialize(): any;
  84006. /**
  84007. * Parse properties from a JSON object
  84008. * @param serializationObject defines the JSON object
  84009. */
  84010. parse(serializationObject: any): void;
  84011. }
  84012. }
  84013. declare module BABYLON {
  84014. /**
  84015. * Interface representing a particle system in Babylon.js.
  84016. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  84017. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  84018. */
  84019. export interface IParticleSystem {
  84020. /**
  84021. * List of animations used by the particle system.
  84022. */
  84023. animations: Animation[];
  84024. /**
  84025. * The id of the Particle system.
  84026. */
  84027. id: string;
  84028. /**
  84029. * The name of the Particle system.
  84030. */
  84031. name: string;
  84032. /**
  84033. * The emitter represents the Mesh or position we are attaching the particle system to.
  84034. */
  84035. emitter: Nullable<AbstractMesh | Vector3>;
  84036. /**
  84037. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84038. */
  84039. isBillboardBased: boolean;
  84040. /**
  84041. * The rendering group used by the Particle system to chose when to render.
  84042. */
  84043. renderingGroupId: number;
  84044. /**
  84045. * The layer mask we are rendering the particles through.
  84046. */
  84047. layerMask: number;
  84048. /**
  84049. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84050. */
  84051. updateSpeed: number;
  84052. /**
  84053. * The amount of time the particle system is running (depends of the overall update speed).
  84054. */
  84055. targetStopDuration: number;
  84056. /**
  84057. * The texture used to render each particle. (this can be a spritesheet)
  84058. */
  84059. particleTexture: Nullable<Texture>;
  84060. /**
  84061. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  84062. */
  84063. blendMode: number;
  84064. /**
  84065. * Minimum life time of emitting particles.
  84066. */
  84067. minLifeTime: number;
  84068. /**
  84069. * Maximum life time of emitting particles.
  84070. */
  84071. maxLifeTime: number;
  84072. /**
  84073. * Minimum Size of emitting particles.
  84074. */
  84075. minSize: number;
  84076. /**
  84077. * Maximum Size of emitting particles.
  84078. */
  84079. maxSize: number;
  84080. /**
  84081. * Minimum scale of emitting particles on X axis.
  84082. */
  84083. minScaleX: number;
  84084. /**
  84085. * Maximum scale of emitting particles on X axis.
  84086. */
  84087. maxScaleX: number;
  84088. /**
  84089. * Minimum scale of emitting particles on Y axis.
  84090. */
  84091. minScaleY: number;
  84092. /**
  84093. * Maximum scale of emitting particles on Y axis.
  84094. */
  84095. maxScaleY: number;
  84096. /**
  84097. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  84098. */
  84099. color1: Color4;
  84100. /**
  84101. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  84102. */
  84103. color2: Color4;
  84104. /**
  84105. * Color the particle will have at the end of its lifetime.
  84106. */
  84107. colorDead: Color4;
  84108. /**
  84109. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  84110. */
  84111. emitRate: number;
  84112. /**
  84113. * You can use gravity if you want to give an orientation to your particles.
  84114. */
  84115. gravity: Vector3;
  84116. /**
  84117. * Minimum power of emitting particles.
  84118. */
  84119. minEmitPower: number;
  84120. /**
  84121. * Maximum power of emitting particles.
  84122. */
  84123. maxEmitPower: number;
  84124. /**
  84125. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84126. */
  84127. minAngularSpeed: number;
  84128. /**
  84129. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84130. */
  84131. maxAngularSpeed: number;
  84132. /**
  84133. * Gets or sets the minimal initial rotation in radians.
  84134. */
  84135. minInitialRotation: number;
  84136. /**
  84137. * Gets or sets the maximal initial rotation in radians.
  84138. */
  84139. maxInitialRotation: number;
  84140. /**
  84141. * The particle emitter type defines the emitter used by the particle system.
  84142. * It can be for example box, sphere, or cone...
  84143. */
  84144. particleEmitterType: Nullable<IParticleEmitterType>;
  84145. /**
  84146. * Defines the delay in milliseconds before starting the system (0 by default)
  84147. */
  84148. startDelay: number;
  84149. /**
  84150. * 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
  84151. */
  84152. preWarmCycles: number;
  84153. /**
  84154. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  84155. */
  84156. preWarmStepOffset: number;
  84157. /**
  84158. * 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)
  84159. */
  84160. spriteCellChangeSpeed: number;
  84161. /**
  84162. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84163. */
  84164. startSpriteCellID: number;
  84165. /**
  84166. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84167. */
  84168. endSpriteCellID: number;
  84169. /**
  84170. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84171. */
  84172. spriteCellWidth: number;
  84173. /**
  84174. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84175. */
  84176. spriteCellHeight: number;
  84177. /**
  84178. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84179. */
  84180. spriteRandomStartCell: boolean;
  84181. /**
  84182. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  84183. */
  84184. isAnimationSheetEnabled: boolean;
  84185. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84186. translationPivot: Vector2;
  84187. /**
  84188. * Gets or sets a texture used to add random noise to particle positions
  84189. */
  84190. noiseTexture: Nullable<BaseTexture>;
  84191. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84192. noiseStrength: Vector3;
  84193. /**
  84194. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84195. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84196. */
  84197. billboardMode: number;
  84198. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84199. limitVelocityDamping: number;
  84200. /**
  84201. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84202. */
  84203. beginAnimationOnStart: boolean;
  84204. /**
  84205. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84206. */
  84207. beginAnimationFrom: number;
  84208. /**
  84209. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84210. */
  84211. beginAnimationTo: number;
  84212. /**
  84213. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84214. */
  84215. beginAnimationLoop: boolean;
  84216. /**
  84217. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84218. */
  84219. disposeOnStop: boolean;
  84220. /**
  84221. * Gets the maximum number of particles active at the same time.
  84222. * @returns The max number of active particles.
  84223. */
  84224. getCapacity(): number;
  84225. /**
  84226. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84227. * @returns True if it has been started, otherwise false.
  84228. */
  84229. isStarted(): boolean;
  84230. /**
  84231. * Animates the particle system for this frame.
  84232. */
  84233. animate(): void;
  84234. /**
  84235. * Renders the particle system in its current state.
  84236. * @returns the current number of particles
  84237. */
  84238. render(): number;
  84239. /**
  84240. * Dispose the particle system and frees its associated resources.
  84241. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84242. */
  84243. dispose(disposeTexture?: boolean): void;
  84244. /**
  84245. * Clones the particle system.
  84246. * @param name The name of the cloned object
  84247. * @param newEmitter The new emitter to use
  84248. * @returns the cloned particle system
  84249. */
  84250. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  84251. /**
  84252. * Serializes the particle system to a JSON object.
  84253. * @returns the JSON object
  84254. */
  84255. serialize(): any;
  84256. /**
  84257. * Rebuild the particle system
  84258. */
  84259. rebuild(): void;
  84260. /**
  84261. * Starts the particle system and begins to emit
  84262. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  84263. */
  84264. start(delay?: number): void;
  84265. /**
  84266. * Stops the particle system.
  84267. */
  84268. stop(): void;
  84269. /**
  84270. * Remove all active particles
  84271. */
  84272. reset(): void;
  84273. /**
  84274. * Is this system ready to be used/rendered
  84275. * @return true if the system is ready
  84276. */
  84277. isReady(): boolean;
  84278. /**
  84279. * Adds a new color gradient
  84280. * @param gradient defines the gradient to use (between 0 and 1)
  84281. * @param color1 defines the color to affect to the specified gradient
  84282. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84283. * @returns the current particle system
  84284. */
  84285. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84286. /**
  84287. * Remove a specific color gradient
  84288. * @param gradient defines the gradient to remove
  84289. * @returns the current particle system
  84290. */
  84291. removeColorGradient(gradient: number): IParticleSystem;
  84292. /**
  84293. * Adds a new size gradient
  84294. * @param gradient defines the gradient to use (between 0 and 1)
  84295. * @param factor defines the size factor to affect to the specified gradient
  84296. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84297. * @returns the current particle system
  84298. */
  84299. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84300. /**
  84301. * Remove a specific size gradient
  84302. * @param gradient defines the gradient to remove
  84303. * @returns the current particle system
  84304. */
  84305. removeSizeGradient(gradient: number): IParticleSystem;
  84306. /**
  84307. * Gets the current list of color gradients.
  84308. * You must use addColorGradient and removeColorGradient to udpate this list
  84309. * @returns the list of color gradients
  84310. */
  84311. getColorGradients(): Nullable<Array<ColorGradient>>;
  84312. /**
  84313. * Gets the current list of size gradients.
  84314. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84315. * @returns the list of size gradients
  84316. */
  84317. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84318. /**
  84319. * Gets the current list of angular speed gradients.
  84320. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84321. * @returns the list of angular speed gradients
  84322. */
  84323. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84324. /**
  84325. * Adds a new angular speed gradient
  84326. * @param gradient defines the gradient to use (between 0 and 1)
  84327. * @param factor defines the angular speed to affect to the specified gradient
  84328. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84329. * @returns the current particle system
  84330. */
  84331. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84332. /**
  84333. * Remove a specific angular speed gradient
  84334. * @param gradient defines the gradient to remove
  84335. * @returns the current particle system
  84336. */
  84337. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84338. /**
  84339. * Gets the current list of velocity gradients.
  84340. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84341. * @returns the list of velocity gradients
  84342. */
  84343. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84344. /**
  84345. * Adds a new velocity gradient
  84346. * @param gradient defines the gradient to use (between 0 and 1)
  84347. * @param factor defines the velocity to affect to the specified gradient
  84348. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84349. * @returns the current particle system
  84350. */
  84351. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84352. /**
  84353. * Remove a specific velocity gradient
  84354. * @param gradient defines the gradient to remove
  84355. * @returns the current particle system
  84356. */
  84357. removeVelocityGradient(gradient: number): IParticleSystem;
  84358. /**
  84359. * Gets the current list of limit velocity gradients.
  84360. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84361. * @returns the list of limit velocity gradients
  84362. */
  84363. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84364. /**
  84365. * Adds a new limit velocity gradient
  84366. * @param gradient defines the gradient to use (between 0 and 1)
  84367. * @param factor defines the limit velocity to affect to the specified gradient
  84368. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84369. * @returns the current particle system
  84370. */
  84371. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84372. /**
  84373. * Remove a specific limit velocity gradient
  84374. * @param gradient defines the gradient to remove
  84375. * @returns the current particle system
  84376. */
  84377. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84378. /**
  84379. * Adds a new drag gradient
  84380. * @param gradient defines the gradient to use (between 0 and 1)
  84381. * @param factor defines the drag to affect to the specified gradient
  84382. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84383. * @returns the current particle system
  84384. */
  84385. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84386. /**
  84387. * Remove a specific drag gradient
  84388. * @param gradient defines the gradient to remove
  84389. * @returns the current particle system
  84390. */
  84391. removeDragGradient(gradient: number): IParticleSystem;
  84392. /**
  84393. * Gets the current list of drag gradients.
  84394. * You must use addDragGradient and removeDragGradient to udpate this list
  84395. * @returns the list of drag gradients
  84396. */
  84397. getDragGradients(): Nullable<Array<FactorGradient>>;
  84398. /**
  84399. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84400. * @param gradient defines the gradient to use (between 0 and 1)
  84401. * @param factor defines the emit rate to affect to the specified gradient
  84402. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84403. * @returns the current particle system
  84404. */
  84405. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84406. /**
  84407. * Remove a specific emit rate gradient
  84408. * @param gradient defines the gradient to remove
  84409. * @returns the current particle system
  84410. */
  84411. removeEmitRateGradient(gradient: number): IParticleSystem;
  84412. /**
  84413. * Gets the current list of emit rate gradients.
  84414. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84415. * @returns the list of emit rate gradients
  84416. */
  84417. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84418. /**
  84419. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84420. * @param gradient defines the gradient to use (between 0 and 1)
  84421. * @param factor defines the start size to affect to the specified gradient
  84422. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84423. * @returns the current particle system
  84424. */
  84425. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84426. /**
  84427. * Remove a specific start size gradient
  84428. * @param gradient defines the gradient to remove
  84429. * @returns the current particle system
  84430. */
  84431. removeStartSizeGradient(gradient: number): IParticleSystem;
  84432. /**
  84433. * Gets the current list of start size gradients.
  84434. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84435. * @returns the list of start size gradients
  84436. */
  84437. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84438. /**
  84439. * Adds a new life time gradient
  84440. * @param gradient defines the gradient to use (between 0 and 1)
  84441. * @param factor defines the life time factor to affect to the specified gradient
  84442. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84443. * @returns the current particle system
  84444. */
  84445. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84446. /**
  84447. * Remove a specific life time gradient
  84448. * @param gradient defines the gradient to remove
  84449. * @returns the current particle system
  84450. */
  84451. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84452. /**
  84453. * Gets the current list of life time gradients.
  84454. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84455. * @returns the list of life time gradients
  84456. */
  84457. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84458. /**
  84459. * Gets the current list of color gradients.
  84460. * You must use addColorGradient and removeColorGradient to udpate this list
  84461. * @returns the list of color gradients
  84462. */
  84463. getColorGradients(): Nullable<Array<ColorGradient>>;
  84464. /**
  84465. * Adds a new ramp gradient used to remap particle colors
  84466. * @param gradient defines the gradient to use (between 0 and 1)
  84467. * @param color defines the color to affect to the specified gradient
  84468. * @returns the current particle system
  84469. */
  84470. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  84471. /**
  84472. * Gets the current list of ramp gradients.
  84473. * You must use addRampGradient and removeRampGradient to udpate this list
  84474. * @returns the list of ramp gradients
  84475. */
  84476. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84477. /** Gets or sets a boolean indicating that ramp gradients must be used
  84478. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84479. */
  84480. useRampGradients: boolean;
  84481. /**
  84482. * Adds a new color remap gradient
  84483. * @param gradient defines the gradient to use (between 0 and 1)
  84484. * @param min defines the color remap minimal range
  84485. * @param max defines the color remap maximal range
  84486. * @returns the current particle system
  84487. */
  84488. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84489. /**
  84490. * Gets the current list of color remap gradients.
  84491. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84492. * @returns the list of color remap gradients
  84493. */
  84494. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84495. /**
  84496. * Adds a new alpha remap gradient
  84497. * @param gradient defines the gradient to use (between 0 and 1)
  84498. * @param min defines the alpha remap minimal range
  84499. * @param max defines the alpha remap maximal range
  84500. * @returns the current particle system
  84501. */
  84502. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84503. /**
  84504. * Gets the current list of alpha remap gradients.
  84505. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84506. * @returns the list of alpha remap gradients
  84507. */
  84508. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84509. /**
  84510. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84511. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84512. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84513. * @returns the emitter
  84514. */
  84515. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84516. /**
  84517. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84518. * @param radius The radius of the hemisphere to emit from
  84519. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84520. * @returns the emitter
  84521. */
  84522. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  84523. /**
  84524. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84525. * @param radius The radius of the sphere to emit from
  84526. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84527. * @returns the emitter
  84528. */
  84529. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  84530. /**
  84531. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84532. * @param radius The radius of the sphere to emit from
  84533. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84534. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84535. * @returns the emitter
  84536. */
  84537. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84538. /**
  84539. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84540. * @param radius The radius of the emission cylinder
  84541. * @param height The height of the emission cylinder
  84542. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84543. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84544. * @returns the emitter
  84545. */
  84546. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  84547. /**
  84548. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84549. * @param radius The radius of the cylinder to emit from
  84550. * @param height The height of the emission cylinder
  84551. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84552. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84553. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84554. * @returns the emitter
  84555. */
  84556. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  84557. /**
  84558. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84559. * @param radius The radius of the cone to emit from
  84560. * @param angle The base angle of the cone
  84561. * @returns the emitter
  84562. */
  84563. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  84564. /**
  84565. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84566. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84567. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84568. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84569. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84570. * @returns the emitter
  84571. */
  84572. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84573. /**
  84574. * Get hosting scene
  84575. * @returns the scene
  84576. */
  84577. getScene(): Scene;
  84578. }
  84579. }
  84580. declare module BABYLON {
  84581. /**
  84582. * Creates an instance based on a source mesh.
  84583. */
  84584. export class InstancedMesh extends AbstractMesh {
  84585. private _sourceMesh;
  84586. private _currentLOD;
  84587. /** @hidden */
  84588. _indexInSourceMeshInstanceArray: number;
  84589. constructor(name: string, source: Mesh);
  84590. /**
  84591. * Returns the string "InstancedMesh".
  84592. */
  84593. getClassName(): string;
  84594. /** Gets the list of lights affecting that mesh */
  84595. readonly lightSources: Light[];
  84596. _resyncLightSources(): void;
  84597. _resyncLighSource(light: Light): void;
  84598. _removeLightSource(light: Light, dispose: boolean): void;
  84599. /**
  84600. * If the source mesh receives shadows
  84601. */
  84602. readonly receiveShadows: boolean;
  84603. /**
  84604. * The material of the source mesh
  84605. */
  84606. readonly material: Nullable<Material>;
  84607. /**
  84608. * Visibility of the source mesh
  84609. */
  84610. readonly visibility: number;
  84611. /**
  84612. * Skeleton of the source mesh
  84613. */
  84614. readonly skeleton: Nullable<Skeleton>;
  84615. /**
  84616. * Rendering ground id of the source mesh
  84617. */
  84618. renderingGroupId: number;
  84619. /**
  84620. * Returns the total number of vertices (integer).
  84621. */
  84622. getTotalVertices(): number;
  84623. /**
  84624. * Returns a positive integer : the total number of indices in this mesh geometry.
  84625. * @returns the numner of indices or zero if the mesh has no geometry.
  84626. */
  84627. getTotalIndices(): number;
  84628. /**
  84629. * The source mesh of the instance
  84630. */
  84631. readonly sourceMesh: Mesh;
  84632. /**
  84633. * Is this node ready to be used/rendered
  84634. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84635. * @return {boolean} is it ready
  84636. */
  84637. isReady(completeCheck?: boolean): boolean;
  84638. /**
  84639. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84640. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  84641. * @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.
  84642. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  84643. */
  84644. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  84645. /**
  84646. * Sets the vertex data of the mesh geometry for the requested `kind`.
  84647. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  84648. * The `data` are either a numeric array either a Float32Array.
  84649. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  84650. * 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).
  84651. * Note that a new underlying VertexBuffer object is created each call.
  84652. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  84653. *
  84654. * Possible `kind` values :
  84655. * - VertexBuffer.PositionKind
  84656. * - VertexBuffer.UVKind
  84657. * - VertexBuffer.UV2Kind
  84658. * - VertexBuffer.UV3Kind
  84659. * - VertexBuffer.UV4Kind
  84660. * - VertexBuffer.UV5Kind
  84661. * - VertexBuffer.UV6Kind
  84662. * - VertexBuffer.ColorKind
  84663. * - VertexBuffer.MatricesIndicesKind
  84664. * - VertexBuffer.MatricesIndicesExtraKind
  84665. * - VertexBuffer.MatricesWeightsKind
  84666. * - VertexBuffer.MatricesWeightsExtraKind
  84667. *
  84668. * Returns the Mesh.
  84669. */
  84670. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  84671. /**
  84672. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  84673. * If the mesh has no geometry, it is simply returned as it is.
  84674. * The `data` are either a numeric array either a Float32Array.
  84675. * No new underlying VertexBuffer object is created.
  84676. * 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.
  84677. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  84678. *
  84679. * Possible `kind` values :
  84680. * - VertexBuffer.PositionKind
  84681. * - VertexBuffer.UVKind
  84682. * - VertexBuffer.UV2Kind
  84683. * - VertexBuffer.UV3Kind
  84684. * - VertexBuffer.UV4Kind
  84685. * - VertexBuffer.UV5Kind
  84686. * - VertexBuffer.UV6Kind
  84687. * - VertexBuffer.ColorKind
  84688. * - VertexBuffer.MatricesIndicesKind
  84689. * - VertexBuffer.MatricesIndicesExtraKind
  84690. * - VertexBuffer.MatricesWeightsKind
  84691. * - VertexBuffer.MatricesWeightsExtraKind
  84692. *
  84693. * Returns the Mesh.
  84694. */
  84695. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  84696. /**
  84697. * Sets the mesh indices.
  84698. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  84699. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  84700. * This method creates a new index buffer each call.
  84701. * Returns the Mesh.
  84702. */
  84703. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  84704. /**
  84705. * Boolean : True if the mesh owns the requested kind of data.
  84706. */
  84707. isVerticesDataPresent(kind: string): boolean;
  84708. /**
  84709. * Returns an array of indices (IndicesArray).
  84710. */
  84711. getIndices(): Nullable<IndicesArray>;
  84712. readonly _positions: Nullable<Vector3[]>;
  84713. /**
  84714. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84715. * This means the mesh underlying bounding box and sphere are recomputed.
  84716. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84717. * @returns the current mesh
  84718. */
  84719. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  84720. /** @hidden */
  84721. _preActivate(): InstancedMesh;
  84722. /** @hidden */
  84723. _activate(renderId: number, intermediateRendering: boolean): boolean;
  84724. /** @hidden */
  84725. _postActivate(): void;
  84726. getWorldMatrix(): Matrix;
  84727. readonly isAnInstance: boolean;
  84728. /**
  84729. * Returns the current associated LOD AbstractMesh.
  84730. */
  84731. getLOD(camera: Camera): AbstractMesh;
  84732. /** @hidden */
  84733. _syncSubMeshes(): InstancedMesh;
  84734. /** @hidden */
  84735. _generatePointsArray(): boolean;
  84736. /**
  84737. * Creates a new InstancedMesh from the current mesh.
  84738. * - name (string) : the cloned mesh name
  84739. * - newParent (optional Node) : the optional Node to parent the clone to.
  84740. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  84741. *
  84742. * Returns the clone.
  84743. */
  84744. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84745. /**
  84746. * Disposes the InstancedMesh.
  84747. * Returns nothing.
  84748. */
  84749. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84750. }
  84751. }
  84752. declare module BABYLON {
  84753. /**
  84754. * Defines the options associated with the creation of a shader material.
  84755. */
  84756. export interface IShaderMaterialOptions {
  84757. /**
  84758. * Does the material work in alpha blend mode
  84759. */
  84760. needAlphaBlending: boolean;
  84761. /**
  84762. * Does the material work in alpha test mode
  84763. */
  84764. needAlphaTesting: boolean;
  84765. /**
  84766. * The list of attribute names used in the shader
  84767. */
  84768. attributes: string[];
  84769. /**
  84770. * The list of unifrom names used in the shader
  84771. */
  84772. uniforms: string[];
  84773. /**
  84774. * The list of UBO names used in the shader
  84775. */
  84776. uniformBuffers: string[];
  84777. /**
  84778. * The list of sampler names used in the shader
  84779. */
  84780. samplers: string[];
  84781. /**
  84782. * The list of defines used in the shader
  84783. */
  84784. defines: string[];
  84785. }
  84786. /**
  84787. * 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.
  84788. *
  84789. * This returned material effects how the mesh will look based on the code in the shaders.
  84790. *
  84791. * @see http://doc.babylonjs.com/how_to/shader_material
  84792. */
  84793. export class ShaderMaterial extends Material {
  84794. private _shaderPath;
  84795. private _options;
  84796. private _textures;
  84797. private _textureArrays;
  84798. private _floats;
  84799. private _ints;
  84800. private _floatsArrays;
  84801. private _colors3;
  84802. private _colors3Arrays;
  84803. private _colors4;
  84804. private _colors4Arrays;
  84805. private _vectors2;
  84806. private _vectors3;
  84807. private _vectors4;
  84808. private _matrices;
  84809. private _matrices3x3;
  84810. private _matrices2x2;
  84811. private _vectors2Arrays;
  84812. private _vectors3Arrays;
  84813. private _vectors4Arrays;
  84814. private _cachedWorldViewMatrix;
  84815. private _cachedWorldViewProjectionMatrix;
  84816. private _renderId;
  84817. /**
  84818. * Instantiate a new shader material.
  84819. * 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.
  84820. * This returned material effects how the mesh will look based on the code in the shaders.
  84821. * @see http://doc.babylonjs.com/how_to/shader_material
  84822. * @param name Define the name of the material in the scene
  84823. * @param scene Define the scene the material belongs to
  84824. * @param shaderPath Defines the route to the shader code in one of three ways:
  84825. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  84826. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  84827. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  84828. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  84829. * @param options Define the options used to create the shader
  84830. */
  84831. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  84832. /**
  84833. * Gets the options used to compile the shader.
  84834. * They can be modified to trigger a new compilation
  84835. */
  84836. readonly options: IShaderMaterialOptions;
  84837. /**
  84838. * Gets the current class name of the material e.g. "ShaderMaterial"
  84839. * Mainly use in serialization.
  84840. * @returns the class name
  84841. */
  84842. getClassName(): string;
  84843. /**
  84844. * Specifies if the material will require alpha blending
  84845. * @returns a boolean specifying if alpha blending is needed
  84846. */
  84847. needAlphaBlending(): boolean;
  84848. /**
  84849. * Specifies if this material should be rendered in alpha test mode
  84850. * @returns a boolean specifying if an alpha test is needed.
  84851. */
  84852. needAlphaTesting(): boolean;
  84853. private _checkUniform;
  84854. /**
  84855. * Set a texture in the shader.
  84856. * @param name Define the name of the uniform samplers as defined in the shader
  84857. * @param texture Define the texture to bind to this sampler
  84858. * @return the material itself allowing "fluent" like uniform updates
  84859. */
  84860. setTexture(name: string, texture: Texture): ShaderMaterial;
  84861. /**
  84862. * Set a texture array in the shader.
  84863. * @param name Define the name of the uniform sampler array as defined in the shader
  84864. * @param textures Define the list of textures to bind to this sampler
  84865. * @return the material itself allowing "fluent" like uniform updates
  84866. */
  84867. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  84868. /**
  84869. * Set a float in the shader.
  84870. * @param name Define the name of the uniform as defined in the shader
  84871. * @param value Define the value to give to the uniform
  84872. * @return the material itself allowing "fluent" like uniform updates
  84873. */
  84874. setFloat(name: string, value: number): ShaderMaterial;
  84875. /**
  84876. * Set a int in the shader.
  84877. * @param name Define the name of the uniform as defined in the shader
  84878. * @param value Define the value to give to the uniform
  84879. * @return the material itself allowing "fluent" like uniform updates
  84880. */
  84881. setInt(name: string, value: number): ShaderMaterial;
  84882. /**
  84883. * Set an array of floats in the shader.
  84884. * @param name Define the name of the uniform as defined in the shader
  84885. * @param value Define the value to give to the uniform
  84886. * @return the material itself allowing "fluent" like uniform updates
  84887. */
  84888. setFloats(name: string, value: number[]): ShaderMaterial;
  84889. /**
  84890. * Set a vec3 in the shader from a Color3.
  84891. * @param name Define the name of the uniform as defined in the shader
  84892. * @param value Define the value to give to the uniform
  84893. * @return the material itself allowing "fluent" like uniform updates
  84894. */
  84895. setColor3(name: string, value: Color3): ShaderMaterial;
  84896. /**
  84897. * Set a vec3 array in the shader from a Color3 array.
  84898. * @param name Define the name of the uniform as defined in the shader
  84899. * @param value Define the value to give to the uniform
  84900. * @return the material itself allowing "fluent" like uniform updates
  84901. */
  84902. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  84903. /**
  84904. * Set a vec4 in the shader from a Color4.
  84905. * @param name Define the name of the uniform as defined in the shader
  84906. * @param value Define the value to give to the uniform
  84907. * @return the material itself allowing "fluent" like uniform updates
  84908. */
  84909. setColor4(name: string, value: Color4): ShaderMaterial;
  84910. /**
  84911. * Set a vec4 array in the shader from a Color4 array.
  84912. * @param name Define the name of the uniform as defined in the shader
  84913. * @param value Define the value to give to the uniform
  84914. * @return the material itself allowing "fluent" like uniform updates
  84915. */
  84916. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  84917. /**
  84918. * Set a vec2 in the shader from a Vector2.
  84919. * @param name Define the name of the uniform as defined in the shader
  84920. * @param value Define the value to give to the uniform
  84921. * @return the material itself allowing "fluent" like uniform updates
  84922. */
  84923. setVector2(name: string, value: Vector2): ShaderMaterial;
  84924. /**
  84925. * Set a vec3 in the shader from a Vector3.
  84926. * @param name Define the name of the uniform as defined in the shader
  84927. * @param value Define the value to give to the uniform
  84928. * @return the material itself allowing "fluent" like uniform updates
  84929. */
  84930. setVector3(name: string, value: Vector3): ShaderMaterial;
  84931. /**
  84932. * Set a vec4 in the shader from a Vector4.
  84933. * @param name Define the name of the uniform as defined in the shader
  84934. * @param value Define the value to give to the uniform
  84935. * @return the material itself allowing "fluent" like uniform updates
  84936. */
  84937. setVector4(name: string, value: Vector4): ShaderMaterial;
  84938. /**
  84939. * Set a mat4 in the shader from a Matrix.
  84940. * @param name Define the name of the uniform as defined in the shader
  84941. * @param value Define the value to give to the uniform
  84942. * @return the material itself allowing "fluent" like uniform updates
  84943. */
  84944. setMatrix(name: string, value: Matrix): ShaderMaterial;
  84945. /**
  84946. * Set a mat3 in the shader from a Float32Array.
  84947. * @param name Define the name of the uniform as defined in the shader
  84948. * @param value Define the value to give to the uniform
  84949. * @return the material itself allowing "fluent" like uniform updates
  84950. */
  84951. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  84952. /**
  84953. * Set a mat2 in the shader from a Float32Array.
  84954. * @param name Define the name of the uniform as defined in the shader
  84955. * @param value Define the value to give to the uniform
  84956. * @return the material itself allowing "fluent" like uniform updates
  84957. */
  84958. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  84959. /**
  84960. * Set a vec2 array in the shader from a number array.
  84961. * @param name Define the name of the uniform as defined in the shader
  84962. * @param value Define the value to give to the uniform
  84963. * @return the material itself allowing "fluent" like uniform updates
  84964. */
  84965. setArray2(name: string, value: number[]): ShaderMaterial;
  84966. /**
  84967. * Set a vec3 array in the shader from a number array.
  84968. * @param name Define the name of the uniform as defined in the shader
  84969. * @param value Define the value to give to the uniform
  84970. * @return the material itself allowing "fluent" like uniform updates
  84971. */
  84972. setArray3(name: string, value: number[]): ShaderMaterial;
  84973. /**
  84974. * Set a vec4 array in the shader from a number array.
  84975. * @param name Define the name of the uniform as defined in the shader
  84976. * @param value Define the value to give to the uniform
  84977. * @return the material itself allowing "fluent" like uniform updates
  84978. */
  84979. setArray4(name: string, value: number[]): ShaderMaterial;
  84980. private _checkCache;
  84981. /**
  84982. * Specifies that the submesh is ready to be used
  84983. * @param mesh defines the mesh to check
  84984. * @param subMesh defines which submesh to check
  84985. * @param useInstances specifies that instances should be used
  84986. * @returns a boolean indicating that the submesh is ready or not
  84987. */
  84988. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84989. /**
  84990. * Checks if the material is ready to render the requested mesh
  84991. * @param mesh Define the mesh to render
  84992. * @param useInstances Define whether or not the material is used with instances
  84993. * @returns true if ready, otherwise false
  84994. */
  84995. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84996. /**
  84997. * Binds the world matrix to the material
  84998. * @param world defines the world transformation matrix
  84999. */
  85000. bindOnlyWorldMatrix(world: Matrix): void;
  85001. /**
  85002. * Binds the material to the mesh
  85003. * @param world defines the world transformation matrix
  85004. * @param mesh defines the mesh to bind the material to
  85005. */
  85006. bind(world: Matrix, mesh?: Mesh): void;
  85007. /**
  85008. * Gets the active textures from the material
  85009. * @returns an array of textures
  85010. */
  85011. getActiveTextures(): BaseTexture[];
  85012. /**
  85013. * Specifies if the material uses a texture
  85014. * @param texture defines the texture to check against the material
  85015. * @returns a boolean specifying if the material uses the texture
  85016. */
  85017. hasTexture(texture: BaseTexture): boolean;
  85018. /**
  85019. * Makes a duplicate of the material, and gives it a new name
  85020. * @param name defines the new name for the duplicated material
  85021. * @returns the cloned material
  85022. */
  85023. clone(name: string): ShaderMaterial;
  85024. /**
  85025. * Disposes the material
  85026. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85027. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85028. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85029. */
  85030. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85031. /**
  85032. * Serializes this material in a JSON representation
  85033. * @returns the serialized material object
  85034. */
  85035. serialize(): any;
  85036. /**
  85037. * Creates a shader material from parsed shader material data
  85038. * @param source defines the JSON represnetation of the material
  85039. * @param scene defines the hosting scene
  85040. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  85041. * @returns a new material
  85042. */
  85043. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  85044. }
  85045. }
  85046. declare module BABYLON {
  85047. /** @hidden */
  85048. export var colorPixelShader: {
  85049. name: string;
  85050. shader: string;
  85051. };
  85052. }
  85053. declare module BABYLON {
  85054. /** @hidden */
  85055. export var colorVertexShader: {
  85056. name: string;
  85057. shader: string;
  85058. };
  85059. }
  85060. declare module BABYLON {
  85061. /**
  85062. * Line mesh
  85063. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  85064. */
  85065. export class LinesMesh extends Mesh {
  85066. /**
  85067. * If vertex color should be applied to the mesh
  85068. */
  85069. readonly useVertexColor?: boolean | undefined;
  85070. /**
  85071. * If vertex alpha should be applied to the mesh
  85072. */
  85073. readonly useVertexAlpha?: boolean | undefined;
  85074. /**
  85075. * Color of the line (Default: White)
  85076. */
  85077. color: Color3;
  85078. /**
  85079. * Alpha of the line (Default: 1)
  85080. */
  85081. alpha: number;
  85082. /**
  85083. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  85084. * This margin is expressed in world space coordinates, so its value may vary.
  85085. * Default value is 0.1
  85086. */
  85087. intersectionThreshold: number;
  85088. private _colorShader;
  85089. private color4;
  85090. /**
  85091. * Creates a new LinesMesh
  85092. * @param name defines the name
  85093. * @param scene defines the hosting scene
  85094. * @param parent defines the parent mesh if any
  85095. * @param source defines the optional source LinesMesh used to clone data from
  85096. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  85097. * When false, achieved by calling a clone(), also passing False.
  85098. * This will make creation of children, recursive.
  85099. * @param useVertexColor defines if this LinesMesh supports vertex color
  85100. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  85101. */
  85102. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  85103. /**
  85104. * If vertex color should be applied to the mesh
  85105. */
  85106. useVertexColor?: boolean | undefined,
  85107. /**
  85108. * If vertex alpha should be applied to the mesh
  85109. */
  85110. useVertexAlpha?: boolean | undefined);
  85111. private _addClipPlaneDefine;
  85112. private _removeClipPlaneDefine;
  85113. isReady(): boolean;
  85114. /**
  85115. * Returns the string "LineMesh"
  85116. */
  85117. getClassName(): string;
  85118. /**
  85119. * @hidden
  85120. */
  85121. /**
  85122. * @hidden
  85123. */
  85124. material: Material;
  85125. /**
  85126. * @hidden
  85127. */
  85128. readonly checkCollisions: boolean;
  85129. /** @hidden */
  85130. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  85131. /** @hidden */
  85132. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  85133. /**
  85134. * Disposes of the line mesh
  85135. * @param doNotRecurse If children should be disposed
  85136. */
  85137. dispose(doNotRecurse?: boolean): void;
  85138. /**
  85139. * Returns a new LineMesh object cloned from the current one.
  85140. */
  85141. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85142. /**
  85143. * Creates a new InstancedLinesMesh object from the mesh model.
  85144. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  85145. * @param name defines the name of the new instance
  85146. * @returns a new InstancedLinesMesh
  85147. */
  85148. createInstance(name: string): InstancedLinesMesh;
  85149. }
  85150. /**
  85151. * Creates an instance based on a source LinesMesh
  85152. */
  85153. export class InstancedLinesMesh extends InstancedMesh {
  85154. /**
  85155. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  85156. * This margin is expressed in world space coordinates, so its value may vary.
  85157. * Initilized with the intersectionThreshold value of the source LinesMesh
  85158. */
  85159. intersectionThreshold: number;
  85160. constructor(name: string, source: LinesMesh);
  85161. /**
  85162. * Returns the string "InstancedLinesMesh".
  85163. */
  85164. getClassName(): string;
  85165. }
  85166. }
  85167. declare module BABYLON {
  85168. /** @hidden */
  85169. export var linePixelShader: {
  85170. name: string;
  85171. shader: string;
  85172. };
  85173. }
  85174. declare module BABYLON {
  85175. /** @hidden */
  85176. export var lineVertexShader: {
  85177. name: string;
  85178. shader: string;
  85179. };
  85180. }
  85181. declare module BABYLON {
  85182. interface AbstractMesh {
  85183. /**
  85184. * Gets the edgesRenderer associated with the mesh
  85185. */
  85186. edgesRenderer: Nullable<EdgesRenderer>;
  85187. }
  85188. interface LinesMesh {
  85189. /**
  85190. * Enables the edge rendering mode on the mesh.
  85191. * This mode makes the mesh edges visible
  85192. * @param epsilon defines the maximal distance between two angles to detect a face
  85193. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85194. * @returns the currentAbstractMesh
  85195. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85196. */
  85197. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  85198. }
  85199. interface InstancedLinesMesh {
  85200. /**
  85201. * Enables the edge rendering mode on the mesh.
  85202. * This mode makes the mesh edges visible
  85203. * @param epsilon defines the maximal distance between two angles to detect a face
  85204. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  85205. * @returns the current InstancedLinesMesh
  85206. * @see https://www.babylonjs-playground.com/#19O9TU#0
  85207. */
  85208. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  85209. }
  85210. /**
  85211. * Defines the minimum contract an Edges renderer should follow.
  85212. */
  85213. export interface IEdgesRenderer extends IDisposable {
  85214. /**
  85215. * Gets or sets a boolean indicating if the edgesRenderer is active
  85216. */
  85217. isEnabled: boolean;
  85218. /**
  85219. * Renders the edges of the attached mesh,
  85220. */
  85221. render(): void;
  85222. /**
  85223. * Checks wether or not the edges renderer is ready to render.
  85224. * @return true if ready, otherwise false.
  85225. */
  85226. isReady(): boolean;
  85227. }
  85228. /**
  85229. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  85230. */
  85231. export class EdgesRenderer implements IEdgesRenderer {
  85232. /**
  85233. * Define the size of the edges with an orthographic camera
  85234. */
  85235. edgesWidthScalerForOrthographic: number;
  85236. /**
  85237. * Define the size of the edges with a perspective camera
  85238. */
  85239. edgesWidthScalerForPerspective: number;
  85240. protected _source: AbstractMesh;
  85241. protected _linesPositions: number[];
  85242. protected _linesNormals: number[];
  85243. protected _linesIndices: number[];
  85244. protected _epsilon: number;
  85245. protected _indicesCount: number;
  85246. protected _lineShader: ShaderMaterial;
  85247. protected _ib: DataBuffer;
  85248. protected _buffers: {
  85249. [key: string]: Nullable<VertexBuffer>;
  85250. };
  85251. protected _checkVerticesInsteadOfIndices: boolean;
  85252. private _meshRebuildObserver;
  85253. private _meshDisposeObserver;
  85254. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  85255. isEnabled: boolean;
  85256. /**
  85257. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  85258. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  85259. * @param source Mesh used to create edges
  85260. * @param epsilon sum of angles in adjacency to check for edge
  85261. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  85262. * @param generateEdgesLines - should generate Lines or only prepare resources.
  85263. */
  85264. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  85265. protected _prepareRessources(): void;
  85266. /** @hidden */
  85267. _rebuild(): void;
  85268. /**
  85269. * Releases the required resources for the edges renderer
  85270. */
  85271. dispose(): void;
  85272. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  85273. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  85274. /**
  85275. * Checks if the pair of p0 and p1 is en edge
  85276. * @param faceIndex
  85277. * @param edge
  85278. * @param faceNormals
  85279. * @param p0
  85280. * @param p1
  85281. * @private
  85282. */
  85283. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  85284. /**
  85285. * push line into the position, normal and index buffer
  85286. * @protected
  85287. */
  85288. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  85289. /**
  85290. * Generates lines edges from adjacencjes
  85291. * @private
  85292. */
  85293. _generateEdgesLines(): void;
  85294. /**
  85295. * Checks wether or not the edges renderer is ready to render.
  85296. * @return true if ready, otherwise false.
  85297. */
  85298. isReady(): boolean;
  85299. /**
  85300. * Renders the edges of the attached mesh,
  85301. */
  85302. render(): void;
  85303. }
  85304. /**
  85305. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  85306. */
  85307. export class LineEdgesRenderer extends EdgesRenderer {
  85308. /**
  85309. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  85310. * @param source LineMesh used to generate edges
  85311. * @param epsilon not important (specified angle for edge detection)
  85312. * @param checkVerticesInsteadOfIndices not important for LineMesh
  85313. */
  85314. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  85315. /**
  85316. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  85317. */
  85318. _generateEdgesLines(): void;
  85319. }
  85320. }
  85321. declare module BABYLON {
  85322. /**
  85323. * This represents the object necessary to create a rendering group.
  85324. * This is exclusively used and created by the rendering manager.
  85325. * To modify the behavior, you use the available helpers in your scene or meshes.
  85326. * @hidden
  85327. */
  85328. export class RenderingGroup {
  85329. index: number;
  85330. private static _zeroVector;
  85331. private _scene;
  85332. private _opaqueSubMeshes;
  85333. private _transparentSubMeshes;
  85334. private _alphaTestSubMeshes;
  85335. private _depthOnlySubMeshes;
  85336. private _particleSystems;
  85337. private _spriteManagers;
  85338. private _opaqueSortCompareFn;
  85339. private _alphaTestSortCompareFn;
  85340. private _transparentSortCompareFn;
  85341. private _renderOpaque;
  85342. private _renderAlphaTest;
  85343. private _renderTransparent;
  85344. /** @hidden */
  85345. _edgesRenderers: SmartArray<IEdgesRenderer>;
  85346. onBeforeTransparentRendering: () => void;
  85347. /**
  85348. * Set the opaque sort comparison function.
  85349. * If null the sub meshes will be render in the order they were created
  85350. */
  85351. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85352. /**
  85353. * Set the alpha test sort comparison function.
  85354. * If null the sub meshes will be render in the order they were created
  85355. */
  85356. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85357. /**
  85358. * Set the transparent sort comparison function.
  85359. * If null the sub meshes will be render in the order they were created
  85360. */
  85361. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  85362. /**
  85363. * Creates a new rendering group.
  85364. * @param index The rendering group index
  85365. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  85366. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  85367. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  85368. */
  85369. 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>);
  85370. /**
  85371. * Render all the sub meshes contained in the group.
  85372. * @param customRenderFunction Used to override the default render behaviour of the group.
  85373. * @returns true if rendered some submeshes.
  85374. */
  85375. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  85376. /**
  85377. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  85378. * @param subMeshes The submeshes to render
  85379. */
  85380. private renderOpaqueSorted;
  85381. /**
  85382. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  85383. * @param subMeshes The submeshes to render
  85384. */
  85385. private renderAlphaTestSorted;
  85386. /**
  85387. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  85388. * @param subMeshes The submeshes to render
  85389. */
  85390. private renderTransparentSorted;
  85391. /**
  85392. * Renders the submeshes in a specified order.
  85393. * @param subMeshes The submeshes to sort before render
  85394. * @param sortCompareFn The comparison function use to sort
  85395. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  85396. * @param transparent Specifies to activate blending if true
  85397. */
  85398. private static renderSorted;
  85399. /**
  85400. * Renders the submeshes in the order they were dispatched (no sort applied).
  85401. * @param subMeshes The submeshes to render
  85402. */
  85403. private static renderUnsorted;
  85404. /**
  85405. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85406. * are rendered back to front if in the same alpha index.
  85407. *
  85408. * @param a The first submesh
  85409. * @param b The second submesh
  85410. * @returns The result of the comparison
  85411. */
  85412. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  85413. /**
  85414. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85415. * are rendered back to front.
  85416. *
  85417. * @param a The first submesh
  85418. * @param b The second submesh
  85419. * @returns The result of the comparison
  85420. */
  85421. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  85422. /**
  85423. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  85424. * are rendered front to back (prevent overdraw).
  85425. *
  85426. * @param a The first submesh
  85427. * @param b The second submesh
  85428. * @returns The result of the comparison
  85429. */
  85430. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  85431. /**
  85432. * Resets the different lists of submeshes to prepare a new frame.
  85433. */
  85434. prepare(): void;
  85435. dispose(): void;
  85436. /**
  85437. * Inserts the submesh in its correct queue depending on its material.
  85438. * @param subMesh The submesh to dispatch
  85439. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85440. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85441. */
  85442. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85443. dispatchSprites(spriteManager: ISpriteManager): void;
  85444. dispatchParticles(particleSystem: IParticleSystem): void;
  85445. private _renderParticles;
  85446. private _renderSprites;
  85447. }
  85448. }
  85449. declare module BABYLON {
  85450. /**
  85451. * Interface describing the different options available in the rendering manager
  85452. * regarding Auto Clear between groups.
  85453. */
  85454. export interface IRenderingManagerAutoClearSetup {
  85455. /**
  85456. * Defines whether or not autoclear is enable.
  85457. */
  85458. autoClear: boolean;
  85459. /**
  85460. * Defines whether or not to autoclear the depth buffer.
  85461. */
  85462. depth: boolean;
  85463. /**
  85464. * Defines whether or not to autoclear the stencil buffer.
  85465. */
  85466. stencil: boolean;
  85467. }
  85468. /**
  85469. * This class is used by the onRenderingGroupObservable
  85470. */
  85471. export class RenderingGroupInfo {
  85472. /**
  85473. * The Scene that being rendered
  85474. */
  85475. scene: Scene;
  85476. /**
  85477. * The camera currently used for the rendering pass
  85478. */
  85479. camera: Nullable<Camera>;
  85480. /**
  85481. * The ID of the renderingGroup being processed
  85482. */
  85483. renderingGroupId: number;
  85484. }
  85485. /**
  85486. * This is the manager responsible of all the rendering for meshes sprites and particles.
  85487. * It is enable to manage the different groups as well as the different necessary sort functions.
  85488. * This should not be used directly aside of the few static configurations
  85489. */
  85490. export class RenderingManager {
  85491. /**
  85492. * The max id used for rendering groups (not included)
  85493. */
  85494. static MAX_RENDERINGGROUPS: number;
  85495. /**
  85496. * The min id used for rendering groups (included)
  85497. */
  85498. static MIN_RENDERINGGROUPS: number;
  85499. /**
  85500. * Used to globally prevent autoclearing scenes.
  85501. */
  85502. static AUTOCLEAR: boolean;
  85503. /**
  85504. * @hidden
  85505. */
  85506. _useSceneAutoClearSetup: boolean;
  85507. private _scene;
  85508. private _renderingGroups;
  85509. private _depthStencilBufferAlreadyCleaned;
  85510. private _autoClearDepthStencil;
  85511. private _customOpaqueSortCompareFn;
  85512. private _customAlphaTestSortCompareFn;
  85513. private _customTransparentSortCompareFn;
  85514. private _renderingGroupInfo;
  85515. /**
  85516. * Instantiates a new rendering group for a particular scene
  85517. * @param scene Defines the scene the groups belongs to
  85518. */
  85519. constructor(scene: Scene);
  85520. private _clearDepthStencilBuffer;
  85521. /**
  85522. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  85523. * @hidden
  85524. */
  85525. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  85526. /**
  85527. * Resets the different information of the group to prepare a new frame
  85528. * @hidden
  85529. */
  85530. reset(): void;
  85531. /**
  85532. * Dispose and release the group and its associated resources.
  85533. * @hidden
  85534. */
  85535. dispose(): void;
  85536. /**
  85537. * Clear the info related to rendering groups preventing retention points during dispose.
  85538. */
  85539. freeRenderingGroups(): void;
  85540. private _prepareRenderingGroup;
  85541. /**
  85542. * Add a sprite manager to the rendering manager in order to render it this frame.
  85543. * @param spriteManager Define the sprite manager to render
  85544. */
  85545. dispatchSprites(spriteManager: ISpriteManager): void;
  85546. /**
  85547. * Add a particle system to the rendering manager in order to render it this frame.
  85548. * @param particleSystem Define the particle system to render
  85549. */
  85550. dispatchParticles(particleSystem: IParticleSystem): void;
  85551. /**
  85552. * Add a submesh to the manager in order to render it this frame
  85553. * @param subMesh The submesh to dispatch
  85554. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  85555. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  85556. */
  85557. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  85558. /**
  85559. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85560. * This allowed control for front to back rendering or reversly depending of the special needs.
  85561. *
  85562. * @param renderingGroupId The rendering group id corresponding to its index
  85563. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85564. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85565. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85566. */
  85567. 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;
  85568. /**
  85569. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85570. *
  85571. * @param renderingGroupId The rendering group id corresponding to its index
  85572. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85573. * @param depth Automatically clears depth between groups if true and autoClear is true.
  85574. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  85575. */
  85576. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  85577. /**
  85578. * Gets the current auto clear configuration for one rendering group of the rendering
  85579. * manager.
  85580. * @param index the rendering group index to get the information for
  85581. * @returns The auto clear setup for the requested rendering group
  85582. */
  85583. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  85584. }
  85585. }
  85586. declare module BABYLON {
  85587. /**
  85588. * This Helps creating a texture that will be created from a camera in your scene.
  85589. * It is basically a dynamic texture that could be used to create special effects for instance.
  85590. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  85591. */
  85592. export class RenderTargetTexture extends Texture {
  85593. isCube: boolean;
  85594. /**
  85595. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  85596. */
  85597. static readonly REFRESHRATE_RENDER_ONCE: number;
  85598. /**
  85599. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  85600. */
  85601. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  85602. /**
  85603. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  85604. * the central point of your effect and can save a lot of performances.
  85605. */
  85606. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  85607. /**
  85608. * Use this predicate to dynamically define the list of mesh you want to render.
  85609. * If set, the renderList property will be overwritten.
  85610. */
  85611. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  85612. private _renderList;
  85613. /**
  85614. * Use this list to define the list of mesh you want to render.
  85615. */
  85616. renderList: Nullable<Array<AbstractMesh>>;
  85617. private _hookArray;
  85618. /**
  85619. * Define if particles should be rendered in your texture.
  85620. */
  85621. renderParticles: boolean;
  85622. /**
  85623. * Define if sprites should be rendered in your texture.
  85624. */
  85625. renderSprites: boolean;
  85626. /**
  85627. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  85628. */
  85629. coordinatesMode: number;
  85630. /**
  85631. * Define the camera used to render the texture.
  85632. */
  85633. activeCamera: Nullable<Camera>;
  85634. /**
  85635. * Override the render function of the texture with your own one.
  85636. */
  85637. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  85638. /**
  85639. * Define if camera post processes should be use while rendering the texture.
  85640. */
  85641. useCameraPostProcesses: boolean;
  85642. /**
  85643. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  85644. */
  85645. ignoreCameraViewport: boolean;
  85646. private _postProcessManager;
  85647. private _postProcesses;
  85648. private _resizeObserver;
  85649. /**
  85650. * An event triggered when the texture is unbind.
  85651. */
  85652. onBeforeBindObservable: Observable<RenderTargetTexture>;
  85653. /**
  85654. * An event triggered when the texture is unbind.
  85655. */
  85656. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  85657. private _onAfterUnbindObserver;
  85658. /**
  85659. * Set a after unbind callback in the texture.
  85660. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  85661. */
  85662. onAfterUnbind: () => void;
  85663. /**
  85664. * An event triggered before rendering the texture
  85665. */
  85666. onBeforeRenderObservable: Observable<number>;
  85667. private _onBeforeRenderObserver;
  85668. /**
  85669. * Set a before render callback in the texture.
  85670. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  85671. */
  85672. onBeforeRender: (faceIndex: number) => void;
  85673. /**
  85674. * An event triggered after rendering the texture
  85675. */
  85676. onAfterRenderObservable: Observable<number>;
  85677. private _onAfterRenderObserver;
  85678. /**
  85679. * Set a after render callback in the texture.
  85680. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  85681. */
  85682. onAfterRender: (faceIndex: number) => void;
  85683. /**
  85684. * An event triggered after the texture clear
  85685. */
  85686. onClearObservable: Observable<Engine>;
  85687. private _onClearObserver;
  85688. /**
  85689. * Set a clear callback in the texture.
  85690. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  85691. */
  85692. onClear: (Engine: Engine) => void;
  85693. /**
  85694. * An event triggered when the texture is resized.
  85695. */
  85696. onResizeObservable: Observable<RenderTargetTexture>;
  85697. /**
  85698. * Define the clear color of the Render Target if it should be different from the scene.
  85699. */
  85700. clearColor: Color4;
  85701. protected _size: number | {
  85702. width: number;
  85703. height: number;
  85704. };
  85705. protected _initialSizeParameter: number | {
  85706. width: number;
  85707. height: number;
  85708. } | {
  85709. ratio: number;
  85710. };
  85711. protected _sizeRatio: Nullable<number>;
  85712. /** @hidden */
  85713. _generateMipMaps: boolean;
  85714. protected _renderingManager: RenderingManager;
  85715. /** @hidden */
  85716. _waitingRenderList: string[];
  85717. protected _doNotChangeAspectRatio: boolean;
  85718. protected _currentRefreshId: number;
  85719. protected _refreshRate: number;
  85720. protected _textureMatrix: Matrix;
  85721. protected _samples: number;
  85722. protected _renderTargetOptions: RenderTargetCreationOptions;
  85723. /**
  85724. * Gets render target creation options that were used.
  85725. */
  85726. readonly renderTargetOptions: RenderTargetCreationOptions;
  85727. protected _engine: Engine;
  85728. protected _onRatioRescale(): void;
  85729. /**
  85730. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  85731. * It must define where the camera used to render the texture is set
  85732. */
  85733. boundingBoxPosition: Vector3;
  85734. private _boundingBoxSize;
  85735. /**
  85736. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  85737. * When defined, the cubemap will switch to local mode
  85738. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  85739. * @example https://www.babylonjs-playground.com/#RNASML
  85740. */
  85741. boundingBoxSize: Vector3;
  85742. /**
  85743. * In case the RTT has been created with a depth texture, get the associated
  85744. * depth texture.
  85745. * Otherwise, return null.
  85746. */
  85747. depthStencilTexture: Nullable<InternalTexture>;
  85748. /**
  85749. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  85750. * or used a shadow, depth texture...
  85751. * @param name The friendly name of the texture
  85752. * @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)
  85753. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  85754. * @param generateMipMaps True if mip maps need to be generated after render.
  85755. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  85756. * @param type The type of the buffer in the RTT (int, half float, float...)
  85757. * @param isCube True if a cube texture needs to be created
  85758. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  85759. * @param generateDepthBuffer True to generate a depth buffer
  85760. * @param generateStencilBuffer True to generate a stencil buffer
  85761. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  85762. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  85763. * @param delayAllocation if the texture allocation should be delayed (default: false)
  85764. */
  85765. constructor(name: string, size: number | {
  85766. width: number;
  85767. height: number;
  85768. } | {
  85769. ratio: number;
  85770. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  85771. /**
  85772. * Creates a depth stencil texture.
  85773. * This is only available in WebGL 2 or with the depth texture extension available.
  85774. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  85775. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  85776. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  85777. */
  85778. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  85779. private _processSizeParameter;
  85780. /**
  85781. * Define the number of samples to use in case of MSAA.
  85782. * It defaults to one meaning no MSAA has been enabled.
  85783. */
  85784. samples: number;
  85785. /**
  85786. * Resets the refresh counter of the texture and start bak from scratch.
  85787. * Could be useful to regenerate the texture if it is setup to render only once.
  85788. */
  85789. resetRefreshCounter(): void;
  85790. /**
  85791. * Define the refresh rate of the texture or the rendering frequency.
  85792. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85793. */
  85794. refreshRate: number;
  85795. /**
  85796. * Adds a post process to the render target rendering passes.
  85797. * @param postProcess define the post process to add
  85798. */
  85799. addPostProcess(postProcess: PostProcess): void;
  85800. /**
  85801. * Clear all the post processes attached to the render target
  85802. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  85803. */
  85804. clearPostProcesses(dispose?: boolean): void;
  85805. /**
  85806. * Remove one of the post process from the list of attached post processes to the texture
  85807. * @param postProcess define the post process to remove from the list
  85808. */
  85809. removePostProcess(postProcess: PostProcess): void;
  85810. /** @hidden */
  85811. _shouldRender(): boolean;
  85812. /**
  85813. * Gets the actual render size of the texture.
  85814. * @returns the width of the render size
  85815. */
  85816. getRenderSize(): number;
  85817. /**
  85818. * Gets the actual render width of the texture.
  85819. * @returns the width of the render size
  85820. */
  85821. getRenderWidth(): number;
  85822. /**
  85823. * Gets the actual render height of the texture.
  85824. * @returns the height of the render size
  85825. */
  85826. getRenderHeight(): number;
  85827. /**
  85828. * Get if the texture can be rescaled or not.
  85829. */
  85830. readonly canRescale: boolean;
  85831. /**
  85832. * Resize the texture using a ratio.
  85833. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  85834. */
  85835. scale(ratio: number): void;
  85836. /**
  85837. * Get the texture reflection matrix used to rotate/transform the reflection.
  85838. * @returns the reflection matrix
  85839. */
  85840. getReflectionTextureMatrix(): Matrix;
  85841. /**
  85842. * Resize the texture to a new desired size.
  85843. * Be carrefull as it will recreate all the data in the new texture.
  85844. * @param size Define the new size. It can be:
  85845. * - a number for squared texture,
  85846. * - an object containing { width: number, height: number }
  85847. * - or an object containing a ratio { ratio: number }
  85848. */
  85849. resize(size: number | {
  85850. width: number;
  85851. height: number;
  85852. } | {
  85853. ratio: number;
  85854. }): void;
  85855. /**
  85856. * Renders all the objects from the render list into the texture.
  85857. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  85858. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  85859. */
  85860. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  85861. private _bestReflectionRenderTargetDimension;
  85862. /**
  85863. * @hidden
  85864. * @param faceIndex face index to bind to if this is a cubetexture
  85865. */
  85866. _bindFrameBuffer(faceIndex?: number): void;
  85867. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85868. private renderToTarget;
  85869. /**
  85870. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  85871. * This allowed control for front to back rendering or reversly depending of the special needs.
  85872. *
  85873. * @param renderingGroupId The rendering group id corresponding to its index
  85874. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  85875. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  85876. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  85877. */
  85878. 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;
  85879. /**
  85880. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  85881. *
  85882. * @param renderingGroupId The rendering group id corresponding to its index
  85883. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  85884. */
  85885. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  85886. /**
  85887. * Clones the texture.
  85888. * @returns the cloned texture
  85889. */
  85890. clone(): RenderTargetTexture;
  85891. /**
  85892. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  85893. * @returns The JSON representation of the texture
  85894. */
  85895. serialize(): any;
  85896. /**
  85897. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  85898. */
  85899. disposeFramebufferObjects(): void;
  85900. /**
  85901. * Dispose the texture and release its associated resources.
  85902. */
  85903. dispose(): void;
  85904. /** @hidden */
  85905. _rebuild(): void;
  85906. /**
  85907. * Clear the info related to rendering groups preventing retention point in material dispose.
  85908. */
  85909. freeRenderingGroups(): void;
  85910. /**
  85911. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  85912. * @returns the view count
  85913. */
  85914. getViewCount(): number;
  85915. }
  85916. }
  85917. declare module BABYLON {
  85918. /**
  85919. * Base class for the main features of a material in Babylon.js
  85920. */
  85921. export class Material implements IAnimatable {
  85922. /**
  85923. * Returns the triangle fill mode
  85924. */
  85925. static readonly TriangleFillMode: number;
  85926. /**
  85927. * Returns the wireframe mode
  85928. */
  85929. static readonly WireFrameFillMode: number;
  85930. /**
  85931. * Returns the point fill mode
  85932. */
  85933. static readonly PointFillMode: number;
  85934. /**
  85935. * Returns the point list draw mode
  85936. */
  85937. static readonly PointListDrawMode: number;
  85938. /**
  85939. * Returns the line list draw mode
  85940. */
  85941. static readonly LineListDrawMode: number;
  85942. /**
  85943. * Returns the line loop draw mode
  85944. */
  85945. static readonly LineLoopDrawMode: number;
  85946. /**
  85947. * Returns the line strip draw mode
  85948. */
  85949. static readonly LineStripDrawMode: number;
  85950. /**
  85951. * Returns the triangle strip draw mode
  85952. */
  85953. static readonly TriangleStripDrawMode: number;
  85954. /**
  85955. * Returns the triangle fan draw mode
  85956. */
  85957. static readonly TriangleFanDrawMode: number;
  85958. /**
  85959. * Stores the clock-wise side orientation
  85960. */
  85961. static readonly ClockWiseSideOrientation: number;
  85962. /**
  85963. * Stores the counter clock-wise side orientation
  85964. */
  85965. static readonly CounterClockWiseSideOrientation: number;
  85966. /**
  85967. * The dirty texture flag value
  85968. */
  85969. static readonly TextureDirtyFlag: number;
  85970. /**
  85971. * The dirty light flag value
  85972. */
  85973. static readonly LightDirtyFlag: number;
  85974. /**
  85975. * The dirty fresnel flag value
  85976. */
  85977. static readonly FresnelDirtyFlag: number;
  85978. /**
  85979. * The dirty attribute flag value
  85980. */
  85981. static readonly AttributesDirtyFlag: number;
  85982. /**
  85983. * The dirty misc flag value
  85984. */
  85985. static readonly MiscDirtyFlag: number;
  85986. /**
  85987. * The all dirty flag value
  85988. */
  85989. static readonly AllDirtyFlag: number;
  85990. /**
  85991. * The ID of the material
  85992. */
  85993. id: string;
  85994. /**
  85995. * Gets or sets the unique id of the material
  85996. */
  85997. uniqueId: number;
  85998. /**
  85999. * The name of the material
  86000. */
  86001. name: string;
  86002. /**
  86003. * Gets or sets user defined metadata
  86004. */
  86005. metadata: any;
  86006. /**
  86007. * For internal use only. Please do not use.
  86008. */
  86009. reservedDataStore: any;
  86010. /**
  86011. * Specifies if the ready state should be checked on each call
  86012. */
  86013. checkReadyOnEveryCall: boolean;
  86014. /**
  86015. * Specifies if the ready state should be checked once
  86016. */
  86017. checkReadyOnlyOnce: boolean;
  86018. /**
  86019. * The state of the material
  86020. */
  86021. state: string;
  86022. /**
  86023. * The alpha value of the material
  86024. */
  86025. protected _alpha: number;
  86026. /**
  86027. * List of inspectable custom properties (used by the Inspector)
  86028. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86029. */
  86030. inspectableCustomProperties: IInspectable[];
  86031. /**
  86032. * Sets the alpha value of the material
  86033. */
  86034. /**
  86035. * Gets the alpha value of the material
  86036. */
  86037. alpha: number;
  86038. /**
  86039. * Specifies if back face culling is enabled
  86040. */
  86041. protected _backFaceCulling: boolean;
  86042. /**
  86043. * Sets the back-face culling state
  86044. */
  86045. /**
  86046. * Gets the back-face culling state
  86047. */
  86048. backFaceCulling: boolean;
  86049. /**
  86050. * Stores the value for side orientation
  86051. */
  86052. sideOrientation: number;
  86053. /**
  86054. * Callback triggered when the material is compiled
  86055. */
  86056. onCompiled: Nullable<(effect: Effect) => void>;
  86057. /**
  86058. * Callback triggered when an error occurs
  86059. */
  86060. onError: Nullable<(effect: Effect, errors: string) => void>;
  86061. /**
  86062. * Callback triggered to get the render target textures
  86063. */
  86064. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  86065. /**
  86066. * Gets a boolean indicating that current material needs to register RTT
  86067. */
  86068. readonly hasRenderTargetTextures: boolean;
  86069. /**
  86070. * Specifies if the material should be serialized
  86071. */
  86072. doNotSerialize: boolean;
  86073. /**
  86074. * @hidden
  86075. */
  86076. _storeEffectOnSubMeshes: boolean;
  86077. /**
  86078. * Stores the animations for the material
  86079. */
  86080. animations: Nullable<Array<Animation>>;
  86081. /**
  86082. * An event triggered when the material is disposed
  86083. */
  86084. onDisposeObservable: Observable<Material>;
  86085. /**
  86086. * An observer which watches for dispose events
  86087. */
  86088. private _onDisposeObserver;
  86089. private _onUnBindObservable;
  86090. /**
  86091. * Called during a dispose event
  86092. */
  86093. onDispose: () => void;
  86094. private _onBindObservable;
  86095. /**
  86096. * An event triggered when the material is bound
  86097. */
  86098. readonly onBindObservable: Observable<AbstractMesh>;
  86099. /**
  86100. * An observer which watches for bind events
  86101. */
  86102. private _onBindObserver;
  86103. /**
  86104. * Called during a bind event
  86105. */
  86106. onBind: (Mesh: AbstractMesh) => void;
  86107. /**
  86108. * An event triggered when the material is unbound
  86109. */
  86110. readonly onUnBindObservable: Observable<Material>;
  86111. /**
  86112. * Stores the value of the alpha mode
  86113. */
  86114. private _alphaMode;
  86115. /**
  86116. * Sets the value of the alpha mode.
  86117. *
  86118. * | Value | Type | Description |
  86119. * | --- | --- | --- |
  86120. * | 0 | ALPHA_DISABLE | |
  86121. * | 1 | ALPHA_ADD | |
  86122. * | 2 | ALPHA_COMBINE | |
  86123. * | 3 | ALPHA_SUBTRACT | |
  86124. * | 4 | ALPHA_MULTIPLY | |
  86125. * | 5 | ALPHA_MAXIMIZED | |
  86126. * | 6 | ALPHA_ONEONE | |
  86127. * | 7 | ALPHA_PREMULTIPLIED | |
  86128. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  86129. * | 9 | ALPHA_INTERPOLATE | |
  86130. * | 10 | ALPHA_SCREENMODE | |
  86131. *
  86132. */
  86133. /**
  86134. * Gets the value of the alpha mode
  86135. */
  86136. alphaMode: number;
  86137. /**
  86138. * Stores the state of the need depth pre-pass value
  86139. */
  86140. private _needDepthPrePass;
  86141. /**
  86142. * Sets the need depth pre-pass value
  86143. */
  86144. /**
  86145. * Gets the depth pre-pass value
  86146. */
  86147. needDepthPrePass: boolean;
  86148. /**
  86149. * Specifies if depth writing should be disabled
  86150. */
  86151. disableDepthWrite: boolean;
  86152. /**
  86153. * Specifies if depth writing should be forced
  86154. */
  86155. forceDepthWrite: boolean;
  86156. /**
  86157. * Specifies if there should be a separate pass for culling
  86158. */
  86159. separateCullingPass: boolean;
  86160. /**
  86161. * Stores the state specifing if fog should be enabled
  86162. */
  86163. private _fogEnabled;
  86164. /**
  86165. * Sets the state for enabling fog
  86166. */
  86167. /**
  86168. * Gets the value of the fog enabled state
  86169. */
  86170. fogEnabled: boolean;
  86171. /**
  86172. * Stores the size of points
  86173. */
  86174. pointSize: number;
  86175. /**
  86176. * Stores the z offset value
  86177. */
  86178. zOffset: number;
  86179. /**
  86180. * Gets a value specifying if wireframe mode is enabled
  86181. */
  86182. /**
  86183. * Sets the state of wireframe mode
  86184. */
  86185. wireframe: boolean;
  86186. /**
  86187. * Gets the value specifying if point clouds are enabled
  86188. */
  86189. /**
  86190. * Sets the state of point cloud mode
  86191. */
  86192. pointsCloud: boolean;
  86193. /**
  86194. * Gets the material fill mode
  86195. */
  86196. /**
  86197. * Sets the material fill mode
  86198. */
  86199. fillMode: number;
  86200. /**
  86201. * @hidden
  86202. * Stores the effects for the material
  86203. */
  86204. _effect: Nullable<Effect>;
  86205. /**
  86206. * @hidden
  86207. * Specifies if the material was previously ready
  86208. */
  86209. _wasPreviouslyReady: boolean;
  86210. /**
  86211. * Specifies if uniform buffers should be used
  86212. */
  86213. private _useUBO;
  86214. /**
  86215. * Stores a reference to the scene
  86216. */
  86217. private _scene;
  86218. /**
  86219. * Stores the fill mode state
  86220. */
  86221. private _fillMode;
  86222. /**
  86223. * Specifies if the depth write state should be cached
  86224. */
  86225. private _cachedDepthWriteState;
  86226. /**
  86227. * Stores the uniform buffer
  86228. */
  86229. protected _uniformBuffer: UniformBuffer;
  86230. /** @hidden */
  86231. _indexInSceneMaterialArray: number;
  86232. /** @hidden */
  86233. meshMap: Nullable<{
  86234. [id: string]: AbstractMesh | undefined;
  86235. }>;
  86236. /**
  86237. * Creates a material instance
  86238. * @param name defines the name of the material
  86239. * @param scene defines the scene to reference
  86240. * @param doNotAdd specifies if the material should be added to the scene
  86241. */
  86242. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  86243. /**
  86244. * Returns a string representation of the current material
  86245. * @param fullDetails defines a boolean indicating which levels of logging is desired
  86246. * @returns a string with material information
  86247. */
  86248. toString(fullDetails?: boolean): string;
  86249. /**
  86250. * Gets the class name of the material
  86251. * @returns a string with the class name of the material
  86252. */
  86253. getClassName(): string;
  86254. /**
  86255. * Specifies if updates for the material been locked
  86256. */
  86257. readonly isFrozen: boolean;
  86258. /**
  86259. * Locks updates for the material
  86260. */
  86261. freeze(): void;
  86262. /**
  86263. * Unlocks updates for the material
  86264. */
  86265. unfreeze(): void;
  86266. /**
  86267. * Specifies if the material is ready to be used
  86268. * @param mesh defines the mesh to check
  86269. * @param useInstances specifies if instances should be used
  86270. * @returns a boolean indicating if the material is ready to be used
  86271. */
  86272. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86273. /**
  86274. * Specifies that the submesh is ready to be used
  86275. * @param mesh defines the mesh to check
  86276. * @param subMesh defines which submesh to check
  86277. * @param useInstances specifies that instances should be used
  86278. * @returns a boolean indicating that the submesh is ready or not
  86279. */
  86280. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86281. /**
  86282. * Returns the material effect
  86283. * @returns the effect associated with the material
  86284. */
  86285. getEffect(): Nullable<Effect>;
  86286. /**
  86287. * Returns the current scene
  86288. * @returns a Scene
  86289. */
  86290. getScene(): Scene;
  86291. /**
  86292. * Specifies if the material will require alpha blending
  86293. * @returns a boolean specifying if alpha blending is needed
  86294. */
  86295. needAlphaBlending(): boolean;
  86296. /**
  86297. * Specifies if the mesh will require alpha blending
  86298. * @param mesh defines the mesh to check
  86299. * @returns a boolean specifying if alpha blending is needed for the mesh
  86300. */
  86301. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  86302. /**
  86303. * Specifies if this material should be rendered in alpha test mode
  86304. * @returns a boolean specifying if an alpha test is needed.
  86305. */
  86306. needAlphaTesting(): boolean;
  86307. /**
  86308. * Gets the texture used for the alpha test
  86309. * @returns the texture to use for alpha testing
  86310. */
  86311. getAlphaTestTexture(): Nullable<BaseTexture>;
  86312. /**
  86313. * Marks the material to indicate that it needs to be re-calculated
  86314. */
  86315. markDirty(): void;
  86316. /** @hidden */
  86317. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  86318. /**
  86319. * Binds the material to the mesh
  86320. * @param world defines the world transformation matrix
  86321. * @param mesh defines the mesh to bind the material to
  86322. */
  86323. bind(world: Matrix, mesh?: Mesh): void;
  86324. /**
  86325. * Binds the submesh to the material
  86326. * @param world defines the world transformation matrix
  86327. * @param mesh defines the mesh containing the submesh
  86328. * @param subMesh defines the submesh to bind the material to
  86329. */
  86330. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  86331. /**
  86332. * Binds the world matrix to the material
  86333. * @param world defines the world transformation matrix
  86334. */
  86335. bindOnlyWorldMatrix(world: Matrix): void;
  86336. /**
  86337. * Binds the scene's uniform buffer to the effect.
  86338. * @param effect defines the effect to bind to the scene uniform buffer
  86339. * @param sceneUbo defines the uniform buffer storing scene data
  86340. */
  86341. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  86342. /**
  86343. * Binds the view matrix to the effect
  86344. * @param effect defines the effect to bind the view matrix to
  86345. */
  86346. bindView(effect: Effect): void;
  86347. /**
  86348. * Binds the view projection matrix to the effect
  86349. * @param effect defines the effect to bind the view projection matrix to
  86350. */
  86351. bindViewProjection(effect: Effect): void;
  86352. /**
  86353. * Specifies if material alpha testing should be turned on for the mesh
  86354. * @param mesh defines the mesh to check
  86355. */
  86356. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  86357. /**
  86358. * Processes to execute after binding the material to a mesh
  86359. * @param mesh defines the rendered mesh
  86360. */
  86361. protected _afterBind(mesh?: Mesh): void;
  86362. /**
  86363. * Unbinds the material from the mesh
  86364. */
  86365. unbind(): void;
  86366. /**
  86367. * Gets the active textures from the material
  86368. * @returns an array of textures
  86369. */
  86370. getActiveTextures(): BaseTexture[];
  86371. /**
  86372. * Specifies if the material uses a texture
  86373. * @param texture defines the texture to check against the material
  86374. * @returns a boolean specifying if the material uses the texture
  86375. */
  86376. hasTexture(texture: BaseTexture): boolean;
  86377. /**
  86378. * Makes a duplicate of the material, and gives it a new name
  86379. * @param name defines the new name for the duplicated material
  86380. * @returns the cloned material
  86381. */
  86382. clone(name: string): Nullable<Material>;
  86383. /**
  86384. * Gets the meshes bound to the material
  86385. * @returns an array of meshes bound to the material
  86386. */
  86387. getBindedMeshes(): AbstractMesh[];
  86388. /**
  86389. * Force shader compilation
  86390. * @param mesh defines the mesh associated with this material
  86391. * @param onCompiled defines a function to execute once the material is compiled
  86392. * @param options defines the options to configure the compilation
  86393. */
  86394. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  86395. clipPlane: boolean;
  86396. }>): void;
  86397. /**
  86398. * Force shader compilation
  86399. * @param mesh defines the mesh that will use this material
  86400. * @param options defines additional options for compiling the shaders
  86401. * @returns a promise that resolves when the compilation completes
  86402. */
  86403. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  86404. clipPlane: boolean;
  86405. }>): Promise<void>;
  86406. private static readonly _AllDirtyCallBack;
  86407. private static readonly _ImageProcessingDirtyCallBack;
  86408. private static readonly _TextureDirtyCallBack;
  86409. private static readonly _FresnelDirtyCallBack;
  86410. private static readonly _MiscDirtyCallBack;
  86411. private static readonly _LightsDirtyCallBack;
  86412. private static readonly _AttributeDirtyCallBack;
  86413. private static _FresnelAndMiscDirtyCallBack;
  86414. private static _TextureAndMiscDirtyCallBack;
  86415. private static readonly _DirtyCallbackArray;
  86416. private static readonly _RunDirtyCallBacks;
  86417. /**
  86418. * Marks a define in the material to indicate that it needs to be re-computed
  86419. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  86420. */
  86421. markAsDirty(flag: number): void;
  86422. /**
  86423. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  86424. * @param func defines a function which checks material defines against the submeshes
  86425. */
  86426. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  86427. /**
  86428. * Indicates that we need to re-calculated for all submeshes
  86429. */
  86430. protected _markAllSubMeshesAsAllDirty(): void;
  86431. /**
  86432. * Indicates that image processing needs to be re-calculated for all submeshes
  86433. */
  86434. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  86435. /**
  86436. * Indicates that textures need to be re-calculated for all submeshes
  86437. */
  86438. protected _markAllSubMeshesAsTexturesDirty(): void;
  86439. /**
  86440. * Indicates that fresnel needs to be re-calculated for all submeshes
  86441. */
  86442. protected _markAllSubMeshesAsFresnelDirty(): void;
  86443. /**
  86444. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  86445. */
  86446. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  86447. /**
  86448. * Indicates that lights need to be re-calculated for all submeshes
  86449. */
  86450. protected _markAllSubMeshesAsLightsDirty(): void;
  86451. /**
  86452. * Indicates that attributes need to be re-calculated for all submeshes
  86453. */
  86454. protected _markAllSubMeshesAsAttributesDirty(): void;
  86455. /**
  86456. * Indicates that misc needs to be re-calculated for all submeshes
  86457. */
  86458. protected _markAllSubMeshesAsMiscDirty(): void;
  86459. /**
  86460. * Indicates that textures and misc need to be re-calculated for all submeshes
  86461. */
  86462. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  86463. /**
  86464. * Disposes the material
  86465. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86466. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86467. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86468. */
  86469. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86470. /** @hidden */
  86471. private releaseVertexArrayObject;
  86472. /**
  86473. * Serializes this material
  86474. * @returns the serialized material object
  86475. */
  86476. serialize(): any;
  86477. /**
  86478. * Creates a material from parsed material data
  86479. * @param parsedMaterial defines parsed material data
  86480. * @param scene defines the hosting scene
  86481. * @param rootUrl defines the root URL to use to load textures
  86482. * @returns a new material
  86483. */
  86484. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  86485. }
  86486. }
  86487. declare module BABYLON {
  86488. /**
  86489. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86490. * separate meshes. This can be use to improve performances.
  86491. * @see http://doc.babylonjs.com/how_to/multi_materials
  86492. */
  86493. export class MultiMaterial extends Material {
  86494. private _subMaterials;
  86495. /**
  86496. * Gets or Sets the list of Materials used within the multi material.
  86497. * They need to be ordered according to the submeshes order in the associated mesh
  86498. */
  86499. subMaterials: Nullable<Material>[];
  86500. /**
  86501. * Function used to align with Node.getChildren()
  86502. * @returns the list of Materials used within the multi material
  86503. */
  86504. getChildren(): Nullable<Material>[];
  86505. /**
  86506. * Instantiates a new Multi Material
  86507. * A multi-material is used to apply different materials to different parts of the same object without the need of
  86508. * separate meshes. This can be use to improve performances.
  86509. * @see http://doc.babylonjs.com/how_to/multi_materials
  86510. * @param name Define the name in the scene
  86511. * @param scene Define the scene the material belongs to
  86512. */
  86513. constructor(name: string, scene: Scene);
  86514. private _hookArray;
  86515. /**
  86516. * Get one of the submaterial by its index in the submaterials array
  86517. * @param index The index to look the sub material at
  86518. * @returns The Material if the index has been defined
  86519. */
  86520. getSubMaterial(index: number): Nullable<Material>;
  86521. /**
  86522. * Get the list of active textures for the whole sub materials list.
  86523. * @returns All the textures that will be used during the rendering
  86524. */
  86525. getActiveTextures(): BaseTexture[];
  86526. /**
  86527. * Gets the current class name of the material e.g. "MultiMaterial"
  86528. * Mainly use in serialization.
  86529. * @returns the class name
  86530. */
  86531. getClassName(): string;
  86532. /**
  86533. * Checks if the material is ready to render the requested sub mesh
  86534. * @param mesh Define the mesh the submesh belongs to
  86535. * @param subMesh Define the sub mesh to look readyness for
  86536. * @param useInstances Define whether or not the material is used with instances
  86537. * @returns true if ready, otherwise false
  86538. */
  86539. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86540. /**
  86541. * Clones the current material and its related sub materials
  86542. * @param name Define the name of the newly cloned material
  86543. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  86544. * @returns the cloned material
  86545. */
  86546. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  86547. /**
  86548. * Serializes the materials into a JSON representation.
  86549. * @returns the JSON representation
  86550. */
  86551. serialize(): any;
  86552. /**
  86553. * Dispose the material and release its associated resources
  86554. * @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)
  86555. * @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)
  86556. * @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)
  86557. */
  86558. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  86559. /**
  86560. * Creates a MultiMaterial from parsed MultiMaterial data.
  86561. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  86562. * @param scene defines the hosting scene
  86563. * @returns a new MultiMaterial
  86564. */
  86565. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  86566. }
  86567. }
  86568. declare module BABYLON {
  86569. /**
  86570. * Base class for submeshes
  86571. */
  86572. export class BaseSubMesh {
  86573. /** @hidden */
  86574. _materialDefines: Nullable<MaterialDefines>;
  86575. /** @hidden */
  86576. _materialEffect: Nullable<Effect>;
  86577. /**
  86578. * Gets associated effect
  86579. */
  86580. readonly effect: Nullable<Effect>;
  86581. /**
  86582. * Sets associated effect (effect used to render this submesh)
  86583. * @param effect defines the effect to associate with
  86584. * @param defines defines the set of defines used to compile this effect
  86585. */
  86586. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  86587. }
  86588. /**
  86589. * Defines a subdivision inside a mesh
  86590. */
  86591. export class SubMesh extends BaseSubMesh implements ICullable {
  86592. /** the material index to use */
  86593. materialIndex: number;
  86594. /** vertex index start */
  86595. verticesStart: number;
  86596. /** vertices count */
  86597. verticesCount: number;
  86598. /** index start */
  86599. indexStart: number;
  86600. /** indices count */
  86601. indexCount: number;
  86602. /** @hidden */
  86603. _linesIndexCount: number;
  86604. private _mesh;
  86605. private _renderingMesh;
  86606. private _boundingInfo;
  86607. private _linesIndexBuffer;
  86608. /** @hidden */
  86609. _lastColliderWorldVertices: Nullable<Vector3[]>;
  86610. /** @hidden */
  86611. _trianglePlanes: Plane[];
  86612. /** @hidden */
  86613. _lastColliderTransformMatrix: Nullable<Matrix>;
  86614. /** @hidden */
  86615. _renderId: number;
  86616. /** @hidden */
  86617. _alphaIndex: number;
  86618. /** @hidden */
  86619. _distanceToCamera: number;
  86620. /** @hidden */
  86621. _id: number;
  86622. private _currentMaterial;
  86623. /**
  86624. * Add a new submesh to a mesh
  86625. * @param materialIndex defines the material index to use
  86626. * @param verticesStart defines vertex index start
  86627. * @param verticesCount defines vertices count
  86628. * @param indexStart defines index start
  86629. * @param indexCount defines indices count
  86630. * @param mesh defines the parent mesh
  86631. * @param renderingMesh defines an optional rendering mesh
  86632. * @param createBoundingBox defines if bounding box should be created for this submesh
  86633. * @returns the new submesh
  86634. */
  86635. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  86636. /**
  86637. * Creates a new submesh
  86638. * @param materialIndex defines the material index to use
  86639. * @param verticesStart defines vertex index start
  86640. * @param verticesCount defines vertices count
  86641. * @param indexStart defines index start
  86642. * @param indexCount defines indices count
  86643. * @param mesh defines the parent mesh
  86644. * @param renderingMesh defines an optional rendering mesh
  86645. * @param createBoundingBox defines if bounding box should be created for this submesh
  86646. */
  86647. constructor(
  86648. /** the material index to use */
  86649. materialIndex: number,
  86650. /** vertex index start */
  86651. verticesStart: number,
  86652. /** vertices count */
  86653. verticesCount: number,
  86654. /** index start */
  86655. indexStart: number,
  86656. /** indices count */
  86657. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  86658. /**
  86659. * Returns true if this submesh covers the entire parent mesh
  86660. * @ignorenaming
  86661. */
  86662. readonly IsGlobal: boolean;
  86663. /**
  86664. * Returns the submesh BoudingInfo object
  86665. * @returns current bounding info (or mesh's one if the submesh is global)
  86666. */
  86667. getBoundingInfo(): BoundingInfo;
  86668. /**
  86669. * Sets the submesh BoundingInfo
  86670. * @param boundingInfo defines the new bounding info to use
  86671. * @returns the SubMesh
  86672. */
  86673. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  86674. /**
  86675. * Returns the mesh of the current submesh
  86676. * @return the parent mesh
  86677. */
  86678. getMesh(): AbstractMesh;
  86679. /**
  86680. * Returns the rendering mesh of the submesh
  86681. * @returns the rendering mesh (could be different from parent mesh)
  86682. */
  86683. getRenderingMesh(): Mesh;
  86684. /**
  86685. * Returns the submesh material
  86686. * @returns null or the current material
  86687. */
  86688. getMaterial(): Nullable<Material>;
  86689. /**
  86690. * Sets a new updated BoundingInfo object to the submesh
  86691. * @param data defines an optional position array to use to determine the bounding info
  86692. * @returns the SubMesh
  86693. */
  86694. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  86695. /** @hidden */
  86696. _checkCollision(collider: Collider): boolean;
  86697. /**
  86698. * Updates the submesh BoundingInfo
  86699. * @param world defines the world matrix to use to update the bounding info
  86700. * @returns the submesh
  86701. */
  86702. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  86703. /**
  86704. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  86705. * @param frustumPlanes defines the frustum planes
  86706. * @returns true if the submesh is intersecting with the frustum
  86707. */
  86708. isInFrustum(frustumPlanes: Plane[]): boolean;
  86709. /**
  86710. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  86711. * @param frustumPlanes defines the frustum planes
  86712. * @returns true if the submesh is inside the frustum
  86713. */
  86714. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86715. /**
  86716. * Renders the submesh
  86717. * @param enableAlphaMode defines if alpha needs to be used
  86718. * @returns the submesh
  86719. */
  86720. render(enableAlphaMode: boolean): SubMesh;
  86721. /**
  86722. * @hidden
  86723. */
  86724. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  86725. /**
  86726. * Checks if the submesh intersects with a ray
  86727. * @param ray defines the ray to test
  86728. * @returns true is the passed ray intersects the submesh bounding box
  86729. */
  86730. canIntersects(ray: Ray): boolean;
  86731. /**
  86732. * Intersects current submesh with a ray
  86733. * @param ray defines the ray to test
  86734. * @param positions defines mesh's positions array
  86735. * @param indices defines mesh's indices array
  86736. * @param fastCheck defines if only bounding info should be used
  86737. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  86738. * @returns intersection info or null if no intersection
  86739. */
  86740. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  86741. /** @hidden */
  86742. private _intersectLines;
  86743. /** @hidden */
  86744. private _intersectUnIndexedLines;
  86745. /** @hidden */
  86746. private _intersectTriangles;
  86747. /** @hidden */
  86748. private _intersectUnIndexedTriangles;
  86749. /** @hidden */
  86750. _rebuild(): void;
  86751. /**
  86752. * Creates a new submesh from the passed mesh
  86753. * @param newMesh defines the new hosting mesh
  86754. * @param newRenderingMesh defines an optional rendering mesh
  86755. * @returns the new submesh
  86756. */
  86757. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  86758. /**
  86759. * Release associated resources
  86760. */
  86761. dispose(): void;
  86762. /**
  86763. * Gets the class name
  86764. * @returns the string "SubMesh".
  86765. */
  86766. getClassName(): string;
  86767. /**
  86768. * Creates a new submesh from indices data
  86769. * @param materialIndex the index of the main mesh material
  86770. * @param startIndex the index where to start the copy in the mesh indices array
  86771. * @param indexCount the number of indices to copy then from the startIndex
  86772. * @param mesh the main mesh to create the submesh from
  86773. * @param renderingMesh the optional rendering mesh
  86774. * @returns a new submesh
  86775. */
  86776. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  86777. }
  86778. }
  86779. declare module BABYLON {
  86780. /**
  86781. * Class used to represent data loading progression
  86782. */
  86783. export class SceneLoaderFlags {
  86784. private static _ForceFullSceneLoadingForIncremental;
  86785. private static _ShowLoadingScreen;
  86786. private static _CleanBoneMatrixWeights;
  86787. private static _loggingLevel;
  86788. /**
  86789. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  86790. */
  86791. static ForceFullSceneLoadingForIncremental: boolean;
  86792. /**
  86793. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  86794. */
  86795. static ShowLoadingScreen: boolean;
  86796. /**
  86797. * Defines the current logging level (while loading the scene)
  86798. * @ignorenaming
  86799. */
  86800. static loggingLevel: number;
  86801. /**
  86802. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  86803. */
  86804. static CleanBoneMatrixWeights: boolean;
  86805. }
  86806. }
  86807. declare module BABYLON {
  86808. /**
  86809. * Class used to store geometry data (vertex buffers + index buffer)
  86810. */
  86811. export class Geometry implements IGetSetVerticesData {
  86812. /**
  86813. * Gets or sets the ID of the geometry
  86814. */
  86815. id: string;
  86816. /**
  86817. * Gets or sets the unique ID of the geometry
  86818. */
  86819. uniqueId: number;
  86820. /**
  86821. * Gets the delay loading state of the geometry (none by default which means not delayed)
  86822. */
  86823. delayLoadState: number;
  86824. /**
  86825. * Gets the file containing the data to load when running in delay load state
  86826. */
  86827. delayLoadingFile: Nullable<string>;
  86828. /**
  86829. * Callback called when the geometry is updated
  86830. */
  86831. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  86832. private _scene;
  86833. private _engine;
  86834. private _meshes;
  86835. private _totalVertices;
  86836. /** @hidden */
  86837. _indices: IndicesArray;
  86838. /** @hidden */
  86839. _vertexBuffers: {
  86840. [key: string]: VertexBuffer;
  86841. };
  86842. private _isDisposed;
  86843. private _extend;
  86844. private _boundingBias;
  86845. /** @hidden */
  86846. _delayInfo: Array<string>;
  86847. private _indexBuffer;
  86848. private _indexBufferIsUpdatable;
  86849. /** @hidden */
  86850. _boundingInfo: Nullable<BoundingInfo>;
  86851. /** @hidden */
  86852. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  86853. /** @hidden */
  86854. _softwareSkinningFrameId: number;
  86855. private _vertexArrayObjects;
  86856. private _updatable;
  86857. /** @hidden */
  86858. _positions: Nullable<Vector3[]>;
  86859. /**
  86860. * 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
  86861. */
  86862. /**
  86863. * 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
  86864. */
  86865. boundingBias: Vector2;
  86866. /**
  86867. * Static function used to attach a new empty geometry to a mesh
  86868. * @param mesh defines the mesh to attach the geometry to
  86869. * @returns the new Geometry
  86870. */
  86871. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  86872. /**
  86873. * Creates a new geometry
  86874. * @param id defines the unique ID
  86875. * @param scene defines the hosting scene
  86876. * @param vertexData defines the VertexData used to get geometry data
  86877. * @param updatable defines if geometry must be updatable (false by default)
  86878. * @param mesh defines the mesh that will be associated with the geometry
  86879. */
  86880. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  86881. /**
  86882. * Gets the current extend of the geometry
  86883. */
  86884. readonly extend: {
  86885. minimum: Vector3;
  86886. maximum: Vector3;
  86887. };
  86888. /**
  86889. * Gets the hosting scene
  86890. * @returns the hosting Scene
  86891. */
  86892. getScene(): Scene;
  86893. /**
  86894. * Gets the hosting engine
  86895. * @returns the hosting Engine
  86896. */
  86897. getEngine(): Engine;
  86898. /**
  86899. * Defines if the geometry is ready to use
  86900. * @returns true if the geometry is ready to be used
  86901. */
  86902. isReady(): boolean;
  86903. /**
  86904. * Gets a value indicating that the geometry should not be serialized
  86905. */
  86906. readonly doNotSerialize: boolean;
  86907. /** @hidden */
  86908. _rebuild(): void;
  86909. /**
  86910. * Affects all geometry data in one call
  86911. * @param vertexData defines the geometry data
  86912. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  86913. */
  86914. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  86915. /**
  86916. * Set specific vertex data
  86917. * @param kind defines the data kind (Position, normal, etc...)
  86918. * @param data defines the vertex data to use
  86919. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  86920. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  86921. */
  86922. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  86923. /**
  86924. * Removes a specific vertex data
  86925. * @param kind defines the data kind (Position, normal, etc...)
  86926. */
  86927. removeVerticesData(kind: string): void;
  86928. /**
  86929. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  86930. * @param buffer defines the vertex buffer to use
  86931. * @param totalVertices defines the total number of vertices for position kind (could be null)
  86932. */
  86933. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  86934. /**
  86935. * Update a specific vertex buffer
  86936. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  86937. * It will do nothing if the buffer is not updatable
  86938. * @param kind defines the data kind (Position, normal, etc...)
  86939. * @param data defines the data to use
  86940. * @param offset defines the offset in the target buffer where to store the data
  86941. * @param useBytes set to true if the offset is in bytes
  86942. */
  86943. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  86944. /**
  86945. * Update a specific vertex buffer
  86946. * This function will create a new buffer if the current one is not updatable
  86947. * @param kind defines the data kind (Position, normal, etc...)
  86948. * @param data defines the data to use
  86949. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  86950. */
  86951. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  86952. private _updateBoundingInfo;
  86953. /** @hidden */
  86954. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  86955. /**
  86956. * Gets total number of vertices
  86957. * @returns the total number of vertices
  86958. */
  86959. getTotalVertices(): number;
  86960. /**
  86961. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  86962. * @param kind defines the data kind (Position, normal, etc...)
  86963. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  86964. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  86965. * @returns a float array containing vertex data
  86966. */
  86967. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  86968. /**
  86969. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  86970. * @param kind defines the data kind (Position, normal, etc...)
  86971. * @returns true if the vertex buffer with the specified kind is updatable
  86972. */
  86973. isVertexBufferUpdatable(kind: string): boolean;
  86974. /**
  86975. * Gets a specific vertex buffer
  86976. * @param kind defines the data kind (Position, normal, etc...)
  86977. * @returns a VertexBuffer
  86978. */
  86979. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  86980. /**
  86981. * Returns all vertex buffers
  86982. * @return an object holding all vertex buffers indexed by kind
  86983. */
  86984. getVertexBuffers(): Nullable<{
  86985. [key: string]: VertexBuffer;
  86986. }>;
  86987. /**
  86988. * Gets a boolean indicating if specific vertex buffer is present
  86989. * @param kind defines the data kind (Position, normal, etc...)
  86990. * @returns true if data is present
  86991. */
  86992. isVerticesDataPresent(kind: string): boolean;
  86993. /**
  86994. * Gets a list of all attached data kinds (Position, normal, etc...)
  86995. * @returns a list of string containing all kinds
  86996. */
  86997. getVerticesDataKinds(): string[];
  86998. /**
  86999. * Update index buffer
  87000. * @param indices defines the indices to store in the index buffer
  87001. * @param offset defines the offset in the target buffer where to store the data
  87002. * @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)
  87003. */
  87004. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  87005. /**
  87006. * Creates a new index buffer
  87007. * @param indices defines the indices to store in the index buffer
  87008. * @param totalVertices defines the total number of vertices (could be null)
  87009. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87010. */
  87011. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  87012. /**
  87013. * Return the total number of indices
  87014. * @returns the total number of indices
  87015. */
  87016. getTotalIndices(): number;
  87017. /**
  87018. * Gets the index buffer array
  87019. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87020. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87021. * @returns the index buffer array
  87022. */
  87023. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87024. /**
  87025. * Gets the index buffer
  87026. * @return the index buffer
  87027. */
  87028. getIndexBuffer(): Nullable<DataBuffer>;
  87029. /** @hidden */
  87030. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  87031. /**
  87032. * Release the associated resources for a specific mesh
  87033. * @param mesh defines the source mesh
  87034. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  87035. */
  87036. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  87037. /**
  87038. * Apply current geometry to a given mesh
  87039. * @param mesh defines the mesh to apply geometry to
  87040. */
  87041. applyToMesh(mesh: Mesh): void;
  87042. private _updateExtend;
  87043. private _applyToMesh;
  87044. private notifyUpdate;
  87045. /**
  87046. * Load the geometry if it was flagged as delay loaded
  87047. * @param scene defines the hosting scene
  87048. * @param onLoaded defines a callback called when the geometry is loaded
  87049. */
  87050. load(scene: Scene, onLoaded?: () => void): void;
  87051. private _queueLoad;
  87052. /**
  87053. * Invert the geometry to move from a right handed system to a left handed one.
  87054. */
  87055. toLeftHanded(): void;
  87056. /** @hidden */
  87057. _resetPointsArrayCache(): void;
  87058. /** @hidden */
  87059. _generatePointsArray(): boolean;
  87060. /**
  87061. * Gets a value indicating if the geometry is disposed
  87062. * @returns true if the geometry was disposed
  87063. */
  87064. isDisposed(): boolean;
  87065. private _disposeVertexArrayObjects;
  87066. /**
  87067. * Free all associated resources
  87068. */
  87069. dispose(): void;
  87070. /**
  87071. * Clone the current geometry into a new geometry
  87072. * @param id defines the unique ID of the new geometry
  87073. * @returns a new geometry object
  87074. */
  87075. copy(id: string): Geometry;
  87076. /**
  87077. * Serialize the current geometry info (and not the vertices data) into a JSON object
  87078. * @return a JSON representation of the current geometry data (without the vertices data)
  87079. */
  87080. serialize(): any;
  87081. private toNumberArray;
  87082. /**
  87083. * Serialize all vertices data into a JSON oject
  87084. * @returns a JSON representation of the current geometry data
  87085. */
  87086. serializeVerticeData(): any;
  87087. /**
  87088. * Extracts a clone of a mesh geometry
  87089. * @param mesh defines the source mesh
  87090. * @param id defines the unique ID of the new geometry object
  87091. * @returns the new geometry object
  87092. */
  87093. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  87094. /**
  87095. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  87096. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  87097. * Be aware Math.random() could cause collisions, but:
  87098. * "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"
  87099. * @returns a string containing a new GUID
  87100. */
  87101. static RandomId(): string;
  87102. /** @hidden */
  87103. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  87104. private static _CleanMatricesWeights;
  87105. /**
  87106. * Create a new geometry from persisted data (Using .babylon file format)
  87107. * @param parsedVertexData defines the persisted data
  87108. * @param scene defines the hosting scene
  87109. * @param rootUrl defines the root url to use to load assets (like delayed data)
  87110. * @returns the new geometry object
  87111. */
  87112. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  87113. }
  87114. }
  87115. declare module BABYLON {
  87116. /**
  87117. * Define an interface for all classes that will get and set the data on vertices
  87118. */
  87119. export interface IGetSetVerticesData {
  87120. /**
  87121. * Gets a boolean indicating if specific vertex data is present
  87122. * @param kind defines the vertex data kind to use
  87123. * @returns true is data kind is present
  87124. */
  87125. isVerticesDataPresent(kind: string): boolean;
  87126. /**
  87127. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87128. * @param kind defines the data kind (Position, normal, etc...)
  87129. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87130. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87131. * @returns a float array containing vertex data
  87132. */
  87133. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87134. /**
  87135. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87136. * @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.
  87137. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87138. * @returns the indices array or an empty array if the mesh has no geometry
  87139. */
  87140. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87141. /**
  87142. * Set specific vertex data
  87143. * @param kind defines the data kind (Position, normal, etc...)
  87144. * @param data defines the vertex data to use
  87145. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87146. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87147. */
  87148. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  87149. /**
  87150. * Update a specific associated vertex buffer
  87151. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87152. * - VertexBuffer.PositionKind
  87153. * - VertexBuffer.UVKind
  87154. * - VertexBuffer.UV2Kind
  87155. * - VertexBuffer.UV3Kind
  87156. * - VertexBuffer.UV4Kind
  87157. * - VertexBuffer.UV5Kind
  87158. * - VertexBuffer.UV6Kind
  87159. * - VertexBuffer.ColorKind
  87160. * - VertexBuffer.MatricesIndicesKind
  87161. * - VertexBuffer.MatricesIndicesExtraKind
  87162. * - VertexBuffer.MatricesWeightsKind
  87163. * - VertexBuffer.MatricesWeightsExtraKind
  87164. * @param data defines the data source
  87165. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  87166. * @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)
  87167. */
  87168. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  87169. /**
  87170. * Creates a new index buffer
  87171. * @param indices defines the indices to store in the index buffer
  87172. * @param totalVertices defines the total number of vertices (could be null)
  87173. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87174. */
  87175. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  87176. }
  87177. /**
  87178. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  87179. */
  87180. export class VertexData {
  87181. /**
  87182. * Mesh side orientation : usually the external or front surface
  87183. */
  87184. static readonly FRONTSIDE: number;
  87185. /**
  87186. * Mesh side orientation : usually the internal or back surface
  87187. */
  87188. static readonly BACKSIDE: number;
  87189. /**
  87190. * Mesh side orientation : both internal and external or front and back surfaces
  87191. */
  87192. static readonly DOUBLESIDE: number;
  87193. /**
  87194. * Mesh side orientation : by default, `FRONTSIDE`
  87195. */
  87196. static readonly DEFAULTSIDE: number;
  87197. /**
  87198. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  87199. */
  87200. positions: Nullable<FloatArray>;
  87201. /**
  87202. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  87203. */
  87204. normals: Nullable<FloatArray>;
  87205. /**
  87206. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  87207. */
  87208. tangents: Nullable<FloatArray>;
  87209. /**
  87210. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87211. */
  87212. uvs: Nullable<FloatArray>;
  87213. /**
  87214. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87215. */
  87216. uvs2: Nullable<FloatArray>;
  87217. /**
  87218. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87219. */
  87220. uvs3: Nullable<FloatArray>;
  87221. /**
  87222. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87223. */
  87224. uvs4: Nullable<FloatArray>;
  87225. /**
  87226. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87227. */
  87228. uvs5: Nullable<FloatArray>;
  87229. /**
  87230. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  87231. */
  87232. uvs6: Nullable<FloatArray>;
  87233. /**
  87234. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  87235. */
  87236. colors: Nullable<FloatArray>;
  87237. /**
  87238. * 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).
  87239. */
  87240. matricesIndices: Nullable<FloatArray>;
  87241. /**
  87242. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  87243. */
  87244. matricesWeights: Nullable<FloatArray>;
  87245. /**
  87246. * An array extending the number of possible indices
  87247. */
  87248. matricesIndicesExtra: Nullable<FloatArray>;
  87249. /**
  87250. * An array extending the number of possible weights when the number of indices is extended
  87251. */
  87252. matricesWeightsExtra: Nullable<FloatArray>;
  87253. /**
  87254. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  87255. */
  87256. indices: Nullable<IndicesArray>;
  87257. /**
  87258. * Uses the passed data array to set the set the values for the specified kind of data
  87259. * @param data a linear array of floating numbers
  87260. * @param kind the type of data that is being set, eg positions, colors etc
  87261. */
  87262. set(data: FloatArray, kind: string): void;
  87263. /**
  87264. * Associates the vertexData to the passed Mesh.
  87265. * Sets it as updatable or not (default `false`)
  87266. * @param mesh the mesh the vertexData is applied to
  87267. * @param updatable when used and having the value true allows new data to update the vertexData
  87268. * @returns the VertexData
  87269. */
  87270. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  87271. /**
  87272. * Associates the vertexData to the passed Geometry.
  87273. * Sets it as updatable or not (default `false`)
  87274. * @param geometry the geometry the vertexData is applied to
  87275. * @param updatable when used and having the value true allows new data to update the vertexData
  87276. * @returns VertexData
  87277. */
  87278. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  87279. /**
  87280. * Updates the associated mesh
  87281. * @param mesh the mesh to be updated
  87282. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87283. * @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
  87284. * @returns VertexData
  87285. */
  87286. updateMesh(mesh: Mesh): VertexData;
  87287. /**
  87288. * Updates the associated geometry
  87289. * @param geometry the geometry to be updated
  87290. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87291. * @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
  87292. * @returns VertexData.
  87293. */
  87294. updateGeometry(geometry: Geometry): VertexData;
  87295. private _applyTo;
  87296. private _update;
  87297. /**
  87298. * Transforms each position and each normal of the vertexData according to the passed Matrix
  87299. * @param matrix the transforming matrix
  87300. * @returns the VertexData
  87301. */
  87302. transform(matrix: Matrix): VertexData;
  87303. /**
  87304. * Merges the passed VertexData into the current one
  87305. * @param other the VertexData to be merged into the current one
  87306. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  87307. * @returns the modified VertexData
  87308. */
  87309. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  87310. private _mergeElement;
  87311. private _validate;
  87312. /**
  87313. * Serializes the VertexData
  87314. * @returns a serialized object
  87315. */
  87316. serialize(): any;
  87317. /**
  87318. * Extracts the vertexData from a mesh
  87319. * @param mesh the mesh from which to extract the VertexData
  87320. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  87321. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87322. * @returns the object VertexData associated to the passed mesh
  87323. */
  87324. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87325. /**
  87326. * Extracts the vertexData from the geometry
  87327. * @param geometry the geometry from which to extract the VertexData
  87328. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  87329. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87330. * @returns the object VertexData associated to the passed mesh
  87331. */
  87332. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  87333. private static _ExtractFrom;
  87334. /**
  87335. * Creates the VertexData for a Ribbon
  87336. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  87337. * * pathArray array of paths, each of which an array of successive Vector3
  87338. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  87339. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  87340. * * 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
  87341. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87342. * * 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)
  87343. * * 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)
  87344. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  87345. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  87346. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  87347. * @returns the VertexData of the ribbon
  87348. */
  87349. static CreateRibbon(options: {
  87350. pathArray: Vector3[][];
  87351. closeArray?: boolean;
  87352. closePath?: boolean;
  87353. offset?: number;
  87354. sideOrientation?: number;
  87355. frontUVs?: Vector4;
  87356. backUVs?: Vector4;
  87357. invertUV?: boolean;
  87358. uvs?: Vector2[];
  87359. colors?: Color4[];
  87360. }): VertexData;
  87361. /**
  87362. * Creates the VertexData for a box
  87363. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87364. * * size sets the width, height and depth of the box to the value of size, optional default 1
  87365. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  87366. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  87367. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  87368. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87369. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87370. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87371. * * 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)
  87372. * * 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)
  87373. * @returns the VertexData of the box
  87374. */
  87375. static CreateBox(options: {
  87376. size?: number;
  87377. width?: number;
  87378. height?: number;
  87379. depth?: number;
  87380. faceUV?: Vector4[];
  87381. faceColors?: Color4[];
  87382. sideOrientation?: number;
  87383. frontUVs?: Vector4;
  87384. backUVs?: Vector4;
  87385. }): VertexData;
  87386. /**
  87387. * Creates the VertexData for a tiled box
  87388. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87389. * * faceTiles sets the pattern, tile size and number of tiles for a face
  87390. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87391. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87392. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87393. * @returns the VertexData of the box
  87394. */
  87395. static CreateTiledBox(options: {
  87396. pattern?: number;
  87397. width?: number;
  87398. height?: number;
  87399. depth?: number;
  87400. tileSize?: number;
  87401. tileWidth?: number;
  87402. tileHeight?: number;
  87403. alignHorizontal?: number;
  87404. alignVertical?: number;
  87405. faceUV?: Vector4[];
  87406. faceColors?: Color4[];
  87407. sideOrientation?: number;
  87408. }): VertexData;
  87409. /**
  87410. * Creates the VertexData for a tiled plane
  87411. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87412. * * pattern a limited pattern arrangement depending on the number
  87413. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  87414. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  87415. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  87416. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87417. * * 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)
  87418. * * 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)
  87419. * @returns the VertexData of the tiled plane
  87420. */
  87421. static CreateTiledPlane(options: {
  87422. pattern?: number;
  87423. tileSize?: number;
  87424. tileWidth?: number;
  87425. tileHeight?: number;
  87426. size?: number;
  87427. width?: number;
  87428. height?: number;
  87429. alignHorizontal?: number;
  87430. alignVertical?: number;
  87431. sideOrientation?: number;
  87432. frontUVs?: Vector4;
  87433. backUVs?: Vector4;
  87434. }): VertexData;
  87435. /**
  87436. * Creates the VertexData for an ellipsoid, defaults to a sphere
  87437. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87438. * * segments sets the number of horizontal strips optional, default 32
  87439. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  87440. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  87441. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  87442. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  87443. * * 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
  87444. * * 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
  87445. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87446. * * 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)
  87447. * * 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)
  87448. * @returns the VertexData of the ellipsoid
  87449. */
  87450. static CreateSphere(options: {
  87451. segments?: number;
  87452. diameter?: number;
  87453. diameterX?: number;
  87454. diameterY?: number;
  87455. diameterZ?: number;
  87456. arc?: number;
  87457. slice?: number;
  87458. sideOrientation?: number;
  87459. frontUVs?: Vector4;
  87460. backUVs?: Vector4;
  87461. }): VertexData;
  87462. /**
  87463. * Creates the VertexData for a cylinder, cone or prism
  87464. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87465. * * height sets the height (y direction) of the cylinder, optional, default 2
  87466. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  87467. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  87468. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  87469. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87470. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  87471. * * 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
  87472. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87473. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87474. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  87475. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  87476. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87477. * * 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)
  87478. * * 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)
  87479. * @returns the VertexData of the cylinder, cone or prism
  87480. */
  87481. static CreateCylinder(options: {
  87482. height?: number;
  87483. diameterTop?: number;
  87484. diameterBottom?: number;
  87485. diameter?: number;
  87486. tessellation?: number;
  87487. subdivisions?: number;
  87488. arc?: number;
  87489. faceColors?: Color4[];
  87490. faceUV?: Vector4[];
  87491. hasRings?: boolean;
  87492. enclose?: boolean;
  87493. sideOrientation?: number;
  87494. frontUVs?: Vector4;
  87495. backUVs?: Vector4;
  87496. }): VertexData;
  87497. /**
  87498. * Creates the VertexData for a torus
  87499. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87500. * * diameter the diameter of the torus, optional default 1
  87501. * * thickness the diameter of the tube forming the torus, optional default 0.5
  87502. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  87503. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87504. * * 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)
  87505. * * 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)
  87506. * @returns the VertexData of the torus
  87507. */
  87508. static CreateTorus(options: {
  87509. diameter?: number;
  87510. thickness?: number;
  87511. tessellation?: number;
  87512. sideOrientation?: number;
  87513. frontUVs?: Vector4;
  87514. backUVs?: Vector4;
  87515. }): VertexData;
  87516. /**
  87517. * Creates the VertexData of the LineSystem
  87518. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  87519. * - lines an array of lines, each line being an array of successive Vector3
  87520. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  87521. * @returns the VertexData of the LineSystem
  87522. */
  87523. static CreateLineSystem(options: {
  87524. lines: Vector3[][];
  87525. colors?: Nullable<Color4[][]>;
  87526. }): VertexData;
  87527. /**
  87528. * Create the VertexData for a DashedLines
  87529. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  87530. * - points an array successive Vector3
  87531. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  87532. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  87533. * - dashNb the intended total number of dashes, optional, default 200
  87534. * @returns the VertexData for the DashedLines
  87535. */
  87536. static CreateDashedLines(options: {
  87537. points: Vector3[];
  87538. dashSize?: number;
  87539. gapSize?: number;
  87540. dashNb?: number;
  87541. }): VertexData;
  87542. /**
  87543. * Creates the VertexData for a Ground
  87544. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87545. * - width the width (x direction) of the ground, optional, default 1
  87546. * - height the height (z direction) of the ground, optional, default 1
  87547. * - subdivisions the number of subdivisions per side, optional, default 1
  87548. * @returns the VertexData of the Ground
  87549. */
  87550. static CreateGround(options: {
  87551. width?: number;
  87552. height?: number;
  87553. subdivisions?: number;
  87554. subdivisionsX?: number;
  87555. subdivisionsY?: number;
  87556. }): VertexData;
  87557. /**
  87558. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  87559. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  87560. * * xmin the ground minimum X coordinate, optional, default -1
  87561. * * zmin the ground minimum Z coordinate, optional, default -1
  87562. * * xmax the ground maximum X coordinate, optional, default 1
  87563. * * zmax the ground maximum Z coordinate, optional, default 1
  87564. * * 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}
  87565. * * 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}
  87566. * @returns the VertexData of the TiledGround
  87567. */
  87568. static CreateTiledGround(options: {
  87569. xmin: number;
  87570. zmin: number;
  87571. xmax: number;
  87572. zmax: number;
  87573. subdivisions?: {
  87574. w: number;
  87575. h: number;
  87576. };
  87577. precision?: {
  87578. w: number;
  87579. h: number;
  87580. };
  87581. }): VertexData;
  87582. /**
  87583. * Creates the VertexData of the Ground designed from a heightmap
  87584. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  87585. * * width the width (x direction) of the ground
  87586. * * height the height (z direction) of the ground
  87587. * * subdivisions the number of subdivisions per side
  87588. * * minHeight the minimum altitude on the ground, optional, default 0
  87589. * * maxHeight the maximum altitude on the ground, optional default 1
  87590. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  87591. * * buffer the array holding the image color data
  87592. * * bufferWidth the width of image
  87593. * * bufferHeight the height of image
  87594. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  87595. * @returns the VertexData of the Ground designed from a heightmap
  87596. */
  87597. static CreateGroundFromHeightMap(options: {
  87598. width: number;
  87599. height: number;
  87600. subdivisions: number;
  87601. minHeight: number;
  87602. maxHeight: number;
  87603. colorFilter: Color3;
  87604. buffer: Uint8Array;
  87605. bufferWidth: number;
  87606. bufferHeight: number;
  87607. alphaFilter: number;
  87608. }): VertexData;
  87609. /**
  87610. * Creates the VertexData for a Plane
  87611. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  87612. * * size sets the width and height of the plane to the value of size, optional default 1
  87613. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  87614. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  87615. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87616. * * 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)
  87617. * * 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)
  87618. * @returns the VertexData of the box
  87619. */
  87620. static CreatePlane(options: {
  87621. size?: number;
  87622. width?: number;
  87623. height?: number;
  87624. sideOrientation?: number;
  87625. frontUVs?: Vector4;
  87626. backUVs?: Vector4;
  87627. }): VertexData;
  87628. /**
  87629. * Creates the VertexData of the Disc or regular Polygon
  87630. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  87631. * * radius the radius of the disc, optional default 0.5
  87632. * * tessellation the number of polygon sides, optional, default 64
  87633. * * 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
  87634. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87635. * * 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)
  87636. * * 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)
  87637. * @returns the VertexData of the box
  87638. */
  87639. static CreateDisc(options: {
  87640. radius?: number;
  87641. tessellation?: number;
  87642. arc?: number;
  87643. sideOrientation?: number;
  87644. frontUVs?: Vector4;
  87645. backUVs?: Vector4;
  87646. }): VertexData;
  87647. /**
  87648. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  87649. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  87650. * @param polygon a mesh built from polygonTriangulation.build()
  87651. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87652. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87653. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87654. * @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)
  87655. * @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)
  87656. * @returns the VertexData of the Polygon
  87657. */
  87658. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  87659. /**
  87660. * Creates the VertexData of the IcoSphere
  87661. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  87662. * * radius the radius of the IcoSphere, optional default 1
  87663. * * radiusX allows stretching in the x direction, optional, default radius
  87664. * * radiusY allows stretching in the y direction, optional, default radius
  87665. * * radiusZ allows stretching in the z direction, optional, default radius
  87666. * * flat when true creates a flat shaded mesh, optional, default true
  87667. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87668. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87669. * * 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)
  87670. * * 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)
  87671. * @returns the VertexData of the IcoSphere
  87672. */
  87673. static CreateIcoSphere(options: {
  87674. radius?: number;
  87675. radiusX?: number;
  87676. radiusY?: number;
  87677. radiusZ?: number;
  87678. flat?: boolean;
  87679. subdivisions?: number;
  87680. sideOrientation?: number;
  87681. frontUVs?: Vector4;
  87682. backUVs?: Vector4;
  87683. }): VertexData;
  87684. /**
  87685. * Creates the VertexData for a Polyhedron
  87686. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  87687. * * type provided types are:
  87688. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  87689. * * 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)
  87690. * * size the size of the IcoSphere, optional default 1
  87691. * * sizeX allows stretching in the x direction, optional, default size
  87692. * * sizeY allows stretching in the y direction, optional, default size
  87693. * * sizeZ allows stretching in the z direction, optional, default size
  87694. * * 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
  87695. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  87696. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  87697. * * flat when true creates a flat shaded mesh, optional, default true
  87698. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  87699. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87700. * * 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)
  87701. * * 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)
  87702. * @returns the VertexData of the Polyhedron
  87703. */
  87704. static CreatePolyhedron(options: {
  87705. type?: number;
  87706. size?: number;
  87707. sizeX?: number;
  87708. sizeY?: number;
  87709. sizeZ?: number;
  87710. custom?: any;
  87711. faceUV?: Vector4[];
  87712. faceColors?: Color4[];
  87713. flat?: boolean;
  87714. sideOrientation?: number;
  87715. frontUVs?: Vector4;
  87716. backUVs?: Vector4;
  87717. }): VertexData;
  87718. /**
  87719. * Creates the VertexData for a TorusKnot
  87720. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  87721. * * radius the radius of the torus knot, optional, default 2
  87722. * * tube the thickness of the tube, optional, default 0.5
  87723. * * radialSegments the number of sides on each tube segments, optional, default 32
  87724. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  87725. * * p the number of windings around the z axis, optional, default 2
  87726. * * q the number of windings around the x axis, optional, default 3
  87727. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87728. * * 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)
  87729. * * 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)
  87730. * @returns the VertexData of the Torus Knot
  87731. */
  87732. static CreateTorusKnot(options: {
  87733. radius?: number;
  87734. tube?: number;
  87735. radialSegments?: number;
  87736. tubularSegments?: number;
  87737. p?: number;
  87738. q?: number;
  87739. sideOrientation?: number;
  87740. frontUVs?: Vector4;
  87741. backUVs?: Vector4;
  87742. }): VertexData;
  87743. /**
  87744. * Compute normals for given positions and indices
  87745. * @param positions an array of vertex positions, [...., x, y, z, ......]
  87746. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  87747. * @param normals an array of vertex normals, [...., x, y, z, ......]
  87748. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  87749. * * facetNormals : optional array of facet normals (vector3)
  87750. * * facetPositions : optional array of facet positions (vector3)
  87751. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  87752. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  87753. * * bInfo : optional bounding info, required for facetPartitioning computation
  87754. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  87755. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  87756. * * useRightHandedSystem: optional boolean to for right handed system computation
  87757. * * depthSort : optional boolean to enable the facet depth sort computation
  87758. * * distanceTo : optional Vector3 to compute the facet depth from this location
  87759. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  87760. */
  87761. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  87762. facetNormals?: any;
  87763. facetPositions?: any;
  87764. facetPartitioning?: any;
  87765. ratio?: number;
  87766. bInfo?: any;
  87767. bbSize?: Vector3;
  87768. subDiv?: any;
  87769. useRightHandedSystem?: boolean;
  87770. depthSort?: boolean;
  87771. distanceTo?: Vector3;
  87772. depthSortedFacets?: any;
  87773. }): void;
  87774. /** @hidden */
  87775. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  87776. /**
  87777. * Applies VertexData created from the imported parameters to the geometry
  87778. * @param parsedVertexData the parsed data from an imported file
  87779. * @param geometry the geometry to apply the VertexData to
  87780. */
  87781. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  87782. }
  87783. }
  87784. declare module BABYLON {
  87785. /**
  87786. * Defines a target to use with MorphTargetManager
  87787. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87788. */
  87789. export class MorphTarget implements IAnimatable {
  87790. /** defines the name of the target */
  87791. name: string;
  87792. /**
  87793. * Gets or sets the list of animations
  87794. */
  87795. animations: Animation[];
  87796. private _scene;
  87797. private _positions;
  87798. private _normals;
  87799. private _tangents;
  87800. private _uvs;
  87801. private _influence;
  87802. /**
  87803. * Observable raised when the influence changes
  87804. */
  87805. onInfluenceChanged: Observable<boolean>;
  87806. /** @hidden */
  87807. _onDataLayoutChanged: Observable<void>;
  87808. /**
  87809. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  87810. */
  87811. influence: number;
  87812. /**
  87813. * Gets or sets the id of the morph Target
  87814. */
  87815. id: string;
  87816. private _animationPropertiesOverride;
  87817. /**
  87818. * Gets or sets the animation properties override
  87819. */
  87820. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87821. /**
  87822. * Creates a new MorphTarget
  87823. * @param name defines the name of the target
  87824. * @param influence defines the influence to use
  87825. * @param scene defines the scene the morphtarget belongs to
  87826. */
  87827. constructor(
  87828. /** defines the name of the target */
  87829. name: string, influence?: number, scene?: Nullable<Scene>);
  87830. /**
  87831. * Gets a boolean defining if the target contains position data
  87832. */
  87833. readonly hasPositions: boolean;
  87834. /**
  87835. * Gets a boolean defining if the target contains normal data
  87836. */
  87837. readonly hasNormals: boolean;
  87838. /**
  87839. * Gets a boolean defining if the target contains tangent data
  87840. */
  87841. readonly hasTangents: boolean;
  87842. /**
  87843. * Gets a boolean defining if the target contains texture coordinates data
  87844. */
  87845. readonly hasUVs: boolean;
  87846. /**
  87847. * Affects position data to this target
  87848. * @param data defines the position data to use
  87849. */
  87850. setPositions(data: Nullable<FloatArray>): void;
  87851. /**
  87852. * Gets the position data stored in this target
  87853. * @returns a FloatArray containing the position data (or null if not present)
  87854. */
  87855. getPositions(): Nullable<FloatArray>;
  87856. /**
  87857. * Affects normal data to this target
  87858. * @param data defines the normal data to use
  87859. */
  87860. setNormals(data: Nullable<FloatArray>): void;
  87861. /**
  87862. * Gets the normal data stored in this target
  87863. * @returns a FloatArray containing the normal data (or null if not present)
  87864. */
  87865. getNormals(): Nullable<FloatArray>;
  87866. /**
  87867. * Affects tangent data to this target
  87868. * @param data defines the tangent data to use
  87869. */
  87870. setTangents(data: Nullable<FloatArray>): void;
  87871. /**
  87872. * Gets the tangent data stored in this target
  87873. * @returns a FloatArray containing the tangent data (or null if not present)
  87874. */
  87875. getTangents(): Nullable<FloatArray>;
  87876. /**
  87877. * Affects texture coordinates data to this target
  87878. * @param data defines the texture coordinates data to use
  87879. */
  87880. setUVs(data: Nullable<FloatArray>): void;
  87881. /**
  87882. * Gets the texture coordinates data stored in this target
  87883. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  87884. */
  87885. getUVs(): Nullable<FloatArray>;
  87886. /**
  87887. * Serializes the current target into a Serialization object
  87888. * @returns the serialized object
  87889. */
  87890. serialize(): any;
  87891. /**
  87892. * Returns the string "MorphTarget"
  87893. * @returns "MorphTarget"
  87894. */
  87895. getClassName(): string;
  87896. /**
  87897. * Creates a new target from serialized data
  87898. * @param serializationObject defines the serialized data to use
  87899. * @returns a new MorphTarget
  87900. */
  87901. static Parse(serializationObject: any): MorphTarget;
  87902. /**
  87903. * Creates a MorphTarget from mesh data
  87904. * @param mesh defines the source mesh
  87905. * @param name defines the name to use for the new target
  87906. * @param influence defines the influence to attach to the target
  87907. * @returns a new MorphTarget
  87908. */
  87909. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  87910. }
  87911. }
  87912. declare module BABYLON {
  87913. /**
  87914. * This class is used to deform meshes using morphing between different targets
  87915. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87916. */
  87917. export class MorphTargetManager {
  87918. private _targets;
  87919. private _targetInfluenceChangedObservers;
  87920. private _targetDataLayoutChangedObservers;
  87921. private _activeTargets;
  87922. private _scene;
  87923. private _influences;
  87924. private _supportsNormals;
  87925. private _supportsTangents;
  87926. private _supportsUVs;
  87927. private _vertexCount;
  87928. private _uniqueId;
  87929. private _tempInfluences;
  87930. /**
  87931. * Gets or sets a boolean indicating if normals must be morphed
  87932. */
  87933. enableNormalMorphing: boolean;
  87934. /**
  87935. * Gets or sets a boolean indicating if tangents must be morphed
  87936. */
  87937. enableTangentMorphing: boolean;
  87938. /**
  87939. * Gets or sets a boolean indicating if UV must be morphed
  87940. */
  87941. enableUVMorphing: boolean;
  87942. /**
  87943. * Creates a new MorphTargetManager
  87944. * @param scene defines the current scene
  87945. */
  87946. constructor(scene?: Nullable<Scene>);
  87947. /**
  87948. * Gets the unique ID of this manager
  87949. */
  87950. readonly uniqueId: number;
  87951. /**
  87952. * Gets the number of vertices handled by this manager
  87953. */
  87954. readonly vertexCount: number;
  87955. /**
  87956. * Gets a boolean indicating if this manager supports morphing of normals
  87957. */
  87958. readonly supportsNormals: boolean;
  87959. /**
  87960. * Gets a boolean indicating if this manager supports morphing of tangents
  87961. */
  87962. readonly supportsTangents: boolean;
  87963. /**
  87964. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  87965. */
  87966. readonly supportsUVs: boolean;
  87967. /**
  87968. * Gets the number of targets stored in this manager
  87969. */
  87970. readonly numTargets: number;
  87971. /**
  87972. * Gets the number of influencers (ie. the number of targets with influences > 0)
  87973. */
  87974. readonly numInfluencers: number;
  87975. /**
  87976. * Gets the list of influences (one per target)
  87977. */
  87978. readonly influences: Float32Array;
  87979. /**
  87980. * Gets the active target at specified index. An active target is a target with an influence > 0
  87981. * @param index defines the index to check
  87982. * @returns the requested target
  87983. */
  87984. getActiveTarget(index: number): MorphTarget;
  87985. /**
  87986. * Gets the target at specified index
  87987. * @param index defines the index to check
  87988. * @returns the requested target
  87989. */
  87990. getTarget(index: number): MorphTarget;
  87991. /**
  87992. * Add a new target to this manager
  87993. * @param target defines the target to add
  87994. */
  87995. addTarget(target: MorphTarget): void;
  87996. /**
  87997. * Removes a target from the manager
  87998. * @param target defines the target to remove
  87999. */
  88000. removeTarget(target: MorphTarget): void;
  88001. /**
  88002. * Serializes the current manager into a Serialization object
  88003. * @returns the serialized object
  88004. */
  88005. serialize(): any;
  88006. private _syncActiveTargets;
  88007. /**
  88008. * Syncrhonize the targets with all the meshes using this morph target manager
  88009. */
  88010. synchronize(): void;
  88011. /**
  88012. * Creates a new MorphTargetManager from serialized data
  88013. * @param serializationObject defines the serialized data
  88014. * @param scene defines the hosting scene
  88015. * @returns the new MorphTargetManager
  88016. */
  88017. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  88018. }
  88019. }
  88020. declare module BABYLON {
  88021. /**
  88022. * Class used to represent a specific level of detail of a mesh
  88023. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  88024. */
  88025. export class MeshLODLevel {
  88026. /** Defines the distance where this level should start being displayed */
  88027. distance: number;
  88028. /** Defines the mesh to use to render this level */
  88029. mesh: Nullable<Mesh>;
  88030. /**
  88031. * Creates a new LOD level
  88032. * @param distance defines the distance where this level should star being displayed
  88033. * @param mesh defines the mesh to use to render this level
  88034. */
  88035. constructor(
  88036. /** Defines the distance where this level should start being displayed */
  88037. distance: number,
  88038. /** Defines the mesh to use to render this level */
  88039. mesh: Nullable<Mesh>);
  88040. }
  88041. }
  88042. declare module BABYLON {
  88043. /**
  88044. * Mesh representing the gorund
  88045. */
  88046. export class GroundMesh extends Mesh {
  88047. /** If octree should be generated */
  88048. generateOctree: boolean;
  88049. private _heightQuads;
  88050. /** @hidden */
  88051. _subdivisionsX: number;
  88052. /** @hidden */
  88053. _subdivisionsY: number;
  88054. /** @hidden */
  88055. _width: number;
  88056. /** @hidden */
  88057. _height: number;
  88058. /** @hidden */
  88059. _minX: number;
  88060. /** @hidden */
  88061. _maxX: number;
  88062. /** @hidden */
  88063. _minZ: number;
  88064. /** @hidden */
  88065. _maxZ: number;
  88066. constructor(name: string, scene: Scene);
  88067. /**
  88068. * "GroundMesh"
  88069. * @returns "GroundMesh"
  88070. */
  88071. getClassName(): string;
  88072. /**
  88073. * The minimum of x and y subdivisions
  88074. */
  88075. readonly subdivisions: number;
  88076. /**
  88077. * X subdivisions
  88078. */
  88079. readonly subdivisionsX: number;
  88080. /**
  88081. * Y subdivisions
  88082. */
  88083. readonly subdivisionsY: number;
  88084. /**
  88085. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  88086. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  88087. * @param chunksCount the number of subdivisions for x and y
  88088. * @param octreeBlocksSize (Default: 32)
  88089. */
  88090. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  88091. /**
  88092. * Returns a height (y) value in the Worl system :
  88093. * the ground altitude at the coordinates (x, z) expressed in the World system.
  88094. * @param x x coordinate
  88095. * @param z z coordinate
  88096. * @returns the ground y position if (x, z) are outside the ground surface.
  88097. */
  88098. getHeightAtCoordinates(x: number, z: number): number;
  88099. /**
  88100. * Returns a normalized vector (Vector3) orthogonal to the ground
  88101. * at the ground coordinates (x, z) expressed in the World system.
  88102. * @param x x coordinate
  88103. * @param z z coordinate
  88104. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  88105. */
  88106. getNormalAtCoordinates(x: number, z: number): Vector3;
  88107. /**
  88108. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  88109. * at the ground coordinates (x, z) expressed in the World system.
  88110. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  88111. * @param x x coordinate
  88112. * @param z z coordinate
  88113. * @param ref vector to store the result
  88114. * @returns the GroundMesh.
  88115. */
  88116. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  88117. /**
  88118. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  88119. * if the ground has been updated.
  88120. * This can be used in the render loop.
  88121. * @returns the GroundMesh.
  88122. */
  88123. updateCoordinateHeights(): GroundMesh;
  88124. private _getFacetAt;
  88125. private _initHeightQuads;
  88126. private _computeHeightQuads;
  88127. /**
  88128. * Serializes this ground mesh
  88129. * @param serializationObject object to write serialization to
  88130. */
  88131. serialize(serializationObject: any): void;
  88132. /**
  88133. * Parses a serialized ground mesh
  88134. * @param parsedMesh the serialized mesh
  88135. * @param scene the scene to create the ground mesh in
  88136. * @returns the created ground mesh
  88137. */
  88138. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  88139. }
  88140. }
  88141. declare module BABYLON {
  88142. /**
  88143. * Interface for Physics-Joint data
  88144. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88145. */
  88146. export interface PhysicsJointData {
  88147. /**
  88148. * The main pivot of the joint
  88149. */
  88150. mainPivot?: Vector3;
  88151. /**
  88152. * The connected pivot of the joint
  88153. */
  88154. connectedPivot?: Vector3;
  88155. /**
  88156. * The main axis of the joint
  88157. */
  88158. mainAxis?: Vector3;
  88159. /**
  88160. * The connected axis of the joint
  88161. */
  88162. connectedAxis?: Vector3;
  88163. /**
  88164. * The collision of the joint
  88165. */
  88166. collision?: boolean;
  88167. /**
  88168. * Native Oimo/Cannon/Energy data
  88169. */
  88170. nativeParams?: any;
  88171. }
  88172. /**
  88173. * This is a holder class for the physics joint created by the physics plugin
  88174. * It holds a set of functions to control the underlying joint
  88175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88176. */
  88177. export class PhysicsJoint {
  88178. /**
  88179. * The type of the physics joint
  88180. */
  88181. type: number;
  88182. /**
  88183. * The data for the physics joint
  88184. */
  88185. jointData: PhysicsJointData;
  88186. private _physicsJoint;
  88187. protected _physicsPlugin: IPhysicsEnginePlugin;
  88188. /**
  88189. * Initializes the physics joint
  88190. * @param type The type of the physics joint
  88191. * @param jointData The data for the physics joint
  88192. */
  88193. constructor(
  88194. /**
  88195. * The type of the physics joint
  88196. */
  88197. type: number,
  88198. /**
  88199. * The data for the physics joint
  88200. */
  88201. jointData: PhysicsJointData);
  88202. /**
  88203. * Gets the physics joint
  88204. */
  88205. /**
  88206. * Sets the physics joint
  88207. */
  88208. physicsJoint: any;
  88209. /**
  88210. * Sets the physics plugin
  88211. */
  88212. physicsPlugin: IPhysicsEnginePlugin;
  88213. /**
  88214. * Execute a function that is physics-plugin specific.
  88215. * @param {Function} func the function that will be executed.
  88216. * It accepts two parameters: the physics world and the physics joint
  88217. */
  88218. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  88219. /**
  88220. * Distance-Joint type
  88221. */
  88222. static DistanceJoint: number;
  88223. /**
  88224. * Hinge-Joint type
  88225. */
  88226. static HingeJoint: number;
  88227. /**
  88228. * Ball-and-Socket joint type
  88229. */
  88230. static BallAndSocketJoint: number;
  88231. /**
  88232. * Wheel-Joint type
  88233. */
  88234. static WheelJoint: number;
  88235. /**
  88236. * Slider-Joint type
  88237. */
  88238. static SliderJoint: number;
  88239. /**
  88240. * Prismatic-Joint type
  88241. */
  88242. static PrismaticJoint: number;
  88243. /**
  88244. * Universal-Joint type
  88245. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  88246. */
  88247. static UniversalJoint: number;
  88248. /**
  88249. * Hinge-Joint 2 type
  88250. */
  88251. static Hinge2Joint: number;
  88252. /**
  88253. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  88254. */
  88255. static PointToPointJoint: number;
  88256. /**
  88257. * Spring-Joint type
  88258. */
  88259. static SpringJoint: number;
  88260. /**
  88261. * Lock-Joint type
  88262. */
  88263. static LockJoint: number;
  88264. }
  88265. /**
  88266. * A class representing a physics distance joint
  88267. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88268. */
  88269. export class DistanceJoint extends PhysicsJoint {
  88270. /**
  88271. *
  88272. * @param jointData The data for the Distance-Joint
  88273. */
  88274. constructor(jointData: DistanceJointData);
  88275. /**
  88276. * Update the predefined distance.
  88277. * @param maxDistance The maximum preferred distance
  88278. * @param minDistance The minimum preferred distance
  88279. */
  88280. updateDistance(maxDistance: number, minDistance?: number): void;
  88281. }
  88282. /**
  88283. * Represents a Motor-Enabled Joint
  88284. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88285. */
  88286. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  88287. /**
  88288. * Initializes the Motor-Enabled Joint
  88289. * @param type The type of the joint
  88290. * @param jointData The physica joint data for the joint
  88291. */
  88292. constructor(type: number, jointData: PhysicsJointData);
  88293. /**
  88294. * Set the motor values.
  88295. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88296. * @param force the force to apply
  88297. * @param maxForce max force for this motor.
  88298. */
  88299. setMotor(force?: number, maxForce?: number): void;
  88300. /**
  88301. * Set the motor's limits.
  88302. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88303. * @param upperLimit The upper limit of the motor
  88304. * @param lowerLimit The lower limit of the motor
  88305. */
  88306. setLimit(upperLimit: number, lowerLimit?: number): void;
  88307. }
  88308. /**
  88309. * This class represents a single physics Hinge-Joint
  88310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88311. */
  88312. export class HingeJoint extends MotorEnabledJoint {
  88313. /**
  88314. * Initializes the Hinge-Joint
  88315. * @param jointData The joint data for the Hinge-Joint
  88316. */
  88317. constructor(jointData: PhysicsJointData);
  88318. /**
  88319. * Set the motor values.
  88320. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88321. * @param {number} force the force to apply
  88322. * @param {number} maxForce max force for this motor.
  88323. */
  88324. setMotor(force?: number, maxForce?: number): void;
  88325. /**
  88326. * Set the motor's limits.
  88327. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88328. * @param upperLimit The upper limit of the motor
  88329. * @param lowerLimit The lower limit of the motor
  88330. */
  88331. setLimit(upperLimit: number, lowerLimit?: number): void;
  88332. }
  88333. /**
  88334. * This class represents a dual hinge physics joint (same as wheel joint)
  88335. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88336. */
  88337. export class Hinge2Joint extends MotorEnabledJoint {
  88338. /**
  88339. * Initializes the Hinge2-Joint
  88340. * @param jointData The joint data for the Hinge2-Joint
  88341. */
  88342. constructor(jointData: PhysicsJointData);
  88343. /**
  88344. * Set the motor values.
  88345. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88346. * @param {number} targetSpeed the speed the motor is to reach
  88347. * @param {number} maxForce max force for this motor.
  88348. * @param {motorIndex} the motor's index, 0 or 1.
  88349. */
  88350. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  88351. /**
  88352. * Set the motor limits.
  88353. * Attention, this function is plugin specific. Engines won't react 100% the same.
  88354. * @param {number} upperLimit the upper limit
  88355. * @param {number} lowerLimit lower limit
  88356. * @param {motorIndex} the motor's index, 0 or 1.
  88357. */
  88358. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88359. }
  88360. /**
  88361. * Interface for a motor enabled joint
  88362. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88363. */
  88364. export interface IMotorEnabledJoint {
  88365. /**
  88366. * Physics joint
  88367. */
  88368. physicsJoint: any;
  88369. /**
  88370. * Sets the motor of the motor-enabled joint
  88371. * @param force The force of the motor
  88372. * @param maxForce The maximum force of the motor
  88373. * @param motorIndex The index of the motor
  88374. */
  88375. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  88376. /**
  88377. * Sets the limit of the motor
  88378. * @param upperLimit The upper limit of the motor
  88379. * @param lowerLimit The lower limit of the motor
  88380. * @param motorIndex The index of the motor
  88381. */
  88382. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88383. }
  88384. /**
  88385. * Joint data for a Distance-Joint
  88386. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88387. */
  88388. export interface DistanceJointData extends PhysicsJointData {
  88389. /**
  88390. * Max distance the 2 joint objects can be apart
  88391. */
  88392. maxDistance: number;
  88393. }
  88394. /**
  88395. * Joint data from a spring joint
  88396. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88397. */
  88398. export interface SpringJointData extends PhysicsJointData {
  88399. /**
  88400. * Length of the spring
  88401. */
  88402. length: number;
  88403. /**
  88404. * Stiffness of the spring
  88405. */
  88406. stiffness: number;
  88407. /**
  88408. * Damping of the spring
  88409. */
  88410. damping: number;
  88411. /** this callback will be called when applying the force to the impostors. */
  88412. forceApplicationCallback: () => void;
  88413. }
  88414. }
  88415. declare module BABYLON {
  88416. /**
  88417. * Holds the data for the raycast result
  88418. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88419. */
  88420. export class PhysicsRaycastResult {
  88421. private _hasHit;
  88422. private _hitDistance;
  88423. private _hitNormalWorld;
  88424. private _hitPointWorld;
  88425. private _rayFromWorld;
  88426. private _rayToWorld;
  88427. /**
  88428. * Gets if there was a hit
  88429. */
  88430. readonly hasHit: boolean;
  88431. /**
  88432. * Gets the distance from the hit
  88433. */
  88434. readonly hitDistance: number;
  88435. /**
  88436. * Gets the hit normal/direction in the world
  88437. */
  88438. readonly hitNormalWorld: Vector3;
  88439. /**
  88440. * Gets the hit point in the world
  88441. */
  88442. readonly hitPointWorld: Vector3;
  88443. /**
  88444. * Gets the ray "start point" of the ray in the world
  88445. */
  88446. readonly rayFromWorld: Vector3;
  88447. /**
  88448. * Gets the ray "end point" of the ray in the world
  88449. */
  88450. readonly rayToWorld: Vector3;
  88451. /**
  88452. * Sets the hit data (normal & point in world space)
  88453. * @param hitNormalWorld defines the normal in world space
  88454. * @param hitPointWorld defines the point in world space
  88455. */
  88456. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  88457. /**
  88458. * Sets the distance from the start point to the hit point
  88459. * @param distance
  88460. */
  88461. setHitDistance(distance: number): void;
  88462. /**
  88463. * Calculates the distance manually
  88464. */
  88465. calculateHitDistance(): void;
  88466. /**
  88467. * Resets all the values to default
  88468. * @param from The from point on world space
  88469. * @param to The to point on world space
  88470. */
  88471. reset(from?: Vector3, to?: Vector3): void;
  88472. }
  88473. /**
  88474. * Interface for the size containing width and height
  88475. */
  88476. interface IXYZ {
  88477. /**
  88478. * X
  88479. */
  88480. x: number;
  88481. /**
  88482. * Y
  88483. */
  88484. y: number;
  88485. /**
  88486. * Z
  88487. */
  88488. z: number;
  88489. }
  88490. }
  88491. declare module BABYLON {
  88492. /**
  88493. * Interface used to describe a physics joint
  88494. */
  88495. export interface PhysicsImpostorJoint {
  88496. /** Defines the main impostor to which the joint is linked */
  88497. mainImpostor: PhysicsImpostor;
  88498. /** Defines the impostor that is connected to the main impostor using this joint */
  88499. connectedImpostor: PhysicsImpostor;
  88500. /** Defines the joint itself */
  88501. joint: PhysicsJoint;
  88502. }
  88503. /** @hidden */
  88504. export interface IPhysicsEnginePlugin {
  88505. world: any;
  88506. name: string;
  88507. setGravity(gravity: Vector3): void;
  88508. setTimeStep(timeStep: number): void;
  88509. getTimeStep(): number;
  88510. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  88511. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88512. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  88513. generatePhysicsBody(impostor: PhysicsImpostor): void;
  88514. removePhysicsBody(impostor: PhysicsImpostor): void;
  88515. generateJoint(joint: PhysicsImpostorJoint): void;
  88516. removeJoint(joint: PhysicsImpostorJoint): void;
  88517. isSupported(): boolean;
  88518. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  88519. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  88520. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88521. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  88522. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88523. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  88524. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  88525. getBodyMass(impostor: PhysicsImpostor): number;
  88526. getBodyFriction(impostor: PhysicsImpostor): number;
  88527. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  88528. getBodyRestitution(impostor: PhysicsImpostor): number;
  88529. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  88530. getBodyPressure?(impostor: PhysicsImpostor): number;
  88531. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  88532. getBodyStiffness?(impostor: PhysicsImpostor): number;
  88533. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  88534. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  88535. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  88536. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  88537. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  88538. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88539. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  88540. sleepBody(impostor: PhysicsImpostor): void;
  88541. wakeUpBody(impostor: PhysicsImpostor): void;
  88542. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88543. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  88544. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  88545. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  88546. getRadius(impostor: PhysicsImpostor): number;
  88547. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  88548. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  88549. dispose(): void;
  88550. }
  88551. /**
  88552. * Interface used to define a physics engine
  88553. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  88554. */
  88555. export interface IPhysicsEngine {
  88556. /**
  88557. * Gets the gravity vector used by the simulation
  88558. */
  88559. gravity: Vector3;
  88560. /**
  88561. * Sets the gravity vector used by the simulation
  88562. * @param gravity defines the gravity vector to use
  88563. */
  88564. setGravity(gravity: Vector3): void;
  88565. /**
  88566. * Set the time step of the physics engine.
  88567. * Default is 1/60.
  88568. * To slow it down, enter 1/600 for example.
  88569. * To speed it up, 1/30
  88570. * @param newTimeStep the new timestep to apply to this world.
  88571. */
  88572. setTimeStep(newTimeStep: number): void;
  88573. /**
  88574. * Get the time step of the physics engine.
  88575. * @returns the current time step
  88576. */
  88577. getTimeStep(): number;
  88578. /**
  88579. * Release all resources
  88580. */
  88581. dispose(): void;
  88582. /**
  88583. * Gets the name of the current physics plugin
  88584. * @returns the name of the plugin
  88585. */
  88586. getPhysicsPluginName(): string;
  88587. /**
  88588. * Adding a new impostor for the impostor tracking.
  88589. * This will be done by the impostor itself.
  88590. * @param impostor the impostor to add
  88591. */
  88592. addImpostor(impostor: PhysicsImpostor): void;
  88593. /**
  88594. * Remove an impostor from the engine.
  88595. * This impostor and its mesh will not longer be updated by the physics engine.
  88596. * @param impostor the impostor to remove
  88597. */
  88598. removeImpostor(impostor: PhysicsImpostor): void;
  88599. /**
  88600. * Add a joint to the physics engine
  88601. * @param mainImpostor defines the main impostor to which the joint is added.
  88602. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  88603. * @param joint defines the joint that will connect both impostors.
  88604. */
  88605. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88606. /**
  88607. * Removes a joint from the simulation
  88608. * @param mainImpostor defines the impostor used with the joint
  88609. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  88610. * @param joint defines the joint to remove
  88611. */
  88612. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  88613. /**
  88614. * Gets the current plugin used to run the simulation
  88615. * @returns current plugin
  88616. */
  88617. getPhysicsPlugin(): IPhysicsEnginePlugin;
  88618. /**
  88619. * Gets the list of physic impostors
  88620. * @returns an array of PhysicsImpostor
  88621. */
  88622. getImpostors(): Array<PhysicsImpostor>;
  88623. /**
  88624. * Gets the impostor for a physics enabled object
  88625. * @param object defines the object impersonated by the impostor
  88626. * @returns the PhysicsImpostor or null if not found
  88627. */
  88628. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  88629. /**
  88630. * Gets the impostor for a physics body object
  88631. * @param body defines physics body used by the impostor
  88632. * @returns the PhysicsImpostor or null if not found
  88633. */
  88634. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  88635. /**
  88636. * Does a raycast in the physics world
  88637. * @param from when should the ray start?
  88638. * @param to when should the ray end?
  88639. * @returns PhysicsRaycastResult
  88640. */
  88641. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  88642. /**
  88643. * Called by the scene. No need to call it.
  88644. * @param delta defines the timespam between frames
  88645. */
  88646. _step(delta: number): void;
  88647. }
  88648. }
  88649. declare module BABYLON {
  88650. /**
  88651. * The interface for the physics imposter parameters
  88652. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88653. */
  88654. export interface PhysicsImpostorParameters {
  88655. /**
  88656. * The mass of the physics imposter
  88657. */
  88658. mass: number;
  88659. /**
  88660. * The friction of the physics imposter
  88661. */
  88662. friction?: number;
  88663. /**
  88664. * The coefficient of restitution of the physics imposter
  88665. */
  88666. restitution?: number;
  88667. /**
  88668. * The native options of the physics imposter
  88669. */
  88670. nativeOptions?: any;
  88671. /**
  88672. * Specifies if the parent should be ignored
  88673. */
  88674. ignoreParent?: boolean;
  88675. /**
  88676. * Specifies if bi-directional transformations should be disabled
  88677. */
  88678. disableBidirectionalTransformation?: boolean;
  88679. /**
  88680. * The pressure inside the physics imposter, soft object only
  88681. */
  88682. pressure?: number;
  88683. /**
  88684. * The stiffness the physics imposter, soft object only
  88685. */
  88686. stiffness?: number;
  88687. /**
  88688. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  88689. */
  88690. velocityIterations?: number;
  88691. /**
  88692. * The number of iterations used in maintaining consistent vertex positions, soft object only
  88693. */
  88694. positionIterations?: number;
  88695. /**
  88696. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  88697. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  88698. * Add to fix multiple points
  88699. */
  88700. fixedPoints?: number;
  88701. /**
  88702. * The collision margin around a soft object
  88703. */
  88704. margin?: number;
  88705. /**
  88706. * The collision margin around a soft object
  88707. */
  88708. damping?: number;
  88709. /**
  88710. * The path for a rope based on an extrusion
  88711. */
  88712. path?: any;
  88713. /**
  88714. * The shape of an extrusion used for a rope based on an extrusion
  88715. */
  88716. shape?: any;
  88717. }
  88718. /**
  88719. * Interface for a physics-enabled object
  88720. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88721. */
  88722. export interface IPhysicsEnabledObject {
  88723. /**
  88724. * The position of the physics-enabled object
  88725. */
  88726. position: Vector3;
  88727. /**
  88728. * The rotation of the physics-enabled object
  88729. */
  88730. rotationQuaternion: Nullable<Quaternion>;
  88731. /**
  88732. * The scale of the physics-enabled object
  88733. */
  88734. scaling: Vector3;
  88735. /**
  88736. * The rotation of the physics-enabled object
  88737. */
  88738. rotation?: Vector3;
  88739. /**
  88740. * The parent of the physics-enabled object
  88741. */
  88742. parent?: any;
  88743. /**
  88744. * The bounding info of the physics-enabled object
  88745. * @returns The bounding info of the physics-enabled object
  88746. */
  88747. getBoundingInfo(): BoundingInfo;
  88748. /**
  88749. * Computes the world matrix
  88750. * @param force Specifies if the world matrix should be computed by force
  88751. * @returns A world matrix
  88752. */
  88753. computeWorldMatrix(force: boolean): Matrix;
  88754. /**
  88755. * Gets the world matrix
  88756. * @returns A world matrix
  88757. */
  88758. getWorldMatrix?(): Matrix;
  88759. /**
  88760. * Gets the child meshes
  88761. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  88762. * @returns An array of abstract meshes
  88763. */
  88764. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  88765. /**
  88766. * Gets the vertex data
  88767. * @param kind The type of vertex data
  88768. * @returns A nullable array of numbers, or a float32 array
  88769. */
  88770. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  88771. /**
  88772. * Gets the indices from the mesh
  88773. * @returns A nullable array of index arrays
  88774. */
  88775. getIndices?(): Nullable<IndicesArray>;
  88776. /**
  88777. * Gets the scene from the mesh
  88778. * @returns the indices array or null
  88779. */
  88780. getScene?(): Scene;
  88781. /**
  88782. * Gets the absolute position from the mesh
  88783. * @returns the absolute position
  88784. */
  88785. getAbsolutePosition(): Vector3;
  88786. /**
  88787. * Gets the absolute pivot point from the mesh
  88788. * @returns the absolute pivot point
  88789. */
  88790. getAbsolutePivotPoint(): Vector3;
  88791. /**
  88792. * Rotates the mesh
  88793. * @param axis The axis of rotation
  88794. * @param amount The amount of rotation
  88795. * @param space The space of the rotation
  88796. * @returns The rotation transform node
  88797. */
  88798. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  88799. /**
  88800. * Translates the mesh
  88801. * @param axis The axis of translation
  88802. * @param distance The distance of translation
  88803. * @param space The space of the translation
  88804. * @returns The transform node
  88805. */
  88806. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  88807. /**
  88808. * Sets the absolute position of the mesh
  88809. * @param absolutePosition The absolute position of the mesh
  88810. * @returns The transform node
  88811. */
  88812. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  88813. /**
  88814. * Gets the class name of the mesh
  88815. * @returns The class name
  88816. */
  88817. getClassName(): string;
  88818. }
  88819. /**
  88820. * Represents a physics imposter
  88821. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  88822. */
  88823. export class PhysicsImpostor {
  88824. /**
  88825. * The physics-enabled object used as the physics imposter
  88826. */
  88827. object: IPhysicsEnabledObject;
  88828. /**
  88829. * The type of the physics imposter
  88830. */
  88831. type: number;
  88832. private _options;
  88833. private _scene?;
  88834. /**
  88835. * The default object size of the imposter
  88836. */
  88837. static DEFAULT_OBJECT_SIZE: Vector3;
  88838. /**
  88839. * The identity quaternion of the imposter
  88840. */
  88841. static IDENTITY_QUATERNION: Quaternion;
  88842. /** @hidden */
  88843. _pluginData: any;
  88844. private _physicsEngine;
  88845. private _physicsBody;
  88846. private _bodyUpdateRequired;
  88847. private _onBeforePhysicsStepCallbacks;
  88848. private _onAfterPhysicsStepCallbacks;
  88849. /** @hidden */
  88850. _onPhysicsCollideCallbacks: Array<{
  88851. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  88852. otherImpostors: Array<PhysicsImpostor>;
  88853. }>;
  88854. private _deltaPosition;
  88855. private _deltaRotation;
  88856. private _deltaRotationConjugated;
  88857. /** @hidden */
  88858. _isFromLine: boolean;
  88859. private _parent;
  88860. private _isDisposed;
  88861. private static _tmpVecs;
  88862. private static _tmpQuat;
  88863. /**
  88864. * Specifies if the physics imposter is disposed
  88865. */
  88866. readonly isDisposed: boolean;
  88867. /**
  88868. * Gets the mass of the physics imposter
  88869. */
  88870. mass: number;
  88871. /**
  88872. * Gets the coefficient of friction
  88873. */
  88874. /**
  88875. * Sets the coefficient of friction
  88876. */
  88877. friction: number;
  88878. /**
  88879. * Gets the coefficient of restitution
  88880. */
  88881. /**
  88882. * Sets the coefficient of restitution
  88883. */
  88884. restitution: number;
  88885. /**
  88886. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  88887. */
  88888. /**
  88889. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  88890. */
  88891. pressure: number;
  88892. /**
  88893. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88894. */
  88895. /**
  88896. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  88897. */
  88898. stiffness: number;
  88899. /**
  88900. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88901. */
  88902. /**
  88903. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  88904. */
  88905. velocityIterations: number;
  88906. /**
  88907. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88908. */
  88909. /**
  88910. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  88911. */
  88912. positionIterations: number;
  88913. /**
  88914. * The unique id of the physics imposter
  88915. * set by the physics engine when adding this impostor to the array
  88916. */
  88917. uniqueId: number;
  88918. /**
  88919. * @hidden
  88920. */
  88921. soft: boolean;
  88922. /**
  88923. * @hidden
  88924. */
  88925. segments: number;
  88926. private _joints;
  88927. /**
  88928. * Initializes the physics imposter
  88929. * @param object The physics-enabled object used as the physics imposter
  88930. * @param type The type of the physics imposter
  88931. * @param _options The options for the physics imposter
  88932. * @param _scene The Babylon scene
  88933. */
  88934. constructor(
  88935. /**
  88936. * The physics-enabled object used as the physics imposter
  88937. */
  88938. object: IPhysicsEnabledObject,
  88939. /**
  88940. * The type of the physics imposter
  88941. */
  88942. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  88943. /**
  88944. * This function will completly initialize this impostor.
  88945. * It will create a new body - but only if this mesh has no parent.
  88946. * If it has, this impostor will not be used other than to define the impostor
  88947. * of the child mesh.
  88948. * @hidden
  88949. */
  88950. _init(): void;
  88951. private _getPhysicsParent;
  88952. /**
  88953. * Should a new body be generated.
  88954. * @returns boolean specifying if body initialization is required
  88955. */
  88956. isBodyInitRequired(): boolean;
  88957. /**
  88958. * Sets the updated scaling
  88959. * @param updated Specifies if the scaling is updated
  88960. */
  88961. setScalingUpdated(): void;
  88962. /**
  88963. * Force a regeneration of this or the parent's impostor's body.
  88964. * Use under cautious - This will remove all joints already implemented.
  88965. */
  88966. forceUpdate(): void;
  88967. /**
  88968. * Gets the body that holds this impostor. Either its own, or its parent.
  88969. */
  88970. /**
  88971. * Set the physics body. Used mainly by the physics engine/plugin
  88972. */
  88973. physicsBody: any;
  88974. /**
  88975. * Get the parent of the physics imposter
  88976. * @returns Physics imposter or null
  88977. */
  88978. /**
  88979. * Sets the parent of the physics imposter
  88980. */
  88981. parent: Nullable<PhysicsImpostor>;
  88982. /**
  88983. * Resets the update flags
  88984. */
  88985. resetUpdateFlags(): void;
  88986. /**
  88987. * Gets the object extend size
  88988. * @returns the object extend size
  88989. */
  88990. getObjectExtendSize(): Vector3;
  88991. /**
  88992. * Gets the object center
  88993. * @returns The object center
  88994. */
  88995. getObjectCenter(): Vector3;
  88996. /**
  88997. * Get a specific parametes from the options parameter
  88998. * @param paramName The object parameter name
  88999. * @returns The object parameter
  89000. */
  89001. getParam(paramName: string): any;
  89002. /**
  89003. * Sets a specific parameter in the options given to the physics plugin
  89004. * @param paramName The parameter name
  89005. * @param value The value of the parameter
  89006. */
  89007. setParam(paramName: string, value: number): void;
  89008. /**
  89009. * Specifically change the body's mass option. Won't recreate the physics body object
  89010. * @param mass The mass of the physics imposter
  89011. */
  89012. setMass(mass: number): void;
  89013. /**
  89014. * Gets the linear velocity
  89015. * @returns linear velocity or null
  89016. */
  89017. getLinearVelocity(): Nullable<Vector3>;
  89018. /**
  89019. * Sets the linear velocity
  89020. * @param velocity linear velocity or null
  89021. */
  89022. setLinearVelocity(velocity: Nullable<Vector3>): void;
  89023. /**
  89024. * Gets the angular velocity
  89025. * @returns angular velocity or null
  89026. */
  89027. getAngularVelocity(): Nullable<Vector3>;
  89028. /**
  89029. * Sets the angular velocity
  89030. * @param velocity The velocity or null
  89031. */
  89032. setAngularVelocity(velocity: Nullable<Vector3>): void;
  89033. /**
  89034. * Execute a function with the physics plugin native code
  89035. * Provide a function the will have two variables - the world object and the physics body object
  89036. * @param func The function to execute with the physics plugin native code
  89037. */
  89038. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  89039. /**
  89040. * Register a function that will be executed before the physics world is stepping forward
  89041. * @param func The function to execute before the physics world is stepped forward
  89042. */
  89043. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89044. /**
  89045. * Unregister a function that will be executed before the physics world is stepping forward
  89046. * @param func The function to execute before the physics world is stepped forward
  89047. */
  89048. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89049. /**
  89050. * Register a function that will be executed after the physics step
  89051. * @param func The function to execute after physics step
  89052. */
  89053. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89054. /**
  89055. * Unregisters a function that will be executed after the physics step
  89056. * @param func The function to execute after physics step
  89057. */
  89058. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  89059. /**
  89060. * register a function that will be executed when this impostor collides against a different body
  89061. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  89062. * @param func Callback that is executed on collision
  89063. */
  89064. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  89065. /**
  89066. * Unregisters the physics imposter on contact
  89067. * @param collideAgainst The physics object to collide against
  89068. * @param func Callback to execute on collision
  89069. */
  89070. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  89071. private _tmpQuat;
  89072. private _tmpQuat2;
  89073. /**
  89074. * Get the parent rotation
  89075. * @returns The parent rotation
  89076. */
  89077. getParentsRotation(): Quaternion;
  89078. /**
  89079. * this function is executed by the physics engine.
  89080. */
  89081. beforeStep: () => void;
  89082. /**
  89083. * this function is executed by the physics engine
  89084. */
  89085. afterStep: () => void;
  89086. /**
  89087. * Legacy collision detection event support
  89088. */
  89089. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  89090. /**
  89091. * event and body object due to cannon's event-based architecture.
  89092. */
  89093. onCollide: (e: {
  89094. body: any;
  89095. }) => void;
  89096. /**
  89097. * Apply a force
  89098. * @param force The force to apply
  89099. * @param contactPoint The contact point for the force
  89100. * @returns The physics imposter
  89101. */
  89102. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  89103. /**
  89104. * Apply an impulse
  89105. * @param force The impulse force
  89106. * @param contactPoint The contact point for the impulse force
  89107. * @returns The physics imposter
  89108. */
  89109. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  89110. /**
  89111. * A help function to create a joint
  89112. * @param otherImpostor A physics imposter used to create a joint
  89113. * @param jointType The type of joint
  89114. * @param jointData The data for the joint
  89115. * @returns The physics imposter
  89116. */
  89117. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  89118. /**
  89119. * Add a joint to this impostor with a different impostor
  89120. * @param otherImpostor A physics imposter used to add a joint
  89121. * @param joint The joint to add
  89122. * @returns The physics imposter
  89123. */
  89124. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  89125. /**
  89126. * Add an anchor to a cloth impostor
  89127. * @param otherImpostor rigid impostor to anchor to
  89128. * @param width ratio across width from 0 to 1
  89129. * @param height ratio up height from 0 to 1
  89130. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  89131. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  89132. * @returns impostor the soft imposter
  89133. */
  89134. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89135. /**
  89136. * Add a hook to a rope impostor
  89137. * @param otherImpostor rigid impostor to anchor to
  89138. * @param length ratio across rope from 0 to 1
  89139. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  89140. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  89141. * @returns impostor the rope imposter
  89142. */
  89143. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  89144. /**
  89145. * Will keep this body still, in a sleep mode.
  89146. * @returns the physics imposter
  89147. */
  89148. sleep(): PhysicsImpostor;
  89149. /**
  89150. * Wake the body up.
  89151. * @returns The physics imposter
  89152. */
  89153. wakeUp(): PhysicsImpostor;
  89154. /**
  89155. * Clones the physics imposter
  89156. * @param newObject The physics imposter clones to this physics-enabled object
  89157. * @returns A nullable physics imposter
  89158. */
  89159. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89160. /**
  89161. * Disposes the physics imposter
  89162. */
  89163. dispose(): void;
  89164. /**
  89165. * Sets the delta position
  89166. * @param position The delta position amount
  89167. */
  89168. setDeltaPosition(position: Vector3): void;
  89169. /**
  89170. * Sets the delta rotation
  89171. * @param rotation The delta rotation amount
  89172. */
  89173. setDeltaRotation(rotation: Quaternion): void;
  89174. /**
  89175. * Gets the box size of the physics imposter and stores the result in the input parameter
  89176. * @param result Stores the box size
  89177. * @returns The physics imposter
  89178. */
  89179. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  89180. /**
  89181. * Gets the radius of the physics imposter
  89182. * @returns Radius of the physics imposter
  89183. */
  89184. getRadius(): number;
  89185. /**
  89186. * Sync a bone with this impostor
  89187. * @param bone The bone to sync to the impostor.
  89188. * @param boneMesh The mesh that the bone is influencing.
  89189. * @param jointPivot The pivot of the joint / bone in local space.
  89190. * @param distToJoint Optional distance from the impostor to the joint.
  89191. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  89192. */
  89193. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  89194. /**
  89195. * Sync impostor to a bone
  89196. * @param bone The bone that the impostor will be synced to.
  89197. * @param boneMesh The mesh that the bone is influencing.
  89198. * @param jointPivot The pivot of the joint / bone in local space.
  89199. * @param distToJoint Optional distance from the impostor to the joint.
  89200. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  89201. * @param boneAxis Optional vector3 axis the bone is aligned with
  89202. */
  89203. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  89204. /**
  89205. * No-Imposter type
  89206. */
  89207. static NoImpostor: number;
  89208. /**
  89209. * Sphere-Imposter type
  89210. */
  89211. static SphereImpostor: number;
  89212. /**
  89213. * Box-Imposter type
  89214. */
  89215. static BoxImpostor: number;
  89216. /**
  89217. * Plane-Imposter type
  89218. */
  89219. static PlaneImpostor: number;
  89220. /**
  89221. * Mesh-imposter type
  89222. */
  89223. static MeshImpostor: number;
  89224. /**
  89225. * Capsule-Impostor type (Ammo.js plugin only)
  89226. */
  89227. static CapsuleImpostor: number;
  89228. /**
  89229. * Cylinder-Imposter type
  89230. */
  89231. static CylinderImpostor: number;
  89232. /**
  89233. * Particle-Imposter type
  89234. */
  89235. static ParticleImpostor: number;
  89236. /**
  89237. * Heightmap-Imposter type
  89238. */
  89239. static HeightmapImpostor: number;
  89240. /**
  89241. * ConvexHull-Impostor type (Ammo.js plugin only)
  89242. */
  89243. static ConvexHullImpostor: number;
  89244. /**
  89245. * Rope-Imposter type
  89246. */
  89247. static RopeImpostor: number;
  89248. /**
  89249. * Cloth-Imposter type
  89250. */
  89251. static ClothImpostor: number;
  89252. /**
  89253. * Softbody-Imposter type
  89254. */
  89255. static SoftbodyImpostor: number;
  89256. }
  89257. }
  89258. declare module BABYLON {
  89259. /**
  89260. * @hidden
  89261. **/
  89262. export class _CreationDataStorage {
  89263. closePath?: boolean;
  89264. closeArray?: boolean;
  89265. idx: number[];
  89266. dashSize: number;
  89267. gapSize: number;
  89268. path3D: Path3D;
  89269. pathArray: Vector3[][];
  89270. arc: number;
  89271. radius: number;
  89272. cap: number;
  89273. tessellation: number;
  89274. }
  89275. /**
  89276. * @hidden
  89277. **/
  89278. class _InstanceDataStorage {
  89279. visibleInstances: any;
  89280. batchCache: _InstancesBatch;
  89281. instancesBufferSize: number;
  89282. instancesBuffer: Nullable<Buffer>;
  89283. instancesData: Float32Array;
  89284. overridenInstanceCount: number;
  89285. isFrozen: boolean;
  89286. previousBatch: Nullable<_InstancesBatch>;
  89287. hardwareInstancedRendering: boolean;
  89288. sideOrientation: number;
  89289. }
  89290. /**
  89291. * @hidden
  89292. **/
  89293. export class _InstancesBatch {
  89294. mustReturn: boolean;
  89295. visibleInstances: Nullable<InstancedMesh[]>[];
  89296. renderSelf: boolean[];
  89297. hardwareInstancedRendering: boolean[];
  89298. }
  89299. /**
  89300. * Class used to represent renderable models
  89301. */
  89302. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  89303. /**
  89304. * Mesh side orientation : usually the external or front surface
  89305. */
  89306. static readonly FRONTSIDE: number;
  89307. /**
  89308. * Mesh side orientation : usually the internal or back surface
  89309. */
  89310. static readonly BACKSIDE: number;
  89311. /**
  89312. * Mesh side orientation : both internal and external or front and back surfaces
  89313. */
  89314. static readonly DOUBLESIDE: number;
  89315. /**
  89316. * Mesh side orientation : by default, `FRONTSIDE`
  89317. */
  89318. static readonly DEFAULTSIDE: number;
  89319. /**
  89320. * Mesh cap setting : no cap
  89321. */
  89322. static readonly NO_CAP: number;
  89323. /**
  89324. * Mesh cap setting : one cap at the beginning of the mesh
  89325. */
  89326. static readonly CAP_START: number;
  89327. /**
  89328. * Mesh cap setting : one cap at the end of the mesh
  89329. */
  89330. static readonly CAP_END: number;
  89331. /**
  89332. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  89333. */
  89334. static readonly CAP_ALL: number;
  89335. /**
  89336. * Mesh pattern setting : no flip or rotate
  89337. */
  89338. static readonly NO_FLIP: number;
  89339. /**
  89340. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  89341. */
  89342. static readonly FLIP_TILE: number;
  89343. /**
  89344. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  89345. */
  89346. static readonly ROTATE_TILE: number;
  89347. /**
  89348. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  89349. */
  89350. static readonly FLIP_ROW: number;
  89351. /**
  89352. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  89353. */
  89354. static readonly ROTATE_ROW: number;
  89355. /**
  89356. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  89357. */
  89358. static readonly FLIP_N_ROTATE_TILE: number;
  89359. /**
  89360. * Mesh pattern setting : rotate pattern and rotate
  89361. */
  89362. static readonly FLIP_N_ROTATE_ROW: number;
  89363. /**
  89364. * Mesh tile positioning : part tiles same on left/right or top/bottom
  89365. */
  89366. static readonly CENTER: number;
  89367. /**
  89368. * Mesh tile positioning : part tiles on left
  89369. */
  89370. static readonly LEFT: number;
  89371. /**
  89372. * Mesh tile positioning : part tiles on right
  89373. */
  89374. static readonly RIGHT: number;
  89375. /**
  89376. * Mesh tile positioning : part tiles on top
  89377. */
  89378. static readonly TOP: number;
  89379. /**
  89380. * Mesh tile positioning : part tiles on bottom
  89381. */
  89382. static readonly BOTTOM: number;
  89383. /**
  89384. * Gets the default side orientation.
  89385. * @param orientation the orientation to value to attempt to get
  89386. * @returns the default orientation
  89387. * @hidden
  89388. */
  89389. static _GetDefaultSideOrientation(orientation?: number): number;
  89390. private _internalMeshDataInfo;
  89391. /**
  89392. * An event triggered before rendering the mesh
  89393. */
  89394. readonly onBeforeRenderObservable: Observable<Mesh>;
  89395. /**
  89396. * An event triggered before binding the mesh
  89397. */
  89398. readonly onBeforeBindObservable: Observable<Mesh>;
  89399. /**
  89400. * An event triggered after rendering the mesh
  89401. */
  89402. readonly onAfterRenderObservable: Observable<Mesh>;
  89403. /**
  89404. * An event triggered before drawing the mesh
  89405. */
  89406. readonly onBeforeDrawObservable: Observable<Mesh>;
  89407. private _onBeforeDrawObserver;
  89408. /**
  89409. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  89410. */
  89411. onBeforeDraw: () => void;
  89412. readonly hasInstances: boolean;
  89413. /**
  89414. * Gets the delay loading state of the mesh (when delay loading is turned on)
  89415. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  89416. */
  89417. delayLoadState: number;
  89418. /**
  89419. * Gets the list of instances created from this mesh
  89420. * it is not supposed to be modified manually.
  89421. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  89422. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89423. */
  89424. instances: InstancedMesh[];
  89425. /**
  89426. * Gets the file containing delay loading data for this mesh
  89427. */
  89428. delayLoadingFile: string;
  89429. /** @hidden */
  89430. _binaryInfo: any;
  89431. /**
  89432. * User defined function used to change how LOD level selection is done
  89433. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89434. */
  89435. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  89436. /**
  89437. * Gets or sets the morph target manager
  89438. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  89439. */
  89440. morphTargetManager: Nullable<MorphTargetManager>;
  89441. /** @hidden */
  89442. _creationDataStorage: Nullable<_CreationDataStorage>;
  89443. /** @hidden */
  89444. _geometry: Nullable<Geometry>;
  89445. /** @hidden */
  89446. _delayInfo: Array<string>;
  89447. /** @hidden */
  89448. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  89449. /** @hidden */
  89450. _instanceDataStorage: _InstanceDataStorage;
  89451. private _effectiveMaterial;
  89452. /** @hidden */
  89453. _shouldGenerateFlatShading: boolean;
  89454. /** @hidden */
  89455. _originalBuilderSideOrientation: number;
  89456. /**
  89457. * Use this property to change the original side orientation defined at construction time
  89458. */
  89459. overrideMaterialSideOrientation: Nullable<number>;
  89460. /**
  89461. * Gets the source mesh (the one used to clone this one from)
  89462. */
  89463. readonly source: Nullable<Mesh>;
  89464. /**
  89465. * Gets or sets a boolean indicating that this mesh does not use index buffer
  89466. */
  89467. isUnIndexed: boolean;
  89468. /**
  89469. * @constructor
  89470. * @param name The value used by scene.getMeshByName() to do a lookup.
  89471. * @param scene The scene to add this mesh to.
  89472. * @param parent The parent of this mesh, if it has one
  89473. * @param source An optional Mesh from which geometry is shared, cloned.
  89474. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  89475. * When false, achieved by calling a clone(), also passing False.
  89476. * This will make creation of children, recursive.
  89477. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  89478. */
  89479. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  89480. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  89481. /**
  89482. * Gets the class name
  89483. * @returns the string "Mesh".
  89484. */
  89485. getClassName(): string;
  89486. /** @hidden */
  89487. readonly _isMesh: boolean;
  89488. /**
  89489. * Returns a description of this mesh
  89490. * @param fullDetails define if full details about this mesh must be used
  89491. * @returns a descriptive string representing this mesh
  89492. */
  89493. toString(fullDetails?: boolean): string;
  89494. /** @hidden */
  89495. _unBindEffect(): void;
  89496. /**
  89497. * Gets a boolean indicating if this mesh has LOD
  89498. */
  89499. readonly hasLODLevels: boolean;
  89500. /**
  89501. * Gets the list of MeshLODLevel associated with the current mesh
  89502. * @returns an array of MeshLODLevel
  89503. */
  89504. getLODLevels(): MeshLODLevel[];
  89505. private _sortLODLevels;
  89506. /**
  89507. * Add a mesh as LOD level triggered at the given distance.
  89508. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89509. * @param distance The distance from the center of the object to show this level
  89510. * @param mesh The mesh to be added as LOD level (can be null)
  89511. * @return This mesh (for chaining)
  89512. */
  89513. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  89514. /**
  89515. * Returns the LOD level mesh at the passed distance or null if not found.
  89516. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89517. * @param distance The distance from the center of the object to show this level
  89518. * @returns a Mesh or `null`
  89519. */
  89520. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  89521. /**
  89522. * Remove a mesh from the LOD array
  89523. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89524. * @param mesh defines the mesh to be removed
  89525. * @return This mesh (for chaining)
  89526. */
  89527. removeLODLevel(mesh: Mesh): Mesh;
  89528. /**
  89529. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  89530. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  89531. * @param camera defines the camera to use to compute distance
  89532. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  89533. * @return This mesh (for chaining)
  89534. */
  89535. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  89536. /**
  89537. * Gets the mesh internal Geometry object
  89538. */
  89539. readonly geometry: Nullable<Geometry>;
  89540. /**
  89541. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  89542. * @returns the total number of vertices
  89543. */
  89544. getTotalVertices(): number;
  89545. /**
  89546. * Returns the content of an associated vertex buffer
  89547. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89548. * - VertexBuffer.PositionKind
  89549. * - VertexBuffer.UVKind
  89550. * - VertexBuffer.UV2Kind
  89551. * - VertexBuffer.UV3Kind
  89552. * - VertexBuffer.UV4Kind
  89553. * - VertexBuffer.UV5Kind
  89554. * - VertexBuffer.UV6Kind
  89555. * - VertexBuffer.ColorKind
  89556. * - VertexBuffer.MatricesIndicesKind
  89557. * - VertexBuffer.MatricesIndicesExtraKind
  89558. * - VertexBuffer.MatricesWeightsKind
  89559. * - VertexBuffer.MatricesWeightsExtraKind
  89560. * @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
  89561. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  89562. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  89563. */
  89564. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  89565. /**
  89566. * Returns the mesh VertexBuffer object from the requested `kind`
  89567. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89568. * - VertexBuffer.PositionKind
  89569. * - VertexBuffer.NormalKind
  89570. * - VertexBuffer.UVKind
  89571. * - VertexBuffer.UV2Kind
  89572. * - VertexBuffer.UV3Kind
  89573. * - VertexBuffer.UV4Kind
  89574. * - VertexBuffer.UV5Kind
  89575. * - VertexBuffer.UV6Kind
  89576. * - VertexBuffer.ColorKind
  89577. * - VertexBuffer.MatricesIndicesKind
  89578. * - VertexBuffer.MatricesIndicesExtraKind
  89579. * - VertexBuffer.MatricesWeightsKind
  89580. * - VertexBuffer.MatricesWeightsExtraKind
  89581. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  89582. */
  89583. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  89584. /**
  89585. * Tests if a specific vertex buffer is associated with this mesh
  89586. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89587. * - VertexBuffer.PositionKind
  89588. * - VertexBuffer.NormalKind
  89589. * - VertexBuffer.UVKind
  89590. * - VertexBuffer.UV2Kind
  89591. * - VertexBuffer.UV3Kind
  89592. * - VertexBuffer.UV4Kind
  89593. * - VertexBuffer.UV5Kind
  89594. * - VertexBuffer.UV6Kind
  89595. * - VertexBuffer.ColorKind
  89596. * - VertexBuffer.MatricesIndicesKind
  89597. * - VertexBuffer.MatricesIndicesExtraKind
  89598. * - VertexBuffer.MatricesWeightsKind
  89599. * - VertexBuffer.MatricesWeightsExtraKind
  89600. * @returns a boolean
  89601. */
  89602. isVerticesDataPresent(kind: string): boolean;
  89603. /**
  89604. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  89605. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  89606. * - VertexBuffer.PositionKind
  89607. * - VertexBuffer.UVKind
  89608. * - VertexBuffer.UV2Kind
  89609. * - VertexBuffer.UV3Kind
  89610. * - VertexBuffer.UV4Kind
  89611. * - VertexBuffer.UV5Kind
  89612. * - VertexBuffer.UV6Kind
  89613. * - VertexBuffer.ColorKind
  89614. * - VertexBuffer.MatricesIndicesKind
  89615. * - VertexBuffer.MatricesIndicesExtraKind
  89616. * - VertexBuffer.MatricesWeightsKind
  89617. * - VertexBuffer.MatricesWeightsExtraKind
  89618. * @returns a boolean
  89619. */
  89620. isVertexBufferUpdatable(kind: string): boolean;
  89621. /**
  89622. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  89623. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  89624. * - VertexBuffer.PositionKind
  89625. * - VertexBuffer.NormalKind
  89626. * - VertexBuffer.UVKind
  89627. * - VertexBuffer.UV2Kind
  89628. * - VertexBuffer.UV3Kind
  89629. * - VertexBuffer.UV4Kind
  89630. * - VertexBuffer.UV5Kind
  89631. * - VertexBuffer.UV6Kind
  89632. * - VertexBuffer.ColorKind
  89633. * - VertexBuffer.MatricesIndicesKind
  89634. * - VertexBuffer.MatricesIndicesExtraKind
  89635. * - VertexBuffer.MatricesWeightsKind
  89636. * - VertexBuffer.MatricesWeightsExtraKind
  89637. * @returns an array of strings
  89638. */
  89639. getVerticesDataKinds(): string[];
  89640. /**
  89641. * Returns a positive integer : the total number of indices in this mesh geometry.
  89642. * @returns the numner of indices or zero if the mesh has no geometry.
  89643. */
  89644. getTotalIndices(): number;
  89645. /**
  89646. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89647. * @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.
  89648. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  89649. * @returns the indices array or an empty array if the mesh has no geometry
  89650. */
  89651. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  89652. readonly isBlocked: boolean;
  89653. /**
  89654. * Determine if the current mesh is ready to be rendered
  89655. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89656. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  89657. * @returns true if all associated assets are ready (material, textures, shaders)
  89658. */
  89659. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  89660. /**
  89661. * 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.
  89662. */
  89663. readonly areNormalsFrozen: boolean;
  89664. /**
  89665. * 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.
  89666. * @returns the current mesh
  89667. */
  89668. freezeNormals(): Mesh;
  89669. /**
  89670. * 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
  89671. * @returns the current mesh
  89672. */
  89673. unfreezeNormals(): Mesh;
  89674. /**
  89675. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  89676. */
  89677. overridenInstanceCount: number;
  89678. /** @hidden */
  89679. _preActivate(): Mesh;
  89680. /** @hidden */
  89681. _preActivateForIntermediateRendering(renderId: number): Mesh;
  89682. /** @hidden */
  89683. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  89684. /**
  89685. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89686. * This means the mesh underlying bounding box and sphere are recomputed.
  89687. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89688. * @returns the current mesh
  89689. */
  89690. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  89691. /** @hidden */
  89692. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  89693. /**
  89694. * This function will subdivide the mesh into multiple submeshes
  89695. * @param count defines the expected number of submeshes
  89696. */
  89697. subdivide(count: number): void;
  89698. /**
  89699. * Copy a FloatArray into a specific associated vertex buffer
  89700. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89701. * - VertexBuffer.PositionKind
  89702. * - VertexBuffer.UVKind
  89703. * - VertexBuffer.UV2Kind
  89704. * - VertexBuffer.UV3Kind
  89705. * - VertexBuffer.UV4Kind
  89706. * - VertexBuffer.UV5Kind
  89707. * - VertexBuffer.UV6Kind
  89708. * - VertexBuffer.ColorKind
  89709. * - VertexBuffer.MatricesIndicesKind
  89710. * - VertexBuffer.MatricesIndicesExtraKind
  89711. * - VertexBuffer.MatricesWeightsKind
  89712. * - VertexBuffer.MatricesWeightsExtraKind
  89713. * @param data defines the data source
  89714. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89715. * @param stride defines the data stride size (can be null)
  89716. * @returns the current mesh
  89717. */
  89718. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89719. /**
  89720. * Flags an associated vertex buffer as updatable
  89721. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  89722. * - VertexBuffer.PositionKind
  89723. * - VertexBuffer.UVKind
  89724. * - VertexBuffer.UV2Kind
  89725. * - VertexBuffer.UV3Kind
  89726. * - VertexBuffer.UV4Kind
  89727. * - VertexBuffer.UV5Kind
  89728. * - VertexBuffer.UV6Kind
  89729. * - VertexBuffer.ColorKind
  89730. * - VertexBuffer.MatricesIndicesKind
  89731. * - VertexBuffer.MatricesIndicesExtraKind
  89732. * - VertexBuffer.MatricesWeightsKind
  89733. * - VertexBuffer.MatricesWeightsExtraKind
  89734. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  89735. */
  89736. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  89737. /**
  89738. * Sets the mesh global Vertex Buffer
  89739. * @param buffer defines the buffer to use
  89740. * @returns the current mesh
  89741. */
  89742. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  89743. /**
  89744. * Update a specific associated vertex buffer
  89745. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  89746. * - VertexBuffer.PositionKind
  89747. * - VertexBuffer.UVKind
  89748. * - VertexBuffer.UV2Kind
  89749. * - VertexBuffer.UV3Kind
  89750. * - VertexBuffer.UV4Kind
  89751. * - VertexBuffer.UV5Kind
  89752. * - VertexBuffer.UV6Kind
  89753. * - VertexBuffer.ColorKind
  89754. * - VertexBuffer.MatricesIndicesKind
  89755. * - VertexBuffer.MatricesIndicesExtraKind
  89756. * - VertexBuffer.MatricesWeightsKind
  89757. * - VertexBuffer.MatricesWeightsExtraKind
  89758. * @param data defines the data source
  89759. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  89760. * @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)
  89761. * @returns the current mesh
  89762. */
  89763. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  89764. /**
  89765. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  89766. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  89767. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  89768. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  89769. * @returns the current mesh
  89770. */
  89771. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  89772. /**
  89773. * Creates a un-shared specific occurence of the geometry for the mesh.
  89774. * @returns the current mesh
  89775. */
  89776. makeGeometryUnique(): Mesh;
  89777. /**
  89778. * Set the index buffer of this mesh
  89779. * @param indices defines the source data
  89780. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  89781. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  89782. * @returns the current mesh
  89783. */
  89784. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  89785. /**
  89786. * Update the current index buffer
  89787. * @param indices defines the source data
  89788. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  89789. * @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)
  89790. * @returns the current mesh
  89791. */
  89792. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  89793. /**
  89794. * Invert the geometry to move from a right handed system to a left handed one.
  89795. * @returns the current mesh
  89796. */
  89797. toLeftHanded(): Mesh;
  89798. /** @hidden */
  89799. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  89800. /** @hidden */
  89801. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  89802. /**
  89803. * Registers for this mesh a javascript function called just before the rendering process
  89804. * @param func defines the function to call before rendering this mesh
  89805. * @returns the current mesh
  89806. */
  89807. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89808. /**
  89809. * Disposes a previously registered javascript function called before the rendering
  89810. * @param func defines the function to remove
  89811. * @returns the current mesh
  89812. */
  89813. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  89814. /**
  89815. * Registers for this mesh a javascript function called just after the rendering is complete
  89816. * @param func defines the function to call after rendering this mesh
  89817. * @returns the current mesh
  89818. */
  89819. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89820. /**
  89821. * Disposes a previously registered javascript function called after the rendering.
  89822. * @param func defines the function to remove
  89823. * @returns the current mesh
  89824. */
  89825. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  89826. /** @hidden */
  89827. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  89828. /** @hidden */
  89829. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  89830. /** @hidden */
  89831. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  89832. /** @hidden */
  89833. _rebuild(): void;
  89834. /** @hidden */
  89835. _freeze(): void;
  89836. /** @hidden */
  89837. _unFreeze(): void;
  89838. /**
  89839. * 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
  89840. * @param subMesh defines the subMesh to render
  89841. * @param enableAlphaMode defines if alpha mode can be changed
  89842. * @returns the current mesh
  89843. */
  89844. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  89845. private _onBeforeDraw;
  89846. /**
  89847. * Renormalize the mesh and patch it up if there are no weights
  89848. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  89849. * However in the case of zero weights then we set just a single influence to 1.
  89850. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  89851. */
  89852. cleanMatrixWeights(): void;
  89853. private normalizeSkinFourWeights;
  89854. private normalizeSkinWeightsAndExtra;
  89855. /**
  89856. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  89857. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  89858. * the user know there was an issue with importing the mesh
  89859. * @returns a validation object with skinned, valid and report string
  89860. */
  89861. validateSkinning(): {
  89862. skinned: boolean;
  89863. valid: boolean;
  89864. report: string;
  89865. };
  89866. /** @hidden */
  89867. _checkDelayState(): Mesh;
  89868. private _queueLoad;
  89869. /**
  89870. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  89871. * A mesh is in the frustum if its bounding box intersects the frustum
  89872. * @param frustumPlanes defines the frustum to test
  89873. * @returns true if the mesh is in the frustum planes
  89874. */
  89875. isInFrustum(frustumPlanes: Plane[]): boolean;
  89876. /**
  89877. * Sets the mesh material by the material or multiMaterial `id` property
  89878. * @param id is a string identifying the material or the multiMaterial
  89879. * @returns the current mesh
  89880. */
  89881. setMaterialByID(id: string): Mesh;
  89882. /**
  89883. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  89884. * @returns an array of IAnimatable
  89885. */
  89886. getAnimatables(): IAnimatable[];
  89887. /**
  89888. * Modifies the mesh geometry according to the passed transformation matrix.
  89889. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  89890. * The mesh normals are modified using the same transformation.
  89891. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89892. * @param transform defines the transform matrix to use
  89893. * @see http://doc.babylonjs.com/resources/baking_transformations
  89894. * @returns the current mesh
  89895. */
  89896. bakeTransformIntoVertices(transform: Matrix): Mesh;
  89897. /**
  89898. * Modifies the mesh geometry according to its own current World Matrix.
  89899. * The mesh World Matrix is then reset.
  89900. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  89901. * Note that, under the hood, this method sets a new VertexBuffer each call.
  89902. * @see http://doc.babylonjs.com/resources/baking_transformations
  89903. * @returns the current mesh
  89904. */
  89905. bakeCurrentTransformIntoVertices(): Mesh;
  89906. /** @hidden */
  89907. readonly _positions: Nullable<Vector3[]>;
  89908. /** @hidden */
  89909. _resetPointsArrayCache(): Mesh;
  89910. /** @hidden */
  89911. _generatePointsArray(): boolean;
  89912. /**
  89913. * Returns a new Mesh object generated from the current mesh properties.
  89914. * This method must not get confused with createInstance()
  89915. * @param name is a string, the name given to the new mesh
  89916. * @param newParent can be any Node object (default `null`)
  89917. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  89918. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  89919. * @returns a new mesh
  89920. */
  89921. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  89922. /**
  89923. * Releases resources associated with this mesh.
  89924. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89925. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89926. */
  89927. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89928. /**
  89929. * Modifies the mesh geometry according to a displacement map.
  89930. * 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.
  89931. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89932. * @param url is a string, the URL from the image file is to be downloaded.
  89933. * @param minHeight is the lower limit of the displacement.
  89934. * @param maxHeight is the upper limit of the displacement.
  89935. * @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.
  89936. * @param uvOffset is an optional vector2 used to offset UV.
  89937. * @param uvScale is an optional vector2 used to scale UV.
  89938. * @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.
  89939. * @returns the Mesh.
  89940. */
  89941. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89942. /**
  89943. * Modifies the mesh geometry according to a displacementMap buffer.
  89944. * 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.
  89945. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  89946. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  89947. * @param heightMapWidth is the width of the buffer image.
  89948. * @param heightMapHeight is the height of the buffer image.
  89949. * @param minHeight is the lower limit of the displacement.
  89950. * @param maxHeight is the upper limit of the displacement.
  89951. * @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.
  89952. * @param uvOffset is an optional vector2 used to offset UV.
  89953. * @param uvScale is an optional vector2 used to scale UV.
  89954. * @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.
  89955. * @returns the Mesh.
  89956. */
  89957. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  89958. /**
  89959. * Modify the mesh to get a flat shading rendering.
  89960. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  89961. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  89962. * @returns current mesh
  89963. */
  89964. convertToFlatShadedMesh(): Mesh;
  89965. /**
  89966. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  89967. * In other words, more vertices, no more indices and a single bigger VBO.
  89968. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  89969. * @returns current mesh
  89970. */
  89971. convertToUnIndexedMesh(): Mesh;
  89972. /**
  89973. * Inverses facet orientations.
  89974. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89975. * @param flipNormals will also inverts the normals
  89976. * @returns current mesh
  89977. */
  89978. flipFaces(flipNormals?: boolean): Mesh;
  89979. /**
  89980. * Increase the number of facets and hence vertices in a mesh
  89981. * Vertex normals are interpolated from existing vertex normals
  89982. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89983. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  89984. */
  89985. increaseVertices(numberPerEdge: number): void;
  89986. /**
  89987. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  89988. * This will undo any application of covertToFlatShadedMesh
  89989. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  89990. */
  89991. forceSharedVertices(): void;
  89992. /** @hidden */
  89993. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  89994. /** @hidden */
  89995. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  89996. /**
  89997. * Creates a new InstancedMesh object from the mesh model.
  89998. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  89999. * @param name defines the name of the new instance
  90000. * @returns a new InstancedMesh
  90001. */
  90002. createInstance(name: string): InstancedMesh;
  90003. /**
  90004. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  90005. * After this call, all the mesh instances have the same submeshes than the current mesh.
  90006. * @returns the current mesh
  90007. */
  90008. synchronizeInstances(): Mesh;
  90009. /**
  90010. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  90011. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  90012. * This should be used together with the simplification to avoid disappearing triangles.
  90013. * @param successCallback an optional success callback to be called after the optimization finished.
  90014. * @returns the current mesh
  90015. */
  90016. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  90017. /**
  90018. * Serialize current mesh
  90019. * @param serializationObject defines the object which will receive the serialization data
  90020. */
  90021. serialize(serializationObject: any): void;
  90022. /** @hidden */
  90023. _syncGeometryWithMorphTargetManager(): void;
  90024. /** @hidden */
  90025. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  90026. /**
  90027. * Returns a new Mesh object parsed from the source provided.
  90028. * @param parsedMesh is the source
  90029. * @param scene defines the hosting scene
  90030. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  90031. * @returns a new Mesh
  90032. */
  90033. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  90034. /**
  90035. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  90036. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90037. * @param name defines the name of the mesh to create
  90038. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  90039. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  90040. * @param closePath creates a seam between the first and the last points of each path of the path array
  90041. * @param offset is taken in account only if the `pathArray` is containing a single path
  90042. * @param scene defines the hosting scene
  90043. * @param updatable defines if the mesh must be flagged as updatable
  90044. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90045. * @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)
  90046. * @returns a new Mesh
  90047. */
  90048. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90049. /**
  90050. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  90051. * @param name defines the name of the mesh to create
  90052. * @param radius sets the radius size (float) of the polygon (default 0.5)
  90053. * @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
  90054. * @param scene defines the hosting scene
  90055. * @param updatable defines if the mesh must be flagged as updatable
  90056. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90057. * @returns a new Mesh
  90058. */
  90059. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  90060. /**
  90061. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  90062. * @param name defines the name of the mesh to create
  90063. * @param size sets the size (float) of each box side (default 1)
  90064. * @param scene defines the hosting scene
  90065. * @param updatable defines if the mesh must be flagged as updatable
  90066. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90067. * @returns a new Mesh
  90068. */
  90069. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  90070. /**
  90071. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  90072. * @param name defines the name of the mesh to create
  90073. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  90074. * @param diameter sets the diameter size (float) of the sphere (default 1)
  90075. * @param scene defines the hosting scene
  90076. * @param updatable defines if the mesh must be flagged as updatable
  90077. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90078. * @returns a new Mesh
  90079. */
  90080. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90081. /**
  90082. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  90083. * @param name defines the name of the mesh to create
  90084. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  90085. * @param diameter sets the diameter size (float) of the sphere (default 1)
  90086. * @param scene defines the hosting scene
  90087. * @returns a new Mesh
  90088. */
  90089. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  90090. /**
  90091. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  90092. * @param name defines the name of the mesh to create
  90093. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  90094. * @param diameterTop set the top cap diameter (floats, default 1)
  90095. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  90096. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  90097. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  90098. * @param scene defines the hosting scene
  90099. * @param updatable defines if the mesh must be flagged as updatable
  90100. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90101. * @returns a new Mesh
  90102. */
  90103. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  90104. /**
  90105. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  90106. * @param name defines the name of the mesh to create
  90107. * @param diameter sets the diameter size (float) of the torus (default 1)
  90108. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  90109. * @param tessellation sets the number of torus sides (postive integer, default 16)
  90110. * @param scene defines the hosting scene
  90111. * @param updatable defines if the mesh must be flagged as updatable
  90112. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90113. * @returns a new Mesh
  90114. */
  90115. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90116. /**
  90117. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  90118. * @param name defines the name of the mesh to create
  90119. * @param radius sets the global radius size (float) of the torus knot (default 2)
  90120. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  90121. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  90122. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  90123. * @param p the number of windings on X axis (positive integers, default 2)
  90124. * @param q the number of windings on Y axis (positive integers, default 3)
  90125. * @param scene defines the hosting scene
  90126. * @param updatable defines if the mesh must be flagged as updatable
  90127. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90128. * @returns a new Mesh
  90129. */
  90130. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90131. /**
  90132. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  90133. * @param name defines the name of the mesh to create
  90134. * @param points is an array successive Vector3
  90135. * @param scene defines the hosting scene
  90136. * @param updatable defines if the mesh must be flagged as updatable
  90137. * @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).
  90138. * @returns a new Mesh
  90139. */
  90140. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  90141. /**
  90142. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  90143. * @param name defines the name of the mesh to create
  90144. * @param points is an array successive Vector3
  90145. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  90146. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  90147. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  90148. * @param scene defines the hosting scene
  90149. * @param updatable defines if the mesh must be flagged as updatable
  90150. * @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)
  90151. * @returns a new Mesh
  90152. */
  90153. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  90154. /**
  90155. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  90156. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  90157. * 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.
  90158. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90159. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  90160. * Remember you can only change the shape positions, not their number when updating a polygon.
  90161. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  90162. * @param name defines the name of the mesh to create
  90163. * @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
  90164. * @param scene defines the hosting scene
  90165. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90166. * @param updatable defines if the mesh must be flagged as updatable
  90167. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90168. * @param earcutInjection can be used to inject your own earcut reference
  90169. * @returns a new Mesh
  90170. */
  90171. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  90172. /**
  90173. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  90174. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  90175. * @param name defines the name of the mesh to create
  90176. * @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
  90177. * @param depth defines the height of extrusion
  90178. * @param scene defines the hosting scene
  90179. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  90180. * @param updatable defines if the mesh must be flagged as updatable
  90181. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90182. * @param earcutInjection can be used to inject your own earcut reference
  90183. * @returns a new Mesh
  90184. */
  90185. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  90186. /**
  90187. * Creates an extruded shape mesh.
  90188. * 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
  90189. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90190. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90191. * @param name defines the name of the mesh to create
  90192. * @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
  90193. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90194. * @param scale is the value to scale the shape
  90195. * @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
  90196. * @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
  90197. * @param scene defines the hosting scene
  90198. * @param updatable defines if the mesh must be flagged as updatable
  90199. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90200. * @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)
  90201. * @returns a new Mesh
  90202. */
  90203. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90204. /**
  90205. * Creates an custom extruded shape mesh.
  90206. * The custom extrusion is a parametric shape.
  90207. * It has no predefined shape. Its final shape will depend on the input parameters.
  90208. * Please consider using the same method from the MeshBuilder class instead
  90209. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  90210. * @param name defines the name of the mesh to create
  90211. * @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
  90212. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  90213. * @param scaleFunction is a custom Javascript function called on each path point
  90214. * @param rotationFunction is a custom Javascript function called on each path point
  90215. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  90216. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  90217. * @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
  90218. * @param scene defines the hosting scene
  90219. * @param updatable defines if the mesh must be flagged as updatable
  90220. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90221. * @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)
  90222. * @returns a new Mesh
  90223. */
  90224. 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;
  90225. /**
  90226. * Creates lathe mesh.
  90227. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  90228. * Please consider using the same method from the MeshBuilder class instead
  90229. * @param name defines the name of the mesh to create
  90230. * @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
  90231. * @param radius is the radius value of the lathe
  90232. * @param tessellation is the side number of the lathe.
  90233. * @param scene defines the hosting scene
  90234. * @param updatable defines if the mesh must be flagged as updatable
  90235. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90236. * @returns a new Mesh
  90237. */
  90238. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90239. /**
  90240. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  90241. * @param name defines the name of the mesh to create
  90242. * @param size sets the size (float) of both sides of the plane at once (default 1)
  90243. * @param scene defines the hosting scene
  90244. * @param updatable defines if the mesh must be flagged as updatable
  90245. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90246. * @returns a new Mesh
  90247. */
  90248. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  90249. /**
  90250. * Creates a ground mesh.
  90251. * Please consider using the same method from the MeshBuilder class instead
  90252. * @param name defines the name of the mesh to create
  90253. * @param width set the width of the ground
  90254. * @param height set the height of the ground
  90255. * @param subdivisions sets the number of subdivisions per side
  90256. * @param scene defines the hosting scene
  90257. * @param updatable defines if the mesh must be flagged as updatable
  90258. * @returns a new Mesh
  90259. */
  90260. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  90261. /**
  90262. * Creates a tiled ground mesh.
  90263. * Please consider using the same method from the MeshBuilder class instead
  90264. * @param name defines the name of the mesh to create
  90265. * @param xmin set the ground minimum X coordinate
  90266. * @param zmin set the ground minimum Y coordinate
  90267. * @param xmax set the ground maximum X coordinate
  90268. * @param zmax set the ground maximum Z coordinate
  90269. * @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
  90270. * @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
  90271. * @param scene defines the hosting scene
  90272. * @param updatable defines if the mesh must be flagged as updatable
  90273. * @returns a new Mesh
  90274. */
  90275. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  90276. w: number;
  90277. h: number;
  90278. }, precision: {
  90279. w: number;
  90280. h: number;
  90281. }, scene: Scene, updatable?: boolean): Mesh;
  90282. /**
  90283. * Creates a ground mesh from a height map.
  90284. * Please consider using the same method from the MeshBuilder class instead
  90285. * @see http://doc.babylonjs.com/babylon101/height_map
  90286. * @param name defines the name of the mesh to create
  90287. * @param url sets the URL of the height map image resource
  90288. * @param width set the ground width size
  90289. * @param height set the ground height size
  90290. * @param subdivisions sets the number of subdivision per side
  90291. * @param minHeight is the minimum altitude on the ground
  90292. * @param maxHeight is the maximum altitude on the ground
  90293. * @param scene defines the hosting scene
  90294. * @param updatable defines if the mesh must be flagged as updatable
  90295. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  90296. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  90297. * @returns a new Mesh
  90298. */
  90299. 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;
  90300. /**
  90301. * Creates a tube mesh.
  90302. * The tube is a parametric shape.
  90303. * It has no predefined shape. Its final shape will depend on the input parameters.
  90304. * Please consider using the same method from the MeshBuilder class instead
  90305. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90306. * @param name defines the name of the mesh to create
  90307. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  90308. * @param radius sets the tube radius size
  90309. * @param tessellation is the number of sides on the tubular surface
  90310. * @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
  90311. * @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
  90312. * @param scene defines the hosting scene
  90313. * @param updatable defines if the mesh must be flagged as updatable
  90314. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  90315. * @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)
  90316. * @returns a new Mesh
  90317. */
  90318. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  90319. (i: number, distance: number): number;
  90320. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  90321. /**
  90322. * Creates a polyhedron mesh.
  90323. * Please consider using the same method from the MeshBuilder class instead.
  90324. * * 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
  90325. * * The parameter `size` (positive float, default 1) sets the polygon size
  90326. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  90327. * * 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`
  90328. * * 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
  90329. * * 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)`)
  90330. * * 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
  90331. * * 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
  90332. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90333. * * If you create a double-sided mesh, you can choose what parts of 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
  90334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90335. * @param name defines the name of the mesh to create
  90336. * @param options defines the options used to create the mesh
  90337. * @param scene defines the hosting scene
  90338. * @returns a new Mesh
  90339. */
  90340. static CreatePolyhedron(name: string, options: {
  90341. type?: number;
  90342. size?: number;
  90343. sizeX?: number;
  90344. sizeY?: number;
  90345. sizeZ?: number;
  90346. custom?: any;
  90347. faceUV?: Vector4[];
  90348. faceColors?: Color4[];
  90349. updatable?: boolean;
  90350. sideOrientation?: number;
  90351. }, scene: Scene): Mesh;
  90352. /**
  90353. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  90354. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  90355. * * 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`)
  90356. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  90357. * * 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
  90358. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  90359. * * If you create a double-sided mesh, you can choose what parts of 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
  90360. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90361. * @param name defines the name of the mesh
  90362. * @param options defines the options used to create the mesh
  90363. * @param scene defines the hosting scene
  90364. * @returns a new Mesh
  90365. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  90366. */
  90367. static CreateIcoSphere(name: string, options: {
  90368. radius?: number;
  90369. flat?: boolean;
  90370. subdivisions?: number;
  90371. sideOrientation?: number;
  90372. updatable?: boolean;
  90373. }, scene: Scene): Mesh;
  90374. /**
  90375. * Creates a decal mesh.
  90376. * Please consider using the same method from the MeshBuilder class instead.
  90377. * A decal is a mesh usually applied as a model onto the surface of another mesh
  90378. * @param name defines the name of the mesh
  90379. * @param sourceMesh defines the mesh receiving the decal
  90380. * @param position sets the position of the decal in world coordinates
  90381. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  90382. * @param size sets the decal scaling
  90383. * @param angle sets the angle to rotate the decal
  90384. * @returns a new Mesh
  90385. */
  90386. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  90387. /**
  90388. * Prepare internal position array for software CPU skinning
  90389. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  90390. */
  90391. setPositionsForCPUSkinning(): Float32Array;
  90392. /**
  90393. * Prepare internal normal array for software CPU skinning
  90394. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  90395. */
  90396. setNormalsForCPUSkinning(): Float32Array;
  90397. /**
  90398. * Updates the vertex buffer by applying transformation from the bones
  90399. * @param skeleton defines the skeleton to apply to current mesh
  90400. * @returns the current mesh
  90401. */
  90402. applySkeleton(skeleton: Skeleton): Mesh;
  90403. /**
  90404. * 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
  90405. * @param meshes defines the list of meshes to scan
  90406. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  90407. */
  90408. static MinMax(meshes: AbstractMesh[]): {
  90409. min: Vector3;
  90410. max: Vector3;
  90411. };
  90412. /**
  90413. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  90414. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  90415. * @returns a vector3
  90416. */
  90417. static Center(meshesOrMinMaxVector: {
  90418. min: Vector3;
  90419. max: Vector3;
  90420. } | AbstractMesh[]): Vector3;
  90421. /**
  90422. * Merge the array of meshes into a single mesh for performance reasons.
  90423. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  90424. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  90425. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  90426. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  90427. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  90428. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  90429. * @returns a new mesh
  90430. */
  90431. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  90432. /** @hidden */
  90433. addInstance(instance: InstancedMesh): void;
  90434. /** @hidden */
  90435. removeInstance(instance: InstancedMesh): void;
  90436. }
  90437. }
  90438. declare module BABYLON {
  90439. /**
  90440. * This is the base class of all the camera used in the application.
  90441. * @see http://doc.babylonjs.com/features/cameras
  90442. */
  90443. export class Camera extends Node {
  90444. /** @hidden */
  90445. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  90446. /**
  90447. * This is the default projection mode used by the cameras.
  90448. * It helps recreating a feeling of perspective and better appreciate depth.
  90449. * This is the best way to simulate real life cameras.
  90450. */
  90451. static readonly PERSPECTIVE_CAMERA: number;
  90452. /**
  90453. * This helps creating camera with an orthographic mode.
  90454. * 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.
  90455. */
  90456. static readonly ORTHOGRAPHIC_CAMERA: number;
  90457. /**
  90458. * This is the default FOV mode for perspective cameras.
  90459. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  90460. */
  90461. static readonly FOVMODE_VERTICAL_FIXED: number;
  90462. /**
  90463. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  90464. */
  90465. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  90466. /**
  90467. * This specifies ther is no need for a camera rig.
  90468. * Basically only one eye is rendered corresponding to the camera.
  90469. */
  90470. static readonly RIG_MODE_NONE: number;
  90471. /**
  90472. * Simulates a camera Rig with one blue eye and one red eye.
  90473. * This can be use with 3d blue and red glasses.
  90474. */
  90475. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  90476. /**
  90477. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  90478. */
  90479. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  90480. /**
  90481. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  90482. */
  90483. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  90484. /**
  90485. * Defines that both eyes of the camera will be rendered over under each other.
  90486. */
  90487. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  90488. /**
  90489. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  90490. */
  90491. static readonly RIG_MODE_VR: number;
  90492. /**
  90493. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  90494. */
  90495. static readonly RIG_MODE_WEBVR: number;
  90496. /**
  90497. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  90498. */
  90499. static readonly RIG_MODE_CUSTOM: number;
  90500. /**
  90501. * Defines if by default attaching controls should prevent the default javascript event to continue.
  90502. */
  90503. static ForceAttachControlToAlwaysPreventDefault: boolean;
  90504. /**
  90505. * Define the input manager associated with the camera.
  90506. */
  90507. inputs: CameraInputsManager<Camera>;
  90508. /** @hidden */
  90509. _position: Vector3;
  90510. /**
  90511. * Define the current local position of the camera in the scene
  90512. */
  90513. position: Vector3;
  90514. /**
  90515. * The vector the camera should consider as up.
  90516. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  90517. */
  90518. upVector: Vector3;
  90519. /**
  90520. * Define the current limit on the left side for an orthographic camera
  90521. * In scene unit
  90522. */
  90523. orthoLeft: Nullable<number>;
  90524. /**
  90525. * Define the current limit on the right side for an orthographic camera
  90526. * In scene unit
  90527. */
  90528. orthoRight: Nullable<number>;
  90529. /**
  90530. * Define the current limit on the bottom side for an orthographic camera
  90531. * In scene unit
  90532. */
  90533. orthoBottom: Nullable<number>;
  90534. /**
  90535. * Define the current limit on the top side for an orthographic camera
  90536. * In scene unit
  90537. */
  90538. orthoTop: Nullable<number>;
  90539. /**
  90540. * Field Of View is set in Radians. (default is 0.8)
  90541. */
  90542. fov: number;
  90543. /**
  90544. * Define the minimum distance the camera can see from.
  90545. * This is important to note that the depth buffer are not infinite and the closer it starts
  90546. * the more your scene might encounter depth fighting issue.
  90547. */
  90548. minZ: number;
  90549. /**
  90550. * Define the maximum distance the camera can see to.
  90551. * This is important to note that the depth buffer are not infinite and the further it end
  90552. * the more your scene might encounter depth fighting issue.
  90553. */
  90554. maxZ: number;
  90555. /**
  90556. * Define the default inertia of the camera.
  90557. * This helps giving a smooth feeling to the camera movement.
  90558. */
  90559. inertia: number;
  90560. /**
  90561. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  90562. */
  90563. mode: number;
  90564. /**
  90565. * Define wether the camera is intermediate.
  90566. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  90567. */
  90568. isIntermediate: boolean;
  90569. /**
  90570. * Define the viewport of the camera.
  90571. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  90572. */
  90573. viewport: Viewport;
  90574. /**
  90575. * Restricts the camera to viewing objects with the same layerMask.
  90576. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  90577. */
  90578. layerMask: number;
  90579. /**
  90580. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  90581. */
  90582. fovMode: number;
  90583. /**
  90584. * Rig mode of the camera.
  90585. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  90586. * This is normally controlled byt the camera themselves as internal use.
  90587. */
  90588. cameraRigMode: number;
  90589. /**
  90590. * Defines the distance between both "eyes" in case of a RIG
  90591. */
  90592. interaxialDistance: number;
  90593. /**
  90594. * Defines if stereoscopic rendering is done side by side or over under.
  90595. */
  90596. isStereoscopicSideBySide: boolean;
  90597. /**
  90598. * 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
  90599. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  90600. * else in the scene. (Eg. security camera)
  90601. *
  90602. * 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)
  90603. */
  90604. customRenderTargets: RenderTargetTexture[];
  90605. /**
  90606. * When set, the camera will render to this render target instead of the default canvas
  90607. *
  90608. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  90609. */
  90610. outputRenderTarget: Nullable<RenderTargetTexture>;
  90611. /**
  90612. * Observable triggered when the camera view matrix has changed.
  90613. */
  90614. onViewMatrixChangedObservable: Observable<Camera>;
  90615. /**
  90616. * Observable triggered when the camera Projection matrix has changed.
  90617. */
  90618. onProjectionMatrixChangedObservable: Observable<Camera>;
  90619. /**
  90620. * Observable triggered when the inputs have been processed.
  90621. */
  90622. onAfterCheckInputsObservable: Observable<Camera>;
  90623. /**
  90624. * Observable triggered when reset has been called and applied to the camera.
  90625. */
  90626. onRestoreStateObservable: Observable<Camera>;
  90627. /** @hidden */
  90628. _cameraRigParams: any;
  90629. /** @hidden */
  90630. _rigCameras: Camera[];
  90631. /** @hidden */
  90632. _rigPostProcess: Nullable<PostProcess>;
  90633. protected _webvrViewMatrix: Matrix;
  90634. /** @hidden */
  90635. _skipRendering: boolean;
  90636. /** @hidden */
  90637. _projectionMatrix: Matrix;
  90638. /** @hidden */
  90639. _postProcesses: Nullable<PostProcess>[];
  90640. /** @hidden */
  90641. _activeMeshes: SmartArray<AbstractMesh>;
  90642. protected _globalPosition: Vector3;
  90643. /** @hidden */
  90644. _computedViewMatrix: Matrix;
  90645. private _doNotComputeProjectionMatrix;
  90646. private _transformMatrix;
  90647. private _frustumPlanes;
  90648. private _refreshFrustumPlanes;
  90649. private _storedFov;
  90650. private _stateStored;
  90651. /**
  90652. * Instantiates a new camera object.
  90653. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  90654. * @see http://doc.babylonjs.com/features/cameras
  90655. * @param name Defines the name of the camera in the scene
  90656. * @param position Defines the position of the camera
  90657. * @param scene Defines the scene the camera belongs too
  90658. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  90659. */
  90660. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90661. /**
  90662. * Store current camera state (fov, position, etc..)
  90663. * @returns the camera
  90664. */
  90665. storeState(): Camera;
  90666. /**
  90667. * Restores the camera state values if it has been stored. You must call storeState() first
  90668. */
  90669. protected _restoreStateValues(): boolean;
  90670. /**
  90671. * Restored camera state. You must call storeState() first.
  90672. * @returns true if restored and false otherwise
  90673. */
  90674. restoreState(): boolean;
  90675. /**
  90676. * Gets the class name of the camera.
  90677. * @returns the class name
  90678. */
  90679. getClassName(): string;
  90680. /** @hidden */
  90681. readonly _isCamera: boolean;
  90682. /**
  90683. * Gets a string representation of the camera useful for debug purpose.
  90684. * @param fullDetails Defines that a more verboe level of logging is required
  90685. * @returns the string representation
  90686. */
  90687. toString(fullDetails?: boolean): string;
  90688. /**
  90689. * Gets the current world space position of the camera.
  90690. */
  90691. readonly globalPosition: Vector3;
  90692. /**
  90693. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  90694. * @returns the active meshe list
  90695. */
  90696. getActiveMeshes(): SmartArray<AbstractMesh>;
  90697. /**
  90698. * Check wether a mesh is part of the current active mesh list of the camera
  90699. * @param mesh Defines the mesh to check
  90700. * @returns true if active, false otherwise
  90701. */
  90702. isActiveMesh(mesh: Mesh): boolean;
  90703. /**
  90704. * Is this camera ready to be used/rendered
  90705. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  90706. * @return true if the camera is ready
  90707. */
  90708. isReady(completeCheck?: boolean): boolean;
  90709. /** @hidden */
  90710. _initCache(): void;
  90711. /** @hidden */
  90712. _updateCache(ignoreParentClass?: boolean): void;
  90713. /** @hidden */
  90714. _isSynchronized(): boolean;
  90715. /** @hidden */
  90716. _isSynchronizedViewMatrix(): boolean;
  90717. /** @hidden */
  90718. _isSynchronizedProjectionMatrix(): boolean;
  90719. /**
  90720. * Attach the input controls to a specific dom element to get the input from.
  90721. * @param element Defines the element the controls should be listened from
  90722. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90723. */
  90724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90725. /**
  90726. * Detach the current controls from the specified dom element.
  90727. * @param element Defines the element to stop listening the inputs from
  90728. */
  90729. detachControl(element: HTMLElement): void;
  90730. /**
  90731. * Update the camera state according to the different inputs gathered during the frame.
  90732. */
  90733. update(): void;
  90734. /** @hidden */
  90735. _checkInputs(): void;
  90736. /** @hidden */
  90737. readonly rigCameras: Camera[];
  90738. /**
  90739. * Gets the post process used by the rig cameras
  90740. */
  90741. readonly rigPostProcess: Nullable<PostProcess>;
  90742. /**
  90743. * Internal, gets the first post proces.
  90744. * @returns the first post process to be run on this camera.
  90745. */
  90746. _getFirstPostProcess(): Nullable<PostProcess>;
  90747. private _cascadePostProcessesToRigCams;
  90748. /**
  90749. * Attach a post process to the camera.
  90750. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90751. * @param postProcess The post process to attach to the camera
  90752. * @param insertAt The position of the post process in case several of them are in use in the scene
  90753. * @returns the position the post process has been inserted at
  90754. */
  90755. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  90756. /**
  90757. * Detach a post process to the camera.
  90758. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  90759. * @param postProcess The post process to detach from the camera
  90760. */
  90761. detachPostProcess(postProcess: PostProcess): void;
  90762. /**
  90763. * Gets the current world matrix of the camera
  90764. */
  90765. getWorldMatrix(): Matrix;
  90766. /** @hidden */
  90767. _getViewMatrix(): Matrix;
  90768. /**
  90769. * Gets the current view matrix of the camera.
  90770. * @param force forces the camera to recompute the matrix without looking at the cached state
  90771. * @returns the view matrix
  90772. */
  90773. getViewMatrix(force?: boolean): Matrix;
  90774. /**
  90775. * Freeze the projection matrix.
  90776. * It will prevent the cache check of the camera projection compute and can speed up perf
  90777. * if no parameter of the camera are meant to change
  90778. * @param projection Defines manually a projection if necessary
  90779. */
  90780. freezeProjectionMatrix(projection?: Matrix): void;
  90781. /**
  90782. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90783. */
  90784. unfreezeProjectionMatrix(): void;
  90785. /**
  90786. * Gets the current projection matrix of the camera.
  90787. * @param force forces the camera to recompute the matrix without looking at the cached state
  90788. * @returns the projection matrix
  90789. */
  90790. getProjectionMatrix(force?: boolean): Matrix;
  90791. /**
  90792. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90793. * @returns a Matrix
  90794. */
  90795. getTransformationMatrix(): Matrix;
  90796. private _updateFrustumPlanes;
  90797. /**
  90798. * Checks if a cullable object (mesh...) is in the camera frustum
  90799. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90800. * @param target The object to check
  90801. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  90802. * @returns true if the object is in frustum otherwise false
  90803. */
  90804. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  90805. /**
  90806. * Checks if a cullable object (mesh...) is in the camera frustum
  90807. * Unlike isInFrustum this cheks the full bounding box
  90808. * @param target The object to check
  90809. * @returns true if the object is in frustum otherwise false
  90810. */
  90811. isCompletelyInFrustum(target: ICullable): boolean;
  90812. /**
  90813. * Gets a ray in the forward direction from the camera.
  90814. * @param length Defines the length of the ray to create
  90815. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90816. * @param origin Defines the start point of the ray which defaults to the camera position
  90817. * @returns the forward ray
  90818. */
  90819. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90820. /**
  90821. * Releases resources associated with this node.
  90822. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90823. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90824. */
  90825. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90826. /** @hidden */
  90827. _isLeftCamera: boolean;
  90828. /**
  90829. * Gets the left camera of a rig setup in case of Rigged Camera
  90830. */
  90831. readonly isLeftCamera: boolean;
  90832. /** @hidden */
  90833. _isRightCamera: boolean;
  90834. /**
  90835. * Gets the right camera of a rig setup in case of Rigged Camera
  90836. */
  90837. readonly isRightCamera: boolean;
  90838. /**
  90839. * Gets the left camera of a rig setup in case of Rigged Camera
  90840. */
  90841. readonly leftCamera: Nullable<FreeCamera>;
  90842. /**
  90843. * Gets the right camera of a rig setup in case of Rigged Camera
  90844. */
  90845. readonly rightCamera: Nullable<FreeCamera>;
  90846. /**
  90847. * Gets the left camera target of a rig setup in case of Rigged Camera
  90848. * @returns the target position
  90849. */
  90850. getLeftTarget(): Nullable<Vector3>;
  90851. /**
  90852. * Gets the right camera target of a rig setup in case of Rigged Camera
  90853. * @returns the target position
  90854. */
  90855. getRightTarget(): Nullable<Vector3>;
  90856. /**
  90857. * @hidden
  90858. */
  90859. setCameraRigMode(mode: number, rigParams: any): void;
  90860. /** @hidden */
  90861. static _setStereoscopicRigMode(camera: Camera): void;
  90862. /** @hidden */
  90863. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90864. /** @hidden */
  90865. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90866. /** @hidden */
  90867. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90868. /** @hidden */
  90869. _getVRProjectionMatrix(): Matrix;
  90870. protected _updateCameraRotationMatrix(): void;
  90871. protected _updateWebVRCameraRotationMatrix(): void;
  90872. /**
  90873. * This function MUST be overwritten by the different WebVR cameras available.
  90874. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90875. * @hidden
  90876. */
  90877. _getWebVRProjectionMatrix(): Matrix;
  90878. /**
  90879. * This function MUST be overwritten by the different WebVR cameras available.
  90880. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90881. * @hidden
  90882. */
  90883. _getWebVRViewMatrix(): Matrix;
  90884. /** @hidden */
  90885. setCameraRigParameter(name: string, value: any): void;
  90886. /**
  90887. * needs to be overridden by children so sub has required properties to be copied
  90888. * @hidden
  90889. */
  90890. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90891. /**
  90892. * May need to be overridden by children
  90893. * @hidden
  90894. */
  90895. _updateRigCameras(): void;
  90896. /** @hidden */
  90897. _setupInputs(): void;
  90898. /**
  90899. * Serialiaze the camera setup to a json represention
  90900. * @returns the JSON representation
  90901. */
  90902. serialize(): any;
  90903. /**
  90904. * Clones the current camera.
  90905. * @param name The cloned camera name
  90906. * @returns the cloned camera
  90907. */
  90908. clone(name: string): Camera;
  90909. /**
  90910. * Gets the direction of the camera relative to a given local axis.
  90911. * @param localAxis Defines the reference axis to provide a relative direction.
  90912. * @return the direction
  90913. */
  90914. getDirection(localAxis: Vector3): Vector3;
  90915. /**
  90916. * Returns the current camera absolute rotation
  90917. */
  90918. readonly absoluteRotation: Quaternion;
  90919. /**
  90920. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90921. * @param localAxis Defines the reference axis to provide a relative direction.
  90922. * @param result Defines the vector to store the result in
  90923. */
  90924. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90925. /**
  90926. * Gets a camera constructor for a given camera type
  90927. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90928. * @param name The name of the camera the result will be able to instantiate
  90929. * @param scene The scene the result will construct the camera in
  90930. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90931. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90932. * @returns a factory method to construc the camera
  90933. */
  90934. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90935. /**
  90936. * Compute the world matrix of the camera.
  90937. * @returns the camera workd matrix
  90938. */
  90939. computeWorldMatrix(): Matrix;
  90940. /**
  90941. * Parse a JSON and creates the camera from the parsed information
  90942. * @param parsedCamera The JSON to parse
  90943. * @param scene The scene to instantiate the camera in
  90944. * @returns the newly constructed camera
  90945. */
  90946. static Parse(parsedCamera: any, scene: Scene): Camera;
  90947. }
  90948. }
  90949. declare module BABYLON {
  90950. /**
  90951. * Class containing static functions to help procedurally build meshes
  90952. */
  90953. export class DiscBuilder {
  90954. /**
  90955. * Creates a plane polygonal mesh. By default, this is a disc
  90956. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  90957. * * 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
  90958. * * 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
  90959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90960. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  90961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90962. * @param name defines the name of the mesh
  90963. * @param options defines the options used to create the mesh
  90964. * @param scene defines the hosting scene
  90965. * @returns the plane polygonal mesh
  90966. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  90967. */
  90968. static CreateDisc(name: string, options: {
  90969. radius?: number;
  90970. tessellation?: number;
  90971. arc?: number;
  90972. updatable?: boolean;
  90973. sideOrientation?: number;
  90974. frontUVs?: Vector4;
  90975. backUVs?: Vector4;
  90976. }, scene?: Nullable<Scene>): Mesh;
  90977. }
  90978. }
  90979. declare module BABYLON {
  90980. /**
  90981. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  90982. *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.
  90983. * The SPS is also a particle system. It provides some methods to manage the particles.
  90984. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  90985. *
  90986. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  90987. */
  90988. export class SolidParticleSystem implements IDisposable {
  90989. /**
  90990. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  90991. * Example : var p = SPS.particles[i];
  90992. */
  90993. particles: SolidParticle[];
  90994. /**
  90995. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  90996. */
  90997. nbParticles: number;
  90998. /**
  90999. * If the particles must ever face the camera (default false). Useful for planar particles.
  91000. */
  91001. billboard: boolean;
  91002. /**
  91003. * Recompute normals when adding a shape
  91004. */
  91005. recomputeNormals: boolean;
  91006. /**
  91007. * This a counter ofr your own usage. It's not set by any SPS functions.
  91008. */
  91009. counter: number;
  91010. /**
  91011. * The SPS name. This name is also given to the underlying mesh.
  91012. */
  91013. name: string;
  91014. /**
  91015. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  91016. */
  91017. mesh: Mesh;
  91018. /**
  91019. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  91020. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  91021. */
  91022. vars: any;
  91023. /**
  91024. * This array is populated when the SPS is set as 'pickable'.
  91025. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  91026. * Each element of this array is an object `{idx: int, faceId: int}`.
  91027. * `idx` is the picked particle index in the `SPS.particles` array
  91028. * `faceId` is the picked face index counted within this particle.
  91029. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  91030. */
  91031. pickedParticles: {
  91032. idx: number;
  91033. faceId: number;
  91034. }[];
  91035. /**
  91036. * This array is populated when `enableDepthSort` is set to true.
  91037. * Each element of this array is an instance of the class DepthSortedParticle.
  91038. */
  91039. depthSortedParticles: DepthSortedParticle[];
  91040. /**
  91041. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  91042. * @hidden
  91043. */
  91044. _bSphereOnly: boolean;
  91045. /**
  91046. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  91047. * @hidden
  91048. */
  91049. _bSphereRadiusFactor: number;
  91050. private _scene;
  91051. private _positions;
  91052. private _indices;
  91053. private _normals;
  91054. private _colors;
  91055. private _uvs;
  91056. private _indices32;
  91057. private _positions32;
  91058. private _normals32;
  91059. private _fixedNormal32;
  91060. private _colors32;
  91061. private _uvs32;
  91062. private _index;
  91063. private _updatable;
  91064. private _pickable;
  91065. private _isVisibilityBoxLocked;
  91066. private _alwaysVisible;
  91067. private _depthSort;
  91068. private _shapeCounter;
  91069. private _copy;
  91070. private _color;
  91071. private _computeParticleColor;
  91072. private _computeParticleTexture;
  91073. private _computeParticleRotation;
  91074. private _computeParticleVertex;
  91075. private _computeBoundingBox;
  91076. private _depthSortParticles;
  91077. private _camera;
  91078. private _mustUnrotateFixedNormals;
  91079. private _particlesIntersect;
  91080. private _needs32Bits;
  91081. /**
  91082. * Creates a SPS (Solid Particle System) object.
  91083. * @param name (String) is the SPS name, this will be the underlying mesh name.
  91084. * @param scene (Scene) is the scene in which the SPS is added.
  91085. * @param options defines the options of the sps e.g.
  91086. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  91087. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  91088. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  91089. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  91090. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  91091. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  91092. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  91093. */
  91094. constructor(name: string, scene: Scene, options?: {
  91095. updatable?: boolean;
  91096. isPickable?: boolean;
  91097. enableDepthSort?: boolean;
  91098. particleIntersection?: boolean;
  91099. boundingSphereOnly?: boolean;
  91100. bSphereRadiusFactor?: number;
  91101. });
  91102. /**
  91103. * Builds the SPS underlying mesh. Returns a standard Mesh.
  91104. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  91105. * @returns the created mesh
  91106. */
  91107. buildMesh(): Mesh;
  91108. /**
  91109. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  91110. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  91111. * Thus the particles generated from `digest()` have their property `position` set yet.
  91112. * @param mesh ( Mesh ) is the mesh to be digested
  91113. * @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
  91114. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  91115. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  91116. * @returns the current SPS
  91117. */
  91118. digest(mesh: Mesh, options?: {
  91119. facetNb?: number;
  91120. number?: number;
  91121. delta?: number;
  91122. }): SolidParticleSystem;
  91123. private _unrotateFixedNormals;
  91124. private _resetCopy;
  91125. private _meshBuilder;
  91126. private _posToShape;
  91127. private _uvsToShapeUV;
  91128. private _addParticle;
  91129. /**
  91130. * Adds some particles to the SPS from the model shape. Returns the shape id.
  91131. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  91132. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  91133. * @param nb (positive integer) the number of particles to be created from this model
  91134. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  91135. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  91136. * @returns the number of shapes in the system
  91137. */
  91138. addShape(mesh: Mesh, nb: number, options?: {
  91139. positionFunction?: any;
  91140. vertexFunction?: any;
  91141. }): number;
  91142. private _rebuildParticle;
  91143. /**
  91144. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  91145. * @returns the SPS.
  91146. */
  91147. rebuildMesh(): SolidParticleSystem;
  91148. /**
  91149. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  91150. * This method calls `updateParticle()` for each particle of the SPS.
  91151. * For an animated SPS, it is usually called within the render loop.
  91152. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  91153. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  91154. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  91155. * @returns the SPS.
  91156. */
  91157. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  91158. /**
  91159. * Disposes the SPS.
  91160. */
  91161. dispose(): void;
  91162. /**
  91163. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  91164. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91165. * @returns the SPS.
  91166. */
  91167. refreshVisibleSize(): SolidParticleSystem;
  91168. /**
  91169. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  91170. * @param size the size (float) of the visibility box
  91171. * note : this doesn't lock the SPS mesh bounding box.
  91172. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91173. */
  91174. setVisibilityBox(size: number): void;
  91175. /**
  91176. * Gets whether the SPS as always visible or not
  91177. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91178. */
  91179. /**
  91180. * Sets the SPS as always visible or not
  91181. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91182. */
  91183. isAlwaysVisible: boolean;
  91184. /**
  91185. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  91186. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91187. */
  91188. /**
  91189. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  91190. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  91191. */
  91192. isVisibilityBoxLocked: boolean;
  91193. /**
  91194. * Tells to `setParticles()` to compute the particle rotations or not.
  91195. * Default value : true. The SPS is faster when it's set to false.
  91196. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91197. */
  91198. /**
  91199. * Gets if `setParticles()` computes the particle rotations or not.
  91200. * Default value : true. The SPS is faster when it's set to false.
  91201. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  91202. */
  91203. computeParticleRotation: boolean;
  91204. /**
  91205. * Tells to `setParticles()` to compute the particle colors or not.
  91206. * Default value : true. The SPS is faster when it's set to false.
  91207. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91208. */
  91209. /**
  91210. * Gets if `setParticles()` computes the particle colors or not.
  91211. * Default value : true. The SPS is faster when it's set to false.
  91212. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  91213. */
  91214. computeParticleColor: boolean;
  91215. /**
  91216. * Gets if `setParticles()` computes the particle textures or not.
  91217. * Default value : true. The SPS is faster when it's set to false.
  91218. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  91219. */
  91220. computeParticleTexture: boolean;
  91221. /**
  91222. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  91223. * Default value : false. The SPS is faster when it's set to false.
  91224. * Note : the particle custom vertex positions aren't stored values.
  91225. */
  91226. /**
  91227. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  91228. * Default value : false. The SPS is faster when it's set to false.
  91229. * Note : the particle custom vertex positions aren't stored values.
  91230. */
  91231. computeParticleVertex: boolean;
  91232. /**
  91233. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  91234. */
  91235. /**
  91236. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  91237. */
  91238. computeBoundingBox: boolean;
  91239. /**
  91240. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  91241. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91242. * Default : `true`
  91243. */
  91244. /**
  91245. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  91246. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  91247. * Default : `true`
  91248. */
  91249. depthSortParticles: boolean;
  91250. /**
  91251. * This function does nothing. It may be overwritten to set all the particle first values.
  91252. * The SPS doesn't call this function, you may have to call it by your own.
  91253. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91254. */
  91255. initParticles(): void;
  91256. /**
  91257. * This function does nothing. It may be overwritten to recycle a particle.
  91258. * The SPS doesn't call this function, you may have to call it by your own.
  91259. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91260. * @param particle The particle to recycle
  91261. * @returns the recycled particle
  91262. */
  91263. recycleParticle(particle: SolidParticle): SolidParticle;
  91264. /**
  91265. * Updates a particle : this function should be overwritten by the user.
  91266. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  91267. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  91268. * @example : just set a particle position or velocity and recycle conditions
  91269. * @param particle The particle to update
  91270. * @returns the updated particle
  91271. */
  91272. updateParticle(particle: SolidParticle): SolidParticle;
  91273. /**
  91274. * Updates a vertex of a particle : it can be overwritten by the user.
  91275. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  91276. * @param particle the current particle
  91277. * @param vertex the current index of the current particle
  91278. * @param pt the index of the current vertex in the particle shape
  91279. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  91280. * @example : just set a vertex particle position
  91281. * @returns the updated vertex
  91282. */
  91283. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  91284. /**
  91285. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  91286. * This does nothing and may be overwritten by the user.
  91287. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91288. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91289. * @param update the boolean update value actually passed to setParticles()
  91290. */
  91291. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91292. /**
  91293. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  91294. * This will be passed three parameters.
  91295. * This does nothing and may be overwritten by the user.
  91296. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91297. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  91298. * @param update the boolean update value actually passed to setParticles()
  91299. */
  91300. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  91301. }
  91302. }
  91303. declare module BABYLON {
  91304. /**
  91305. * Represents one particle of a solid particle system.
  91306. */
  91307. export class SolidParticle {
  91308. /**
  91309. * particle global index
  91310. */
  91311. idx: number;
  91312. /**
  91313. * The color of the particle
  91314. */
  91315. color: Nullable<Color4>;
  91316. /**
  91317. * The world space position of the particle.
  91318. */
  91319. position: Vector3;
  91320. /**
  91321. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  91322. */
  91323. rotation: Vector3;
  91324. /**
  91325. * The world space rotation quaternion of the particle.
  91326. */
  91327. rotationQuaternion: Nullable<Quaternion>;
  91328. /**
  91329. * The scaling of the particle.
  91330. */
  91331. scaling: Vector3;
  91332. /**
  91333. * The uvs of the particle.
  91334. */
  91335. uvs: Vector4;
  91336. /**
  91337. * The current speed of the particle.
  91338. */
  91339. velocity: Vector3;
  91340. /**
  91341. * The pivot point in the particle local space.
  91342. */
  91343. pivot: Vector3;
  91344. /**
  91345. * Must the particle be translated from its pivot point in its local space ?
  91346. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  91347. * Default : false
  91348. */
  91349. translateFromPivot: boolean;
  91350. /**
  91351. * Is the particle active or not ?
  91352. */
  91353. alive: boolean;
  91354. /**
  91355. * Is the particle visible or not ?
  91356. */
  91357. isVisible: boolean;
  91358. /**
  91359. * Index of this particle in the global "positions" array (Internal use)
  91360. * @hidden
  91361. */
  91362. _pos: number;
  91363. /**
  91364. * @hidden Index of this particle in the global "indices" array (Internal use)
  91365. */
  91366. _ind: number;
  91367. /**
  91368. * @hidden ModelShape of this particle (Internal use)
  91369. */
  91370. _model: ModelShape;
  91371. /**
  91372. * ModelShape id of this particle
  91373. */
  91374. shapeId: number;
  91375. /**
  91376. * Index of the particle in its shape id
  91377. */
  91378. idxInShape: number;
  91379. /**
  91380. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  91381. */
  91382. _modelBoundingInfo: BoundingInfo;
  91383. /**
  91384. * @hidden Particle BoundingInfo object (Internal use)
  91385. */
  91386. _boundingInfo: BoundingInfo;
  91387. /**
  91388. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  91389. */
  91390. _sps: SolidParticleSystem;
  91391. /**
  91392. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  91393. */
  91394. _stillInvisible: boolean;
  91395. /**
  91396. * @hidden Last computed particle rotation matrix
  91397. */
  91398. _rotationMatrix: number[];
  91399. /**
  91400. * Parent particle Id, if any.
  91401. * Default null.
  91402. */
  91403. parentId: Nullable<number>;
  91404. /**
  91405. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  91406. * The possible values are :
  91407. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91408. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91409. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91410. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91411. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91412. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  91413. * */
  91414. cullingStrategy: number;
  91415. /**
  91416. * @hidden Internal global position in the SPS.
  91417. */
  91418. _globalPosition: Vector3;
  91419. /**
  91420. * Creates a Solid Particle object.
  91421. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  91422. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  91423. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  91424. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  91425. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  91426. * @param shapeId (integer) is the model shape identifier in the SPS.
  91427. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  91428. * @param sps defines the sps it is associated to
  91429. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  91430. */
  91431. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  91432. /**
  91433. * Legacy support, changed scale to scaling
  91434. */
  91435. /**
  91436. * Legacy support, changed scale to scaling
  91437. */
  91438. scale: Vector3;
  91439. /**
  91440. * Legacy support, changed quaternion to rotationQuaternion
  91441. */
  91442. /**
  91443. * Legacy support, changed quaternion to rotationQuaternion
  91444. */
  91445. quaternion: Nullable<Quaternion>;
  91446. /**
  91447. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  91448. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  91449. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  91450. * @returns true if it intersects
  91451. */
  91452. intersectsMesh(target: Mesh | SolidParticle): boolean;
  91453. /**
  91454. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  91455. * A particle is in the frustum if its bounding box intersects the frustum
  91456. * @param frustumPlanes defines the frustum to test
  91457. * @returns true if the particle is in the frustum planes
  91458. */
  91459. isInFrustum(frustumPlanes: Plane[]): boolean;
  91460. /**
  91461. * get the rotation matrix of the particle
  91462. * @hidden
  91463. */
  91464. getRotationMatrix(m: Matrix): void;
  91465. }
  91466. /**
  91467. * Represents the shape of the model used by one particle of a solid particle system.
  91468. * SPS internal tool, don't use it manually.
  91469. */
  91470. export class ModelShape {
  91471. /**
  91472. * The shape id
  91473. * @hidden
  91474. */
  91475. shapeID: number;
  91476. /**
  91477. * flat array of model positions (internal use)
  91478. * @hidden
  91479. */
  91480. _shape: Vector3[];
  91481. /**
  91482. * flat array of model UVs (internal use)
  91483. * @hidden
  91484. */
  91485. _shapeUV: number[];
  91486. /**
  91487. * length of the shape in the model indices array (internal use)
  91488. * @hidden
  91489. */
  91490. _indicesLength: number;
  91491. /**
  91492. * Custom position function (internal use)
  91493. * @hidden
  91494. */
  91495. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  91496. /**
  91497. * Custom vertex function (internal use)
  91498. * @hidden
  91499. */
  91500. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  91501. /**
  91502. * 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.
  91503. * SPS internal tool, don't use it manually.
  91504. * @hidden
  91505. */
  91506. constructor(id: number, shape: Vector3[], indicesLength: number, shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>);
  91507. }
  91508. /**
  91509. * Represents a Depth Sorted Particle in the solid particle system.
  91510. */
  91511. export class DepthSortedParticle {
  91512. /**
  91513. * Index of the particle in the "indices" array
  91514. */
  91515. ind: number;
  91516. /**
  91517. * Length of the particle shape in the "indices" array
  91518. */
  91519. indicesLength: number;
  91520. /**
  91521. * Squared distance from the particle to the camera
  91522. */
  91523. sqDistance: number;
  91524. }
  91525. }
  91526. declare module BABYLON {
  91527. /**
  91528. * @hidden
  91529. */
  91530. export class _MeshCollisionData {
  91531. _checkCollisions: boolean;
  91532. _collisionMask: number;
  91533. _collisionGroup: number;
  91534. _collider: Nullable<Collider>;
  91535. _oldPositionForCollisions: Vector3;
  91536. _diffPositionForCollisions: Vector3;
  91537. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  91538. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  91539. }
  91540. }
  91541. declare module BABYLON {
  91542. /** @hidden */
  91543. class _FacetDataStorage {
  91544. facetPositions: Vector3[];
  91545. facetNormals: Vector3[];
  91546. facetPartitioning: number[][];
  91547. facetNb: number;
  91548. partitioningSubdivisions: number;
  91549. partitioningBBoxRatio: number;
  91550. facetDataEnabled: boolean;
  91551. facetParameters: any;
  91552. bbSize: Vector3;
  91553. subDiv: {
  91554. max: number;
  91555. X: number;
  91556. Y: number;
  91557. Z: number;
  91558. };
  91559. facetDepthSort: boolean;
  91560. facetDepthSortEnabled: boolean;
  91561. depthSortedIndices: IndicesArray;
  91562. depthSortedFacets: {
  91563. ind: number;
  91564. sqDistance: number;
  91565. }[];
  91566. facetDepthSortFunction: (f1: {
  91567. ind: number;
  91568. sqDistance: number;
  91569. }, f2: {
  91570. ind: number;
  91571. sqDistance: number;
  91572. }) => number;
  91573. facetDepthSortFrom: Vector3;
  91574. facetDepthSortOrigin: Vector3;
  91575. invertedMatrix: Matrix;
  91576. }
  91577. /**
  91578. * @hidden
  91579. **/
  91580. class _InternalAbstractMeshDataInfo {
  91581. _hasVertexAlpha: boolean;
  91582. _useVertexColors: boolean;
  91583. _numBoneInfluencers: number;
  91584. _applyFog: boolean;
  91585. _receiveShadows: boolean;
  91586. _facetData: _FacetDataStorage;
  91587. _visibility: number;
  91588. _skeleton: Nullable<Skeleton>;
  91589. _layerMask: number;
  91590. _computeBonesUsingShaders: boolean;
  91591. _isActive: boolean;
  91592. _onlyForInstances: boolean;
  91593. _isActiveIntermediate: boolean;
  91594. _onlyForInstancesIntermediate: boolean;
  91595. }
  91596. /**
  91597. * Class used to store all common mesh properties
  91598. */
  91599. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  91600. /** No occlusion */
  91601. static OCCLUSION_TYPE_NONE: number;
  91602. /** Occlusion set to optimisitic */
  91603. static OCCLUSION_TYPE_OPTIMISTIC: number;
  91604. /** Occlusion set to strict */
  91605. static OCCLUSION_TYPE_STRICT: number;
  91606. /** Use an accurante occlusion algorithm */
  91607. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  91608. /** Use a conservative occlusion algorithm */
  91609. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  91610. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  91611. * Test order :
  91612. * Is the bounding sphere outside the frustum ?
  91613. * If not, are the bounding box vertices outside the frustum ?
  91614. * It not, then the cullable object is in the frustum.
  91615. */
  91616. static readonly CULLINGSTRATEGY_STANDARD: number;
  91617. /** Culling strategy : Bounding Sphere Only.
  91618. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  91619. * It's also less accurate than the standard because some not visible objects can still be selected.
  91620. * Test : is the bounding sphere outside the frustum ?
  91621. * If not, then the cullable object is in the frustum.
  91622. */
  91623. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  91624. /** Culling strategy : Optimistic Inclusion.
  91625. * This in an inclusion test first, then the standard exclusion test.
  91626. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  91627. * 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.
  91628. * Anyway, it's as accurate as the standard strategy.
  91629. * Test :
  91630. * Is the cullable object bounding sphere center in the frustum ?
  91631. * If not, apply the default culling strategy.
  91632. */
  91633. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  91634. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  91635. * This in an inclusion test first, then the bounding sphere only exclusion test.
  91636. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  91637. * 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.
  91638. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  91639. * Test :
  91640. * Is the cullable object bounding sphere center in the frustum ?
  91641. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  91642. */
  91643. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  91644. /**
  91645. * No billboard
  91646. */
  91647. static readonly BILLBOARDMODE_NONE: number;
  91648. /** Billboard on X axis */
  91649. static readonly BILLBOARDMODE_X: number;
  91650. /** Billboard on Y axis */
  91651. static readonly BILLBOARDMODE_Y: number;
  91652. /** Billboard on Z axis */
  91653. static readonly BILLBOARDMODE_Z: number;
  91654. /** Billboard on all axes */
  91655. static readonly BILLBOARDMODE_ALL: number;
  91656. /** Billboard on using position instead of orientation */
  91657. static readonly BILLBOARDMODE_USE_POSITION: number;
  91658. /** @hidden */
  91659. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  91660. /**
  91661. * The culling strategy to use to check whether the mesh must be rendered or not.
  91662. * This value can be changed at any time and will be used on the next render mesh selection.
  91663. * The possible values are :
  91664. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  91665. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  91666. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  91667. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  91668. * Please read each static variable documentation to get details about the culling process.
  91669. * */
  91670. cullingStrategy: number;
  91671. /**
  91672. * Gets the number of facets in the mesh
  91673. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91674. */
  91675. readonly facetNb: number;
  91676. /**
  91677. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  91678. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91679. */
  91680. partitioningSubdivisions: number;
  91681. /**
  91682. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  91683. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  91684. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  91685. */
  91686. partitioningBBoxRatio: number;
  91687. /**
  91688. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  91689. * Works only for updatable meshes.
  91690. * Doesn't work with multi-materials
  91691. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91692. */
  91693. mustDepthSortFacets: boolean;
  91694. /**
  91695. * The location (Vector3) where the facet depth sort must be computed from.
  91696. * By default, the active camera position.
  91697. * Used only when facet depth sort is enabled
  91698. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  91699. */
  91700. facetDepthSortFrom: Vector3;
  91701. /**
  91702. * gets a boolean indicating if facetData is enabled
  91703. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  91704. */
  91705. readonly isFacetDataEnabled: boolean;
  91706. /** @hidden */
  91707. _updateNonUniformScalingState(value: boolean): boolean;
  91708. /**
  91709. * An event triggered when this mesh collides with another one
  91710. */
  91711. onCollideObservable: Observable<AbstractMesh>;
  91712. /** Set a function to call when this mesh collides with another one */
  91713. onCollide: () => void;
  91714. /**
  91715. * An event triggered when the collision's position changes
  91716. */
  91717. onCollisionPositionChangeObservable: Observable<Vector3>;
  91718. /** Set a function to call when the collision's position changes */
  91719. onCollisionPositionChange: () => void;
  91720. /**
  91721. * An event triggered when material is changed
  91722. */
  91723. onMaterialChangedObservable: Observable<AbstractMesh>;
  91724. /**
  91725. * Gets or sets the orientation for POV movement & rotation
  91726. */
  91727. definedFacingForward: boolean;
  91728. /** @hidden */
  91729. _occlusionQuery: Nullable<WebGLQuery>;
  91730. /** @hidden */
  91731. _renderingGroup: Nullable<RenderingGroup>;
  91732. /**
  91733. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91734. */
  91735. /**
  91736. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  91737. */
  91738. visibility: number;
  91739. /** Gets or sets the alpha index used to sort transparent meshes
  91740. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  91741. */
  91742. alphaIndex: number;
  91743. /**
  91744. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  91745. */
  91746. isVisible: boolean;
  91747. /**
  91748. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91749. */
  91750. isPickable: boolean;
  91751. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  91752. showSubMeshesBoundingBox: boolean;
  91753. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  91754. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  91755. */
  91756. isBlocker: boolean;
  91757. /**
  91758. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  91759. */
  91760. enablePointerMoveEvents: boolean;
  91761. /**
  91762. * Specifies the rendering group id for this mesh (0 by default)
  91763. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91764. */
  91765. renderingGroupId: number;
  91766. private _material;
  91767. /** Gets or sets current material */
  91768. material: Nullable<Material>;
  91769. /**
  91770. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  91771. * @see http://doc.babylonjs.com/babylon101/shadows
  91772. */
  91773. receiveShadows: boolean;
  91774. /** Defines color to use when rendering outline */
  91775. outlineColor: Color3;
  91776. /** Define width to use when rendering outline */
  91777. outlineWidth: number;
  91778. /** Defines color to use when rendering overlay */
  91779. overlayColor: Color3;
  91780. /** Defines alpha to use when rendering overlay */
  91781. overlayAlpha: number;
  91782. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  91783. hasVertexAlpha: boolean;
  91784. /** 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) */
  91785. useVertexColors: boolean;
  91786. /**
  91787. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  91788. */
  91789. computeBonesUsingShaders: boolean;
  91790. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  91791. numBoneInfluencers: number;
  91792. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  91793. applyFog: boolean;
  91794. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  91795. useOctreeForRenderingSelection: boolean;
  91796. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  91797. useOctreeForPicking: boolean;
  91798. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  91799. useOctreeForCollisions: boolean;
  91800. /**
  91801. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  91802. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  91803. */
  91804. layerMask: number;
  91805. /**
  91806. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  91807. */
  91808. alwaysSelectAsActiveMesh: boolean;
  91809. /**
  91810. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  91811. */
  91812. doNotSyncBoundingInfo: boolean;
  91813. /**
  91814. * Gets or sets the current action manager
  91815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91816. */
  91817. actionManager: Nullable<AbstractActionManager>;
  91818. private _meshCollisionData;
  91819. /**
  91820. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  91821. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91822. */
  91823. ellipsoid: Vector3;
  91824. /**
  91825. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  91826. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91827. */
  91828. ellipsoidOffset: Vector3;
  91829. /**
  91830. * Gets or sets a collision mask used to mask collisions (default is -1).
  91831. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91832. */
  91833. collisionMask: number;
  91834. /**
  91835. * Gets or sets the current collision group mask (-1 by default).
  91836. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  91837. */
  91838. collisionGroup: number;
  91839. /**
  91840. * Defines edge width used when edgesRenderer is enabled
  91841. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91842. */
  91843. edgesWidth: number;
  91844. /**
  91845. * Defines edge color used when edgesRenderer is enabled
  91846. * @see https://www.babylonjs-playground.com/#10OJSG#13
  91847. */
  91848. edgesColor: Color4;
  91849. /** @hidden */
  91850. _edgesRenderer: Nullable<IEdgesRenderer>;
  91851. /** @hidden */
  91852. _masterMesh: Nullable<AbstractMesh>;
  91853. /** @hidden */
  91854. _boundingInfo: Nullable<BoundingInfo>;
  91855. /** @hidden */
  91856. _renderId: number;
  91857. /**
  91858. * Gets or sets the list of subMeshes
  91859. * @see http://doc.babylonjs.com/how_to/multi_materials
  91860. */
  91861. subMeshes: SubMesh[];
  91862. /** @hidden */
  91863. _intersectionsInProgress: AbstractMesh[];
  91864. /** @hidden */
  91865. _unIndexed: boolean;
  91866. /** @hidden */
  91867. _lightSources: Light[];
  91868. /** Gets the list of lights affecting that mesh */
  91869. readonly lightSources: Light[];
  91870. /** @hidden */
  91871. readonly _positions: Nullable<Vector3[]>;
  91872. /** @hidden */
  91873. _waitingData: {
  91874. lods: Nullable<any>;
  91875. actions: Nullable<any>;
  91876. freezeWorldMatrix: Nullable<boolean>;
  91877. };
  91878. /** @hidden */
  91879. _bonesTransformMatrices: Nullable<Float32Array>;
  91880. /** @hidden */
  91881. _transformMatrixTexture: Nullable<RawTexture>;
  91882. /**
  91883. * Gets or sets a skeleton to apply skining transformations
  91884. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  91885. */
  91886. skeleton: Nullable<Skeleton>;
  91887. /**
  91888. * An event triggered when the mesh is rebuilt.
  91889. */
  91890. onRebuildObservable: Observable<AbstractMesh>;
  91891. /**
  91892. * Creates a new AbstractMesh
  91893. * @param name defines the name of the mesh
  91894. * @param scene defines the hosting scene
  91895. */
  91896. constructor(name: string, scene?: Nullable<Scene>);
  91897. /**
  91898. * Returns the string "AbstractMesh"
  91899. * @returns "AbstractMesh"
  91900. */
  91901. getClassName(): string;
  91902. /**
  91903. * Gets a string representation of the current mesh
  91904. * @param fullDetails defines a boolean indicating if full details must be included
  91905. * @returns a string representation of the current mesh
  91906. */
  91907. toString(fullDetails?: boolean): string;
  91908. /**
  91909. * @hidden
  91910. */
  91911. protected _getEffectiveParent(): Nullable<Node>;
  91912. /** @hidden */
  91913. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  91914. /** @hidden */
  91915. _rebuild(): void;
  91916. /** @hidden */
  91917. _resyncLightSources(): void;
  91918. /** @hidden */
  91919. _resyncLighSource(light: Light): void;
  91920. /** @hidden */
  91921. _unBindEffect(): void;
  91922. /** @hidden */
  91923. _removeLightSource(light: Light, dispose: boolean): void;
  91924. private _markSubMeshesAsDirty;
  91925. /** @hidden */
  91926. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  91927. /** @hidden */
  91928. _markSubMeshesAsAttributesDirty(): void;
  91929. /** @hidden */
  91930. _markSubMeshesAsMiscDirty(): void;
  91931. /**
  91932. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  91933. */
  91934. scaling: Vector3;
  91935. /**
  91936. * Returns true if the mesh is blocked. Implemented by child classes
  91937. */
  91938. readonly isBlocked: boolean;
  91939. /**
  91940. * Returns the mesh itself by default. Implemented by child classes
  91941. * @param camera defines the camera to use to pick the right LOD level
  91942. * @returns the currentAbstractMesh
  91943. */
  91944. getLOD(camera: Camera): Nullable<AbstractMesh>;
  91945. /**
  91946. * Returns 0 by default. Implemented by child classes
  91947. * @returns an integer
  91948. */
  91949. getTotalVertices(): number;
  91950. /**
  91951. * Returns a positive integer : the total number of indices in this mesh geometry.
  91952. * @returns the numner of indices or zero if the mesh has no geometry.
  91953. */
  91954. getTotalIndices(): number;
  91955. /**
  91956. * Returns null by default. Implemented by child classes
  91957. * @returns null
  91958. */
  91959. getIndices(): Nullable<IndicesArray>;
  91960. /**
  91961. * Returns the array of the requested vertex data kind. Implemented by child classes
  91962. * @param kind defines the vertex data kind to use
  91963. * @returns null
  91964. */
  91965. getVerticesData(kind: string): Nullable<FloatArray>;
  91966. /**
  91967. * Sets the vertex data of the mesh geometry for the requested `kind`.
  91968. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  91969. * Note that a new underlying VertexBuffer object is created each call.
  91970. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  91971. * @param kind defines vertex data kind:
  91972. * * VertexBuffer.PositionKind
  91973. * * VertexBuffer.UVKind
  91974. * * VertexBuffer.UV2Kind
  91975. * * VertexBuffer.UV3Kind
  91976. * * VertexBuffer.UV4Kind
  91977. * * VertexBuffer.UV5Kind
  91978. * * VertexBuffer.UV6Kind
  91979. * * VertexBuffer.ColorKind
  91980. * * VertexBuffer.MatricesIndicesKind
  91981. * * VertexBuffer.MatricesIndicesExtraKind
  91982. * * VertexBuffer.MatricesWeightsKind
  91983. * * VertexBuffer.MatricesWeightsExtraKind
  91984. * @param data defines the data source
  91985. * @param updatable defines if the data must be flagged as updatable (or static)
  91986. * @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
  91987. * @returns the current mesh
  91988. */
  91989. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  91990. /**
  91991. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  91992. * If the mesh has no geometry, it is simply returned as it is.
  91993. * @param kind defines vertex data kind:
  91994. * * VertexBuffer.PositionKind
  91995. * * VertexBuffer.UVKind
  91996. * * VertexBuffer.UV2Kind
  91997. * * VertexBuffer.UV3Kind
  91998. * * VertexBuffer.UV4Kind
  91999. * * VertexBuffer.UV5Kind
  92000. * * VertexBuffer.UV6Kind
  92001. * * VertexBuffer.ColorKind
  92002. * * VertexBuffer.MatricesIndicesKind
  92003. * * VertexBuffer.MatricesIndicesExtraKind
  92004. * * VertexBuffer.MatricesWeightsKind
  92005. * * VertexBuffer.MatricesWeightsExtraKind
  92006. * @param data defines the data source
  92007. * @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
  92008. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  92009. * @returns the current mesh
  92010. */
  92011. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92012. /**
  92013. * Sets the mesh indices,
  92014. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  92015. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  92016. * @param totalVertices Defines the total number of vertices
  92017. * @returns the current mesh
  92018. */
  92019. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  92020. /**
  92021. * Gets a boolean indicating if specific vertex data is present
  92022. * @param kind defines the vertex data kind to use
  92023. * @returns true is data kind is present
  92024. */
  92025. isVerticesDataPresent(kind: string): boolean;
  92026. /**
  92027. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  92028. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  92029. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  92030. * @returns a BoundingInfo
  92031. */
  92032. getBoundingInfo(): BoundingInfo;
  92033. /**
  92034. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  92035. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  92036. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  92037. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  92038. * @returns the current mesh
  92039. */
  92040. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  92041. /**
  92042. * Overwrite the current bounding info
  92043. * @param boundingInfo defines the new bounding info
  92044. * @returns the current mesh
  92045. */
  92046. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  92047. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  92048. readonly useBones: boolean;
  92049. /** @hidden */
  92050. _preActivate(): void;
  92051. /** @hidden */
  92052. _preActivateForIntermediateRendering(renderId: number): void;
  92053. /** @hidden */
  92054. _activate(renderId: number, intermediateRendering: boolean): boolean;
  92055. /** @hidden */
  92056. _postActivate(): void;
  92057. /** @hidden */
  92058. _freeze(): void;
  92059. /** @hidden */
  92060. _unFreeze(): void;
  92061. /**
  92062. * Gets the current world matrix
  92063. * @returns a Matrix
  92064. */
  92065. getWorldMatrix(): Matrix;
  92066. /** @hidden */
  92067. _getWorldMatrixDeterminant(): number;
  92068. /**
  92069. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  92070. */
  92071. readonly isAnInstance: boolean;
  92072. /**
  92073. * Gets a boolean indicating if this mesh has instances
  92074. */
  92075. readonly hasInstances: boolean;
  92076. /**
  92077. * Perform relative position change from the point of view of behind the front of the mesh.
  92078. * This is performed taking into account the meshes current rotation, so you do not have to care.
  92079. * Supports definition of mesh facing forward or backward
  92080. * @param amountRight defines the distance on the right axis
  92081. * @param amountUp defines the distance on the up axis
  92082. * @param amountForward defines the distance on the forward axis
  92083. * @returns the current mesh
  92084. */
  92085. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  92086. /**
  92087. * Calculate relative position change from the point of view of behind the front of the mesh.
  92088. * This is performed taking into account the meshes current rotation, so you do not have to care.
  92089. * Supports definition of mesh facing forward or backward
  92090. * @param amountRight defines the distance on the right axis
  92091. * @param amountUp defines the distance on the up axis
  92092. * @param amountForward defines the distance on the forward axis
  92093. * @returns the new displacement vector
  92094. */
  92095. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  92096. /**
  92097. * Perform relative rotation change from the point of view of behind the front of the mesh.
  92098. * Supports definition of mesh facing forward or backward
  92099. * @param flipBack defines the flip
  92100. * @param twirlClockwise defines the twirl
  92101. * @param tiltRight defines the tilt
  92102. * @returns the current mesh
  92103. */
  92104. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  92105. /**
  92106. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  92107. * Supports definition of mesh facing forward or backward.
  92108. * @param flipBack defines the flip
  92109. * @param twirlClockwise defines the twirl
  92110. * @param tiltRight defines the tilt
  92111. * @returns the new rotation vector
  92112. */
  92113. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  92114. /**
  92115. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  92116. * This means the mesh underlying bounding box and sphere are recomputed.
  92117. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  92118. * @returns the current mesh
  92119. */
  92120. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  92121. /** @hidden */
  92122. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  92123. /** @hidden */
  92124. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  92125. /** @hidden */
  92126. _updateBoundingInfo(): AbstractMesh;
  92127. /** @hidden */
  92128. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  92129. /** @hidden */
  92130. protected _afterComputeWorldMatrix(): void;
  92131. /** @hidden */
  92132. readonly _effectiveMesh: AbstractMesh;
  92133. /**
  92134. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  92135. * A mesh is in the frustum if its bounding box intersects the frustum
  92136. * @param frustumPlanes defines the frustum to test
  92137. * @returns true if the mesh is in the frustum planes
  92138. */
  92139. isInFrustum(frustumPlanes: Plane[]): boolean;
  92140. /**
  92141. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  92142. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  92143. * @param frustumPlanes defines the frustum to test
  92144. * @returns true if the mesh is completely in the frustum planes
  92145. */
  92146. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  92147. /**
  92148. * True if the mesh intersects another mesh or a SolidParticle object
  92149. * @param mesh defines a target mesh or SolidParticle to test
  92150. * @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)
  92151. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  92152. * @returns true if there is an intersection
  92153. */
  92154. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  92155. /**
  92156. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  92157. * @param point defines the point to test
  92158. * @returns true if there is an intersection
  92159. */
  92160. intersectsPoint(point: Vector3): boolean;
  92161. /**
  92162. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  92163. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92164. */
  92165. checkCollisions: boolean;
  92166. /**
  92167. * Gets Collider object used to compute collisions (not physics)
  92168. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92169. */
  92170. readonly collider: Nullable<Collider>;
  92171. /**
  92172. * Move the mesh using collision engine
  92173. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92174. * @param displacement defines the requested displacement vector
  92175. * @returns the current mesh
  92176. */
  92177. moveWithCollisions(displacement: Vector3): AbstractMesh;
  92178. private _onCollisionPositionChange;
  92179. /** @hidden */
  92180. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  92181. /** @hidden */
  92182. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  92183. /** @hidden */
  92184. _checkCollision(collider: Collider): AbstractMesh;
  92185. /** @hidden */
  92186. _generatePointsArray(): boolean;
  92187. /**
  92188. * Checks if the passed Ray intersects with the mesh
  92189. * @param ray defines the ray to use
  92190. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  92191. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92192. * @returns the picking info
  92193. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  92194. */
  92195. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  92196. /**
  92197. * Clones the current mesh
  92198. * @param name defines the mesh name
  92199. * @param newParent defines the new mesh parent
  92200. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  92201. * @returns the new mesh
  92202. */
  92203. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  92204. /**
  92205. * Disposes all the submeshes of the current meshnp
  92206. * @returns the current mesh
  92207. */
  92208. releaseSubMeshes(): AbstractMesh;
  92209. /**
  92210. * Releases resources associated with this abstract mesh.
  92211. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92212. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92213. */
  92214. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92215. /**
  92216. * Adds the passed mesh as a child to the current mesh
  92217. * @param mesh defines the child mesh
  92218. * @returns the current mesh
  92219. */
  92220. addChild(mesh: AbstractMesh): AbstractMesh;
  92221. /**
  92222. * Removes the passed mesh from the current mesh children list
  92223. * @param mesh defines the child mesh
  92224. * @returns the current mesh
  92225. */
  92226. removeChild(mesh: AbstractMesh): AbstractMesh;
  92227. /** @hidden */
  92228. private _initFacetData;
  92229. /**
  92230. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  92231. * This method can be called within the render loop.
  92232. * 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
  92233. * @returns the current mesh
  92234. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92235. */
  92236. updateFacetData(): AbstractMesh;
  92237. /**
  92238. * Returns the facetLocalNormals array.
  92239. * The normals are expressed in the mesh local spac
  92240. * @returns an array of Vector3
  92241. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92242. */
  92243. getFacetLocalNormals(): Vector3[];
  92244. /**
  92245. * Returns the facetLocalPositions array.
  92246. * The facet positions are expressed in the mesh local space
  92247. * @returns an array of Vector3
  92248. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92249. */
  92250. getFacetLocalPositions(): Vector3[];
  92251. /**
  92252. * Returns the facetLocalPartioning array
  92253. * @returns an array of array of numbers
  92254. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92255. */
  92256. getFacetLocalPartitioning(): number[][];
  92257. /**
  92258. * Returns the i-th facet position in the world system.
  92259. * This method allocates a new Vector3 per call
  92260. * @param i defines the facet index
  92261. * @returns a new Vector3
  92262. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92263. */
  92264. getFacetPosition(i: number): Vector3;
  92265. /**
  92266. * Sets the reference Vector3 with the i-th facet position in the world system
  92267. * @param i defines the facet index
  92268. * @param ref defines the target vector
  92269. * @returns the current mesh
  92270. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92271. */
  92272. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  92273. /**
  92274. * Returns the i-th facet normal in the world system.
  92275. * This method allocates a new Vector3 per call
  92276. * @param i defines the facet index
  92277. * @returns a new Vector3
  92278. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92279. */
  92280. getFacetNormal(i: number): Vector3;
  92281. /**
  92282. * Sets the reference Vector3 with the i-th facet normal in the world system
  92283. * @param i defines the facet index
  92284. * @param ref defines the target vector
  92285. * @returns the current mesh
  92286. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92287. */
  92288. getFacetNormalToRef(i: number, ref: Vector3): this;
  92289. /**
  92290. * 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)
  92291. * @param x defines x coordinate
  92292. * @param y defines y coordinate
  92293. * @param z defines z coordinate
  92294. * @returns the array of facet indexes
  92295. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92296. */
  92297. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  92298. /**
  92299. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  92300. * @param projected sets as the (x,y,z) world projection on the facet
  92301. * @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
  92302. * @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
  92303. * @param x defines x coordinate
  92304. * @param y defines y coordinate
  92305. * @param z defines z coordinate
  92306. * @returns the face index if found (or null instead)
  92307. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92308. */
  92309. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92310. /**
  92311. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  92312. * @param projected sets as the (x,y,z) local projection on the facet
  92313. * @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
  92314. * @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
  92315. * @param x defines x coordinate
  92316. * @param y defines y coordinate
  92317. * @param z defines z coordinate
  92318. * @returns the face index if found (or null instead)
  92319. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92320. */
  92321. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  92322. /**
  92323. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  92324. * @returns the parameters
  92325. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92326. */
  92327. getFacetDataParameters(): any;
  92328. /**
  92329. * Disables the feature FacetData and frees the related memory
  92330. * @returns the current mesh
  92331. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  92332. */
  92333. disableFacetData(): AbstractMesh;
  92334. /**
  92335. * Updates the AbstractMesh indices array
  92336. * @param indices defines the data source
  92337. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  92338. * @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)
  92339. * @returns the current mesh
  92340. */
  92341. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  92342. /**
  92343. * Creates new normals data for the mesh
  92344. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  92345. * @returns the current mesh
  92346. */
  92347. createNormals(updatable: boolean): AbstractMesh;
  92348. /**
  92349. * Align the mesh with a normal
  92350. * @param normal defines the normal to use
  92351. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  92352. * @returns the current mesh
  92353. */
  92354. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  92355. /** @hidden */
  92356. _checkOcclusionQuery(): boolean;
  92357. /**
  92358. * Disables the mesh edge rendering mode
  92359. * @returns the currentAbstractMesh
  92360. */
  92361. disableEdgesRendering(): AbstractMesh;
  92362. /**
  92363. * Enables the edge rendering mode on the mesh.
  92364. * This mode makes the mesh edges visible
  92365. * @param epsilon defines the maximal distance between two angles to detect a face
  92366. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  92367. * @returns the currentAbstractMesh
  92368. * @see https://www.babylonjs-playground.com/#19O9TU#0
  92369. */
  92370. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  92371. }
  92372. }
  92373. declare module BABYLON {
  92374. /**
  92375. * Interface used to define ActionEvent
  92376. */
  92377. export interface IActionEvent {
  92378. /** The mesh or sprite that triggered the action */
  92379. source: any;
  92380. /** The X mouse cursor position at the time of the event */
  92381. pointerX: number;
  92382. /** The Y mouse cursor position at the time of the event */
  92383. pointerY: number;
  92384. /** The mesh that is currently pointed at (can be null) */
  92385. meshUnderPointer: Nullable<AbstractMesh>;
  92386. /** the original (browser) event that triggered the ActionEvent */
  92387. sourceEvent?: any;
  92388. /** additional data for the event */
  92389. additionalData?: any;
  92390. }
  92391. /**
  92392. * ActionEvent is the event being sent when an action is triggered.
  92393. */
  92394. export class ActionEvent implements IActionEvent {
  92395. /** The mesh or sprite that triggered the action */
  92396. source: any;
  92397. /** The X mouse cursor position at the time of the event */
  92398. pointerX: number;
  92399. /** The Y mouse cursor position at the time of the event */
  92400. pointerY: number;
  92401. /** The mesh that is currently pointed at (can be null) */
  92402. meshUnderPointer: Nullable<AbstractMesh>;
  92403. /** the original (browser) event that triggered the ActionEvent */
  92404. sourceEvent?: any;
  92405. /** additional data for the event */
  92406. additionalData?: any;
  92407. /**
  92408. * Creates a new ActionEvent
  92409. * @param source The mesh or sprite that triggered the action
  92410. * @param pointerX The X mouse cursor position at the time of the event
  92411. * @param pointerY The Y mouse cursor position at the time of the event
  92412. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  92413. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  92414. * @param additionalData additional data for the event
  92415. */
  92416. constructor(
  92417. /** The mesh or sprite that triggered the action */
  92418. source: any,
  92419. /** The X mouse cursor position at the time of the event */
  92420. pointerX: number,
  92421. /** The Y mouse cursor position at the time of the event */
  92422. pointerY: number,
  92423. /** The mesh that is currently pointed at (can be null) */
  92424. meshUnderPointer: Nullable<AbstractMesh>,
  92425. /** the original (browser) event that triggered the ActionEvent */
  92426. sourceEvent?: any,
  92427. /** additional data for the event */
  92428. additionalData?: any);
  92429. /**
  92430. * Helper function to auto-create an ActionEvent from a source mesh.
  92431. * @param source The source mesh that triggered the event
  92432. * @param evt The original (browser) event
  92433. * @param additionalData additional data for the event
  92434. * @returns the new ActionEvent
  92435. */
  92436. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  92437. /**
  92438. * Helper function to auto-create an ActionEvent from a source sprite
  92439. * @param source The source sprite that triggered the event
  92440. * @param scene Scene associated with the sprite
  92441. * @param evt The original (browser) event
  92442. * @param additionalData additional data for the event
  92443. * @returns the new ActionEvent
  92444. */
  92445. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  92446. /**
  92447. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  92448. * @param scene the scene where the event occurred
  92449. * @param evt The original (browser) event
  92450. * @returns the new ActionEvent
  92451. */
  92452. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  92453. /**
  92454. * Helper function to auto-create an ActionEvent from a primitive
  92455. * @param prim defines the target primitive
  92456. * @param pointerPos defines the pointer position
  92457. * @param evt The original (browser) event
  92458. * @param additionalData additional data for the event
  92459. * @returns the new ActionEvent
  92460. */
  92461. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  92462. }
  92463. }
  92464. declare module BABYLON {
  92465. /**
  92466. * Abstract class used to decouple action Manager from scene and meshes.
  92467. * Do not instantiate.
  92468. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92469. */
  92470. export abstract class AbstractActionManager implements IDisposable {
  92471. /** Gets the list of active triggers */
  92472. static Triggers: {
  92473. [key: string]: number;
  92474. };
  92475. /** Gets the cursor to use when hovering items */
  92476. hoverCursor: string;
  92477. /** Gets the list of actions */
  92478. actions: IAction[];
  92479. /**
  92480. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  92481. */
  92482. isRecursive: boolean;
  92483. /**
  92484. * Releases all associated resources
  92485. */
  92486. abstract dispose(): void;
  92487. /**
  92488. * Does this action manager has pointer triggers
  92489. */
  92490. abstract readonly hasPointerTriggers: boolean;
  92491. /**
  92492. * Does this action manager has pick triggers
  92493. */
  92494. abstract readonly hasPickTriggers: boolean;
  92495. /**
  92496. * Process a specific trigger
  92497. * @param trigger defines the trigger to process
  92498. * @param evt defines the event details to be processed
  92499. */
  92500. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  92501. /**
  92502. * Does this action manager handles actions of any of the given triggers
  92503. * @param triggers defines the triggers to be tested
  92504. * @return a boolean indicating whether one (or more) of the triggers is handled
  92505. */
  92506. abstract hasSpecificTriggers(triggers: number[]): boolean;
  92507. /**
  92508. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  92509. * speed.
  92510. * @param triggerA defines the trigger to be tested
  92511. * @param triggerB defines the trigger to be tested
  92512. * @return a boolean indicating whether one (or more) of the triggers is handled
  92513. */
  92514. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  92515. /**
  92516. * Does this action manager handles actions of a given trigger
  92517. * @param trigger defines the trigger to be tested
  92518. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  92519. * @return whether the trigger is handled
  92520. */
  92521. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  92522. /**
  92523. * Serialize this manager to a JSON object
  92524. * @param name defines the property name to store this manager
  92525. * @returns a JSON representation of this manager
  92526. */
  92527. abstract serialize(name: string): any;
  92528. /**
  92529. * Registers an action to this action manager
  92530. * @param action defines the action to be registered
  92531. * @return the action amended (prepared) after registration
  92532. */
  92533. abstract registerAction(action: IAction): Nullable<IAction>;
  92534. /**
  92535. * Unregisters an action to this action manager
  92536. * @param action defines the action to be unregistered
  92537. * @return a boolean indicating whether the action has been unregistered
  92538. */
  92539. abstract unregisterAction(action: IAction): Boolean;
  92540. /**
  92541. * Does exist one action manager with at least one trigger
  92542. **/
  92543. static readonly HasTriggers: boolean;
  92544. /**
  92545. * Does exist one action manager with at least one pick trigger
  92546. **/
  92547. static readonly HasPickTriggers: boolean;
  92548. /**
  92549. * Does exist one action manager that handles actions of a given trigger
  92550. * @param trigger defines the trigger to be tested
  92551. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  92552. **/
  92553. static HasSpecificTrigger(trigger: number): boolean;
  92554. }
  92555. }
  92556. declare module BABYLON {
  92557. /**
  92558. * Defines how a node can be built from a string name.
  92559. */
  92560. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  92561. /**
  92562. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  92563. */
  92564. export class Node implements IBehaviorAware<Node> {
  92565. /** @hidden */
  92566. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  92567. private static _NodeConstructors;
  92568. /**
  92569. * Add a new node constructor
  92570. * @param type defines the type name of the node to construct
  92571. * @param constructorFunc defines the constructor function
  92572. */
  92573. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  92574. /**
  92575. * Returns a node constructor based on type name
  92576. * @param type defines the type name
  92577. * @param name defines the new node name
  92578. * @param scene defines the hosting scene
  92579. * @param options defines optional options to transmit to constructors
  92580. * @returns the new constructor or null
  92581. */
  92582. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  92583. /**
  92584. * Gets or sets the name of the node
  92585. */
  92586. name: string;
  92587. /**
  92588. * Gets or sets the id of the node
  92589. */
  92590. id: string;
  92591. /**
  92592. * Gets or sets the unique id of the node
  92593. */
  92594. uniqueId: number;
  92595. /**
  92596. * Gets or sets a string used to store user defined state for the node
  92597. */
  92598. state: string;
  92599. /**
  92600. * Gets or sets an object used to store user defined information for the node
  92601. */
  92602. metadata: any;
  92603. /**
  92604. * For internal use only. Please do not use.
  92605. */
  92606. reservedDataStore: any;
  92607. /**
  92608. * List of inspectable custom properties (used by the Inspector)
  92609. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92610. */
  92611. inspectableCustomProperties: IInspectable[];
  92612. /**
  92613. * Gets or sets a boolean used to define if the node must be serialized
  92614. */
  92615. doNotSerialize: boolean;
  92616. /** @hidden */
  92617. _isDisposed: boolean;
  92618. /**
  92619. * Gets a list of Animations associated with the node
  92620. */
  92621. animations: Animation[];
  92622. protected _ranges: {
  92623. [name: string]: Nullable<AnimationRange>;
  92624. };
  92625. /**
  92626. * Callback raised when the node is ready to be used
  92627. */
  92628. onReady: Nullable<(node: Node) => void>;
  92629. private _isEnabled;
  92630. private _isParentEnabled;
  92631. private _isReady;
  92632. /** @hidden */
  92633. _currentRenderId: number;
  92634. private _parentUpdateId;
  92635. /** @hidden */
  92636. _childUpdateId: number;
  92637. /** @hidden */
  92638. _waitingParentId: Nullable<string>;
  92639. /** @hidden */
  92640. _scene: Scene;
  92641. /** @hidden */
  92642. _cache: any;
  92643. private _parentNode;
  92644. private _children;
  92645. /** @hidden */
  92646. _worldMatrix: Matrix;
  92647. /** @hidden */
  92648. _worldMatrixDeterminant: number;
  92649. /** @hidden */
  92650. _worldMatrixDeterminantIsDirty: boolean;
  92651. /** @hidden */
  92652. private _sceneRootNodesIndex;
  92653. /**
  92654. * Gets a boolean indicating if the node has been disposed
  92655. * @returns true if the node was disposed
  92656. */
  92657. isDisposed(): boolean;
  92658. /**
  92659. * Gets or sets the parent of the node (without keeping the current position in the scene)
  92660. * @see https://doc.babylonjs.com/how_to/parenting
  92661. */
  92662. parent: Nullable<Node>;
  92663. private addToSceneRootNodes;
  92664. private removeFromSceneRootNodes;
  92665. private _animationPropertiesOverride;
  92666. /**
  92667. * Gets or sets the animation properties override
  92668. */
  92669. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  92670. /**
  92671. * Gets a string idenfifying the name of the class
  92672. * @returns "Node" string
  92673. */
  92674. getClassName(): string;
  92675. /** @hidden */
  92676. readonly _isNode: boolean;
  92677. /**
  92678. * An event triggered when the mesh is disposed
  92679. */
  92680. onDisposeObservable: Observable<Node>;
  92681. private _onDisposeObserver;
  92682. /**
  92683. * Sets a callback that will be raised when the node will be disposed
  92684. */
  92685. onDispose: () => void;
  92686. /**
  92687. * Creates a new Node
  92688. * @param name the name and id to be given to this node
  92689. * @param scene the scene this node will be added to
  92690. * @param addToRootNodes the node will be added to scene.rootNodes
  92691. */
  92692. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  92693. /**
  92694. * Gets the scene of the node
  92695. * @returns a scene
  92696. */
  92697. getScene(): Scene;
  92698. /**
  92699. * Gets the engine of the node
  92700. * @returns a Engine
  92701. */
  92702. getEngine(): Engine;
  92703. private _behaviors;
  92704. /**
  92705. * Attach a behavior to the node
  92706. * @see http://doc.babylonjs.com/features/behaviour
  92707. * @param behavior defines the behavior to attach
  92708. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  92709. * @returns the current Node
  92710. */
  92711. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  92712. /**
  92713. * Remove an attached behavior
  92714. * @see http://doc.babylonjs.com/features/behaviour
  92715. * @param behavior defines the behavior to attach
  92716. * @returns the current Node
  92717. */
  92718. removeBehavior(behavior: Behavior<Node>): Node;
  92719. /**
  92720. * Gets the list of attached behaviors
  92721. * @see http://doc.babylonjs.com/features/behaviour
  92722. */
  92723. readonly behaviors: Behavior<Node>[];
  92724. /**
  92725. * Gets an attached behavior by name
  92726. * @param name defines the name of the behavior to look for
  92727. * @see http://doc.babylonjs.com/features/behaviour
  92728. * @returns null if behavior was not found else the requested behavior
  92729. */
  92730. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  92731. /**
  92732. * Returns the latest update of the World matrix
  92733. * @returns a Matrix
  92734. */
  92735. getWorldMatrix(): Matrix;
  92736. /** @hidden */
  92737. _getWorldMatrixDeterminant(): number;
  92738. /**
  92739. * Returns directly the latest state of the mesh World matrix.
  92740. * A Matrix is returned.
  92741. */
  92742. readonly worldMatrixFromCache: Matrix;
  92743. /** @hidden */
  92744. _initCache(): void;
  92745. /** @hidden */
  92746. updateCache(force?: boolean): void;
  92747. /** @hidden */
  92748. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92749. /** @hidden */
  92750. _updateCache(ignoreParentClass?: boolean): void;
  92751. /** @hidden */
  92752. _isSynchronized(): boolean;
  92753. /** @hidden */
  92754. _markSyncedWithParent(): void;
  92755. /** @hidden */
  92756. isSynchronizedWithParent(): boolean;
  92757. /** @hidden */
  92758. isSynchronized(): boolean;
  92759. /**
  92760. * Is this node ready to be used/rendered
  92761. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  92762. * @return true if the node is ready
  92763. */
  92764. isReady(completeCheck?: boolean): boolean;
  92765. /**
  92766. * Is this node enabled?
  92767. * 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
  92768. * @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
  92769. * @return whether this node (and its parent) is enabled
  92770. */
  92771. isEnabled(checkAncestors?: boolean): boolean;
  92772. /** @hidden */
  92773. protected _syncParentEnabledState(): void;
  92774. /**
  92775. * Set the enabled state of this node
  92776. * @param value defines the new enabled state
  92777. */
  92778. setEnabled(value: boolean): void;
  92779. /**
  92780. * Is this node a descendant of the given node?
  92781. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  92782. * @param ancestor defines the parent node to inspect
  92783. * @returns a boolean indicating if this node is a descendant of the given node
  92784. */
  92785. isDescendantOf(ancestor: Node): boolean;
  92786. /** @hidden */
  92787. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  92788. /**
  92789. * Will return all nodes that have this node as ascendant
  92790. * @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
  92791. * @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
  92792. * @return all children nodes of all types
  92793. */
  92794. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  92795. /**
  92796. * Get all child-meshes of this node
  92797. * @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)
  92798. * @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
  92799. * @returns an array of AbstractMesh
  92800. */
  92801. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  92802. /**
  92803. * Get all direct children of this node
  92804. * @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
  92805. * @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)
  92806. * @returns an array of Node
  92807. */
  92808. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  92809. /** @hidden */
  92810. _setReady(state: boolean): void;
  92811. /**
  92812. * Get an animation by name
  92813. * @param name defines the name of the animation to look for
  92814. * @returns null if not found else the requested animation
  92815. */
  92816. getAnimationByName(name: string): Nullable<Animation>;
  92817. /**
  92818. * Creates an animation range for this node
  92819. * @param name defines the name of the range
  92820. * @param from defines the starting key
  92821. * @param to defines the end key
  92822. */
  92823. createAnimationRange(name: string, from: number, to: number): void;
  92824. /**
  92825. * Delete a specific animation range
  92826. * @param name defines the name of the range to delete
  92827. * @param deleteFrames defines if animation frames from the range must be deleted as well
  92828. */
  92829. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  92830. /**
  92831. * Get an animation range by name
  92832. * @param name defines the name of the animation range to look for
  92833. * @returns null if not found else the requested animation range
  92834. */
  92835. getAnimationRange(name: string): Nullable<AnimationRange>;
  92836. /**
  92837. * Gets the list of all animation ranges defined on this node
  92838. * @returns an array
  92839. */
  92840. getAnimationRanges(): Nullable<AnimationRange>[];
  92841. /**
  92842. * Will start the animation sequence
  92843. * @param name defines the range frames for animation sequence
  92844. * @param loop defines if the animation should loop (false by default)
  92845. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  92846. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  92847. * @returns the object created for this animation. If range does not exist, it will return null
  92848. */
  92849. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  92850. /**
  92851. * Serialize animation ranges into a JSON compatible object
  92852. * @returns serialization object
  92853. */
  92854. serializeAnimationRanges(): any;
  92855. /**
  92856. * Computes the world matrix of the node
  92857. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92858. * @returns the world matrix
  92859. */
  92860. computeWorldMatrix(force?: boolean): Matrix;
  92861. /**
  92862. * Releases resources associated with this node.
  92863. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92864. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92865. */
  92866. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92867. /**
  92868. * Parse animation range data from a serialization object and store them into a given node
  92869. * @param node defines where to store the animation ranges
  92870. * @param parsedNode defines the serialization object to read data from
  92871. * @param scene defines the hosting scene
  92872. */
  92873. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  92874. /**
  92875. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  92876. * @param includeDescendants Include bounding info from descendants as well (true by default)
  92877. * @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
  92878. * @returns the new bounding vectors
  92879. */
  92880. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  92881. min: Vector3;
  92882. max: Vector3;
  92883. };
  92884. }
  92885. }
  92886. declare module BABYLON {
  92887. /**
  92888. * @hidden
  92889. */
  92890. export class _IAnimationState {
  92891. key: number;
  92892. repeatCount: number;
  92893. workValue?: any;
  92894. loopMode?: number;
  92895. offsetValue?: any;
  92896. highLimitValue?: any;
  92897. }
  92898. /**
  92899. * Class used to store any kind of animation
  92900. */
  92901. export class Animation {
  92902. /**Name of the animation */
  92903. name: string;
  92904. /**Property to animate */
  92905. targetProperty: string;
  92906. /**The frames per second of the animation */
  92907. framePerSecond: number;
  92908. /**The data type of the animation */
  92909. dataType: number;
  92910. /**The loop mode of the animation */
  92911. loopMode?: number | undefined;
  92912. /**Specifies if blending should be enabled */
  92913. enableBlending?: boolean | undefined;
  92914. /**
  92915. * Use matrix interpolation instead of using direct key value when animating matrices
  92916. */
  92917. static AllowMatricesInterpolation: boolean;
  92918. /**
  92919. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  92920. */
  92921. static AllowMatrixDecomposeForInterpolation: boolean;
  92922. /**
  92923. * Stores the key frames of the animation
  92924. */
  92925. private _keys;
  92926. /**
  92927. * Stores the easing function of the animation
  92928. */
  92929. private _easingFunction;
  92930. /**
  92931. * @hidden Internal use only
  92932. */
  92933. _runtimeAnimations: RuntimeAnimation[];
  92934. /**
  92935. * The set of event that will be linked to this animation
  92936. */
  92937. private _events;
  92938. /**
  92939. * Stores an array of target property paths
  92940. */
  92941. targetPropertyPath: string[];
  92942. /**
  92943. * Stores the blending speed of the animation
  92944. */
  92945. blendingSpeed: number;
  92946. /**
  92947. * Stores the animation ranges for the animation
  92948. */
  92949. private _ranges;
  92950. /**
  92951. * @hidden Internal use
  92952. */
  92953. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  92954. /**
  92955. * Sets up an animation
  92956. * @param property The property to animate
  92957. * @param animationType The animation type to apply
  92958. * @param framePerSecond The frames per second of the animation
  92959. * @param easingFunction The easing function used in the animation
  92960. * @returns The created animation
  92961. */
  92962. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  92963. /**
  92964. * Create and start an animation on a node
  92965. * @param name defines the name of the global animation that will be run on all nodes
  92966. * @param node defines the root node where the animation will take place
  92967. * @param targetProperty defines property to animate
  92968. * @param framePerSecond defines the number of frame per second yo use
  92969. * @param totalFrame defines the number of frames in total
  92970. * @param from defines the initial value
  92971. * @param to defines the final value
  92972. * @param loopMode defines which loop mode you want to use (off by default)
  92973. * @param easingFunction defines the easing function to use (linear by default)
  92974. * @param onAnimationEnd defines the callback to call when animation end
  92975. * @returns the animatable created for this animation
  92976. */
  92977. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  92978. /**
  92979. * Create and start an animation on a node and its descendants
  92980. * @param name defines the name of the global animation that will be run on all nodes
  92981. * @param node defines the root node where the animation will take place
  92982. * @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
  92983. * @param targetProperty defines property to animate
  92984. * @param framePerSecond defines the number of frame per second to use
  92985. * @param totalFrame defines the number of frames in total
  92986. * @param from defines the initial value
  92987. * @param to defines the final value
  92988. * @param loopMode defines which loop mode you want to use (off by default)
  92989. * @param easingFunction defines the easing function to use (linear by default)
  92990. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  92991. * @returns the list of animatables created for all nodes
  92992. * @example https://www.babylonjs-playground.com/#MH0VLI
  92993. */
  92994. 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[]>;
  92995. /**
  92996. * Creates a new animation, merges it with the existing animations and starts it
  92997. * @param name Name of the animation
  92998. * @param node Node which contains the scene that begins the animations
  92999. * @param targetProperty Specifies which property to animate
  93000. * @param framePerSecond The frames per second of the animation
  93001. * @param totalFrame The total number of frames
  93002. * @param from The frame at the beginning of the animation
  93003. * @param to The frame at the end of the animation
  93004. * @param loopMode Specifies the loop mode of the animation
  93005. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  93006. * @param onAnimationEnd Callback to run once the animation is complete
  93007. * @returns Nullable animation
  93008. */
  93009. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93010. /**
  93011. * Transition property of an host to the target Value
  93012. * @param property The property to transition
  93013. * @param targetValue The target Value of the property
  93014. * @param host The object where the property to animate belongs
  93015. * @param scene Scene used to run the animation
  93016. * @param frameRate Framerate (in frame/s) to use
  93017. * @param transition The transition type we want to use
  93018. * @param duration The duration of the animation, in milliseconds
  93019. * @param onAnimationEnd Callback trigger at the end of the animation
  93020. * @returns Nullable animation
  93021. */
  93022. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  93023. /**
  93024. * Return the array of runtime animations currently using this animation
  93025. */
  93026. readonly runtimeAnimations: RuntimeAnimation[];
  93027. /**
  93028. * Specifies if any of the runtime animations are currently running
  93029. */
  93030. readonly hasRunningRuntimeAnimations: boolean;
  93031. /**
  93032. * Initializes the animation
  93033. * @param name Name of the animation
  93034. * @param targetProperty Property to animate
  93035. * @param framePerSecond The frames per second of the animation
  93036. * @param dataType The data type of the animation
  93037. * @param loopMode The loop mode of the animation
  93038. * @param enableBlending Specifies if blending should be enabled
  93039. */
  93040. constructor(
  93041. /**Name of the animation */
  93042. name: string,
  93043. /**Property to animate */
  93044. targetProperty: string,
  93045. /**The frames per second of the animation */
  93046. framePerSecond: number,
  93047. /**The data type of the animation */
  93048. dataType: number,
  93049. /**The loop mode of the animation */
  93050. loopMode?: number | undefined,
  93051. /**Specifies if blending should be enabled */
  93052. enableBlending?: boolean | undefined);
  93053. /**
  93054. * Converts the animation to a string
  93055. * @param fullDetails support for multiple levels of logging within scene loading
  93056. * @returns String form of the animation
  93057. */
  93058. toString(fullDetails?: boolean): string;
  93059. /**
  93060. * Add an event to this animation
  93061. * @param event Event to add
  93062. */
  93063. addEvent(event: AnimationEvent): void;
  93064. /**
  93065. * Remove all events found at the given frame
  93066. * @param frame The frame to remove events from
  93067. */
  93068. removeEvents(frame: number): void;
  93069. /**
  93070. * Retrieves all the events from the animation
  93071. * @returns Events from the animation
  93072. */
  93073. getEvents(): AnimationEvent[];
  93074. /**
  93075. * Creates an animation range
  93076. * @param name Name of the animation range
  93077. * @param from Starting frame of the animation range
  93078. * @param to Ending frame of the animation
  93079. */
  93080. createRange(name: string, from: number, to: number): void;
  93081. /**
  93082. * Deletes an animation range by name
  93083. * @param name Name of the animation range to delete
  93084. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  93085. */
  93086. deleteRange(name: string, deleteFrames?: boolean): void;
  93087. /**
  93088. * Gets the animation range by name, or null if not defined
  93089. * @param name Name of the animation range
  93090. * @returns Nullable animation range
  93091. */
  93092. getRange(name: string): Nullable<AnimationRange>;
  93093. /**
  93094. * Gets the key frames from the animation
  93095. * @returns The key frames of the animation
  93096. */
  93097. getKeys(): Array<IAnimationKey>;
  93098. /**
  93099. * Gets the highest frame rate of the animation
  93100. * @returns Highest frame rate of the animation
  93101. */
  93102. getHighestFrame(): number;
  93103. /**
  93104. * Gets the easing function of the animation
  93105. * @returns Easing function of the animation
  93106. */
  93107. getEasingFunction(): IEasingFunction;
  93108. /**
  93109. * Sets the easing function of the animation
  93110. * @param easingFunction A custom mathematical formula for animation
  93111. */
  93112. setEasingFunction(easingFunction: EasingFunction): void;
  93113. /**
  93114. * Interpolates a scalar linearly
  93115. * @param startValue Start value of the animation curve
  93116. * @param endValue End value of the animation curve
  93117. * @param gradient Scalar amount to interpolate
  93118. * @returns Interpolated scalar value
  93119. */
  93120. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  93121. /**
  93122. * Interpolates a scalar cubically
  93123. * @param startValue Start value of the animation curve
  93124. * @param outTangent End tangent of the animation
  93125. * @param endValue End value of the animation curve
  93126. * @param inTangent Start tangent of the animation curve
  93127. * @param gradient Scalar amount to interpolate
  93128. * @returns Interpolated scalar value
  93129. */
  93130. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  93131. /**
  93132. * Interpolates a quaternion using a spherical linear interpolation
  93133. * @param startValue Start value of the animation curve
  93134. * @param endValue End value of the animation curve
  93135. * @param gradient Scalar amount to interpolate
  93136. * @returns Interpolated quaternion value
  93137. */
  93138. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  93139. /**
  93140. * Interpolates a quaternion cubically
  93141. * @param startValue Start value of the animation curve
  93142. * @param outTangent End tangent of the animation curve
  93143. * @param endValue End value of the animation curve
  93144. * @param inTangent Start tangent of the animation curve
  93145. * @param gradient Scalar amount to interpolate
  93146. * @returns Interpolated quaternion value
  93147. */
  93148. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  93149. /**
  93150. * Interpolates a Vector3 linearl
  93151. * @param startValue Start value of the animation curve
  93152. * @param endValue End value of the animation curve
  93153. * @param gradient Scalar amount to interpolate
  93154. * @returns Interpolated scalar value
  93155. */
  93156. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  93157. /**
  93158. * Interpolates a Vector3 cubically
  93159. * @param startValue Start value of the animation curve
  93160. * @param outTangent End tangent of the animation
  93161. * @param endValue End value of the animation curve
  93162. * @param inTangent Start tangent of the animation curve
  93163. * @param gradient Scalar amount to interpolate
  93164. * @returns InterpolatedVector3 value
  93165. */
  93166. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  93167. /**
  93168. * Interpolates a Vector2 linearly
  93169. * @param startValue Start value of the animation curve
  93170. * @param endValue End value of the animation curve
  93171. * @param gradient Scalar amount to interpolate
  93172. * @returns Interpolated Vector2 value
  93173. */
  93174. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  93175. /**
  93176. * Interpolates a Vector2 cubically
  93177. * @param startValue Start value of the animation curve
  93178. * @param outTangent End tangent of the animation
  93179. * @param endValue End value of the animation curve
  93180. * @param inTangent Start tangent of the animation curve
  93181. * @param gradient Scalar amount to interpolate
  93182. * @returns Interpolated Vector2 value
  93183. */
  93184. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  93185. /**
  93186. * Interpolates a size linearly
  93187. * @param startValue Start value of the animation curve
  93188. * @param endValue End value of the animation curve
  93189. * @param gradient Scalar amount to interpolate
  93190. * @returns Interpolated Size value
  93191. */
  93192. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  93193. /**
  93194. * Interpolates a Color3 linearly
  93195. * @param startValue Start value of the animation curve
  93196. * @param endValue End value of the animation curve
  93197. * @param gradient Scalar amount to interpolate
  93198. * @returns Interpolated Color3 value
  93199. */
  93200. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  93201. /**
  93202. * @hidden Internal use only
  93203. */
  93204. _getKeyValue(value: any): any;
  93205. /**
  93206. * @hidden Internal use only
  93207. */
  93208. _interpolate(currentFrame: number, state: _IAnimationState): any;
  93209. /**
  93210. * Defines the function to use to interpolate matrices
  93211. * @param startValue defines the start matrix
  93212. * @param endValue defines the end matrix
  93213. * @param gradient defines the gradient between both matrices
  93214. * @param result defines an optional target matrix where to store the interpolation
  93215. * @returns the interpolated matrix
  93216. */
  93217. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  93218. /**
  93219. * Makes a copy of the animation
  93220. * @returns Cloned animation
  93221. */
  93222. clone(): Animation;
  93223. /**
  93224. * Sets the key frames of the animation
  93225. * @param values The animation key frames to set
  93226. */
  93227. setKeys(values: Array<IAnimationKey>): void;
  93228. /**
  93229. * Serializes the animation to an object
  93230. * @returns Serialized object
  93231. */
  93232. serialize(): any;
  93233. /**
  93234. * Float animation type
  93235. */
  93236. private static _ANIMATIONTYPE_FLOAT;
  93237. /**
  93238. * Vector3 animation type
  93239. */
  93240. private static _ANIMATIONTYPE_VECTOR3;
  93241. /**
  93242. * Quaternion animation type
  93243. */
  93244. private static _ANIMATIONTYPE_QUATERNION;
  93245. /**
  93246. * Matrix animation type
  93247. */
  93248. private static _ANIMATIONTYPE_MATRIX;
  93249. /**
  93250. * Color3 animation type
  93251. */
  93252. private static _ANIMATIONTYPE_COLOR3;
  93253. /**
  93254. * Vector2 animation type
  93255. */
  93256. private static _ANIMATIONTYPE_VECTOR2;
  93257. /**
  93258. * Size animation type
  93259. */
  93260. private static _ANIMATIONTYPE_SIZE;
  93261. /**
  93262. * Relative Loop Mode
  93263. */
  93264. private static _ANIMATIONLOOPMODE_RELATIVE;
  93265. /**
  93266. * Cycle Loop Mode
  93267. */
  93268. private static _ANIMATIONLOOPMODE_CYCLE;
  93269. /**
  93270. * Constant Loop Mode
  93271. */
  93272. private static _ANIMATIONLOOPMODE_CONSTANT;
  93273. /**
  93274. * Get the float animation type
  93275. */
  93276. static readonly ANIMATIONTYPE_FLOAT: number;
  93277. /**
  93278. * Get the Vector3 animation type
  93279. */
  93280. static readonly ANIMATIONTYPE_VECTOR3: number;
  93281. /**
  93282. * Get the Vector2 animation type
  93283. */
  93284. static readonly ANIMATIONTYPE_VECTOR2: number;
  93285. /**
  93286. * Get the Size animation type
  93287. */
  93288. static readonly ANIMATIONTYPE_SIZE: number;
  93289. /**
  93290. * Get the Quaternion animation type
  93291. */
  93292. static readonly ANIMATIONTYPE_QUATERNION: number;
  93293. /**
  93294. * Get the Matrix animation type
  93295. */
  93296. static readonly ANIMATIONTYPE_MATRIX: number;
  93297. /**
  93298. * Get the Color3 animation type
  93299. */
  93300. static readonly ANIMATIONTYPE_COLOR3: number;
  93301. /**
  93302. * Get the Relative Loop Mode
  93303. */
  93304. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  93305. /**
  93306. * Get the Cycle Loop Mode
  93307. */
  93308. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  93309. /**
  93310. * Get the Constant Loop Mode
  93311. */
  93312. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  93313. /** @hidden */
  93314. static _UniversalLerp(left: any, right: any, amount: number): any;
  93315. /**
  93316. * Parses an animation object and creates an animation
  93317. * @param parsedAnimation Parsed animation object
  93318. * @returns Animation object
  93319. */
  93320. static Parse(parsedAnimation: any): Animation;
  93321. /**
  93322. * Appends the serialized animations from the source animations
  93323. * @param source Source containing the animations
  93324. * @param destination Target to store the animations
  93325. */
  93326. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93327. }
  93328. }
  93329. declare module BABYLON {
  93330. /**
  93331. * Interface containing an array of animations
  93332. */
  93333. export interface IAnimatable {
  93334. /**
  93335. * Array of animations
  93336. */
  93337. animations: Nullable<Array<Animation>>;
  93338. }
  93339. }
  93340. declare module BABYLON {
  93341. /**
  93342. * This represents all the required information to add a fresnel effect on a material:
  93343. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93344. */
  93345. export class FresnelParameters {
  93346. private _isEnabled;
  93347. /**
  93348. * Define if the fresnel effect is enable or not.
  93349. */
  93350. isEnabled: boolean;
  93351. /**
  93352. * Define the color used on edges (grazing angle)
  93353. */
  93354. leftColor: Color3;
  93355. /**
  93356. * Define the color used on center
  93357. */
  93358. rightColor: Color3;
  93359. /**
  93360. * Define bias applied to computed fresnel term
  93361. */
  93362. bias: number;
  93363. /**
  93364. * Defined the power exponent applied to fresnel term
  93365. */
  93366. power: number;
  93367. /**
  93368. * Clones the current fresnel and its valuues
  93369. * @returns a clone fresnel configuration
  93370. */
  93371. clone(): FresnelParameters;
  93372. /**
  93373. * Serializes the current fresnel parameters to a JSON representation.
  93374. * @return the JSON serialization
  93375. */
  93376. serialize(): any;
  93377. /**
  93378. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  93379. * @param parsedFresnelParameters Define the JSON representation
  93380. * @returns the parsed parameters
  93381. */
  93382. static Parse(parsedFresnelParameters: any): FresnelParameters;
  93383. }
  93384. }
  93385. declare module BABYLON {
  93386. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  93387. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93388. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93389. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93390. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93391. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93392. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93393. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93394. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93395. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93396. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93397. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93398. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93399. /**
  93400. * Decorator used to define property that can be serialized as reference to a camera
  93401. * @param sourceName defines the name of the property to decorate
  93402. */
  93403. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93404. /**
  93405. * Class used to help serialization objects
  93406. */
  93407. export class SerializationHelper {
  93408. /** @hidden */
  93409. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  93410. /** @hidden */
  93411. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  93412. /** @hidden */
  93413. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  93414. /** @hidden */
  93415. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  93416. /**
  93417. * Appends the serialized animations from the source animations
  93418. * @param source Source containing the animations
  93419. * @param destination Target to store the animations
  93420. */
  93421. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93422. /**
  93423. * Static function used to serialized a specific entity
  93424. * @param entity defines the entity to serialize
  93425. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93426. * @returns a JSON compatible object representing the serialization of the entity
  93427. */
  93428. static Serialize<T>(entity: T, serializationObject?: any): any;
  93429. /**
  93430. * Creates a new entity from a serialization data object
  93431. * @param creationFunction defines a function used to instanciated the new entity
  93432. * @param source defines the source serialization data
  93433. * @param scene defines the hosting scene
  93434. * @param rootUrl defines the root url for resources
  93435. * @returns a new entity
  93436. */
  93437. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93438. /**
  93439. * Clones an object
  93440. * @param creationFunction defines the function used to instanciate the new object
  93441. * @param source defines the source object
  93442. * @returns the cloned object
  93443. */
  93444. static Clone<T>(creationFunction: () => T, source: T): T;
  93445. /**
  93446. * Instanciates a new object based on a source one (some data will be shared between both object)
  93447. * @param creationFunction defines the function used to instanciate the new object
  93448. * @param source defines the source object
  93449. * @returns the new object
  93450. */
  93451. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93452. }
  93453. }
  93454. declare module BABYLON {
  93455. /**
  93456. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  93457. */
  93458. export interface CubeMapInfo {
  93459. /**
  93460. * The pixel array for the front face.
  93461. * This is stored in format, left to right, up to down format.
  93462. */
  93463. front: Nullable<ArrayBufferView>;
  93464. /**
  93465. * The pixel array for the back face.
  93466. * This is stored in format, left to right, up to down format.
  93467. */
  93468. back: Nullable<ArrayBufferView>;
  93469. /**
  93470. * The pixel array for the left face.
  93471. * This is stored in format, left to right, up to down format.
  93472. */
  93473. left: Nullable<ArrayBufferView>;
  93474. /**
  93475. * The pixel array for the right face.
  93476. * This is stored in format, left to right, up to down format.
  93477. */
  93478. right: Nullable<ArrayBufferView>;
  93479. /**
  93480. * The pixel array for the up face.
  93481. * This is stored in format, left to right, up to down format.
  93482. */
  93483. up: Nullable<ArrayBufferView>;
  93484. /**
  93485. * The pixel array for the down face.
  93486. * This is stored in format, left to right, up to down format.
  93487. */
  93488. down: Nullable<ArrayBufferView>;
  93489. /**
  93490. * The size of the cubemap stored.
  93491. *
  93492. * Each faces will be size * size pixels.
  93493. */
  93494. size: number;
  93495. /**
  93496. * The format of the texture.
  93497. *
  93498. * RGBA, RGB.
  93499. */
  93500. format: number;
  93501. /**
  93502. * The type of the texture data.
  93503. *
  93504. * UNSIGNED_INT, FLOAT.
  93505. */
  93506. type: number;
  93507. /**
  93508. * Specifies whether the texture is in gamma space.
  93509. */
  93510. gammaSpace: boolean;
  93511. }
  93512. /**
  93513. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  93514. */
  93515. export class PanoramaToCubeMapTools {
  93516. private static FACE_FRONT;
  93517. private static FACE_BACK;
  93518. private static FACE_RIGHT;
  93519. private static FACE_LEFT;
  93520. private static FACE_DOWN;
  93521. private static FACE_UP;
  93522. /**
  93523. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  93524. *
  93525. * @param float32Array The source data.
  93526. * @param inputWidth The width of the input panorama.
  93527. * @param inputHeight The height of the input panorama.
  93528. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  93529. * @return The cubemap data
  93530. */
  93531. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  93532. private static CreateCubemapTexture;
  93533. private static CalcProjectionSpherical;
  93534. }
  93535. }
  93536. declare module BABYLON {
  93537. /**
  93538. * Helper class dealing with the extraction of spherical polynomial dataArray
  93539. * from a cube map.
  93540. */
  93541. export class CubeMapToSphericalPolynomialTools {
  93542. private static FileFaces;
  93543. /**
  93544. * Converts a texture to the according Spherical Polynomial data.
  93545. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93546. *
  93547. * @param texture The texture to extract the information from.
  93548. * @return The Spherical Polynomial data.
  93549. */
  93550. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  93551. /**
  93552. * Converts a cubemap to the according Spherical Polynomial data.
  93553. * This extracts the first 3 orders only as they are the only one used in the lighting.
  93554. *
  93555. * @param cubeInfo The Cube map to extract the information from.
  93556. * @return The Spherical Polynomial data.
  93557. */
  93558. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  93559. }
  93560. }
  93561. declare module BABYLON {
  93562. /**
  93563. * Class used to manipulate GUIDs
  93564. */
  93565. export class GUID {
  93566. /**
  93567. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  93568. * Be aware Math.random() could cause collisions, but:
  93569. * "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"
  93570. * @returns a pseudo random id
  93571. */
  93572. static RandomId(): string;
  93573. }
  93574. }
  93575. declare module BABYLON {
  93576. /**
  93577. * Base class of all the textures in babylon.
  93578. * It groups all the common properties the materials, post process, lights... might need
  93579. * in order to make a correct use of the texture.
  93580. */
  93581. export class BaseTexture implements IAnimatable {
  93582. /**
  93583. * Default anisotropic filtering level for the application.
  93584. * It is set to 4 as a good tradeoff between perf and quality.
  93585. */
  93586. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  93587. /**
  93588. * Gets or sets the unique id of the texture
  93589. */
  93590. uniqueId: number;
  93591. /**
  93592. * Define the name of the texture.
  93593. */
  93594. name: string;
  93595. /**
  93596. * Gets or sets an object used to store user defined information.
  93597. */
  93598. metadata: any;
  93599. /**
  93600. * For internal use only. Please do not use.
  93601. */
  93602. reservedDataStore: any;
  93603. private _hasAlpha;
  93604. /**
  93605. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  93606. */
  93607. hasAlpha: boolean;
  93608. /**
  93609. * Defines if the alpha value should be determined via the rgb values.
  93610. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  93611. */
  93612. getAlphaFromRGB: boolean;
  93613. /**
  93614. * Intensity or strength of the texture.
  93615. * It is commonly used by materials to fine tune the intensity of the texture
  93616. */
  93617. level: number;
  93618. /**
  93619. * Define the UV chanel to use starting from 0 and defaulting to 0.
  93620. * This is part of the texture as textures usually maps to one uv set.
  93621. */
  93622. coordinatesIndex: number;
  93623. private _coordinatesMode;
  93624. /**
  93625. * How a texture is mapped.
  93626. *
  93627. * | Value | Type | Description |
  93628. * | ----- | ----------------------------------- | ----------- |
  93629. * | 0 | EXPLICIT_MODE | |
  93630. * | 1 | SPHERICAL_MODE | |
  93631. * | 2 | PLANAR_MODE | |
  93632. * | 3 | CUBIC_MODE | |
  93633. * | 4 | PROJECTION_MODE | |
  93634. * | 5 | SKYBOX_MODE | |
  93635. * | 6 | INVCUBIC_MODE | |
  93636. * | 7 | EQUIRECTANGULAR_MODE | |
  93637. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  93638. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  93639. */
  93640. coordinatesMode: number;
  93641. /**
  93642. * | Value | Type | Description |
  93643. * | ----- | ------------------ | ----------- |
  93644. * | 0 | CLAMP_ADDRESSMODE | |
  93645. * | 1 | WRAP_ADDRESSMODE | |
  93646. * | 2 | MIRROR_ADDRESSMODE | |
  93647. */
  93648. wrapU: number;
  93649. /**
  93650. * | Value | Type | Description |
  93651. * | ----- | ------------------ | ----------- |
  93652. * | 0 | CLAMP_ADDRESSMODE | |
  93653. * | 1 | WRAP_ADDRESSMODE | |
  93654. * | 2 | MIRROR_ADDRESSMODE | |
  93655. */
  93656. wrapV: number;
  93657. /**
  93658. * | Value | Type | Description |
  93659. * | ----- | ------------------ | ----------- |
  93660. * | 0 | CLAMP_ADDRESSMODE | |
  93661. * | 1 | WRAP_ADDRESSMODE | |
  93662. * | 2 | MIRROR_ADDRESSMODE | |
  93663. */
  93664. wrapR: number;
  93665. /**
  93666. * With compliant hardware and browser (supporting anisotropic filtering)
  93667. * this defines the level of anisotropic filtering in the texture.
  93668. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  93669. */
  93670. anisotropicFilteringLevel: number;
  93671. /**
  93672. * Define if the texture is a cube texture or if false a 2d texture.
  93673. */
  93674. isCube: boolean;
  93675. /**
  93676. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  93677. */
  93678. is3D: boolean;
  93679. /**
  93680. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  93681. * HDR texture are usually stored in linear space.
  93682. * This only impacts the PBR and Background materials
  93683. */
  93684. gammaSpace: boolean;
  93685. /**
  93686. * Gets or sets whether or not the texture contains RGBD data.
  93687. */
  93688. isRGBD: boolean;
  93689. /**
  93690. * Is Z inverted in the texture (useful in a cube texture).
  93691. */
  93692. invertZ: boolean;
  93693. /**
  93694. * Are mip maps generated for this texture or not.
  93695. */
  93696. readonly noMipmap: boolean;
  93697. /**
  93698. * @hidden
  93699. */
  93700. lodLevelInAlpha: boolean;
  93701. /**
  93702. * With prefiltered texture, defined the offset used during the prefiltering steps.
  93703. */
  93704. lodGenerationOffset: number;
  93705. /**
  93706. * With prefiltered texture, defined the scale used during the prefiltering steps.
  93707. */
  93708. lodGenerationScale: number;
  93709. /**
  93710. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  93711. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  93712. * average roughness values.
  93713. */
  93714. linearSpecularLOD: boolean;
  93715. /**
  93716. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  93717. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  93718. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  93719. */
  93720. irradianceTexture: Nullable<BaseTexture>;
  93721. /**
  93722. * Define if the texture is a render target.
  93723. */
  93724. isRenderTarget: boolean;
  93725. /**
  93726. * Define the unique id of the texture in the scene.
  93727. */
  93728. readonly uid: string;
  93729. /**
  93730. * Return a string representation of the texture.
  93731. * @returns the texture as a string
  93732. */
  93733. toString(): string;
  93734. /**
  93735. * Get the class name of the texture.
  93736. * @returns "BaseTexture"
  93737. */
  93738. getClassName(): string;
  93739. /**
  93740. * Define the list of animation attached to the texture.
  93741. */
  93742. animations: Animation[];
  93743. /**
  93744. * An event triggered when the texture is disposed.
  93745. */
  93746. onDisposeObservable: Observable<BaseTexture>;
  93747. private _onDisposeObserver;
  93748. /**
  93749. * Callback triggered when the texture has been disposed.
  93750. * Kept for back compatibility, you can use the onDisposeObservable instead.
  93751. */
  93752. onDispose: () => void;
  93753. /**
  93754. * Define the current state of the loading sequence when in delayed load mode.
  93755. */
  93756. delayLoadState: number;
  93757. private _scene;
  93758. /** @hidden */
  93759. _texture: Nullable<InternalTexture>;
  93760. private _uid;
  93761. /**
  93762. * Define if the texture is preventinga material to render or not.
  93763. * If not and the texture is not ready, the engine will use a default black texture instead.
  93764. */
  93765. readonly isBlocking: boolean;
  93766. /**
  93767. * Instantiates a new BaseTexture.
  93768. * Base class of all the textures in babylon.
  93769. * It groups all the common properties the materials, post process, lights... might need
  93770. * in order to make a correct use of the texture.
  93771. * @param scene Define the scene the texture blongs to
  93772. */
  93773. constructor(scene: Nullable<Scene>);
  93774. /**
  93775. * Get the scene the texture belongs to.
  93776. * @returns the scene or null if undefined
  93777. */
  93778. getScene(): Nullable<Scene>;
  93779. /**
  93780. * Get the texture transform matrix used to offset tile the texture for istance.
  93781. * @returns the transformation matrix
  93782. */
  93783. getTextureMatrix(): Matrix;
  93784. /**
  93785. * Get the texture reflection matrix used to rotate/transform the reflection.
  93786. * @returns the reflection matrix
  93787. */
  93788. getReflectionTextureMatrix(): Matrix;
  93789. /**
  93790. * Get the underlying lower level texture from Babylon.
  93791. * @returns the insternal texture
  93792. */
  93793. getInternalTexture(): Nullable<InternalTexture>;
  93794. /**
  93795. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  93796. * @returns true if ready or not blocking
  93797. */
  93798. isReadyOrNotBlocking(): boolean;
  93799. /**
  93800. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  93801. * @returns true if fully ready
  93802. */
  93803. isReady(): boolean;
  93804. private _cachedSize;
  93805. /**
  93806. * Get the size of the texture.
  93807. * @returns the texture size.
  93808. */
  93809. getSize(): ISize;
  93810. /**
  93811. * Get the base size of the texture.
  93812. * It can be different from the size if the texture has been resized for POT for instance
  93813. * @returns the base size
  93814. */
  93815. getBaseSize(): ISize;
  93816. /**
  93817. * Update the sampling mode of the texture.
  93818. * Default is Trilinear mode.
  93819. *
  93820. * | Value | Type | Description |
  93821. * | ----- | ------------------ | ----------- |
  93822. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  93823. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  93824. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  93825. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  93826. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  93827. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  93828. * | 7 | NEAREST_LINEAR | |
  93829. * | 8 | NEAREST_NEAREST | |
  93830. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  93831. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  93832. * | 11 | LINEAR_LINEAR | |
  93833. * | 12 | LINEAR_NEAREST | |
  93834. *
  93835. * > _mag_: magnification filter (close to the viewer)
  93836. * > _min_: minification filter (far from the viewer)
  93837. * > _mip_: filter used between mip map levels
  93838. *@param samplingMode Define the new sampling mode of the texture
  93839. */
  93840. updateSamplingMode(samplingMode: number): void;
  93841. /**
  93842. * Scales the texture if is `canRescale()`
  93843. * @param ratio the resize factor we want to use to rescale
  93844. */
  93845. scale(ratio: number): void;
  93846. /**
  93847. * Get if the texture can rescale.
  93848. */
  93849. readonly canRescale: boolean;
  93850. /** @hidden */
  93851. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  93852. /** @hidden */
  93853. _rebuild(): void;
  93854. /**
  93855. * Triggers the load sequence in delayed load mode.
  93856. */
  93857. delayLoad(): void;
  93858. /**
  93859. * Clones the texture.
  93860. * @returns the cloned texture
  93861. */
  93862. clone(): Nullable<BaseTexture>;
  93863. /**
  93864. * Get the texture underlying type (INT, FLOAT...)
  93865. */
  93866. readonly textureType: number;
  93867. /**
  93868. * Get the texture underlying format (RGB, RGBA...)
  93869. */
  93870. readonly textureFormat: number;
  93871. /**
  93872. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  93873. * This will returns an RGBA array buffer containing either in values (0-255) or
  93874. * float values (0-1) depending of the underlying buffer type.
  93875. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  93876. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  93877. * @param buffer defines a user defined buffer to fill with data (can be null)
  93878. * @returns The Array buffer containing the pixels data.
  93879. */
  93880. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  93881. /**
  93882. * Release and destroy the underlying lower level texture aka internalTexture.
  93883. */
  93884. releaseInternalTexture(): void;
  93885. /**
  93886. * Get the polynomial representation of the texture data.
  93887. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  93888. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  93889. */
  93890. sphericalPolynomial: Nullable<SphericalPolynomial>;
  93891. /** @hidden */
  93892. readonly _lodTextureHigh: Nullable<BaseTexture>;
  93893. /** @hidden */
  93894. readonly _lodTextureMid: Nullable<BaseTexture>;
  93895. /** @hidden */
  93896. readonly _lodTextureLow: Nullable<BaseTexture>;
  93897. /**
  93898. * Dispose the texture and release its associated resources.
  93899. */
  93900. dispose(): void;
  93901. /**
  93902. * Serialize the texture into a JSON representation that can be parsed later on.
  93903. * @returns the JSON representation of the texture
  93904. */
  93905. serialize(): any;
  93906. /**
  93907. * Helper function to be called back once a list of texture contains only ready textures.
  93908. * @param textures Define the list of textures to wait for
  93909. * @param callback Define the callback triggered once the entire list will be ready
  93910. */
  93911. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  93912. }
  93913. }
  93914. declare module BABYLON {
  93915. /**
  93916. * Class used to store data associated with WebGL texture data for the engine
  93917. * This class should not be used directly
  93918. */
  93919. export class InternalTexture {
  93920. /** @hidden */
  93921. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  93922. /**
  93923. * The source of the texture data is unknown
  93924. */
  93925. static DATASOURCE_UNKNOWN: number;
  93926. /**
  93927. * Texture data comes from an URL
  93928. */
  93929. static DATASOURCE_URL: number;
  93930. /**
  93931. * Texture data is only used for temporary storage
  93932. */
  93933. static DATASOURCE_TEMP: number;
  93934. /**
  93935. * Texture data comes from raw data (ArrayBuffer)
  93936. */
  93937. static DATASOURCE_RAW: number;
  93938. /**
  93939. * Texture content is dynamic (video or dynamic texture)
  93940. */
  93941. static DATASOURCE_DYNAMIC: number;
  93942. /**
  93943. * Texture content is generated by rendering to it
  93944. */
  93945. static DATASOURCE_RENDERTARGET: number;
  93946. /**
  93947. * Texture content is part of a multi render target process
  93948. */
  93949. static DATASOURCE_MULTIRENDERTARGET: number;
  93950. /**
  93951. * Texture data comes from a cube data file
  93952. */
  93953. static DATASOURCE_CUBE: number;
  93954. /**
  93955. * Texture data comes from a raw cube data
  93956. */
  93957. static DATASOURCE_CUBERAW: number;
  93958. /**
  93959. * Texture data come from a prefiltered cube data file
  93960. */
  93961. static DATASOURCE_CUBEPREFILTERED: number;
  93962. /**
  93963. * Texture content is raw 3D data
  93964. */
  93965. static DATASOURCE_RAW3D: number;
  93966. /**
  93967. * Texture content is a depth texture
  93968. */
  93969. static DATASOURCE_DEPTHTEXTURE: number;
  93970. /**
  93971. * Texture data comes from a raw cube data encoded with RGBD
  93972. */
  93973. static DATASOURCE_CUBERAW_RGBD: number;
  93974. /**
  93975. * Defines if the texture is ready
  93976. */
  93977. isReady: boolean;
  93978. /**
  93979. * Defines if the texture is a cube texture
  93980. */
  93981. isCube: boolean;
  93982. /**
  93983. * Defines if the texture contains 3D data
  93984. */
  93985. is3D: boolean;
  93986. /**
  93987. * Defines if the texture contains multiview data
  93988. */
  93989. isMultiview: boolean;
  93990. /**
  93991. * Gets the URL used to load this texture
  93992. */
  93993. url: string;
  93994. /**
  93995. * Gets the sampling mode of the texture
  93996. */
  93997. samplingMode: number;
  93998. /**
  93999. * Gets a boolean indicating if the texture needs mipmaps generation
  94000. */
  94001. generateMipMaps: boolean;
  94002. /**
  94003. * Gets the number of samples used by the texture (WebGL2+ only)
  94004. */
  94005. samples: number;
  94006. /**
  94007. * Gets the type of the texture (int, float...)
  94008. */
  94009. type: number;
  94010. /**
  94011. * Gets the format of the texture (RGB, RGBA...)
  94012. */
  94013. format: number;
  94014. /**
  94015. * Observable called when the texture is loaded
  94016. */
  94017. onLoadedObservable: Observable<InternalTexture>;
  94018. /**
  94019. * Gets the width of the texture
  94020. */
  94021. width: number;
  94022. /**
  94023. * Gets the height of the texture
  94024. */
  94025. height: number;
  94026. /**
  94027. * Gets the depth of the texture
  94028. */
  94029. depth: number;
  94030. /**
  94031. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  94032. */
  94033. baseWidth: number;
  94034. /**
  94035. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  94036. */
  94037. baseHeight: number;
  94038. /**
  94039. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  94040. */
  94041. baseDepth: number;
  94042. /**
  94043. * Gets a boolean indicating if the texture is inverted on Y axis
  94044. */
  94045. invertY: boolean;
  94046. /** @hidden */
  94047. _invertVScale: boolean;
  94048. /** @hidden */
  94049. _associatedChannel: number;
  94050. /** @hidden */
  94051. _dataSource: number;
  94052. /** @hidden */
  94053. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  94054. /** @hidden */
  94055. _bufferView: Nullable<ArrayBufferView>;
  94056. /** @hidden */
  94057. _bufferViewArray: Nullable<ArrayBufferView[]>;
  94058. /** @hidden */
  94059. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  94060. /** @hidden */
  94061. _size: number;
  94062. /** @hidden */
  94063. _extension: string;
  94064. /** @hidden */
  94065. _files: Nullable<string[]>;
  94066. /** @hidden */
  94067. _workingCanvas: Nullable<HTMLCanvasElement>;
  94068. /** @hidden */
  94069. _workingContext: Nullable<CanvasRenderingContext2D>;
  94070. /** @hidden */
  94071. _framebuffer: Nullable<WebGLFramebuffer>;
  94072. /** @hidden */
  94073. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  94074. /** @hidden */
  94075. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  94076. /** @hidden */
  94077. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  94078. /** @hidden */
  94079. _attachments: Nullable<number[]>;
  94080. /** @hidden */
  94081. _cachedCoordinatesMode: Nullable<number>;
  94082. /** @hidden */
  94083. _cachedWrapU: Nullable<number>;
  94084. /** @hidden */
  94085. _cachedWrapV: Nullable<number>;
  94086. /** @hidden */
  94087. _cachedWrapR: Nullable<number>;
  94088. /** @hidden */
  94089. _cachedAnisotropicFilteringLevel: Nullable<number>;
  94090. /** @hidden */
  94091. _isDisabled: boolean;
  94092. /** @hidden */
  94093. _compression: Nullable<string>;
  94094. /** @hidden */
  94095. _generateStencilBuffer: boolean;
  94096. /** @hidden */
  94097. _generateDepthBuffer: boolean;
  94098. /** @hidden */
  94099. _comparisonFunction: number;
  94100. /** @hidden */
  94101. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  94102. /** @hidden */
  94103. _lodGenerationScale: number;
  94104. /** @hidden */
  94105. _lodGenerationOffset: number;
  94106. /** @hidden */
  94107. _colorTextureArray: Nullable<WebGLTexture>;
  94108. /** @hidden */
  94109. _depthStencilTextureArray: Nullable<WebGLTexture>;
  94110. /** @hidden */
  94111. _lodTextureHigh: Nullable<BaseTexture>;
  94112. /** @hidden */
  94113. _lodTextureMid: Nullable<BaseTexture>;
  94114. /** @hidden */
  94115. _lodTextureLow: Nullable<BaseTexture>;
  94116. /** @hidden */
  94117. _isRGBD: boolean;
  94118. /** @hidden */
  94119. _linearSpecularLOD: boolean;
  94120. /** @hidden */
  94121. _irradianceTexture: Nullable<BaseTexture>;
  94122. /** @hidden */
  94123. _webGLTexture: Nullable<WebGLTexture>;
  94124. /** @hidden */
  94125. _references: number;
  94126. private _engine;
  94127. /**
  94128. * Gets the Engine the texture belongs to.
  94129. * @returns The babylon engine
  94130. */
  94131. getEngine(): Engine;
  94132. /**
  94133. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  94134. */
  94135. readonly dataSource: number;
  94136. /**
  94137. * Creates a new InternalTexture
  94138. * @param engine defines the engine to use
  94139. * @param dataSource defines the type of data that will be used
  94140. * @param delayAllocation if the texture allocation should be delayed (default: false)
  94141. */
  94142. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  94143. /**
  94144. * Increments the number of references (ie. the number of Texture that point to it)
  94145. */
  94146. incrementReferences(): void;
  94147. /**
  94148. * Change the size of the texture (not the size of the content)
  94149. * @param width defines the new width
  94150. * @param height defines the new height
  94151. * @param depth defines the new depth (1 by default)
  94152. */
  94153. updateSize(width: int, height: int, depth?: int): void;
  94154. /** @hidden */
  94155. _rebuild(): void;
  94156. /** @hidden */
  94157. _swapAndDie(target: InternalTexture): void;
  94158. /**
  94159. * Dispose the current allocated resources
  94160. */
  94161. dispose(): void;
  94162. }
  94163. }
  94164. declare module BABYLON {
  94165. /**
  94166. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  94167. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  94168. */
  94169. export class EffectFallbacks {
  94170. private _defines;
  94171. private _currentRank;
  94172. private _maxRank;
  94173. private _mesh;
  94174. /**
  94175. * Removes the fallback from the bound mesh.
  94176. */
  94177. unBindMesh(): void;
  94178. /**
  94179. * Adds a fallback on the specified property.
  94180. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94181. * @param define The name of the define in the shader
  94182. */
  94183. addFallback(rank: number, define: string): void;
  94184. /**
  94185. * Sets the mesh to use CPU skinning when needing to fallback.
  94186. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  94187. * @param mesh The mesh to use the fallbacks.
  94188. */
  94189. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  94190. /**
  94191. * Checks to see if more fallbacks are still availible.
  94192. */
  94193. readonly hasMoreFallbacks: boolean;
  94194. /**
  94195. * Removes the defines that should be removed when falling back.
  94196. * @param currentDefines defines the current define statements for the shader.
  94197. * @param effect defines the current effect we try to compile
  94198. * @returns The resulting defines with defines of the current rank removed.
  94199. */
  94200. reduce(currentDefines: string, effect: Effect): string;
  94201. }
  94202. /**
  94203. * Options to be used when creating an effect.
  94204. */
  94205. export class EffectCreationOptions {
  94206. /**
  94207. * Atrributes that will be used in the shader.
  94208. */
  94209. attributes: string[];
  94210. /**
  94211. * Uniform varible names that will be set in the shader.
  94212. */
  94213. uniformsNames: string[];
  94214. /**
  94215. * Uniform buffer varible names that will be set in the shader.
  94216. */
  94217. uniformBuffersNames: string[];
  94218. /**
  94219. * Sampler texture variable names that will be set in the shader.
  94220. */
  94221. samplers: string[];
  94222. /**
  94223. * Define statements that will be set in the shader.
  94224. */
  94225. defines: any;
  94226. /**
  94227. * Possible fallbacks for this effect to improve performance when needed.
  94228. */
  94229. fallbacks: Nullable<EffectFallbacks>;
  94230. /**
  94231. * Callback that will be called when the shader is compiled.
  94232. */
  94233. onCompiled: Nullable<(effect: Effect) => void>;
  94234. /**
  94235. * Callback that will be called if an error occurs during shader compilation.
  94236. */
  94237. onError: Nullable<(effect: Effect, errors: string) => void>;
  94238. /**
  94239. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94240. */
  94241. indexParameters: any;
  94242. /**
  94243. * Max number of lights that can be used in the shader.
  94244. */
  94245. maxSimultaneousLights: number;
  94246. /**
  94247. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94248. */
  94249. transformFeedbackVaryings: Nullable<string[]>;
  94250. }
  94251. /**
  94252. * Effect containing vertex and fragment shader that can be executed on an object.
  94253. */
  94254. export class Effect implements IDisposable {
  94255. /**
  94256. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94257. */
  94258. static ShadersRepository: string;
  94259. /**
  94260. * Name of the effect.
  94261. */
  94262. name: any;
  94263. /**
  94264. * String container all the define statements that should be set on the shader.
  94265. */
  94266. defines: string;
  94267. /**
  94268. * Callback that will be called when the shader is compiled.
  94269. */
  94270. onCompiled: Nullable<(effect: Effect) => void>;
  94271. /**
  94272. * Callback that will be called if an error occurs during shader compilation.
  94273. */
  94274. onError: Nullable<(effect: Effect, errors: string) => void>;
  94275. /**
  94276. * Callback that will be called when effect is bound.
  94277. */
  94278. onBind: Nullable<(effect: Effect) => void>;
  94279. /**
  94280. * Unique ID of the effect.
  94281. */
  94282. uniqueId: number;
  94283. /**
  94284. * Observable that will be called when the shader is compiled.
  94285. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  94286. */
  94287. onCompileObservable: Observable<Effect>;
  94288. /**
  94289. * Observable that will be called if an error occurs during shader compilation.
  94290. */
  94291. onErrorObservable: Observable<Effect>;
  94292. /** @hidden */
  94293. _onBindObservable: Nullable<Observable<Effect>>;
  94294. /**
  94295. * Observable that will be called when effect is bound.
  94296. */
  94297. readonly onBindObservable: Observable<Effect>;
  94298. /** @hidden */
  94299. _bonesComputationForcedToCPU: boolean;
  94300. private static _uniqueIdSeed;
  94301. private _engine;
  94302. private _uniformBuffersNames;
  94303. private _uniformsNames;
  94304. private _samplerList;
  94305. private _samplers;
  94306. private _isReady;
  94307. private _compilationError;
  94308. private _attributesNames;
  94309. private _attributes;
  94310. private _uniforms;
  94311. /**
  94312. * Key for the effect.
  94313. * @hidden
  94314. */
  94315. _key: string;
  94316. private _indexParameters;
  94317. private _fallbacks;
  94318. private _vertexSourceCode;
  94319. private _fragmentSourceCode;
  94320. private _vertexSourceCodeOverride;
  94321. private _fragmentSourceCodeOverride;
  94322. private _transformFeedbackVaryings;
  94323. /**
  94324. * Compiled shader to webGL program.
  94325. * @hidden
  94326. */
  94327. _pipelineContext: Nullable<IPipelineContext>;
  94328. private _valueCache;
  94329. private static _baseCache;
  94330. /**
  94331. * Instantiates an effect.
  94332. * An effect can be used to create/manage/execute vertex and fragment shaders.
  94333. * @param baseName Name of the effect.
  94334. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  94335. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  94336. * @param samplers List of sampler variables that will be passed to the shader.
  94337. * @param engine Engine to be used to render the effect
  94338. * @param defines Define statements to be added to the shader.
  94339. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  94340. * @param onCompiled Callback that will be called when the shader is compiled.
  94341. * @param onError Callback that will be called if an error occurs during shader compilation.
  94342. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94343. */
  94344. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  94345. private _useFinalCode;
  94346. /**
  94347. * Unique key for this effect
  94348. */
  94349. readonly key: string;
  94350. /**
  94351. * If the effect has been compiled and prepared.
  94352. * @returns if the effect is compiled and prepared.
  94353. */
  94354. isReady(): boolean;
  94355. private _isReadyInternal;
  94356. /**
  94357. * The engine the effect was initialized with.
  94358. * @returns the engine.
  94359. */
  94360. getEngine(): Engine;
  94361. /**
  94362. * The pipeline context for this effect
  94363. * @returns the associated pipeline context
  94364. */
  94365. getPipelineContext(): Nullable<IPipelineContext>;
  94366. /**
  94367. * The set of names of attribute variables for the shader.
  94368. * @returns An array of attribute names.
  94369. */
  94370. getAttributesNames(): string[];
  94371. /**
  94372. * Returns the attribute at the given index.
  94373. * @param index The index of the attribute.
  94374. * @returns The location of the attribute.
  94375. */
  94376. getAttributeLocation(index: number): number;
  94377. /**
  94378. * Returns the attribute based on the name of the variable.
  94379. * @param name of the attribute to look up.
  94380. * @returns the attribute location.
  94381. */
  94382. getAttributeLocationByName(name: string): number;
  94383. /**
  94384. * The number of attributes.
  94385. * @returns the numnber of attributes.
  94386. */
  94387. getAttributesCount(): number;
  94388. /**
  94389. * Gets the index of a uniform variable.
  94390. * @param uniformName of the uniform to look up.
  94391. * @returns the index.
  94392. */
  94393. getUniformIndex(uniformName: string): number;
  94394. /**
  94395. * Returns the attribute based on the name of the variable.
  94396. * @param uniformName of the uniform to look up.
  94397. * @returns the location of the uniform.
  94398. */
  94399. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  94400. /**
  94401. * Returns an array of sampler variable names
  94402. * @returns The array of sampler variable neames.
  94403. */
  94404. getSamplers(): string[];
  94405. /**
  94406. * The error from the last compilation.
  94407. * @returns the error string.
  94408. */
  94409. getCompilationError(): string;
  94410. /**
  94411. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  94412. * @param func The callback to be used.
  94413. */
  94414. executeWhenCompiled(func: (effect: Effect) => void): void;
  94415. private _checkIsReady;
  94416. /** @hidden */
  94417. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  94418. /** @hidden */
  94419. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  94420. /** @hidden */
  94421. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  94422. /**
  94423. * Recompiles the webGL program
  94424. * @param vertexSourceCode The source code for the vertex shader.
  94425. * @param fragmentSourceCode The source code for the fragment shader.
  94426. * @param onCompiled Callback called when completed.
  94427. * @param onError Callback called on error.
  94428. * @hidden
  94429. */
  94430. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  94431. /**
  94432. * Prepares the effect
  94433. * @hidden
  94434. */
  94435. _prepareEffect(): void;
  94436. private _processCompilationErrors;
  94437. /**
  94438. * Checks if the effect is supported. (Must be called after compilation)
  94439. */
  94440. readonly isSupported: boolean;
  94441. /**
  94442. * Binds a texture to the engine to be used as output of the shader.
  94443. * @param channel Name of the output variable.
  94444. * @param texture Texture to bind.
  94445. * @hidden
  94446. */
  94447. _bindTexture(channel: string, texture: InternalTexture): void;
  94448. /**
  94449. * Sets a texture on the engine to be used in the shader.
  94450. * @param channel Name of the sampler variable.
  94451. * @param texture Texture to set.
  94452. */
  94453. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  94454. /**
  94455. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  94456. * @param channel Name of the sampler variable.
  94457. * @param texture Texture to set.
  94458. */
  94459. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  94460. /**
  94461. * Sets an array of textures on the engine to be used in the shader.
  94462. * @param channel Name of the variable.
  94463. * @param textures Textures to set.
  94464. */
  94465. setTextureArray(channel: string, textures: BaseTexture[]): void;
  94466. /**
  94467. * 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)
  94468. * @param channel Name of the sampler variable.
  94469. * @param postProcess Post process to get the input texture from.
  94470. */
  94471. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  94472. /**
  94473. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  94474. * 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)
  94475. * @param channel Name of the sampler variable.
  94476. * @param postProcess Post process to get the output texture from.
  94477. */
  94478. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  94479. /** @hidden */
  94480. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  94481. /** @hidden */
  94482. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  94483. /** @hidden */
  94484. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  94485. /** @hidden */
  94486. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  94487. /**
  94488. * Binds a buffer to a uniform.
  94489. * @param buffer Buffer to bind.
  94490. * @param name Name of the uniform variable to bind to.
  94491. */
  94492. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  94493. /**
  94494. * Binds block to a uniform.
  94495. * @param blockName Name of the block to bind.
  94496. * @param index Index to bind.
  94497. */
  94498. bindUniformBlock(blockName: string, index: number): void;
  94499. /**
  94500. * Sets an interger value on a uniform variable.
  94501. * @param uniformName Name of the variable.
  94502. * @param value Value to be set.
  94503. * @returns this effect.
  94504. */
  94505. setInt(uniformName: string, value: number): Effect;
  94506. /**
  94507. * Sets an int array on a uniform variable.
  94508. * @param uniformName Name of the variable.
  94509. * @param array array to be set.
  94510. * @returns this effect.
  94511. */
  94512. setIntArray(uniformName: string, array: Int32Array): Effect;
  94513. /**
  94514. * 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)
  94515. * @param uniformName Name of the variable.
  94516. * @param array array to be set.
  94517. * @returns this effect.
  94518. */
  94519. setIntArray2(uniformName: string, array: Int32Array): Effect;
  94520. /**
  94521. * 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)
  94522. * @param uniformName Name of the variable.
  94523. * @param array array to be set.
  94524. * @returns this effect.
  94525. */
  94526. setIntArray3(uniformName: string, array: Int32Array): Effect;
  94527. /**
  94528. * 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)
  94529. * @param uniformName Name of the variable.
  94530. * @param array array to be set.
  94531. * @returns this effect.
  94532. */
  94533. setIntArray4(uniformName: string, array: Int32Array): Effect;
  94534. /**
  94535. * Sets an float array on a uniform variable.
  94536. * @param uniformName Name of the variable.
  94537. * @param array array to be set.
  94538. * @returns this effect.
  94539. */
  94540. setFloatArray(uniformName: string, array: Float32Array): Effect;
  94541. /**
  94542. * 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)
  94543. * @param uniformName Name of the variable.
  94544. * @param array array to be set.
  94545. * @returns this effect.
  94546. */
  94547. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  94548. /**
  94549. * 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)
  94550. * @param uniformName Name of the variable.
  94551. * @param array array to be set.
  94552. * @returns this effect.
  94553. */
  94554. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  94555. /**
  94556. * 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)
  94557. * @param uniformName Name of the variable.
  94558. * @param array array to be set.
  94559. * @returns this effect.
  94560. */
  94561. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  94562. /**
  94563. * Sets an array on a uniform variable.
  94564. * @param uniformName Name of the variable.
  94565. * @param array array to be set.
  94566. * @returns this effect.
  94567. */
  94568. setArray(uniformName: string, array: number[]): Effect;
  94569. /**
  94570. * 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)
  94571. * @param uniformName Name of the variable.
  94572. * @param array array to be set.
  94573. * @returns this effect.
  94574. */
  94575. setArray2(uniformName: string, array: number[]): Effect;
  94576. /**
  94577. * 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)
  94578. * @param uniformName Name of the variable.
  94579. * @param array array to be set.
  94580. * @returns this effect.
  94581. */
  94582. setArray3(uniformName: string, array: number[]): Effect;
  94583. /**
  94584. * 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)
  94585. * @param uniformName Name of the variable.
  94586. * @param array array to be set.
  94587. * @returns this effect.
  94588. */
  94589. setArray4(uniformName: string, array: number[]): Effect;
  94590. /**
  94591. * Sets matrices on a uniform variable.
  94592. * @param uniformName Name of the variable.
  94593. * @param matrices matrices to be set.
  94594. * @returns this effect.
  94595. */
  94596. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  94597. /**
  94598. * Sets matrix on a uniform variable.
  94599. * @param uniformName Name of the variable.
  94600. * @param matrix matrix to be set.
  94601. * @returns this effect.
  94602. */
  94603. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  94604. /**
  94605. * 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)
  94606. * @param uniformName Name of the variable.
  94607. * @param matrix matrix to be set.
  94608. * @returns this effect.
  94609. */
  94610. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  94611. /**
  94612. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  94613. * @param uniformName Name of the variable.
  94614. * @param matrix matrix to be set.
  94615. * @returns this effect.
  94616. */
  94617. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  94618. /**
  94619. * Sets a float on a uniform variable.
  94620. * @param uniformName Name of the variable.
  94621. * @param value value to be set.
  94622. * @returns this effect.
  94623. */
  94624. setFloat(uniformName: string, value: number): Effect;
  94625. /**
  94626. * Sets a boolean on a uniform variable.
  94627. * @param uniformName Name of the variable.
  94628. * @param bool value to be set.
  94629. * @returns this effect.
  94630. */
  94631. setBool(uniformName: string, bool: boolean): Effect;
  94632. /**
  94633. * Sets a Vector2 on a uniform variable.
  94634. * @param uniformName Name of the variable.
  94635. * @param vector2 vector2 to be set.
  94636. * @returns this effect.
  94637. */
  94638. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  94639. /**
  94640. * Sets a float2 on a uniform variable.
  94641. * @param uniformName Name of the variable.
  94642. * @param x First float in float2.
  94643. * @param y Second float in float2.
  94644. * @returns this effect.
  94645. */
  94646. setFloat2(uniformName: string, x: number, y: number): Effect;
  94647. /**
  94648. * Sets a Vector3 on a uniform variable.
  94649. * @param uniformName Name of the variable.
  94650. * @param vector3 Value to be set.
  94651. * @returns this effect.
  94652. */
  94653. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  94654. /**
  94655. * Sets a float3 on a uniform variable.
  94656. * @param uniformName Name of the variable.
  94657. * @param x First float in float3.
  94658. * @param y Second float in float3.
  94659. * @param z Third float in float3.
  94660. * @returns this effect.
  94661. */
  94662. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  94663. /**
  94664. * Sets a Vector4 on a uniform variable.
  94665. * @param uniformName Name of the variable.
  94666. * @param vector4 Value to be set.
  94667. * @returns this effect.
  94668. */
  94669. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  94670. /**
  94671. * Sets a float4 on a uniform variable.
  94672. * @param uniformName Name of the variable.
  94673. * @param x First float in float4.
  94674. * @param y Second float in float4.
  94675. * @param z Third float in float4.
  94676. * @param w Fourth float in float4.
  94677. * @returns this effect.
  94678. */
  94679. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  94680. /**
  94681. * Sets a Color3 on a uniform variable.
  94682. * @param uniformName Name of the variable.
  94683. * @param color3 Value to be set.
  94684. * @returns this effect.
  94685. */
  94686. setColor3(uniformName: string, color3: IColor3Like): Effect;
  94687. /**
  94688. * Sets a Color4 on a uniform variable.
  94689. * @param uniformName Name of the variable.
  94690. * @param color3 Value to be set.
  94691. * @param alpha Alpha value to be set.
  94692. * @returns this effect.
  94693. */
  94694. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  94695. /**
  94696. * Sets a Color4 on a uniform variable
  94697. * @param uniformName defines the name of the variable
  94698. * @param color4 defines the value to be set
  94699. * @returns this effect.
  94700. */
  94701. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  94702. /** Release all associated resources */
  94703. dispose(): void;
  94704. /**
  94705. * This function will add a new shader to the shader store
  94706. * @param name the name of the shader
  94707. * @param pixelShader optional pixel shader content
  94708. * @param vertexShader optional vertex shader content
  94709. */
  94710. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  94711. /**
  94712. * Store of each shader (The can be looked up using effect.key)
  94713. */
  94714. static ShadersStore: {
  94715. [key: string]: string;
  94716. };
  94717. /**
  94718. * Store of each included file for a shader (The can be looked up using effect.key)
  94719. */
  94720. static IncludesShadersStore: {
  94721. [key: string]: string;
  94722. };
  94723. /**
  94724. * Resets the cache of effects.
  94725. */
  94726. static ResetCache(): void;
  94727. }
  94728. }
  94729. declare module BABYLON {
  94730. /**
  94731. * Uniform buffer objects.
  94732. *
  94733. * Handles blocks of uniform on the GPU.
  94734. *
  94735. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94736. *
  94737. * For more information, please refer to :
  94738. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94739. */
  94740. export class UniformBuffer {
  94741. private _engine;
  94742. private _buffer;
  94743. private _data;
  94744. private _bufferData;
  94745. private _dynamic?;
  94746. private _uniformLocations;
  94747. private _uniformSizes;
  94748. private _uniformLocationPointer;
  94749. private _needSync;
  94750. private _noUBO;
  94751. private _currentEffect;
  94752. private static _MAX_UNIFORM_SIZE;
  94753. private static _tempBuffer;
  94754. /**
  94755. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  94756. * This is dynamic to allow compat with webgl 1 and 2.
  94757. * You will need to pass the name of the uniform as well as the value.
  94758. */
  94759. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  94760. /**
  94761. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  94762. * This is dynamic to allow compat with webgl 1 and 2.
  94763. * You will need to pass the name of the uniform as well as the value.
  94764. */
  94765. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  94766. /**
  94767. * Lambda to Update a single float in a uniform buffer.
  94768. * This is dynamic to allow compat with webgl 1 and 2.
  94769. * You will need to pass the name of the uniform as well as the value.
  94770. */
  94771. updateFloat: (name: string, x: number) => void;
  94772. /**
  94773. * Lambda to Update a vec2 of float in a uniform buffer.
  94774. * This is dynamic to allow compat with webgl 1 and 2.
  94775. * You will need to pass the name of the uniform as well as the value.
  94776. */
  94777. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  94778. /**
  94779. * Lambda to Update a vec3 of float in a uniform buffer.
  94780. * This is dynamic to allow compat with webgl 1 and 2.
  94781. * You will need to pass the name of the uniform as well as the value.
  94782. */
  94783. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  94784. /**
  94785. * Lambda to Update a vec4 of float in a uniform buffer.
  94786. * This is dynamic to allow compat with webgl 1 and 2.
  94787. * You will need to pass the name of the uniform as well as the value.
  94788. */
  94789. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  94790. /**
  94791. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  94792. * This is dynamic to allow compat with webgl 1 and 2.
  94793. * You will need to pass the name of the uniform as well as the value.
  94794. */
  94795. updateMatrix: (name: string, mat: Matrix) => void;
  94796. /**
  94797. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  94798. * This is dynamic to allow compat with webgl 1 and 2.
  94799. * You will need to pass the name of the uniform as well as the value.
  94800. */
  94801. updateVector3: (name: string, vector: Vector3) => void;
  94802. /**
  94803. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  94804. * This is dynamic to allow compat with webgl 1 and 2.
  94805. * You will need to pass the name of the uniform as well as the value.
  94806. */
  94807. updateVector4: (name: string, vector: Vector4) => void;
  94808. /**
  94809. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  94810. * This is dynamic to allow compat with webgl 1 and 2.
  94811. * You will need to pass the name of the uniform as well as the value.
  94812. */
  94813. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  94814. /**
  94815. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  94816. * This is dynamic to allow compat with webgl 1 and 2.
  94817. * You will need to pass the name of the uniform as well as the value.
  94818. */
  94819. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  94820. /**
  94821. * Instantiates a new Uniform buffer objects.
  94822. *
  94823. * Handles blocks of uniform on the GPU.
  94824. *
  94825. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  94826. *
  94827. * For more information, please refer to :
  94828. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  94829. * @param engine Define the engine the buffer is associated with
  94830. * @param data Define the data contained in the buffer
  94831. * @param dynamic Define if the buffer is updatable
  94832. */
  94833. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  94834. /**
  94835. * Indicates if the buffer is using the WebGL2 UBO implementation,
  94836. * or just falling back on setUniformXXX calls.
  94837. */
  94838. readonly useUbo: boolean;
  94839. /**
  94840. * Indicates if the WebGL underlying uniform buffer is in sync
  94841. * with the javascript cache data.
  94842. */
  94843. readonly isSync: boolean;
  94844. /**
  94845. * Indicates if the WebGL underlying uniform buffer is dynamic.
  94846. * Also, a dynamic UniformBuffer will disable cache verification and always
  94847. * update the underlying WebGL uniform buffer to the GPU.
  94848. * @returns if Dynamic, otherwise false
  94849. */
  94850. isDynamic(): boolean;
  94851. /**
  94852. * The data cache on JS side.
  94853. * @returns the underlying data as a float array
  94854. */
  94855. getData(): Float32Array;
  94856. /**
  94857. * The underlying WebGL Uniform buffer.
  94858. * @returns the webgl buffer
  94859. */
  94860. getBuffer(): Nullable<DataBuffer>;
  94861. /**
  94862. * std140 layout specifies how to align data within an UBO structure.
  94863. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  94864. * for specs.
  94865. */
  94866. private _fillAlignment;
  94867. /**
  94868. * Adds an uniform in the buffer.
  94869. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  94870. * for the layout to be correct !
  94871. * @param name Name of the uniform, as used in the uniform block in the shader.
  94872. * @param size Data size, or data directly.
  94873. */
  94874. addUniform(name: string, size: number | number[]): void;
  94875. /**
  94876. * Adds a Matrix 4x4 to the uniform buffer.
  94877. * @param name Name of the uniform, as used in the uniform block in the shader.
  94878. * @param mat A 4x4 matrix.
  94879. */
  94880. addMatrix(name: string, mat: Matrix): void;
  94881. /**
  94882. * Adds a vec2 to the uniform buffer.
  94883. * @param name Name of the uniform, as used in the uniform block in the shader.
  94884. * @param x Define the x component value of the vec2
  94885. * @param y Define the y component value of the vec2
  94886. */
  94887. addFloat2(name: string, x: number, y: number): void;
  94888. /**
  94889. * Adds a vec3 to the uniform buffer.
  94890. * @param name Name of the uniform, as used in the uniform block in the shader.
  94891. * @param x Define the x component value of the vec3
  94892. * @param y Define the y component value of the vec3
  94893. * @param z Define the z component value of the vec3
  94894. */
  94895. addFloat3(name: string, x: number, y: number, z: number): void;
  94896. /**
  94897. * Adds a vec3 to the uniform buffer.
  94898. * @param name Name of the uniform, as used in the uniform block in the shader.
  94899. * @param color Define the vec3 from a Color
  94900. */
  94901. addColor3(name: string, color: Color3): void;
  94902. /**
  94903. * Adds a vec4 to the uniform buffer.
  94904. * @param name Name of the uniform, as used in the uniform block in the shader.
  94905. * @param color Define the rgb components from a Color
  94906. * @param alpha Define the a component of the vec4
  94907. */
  94908. addColor4(name: string, color: Color3, alpha: number): void;
  94909. /**
  94910. * Adds a vec3 to the uniform buffer.
  94911. * @param name Name of the uniform, as used in the uniform block in the shader.
  94912. * @param vector Define the vec3 components from a Vector
  94913. */
  94914. addVector3(name: string, vector: Vector3): void;
  94915. /**
  94916. * Adds a Matrix 3x3 to the uniform buffer.
  94917. * @param name Name of the uniform, as used in the uniform block in the shader.
  94918. */
  94919. addMatrix3x3(name: string): void;
  94920. /**
  94921. * Adds a Matrix 2x2 to the uniform buffer.
  94922. * @param name Name of the uniform, as used in the uniform block in the shader.
  94923. */
  94924. addMatrix2x2(name: string): void;
  94925. /**
  94926. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  94927. */
  94928. create(): void;
  94929. /** @hidden */
  94930. _rebuild(): void;
  94931. /**
  94932. * Updates the WebGL Uniform Buffer on the GPU.
  94933. * If the `dynamic` flag is set to true, no cache comparison is done.
  94934. * Otherwise, the buffer will be updated only if the cache differs.
  94935. */
  94936. update(): void;
  94937. /**
  94938. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  94939. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94940. * @param data Define the flattened data
  94941. * @param size Define the size of the data.
  94942. */
  94943. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  94944. private _valueCache;
  94945. private _cacheMatrix;
  94946. private _updateMatrix3x3ForUniform;
  94947. private _updateMatrix3x3ForEffect;
  94948. private _updateMatrix2x2ForEffect;
  94949. private _updateMatrix2x2ForUniform;
  94950. private _updateFloatForEffect;
  94951. private _updateFloatForUniform;
  94952. private _updateFloat2ForEffect;
  94953. private _updateFloat2ForUniform;
  94954. private _updateFloat3ForEffect;
  94955. private _updateFloat3ForUniform;
  94956. private _updateFloat4ForEffect;
  94957. private _updateFloat4ForUniform;
  94958. private _updateMatrixForEffect;
  94959. private _updateMatrixForUniform;
  94960. private _updateVector3ForEffect;
  94961. private _updateVector3ForUniform;
  94962. private _updateVector4ForEffect;
  94963. private _updateVector4ForUniform;
  94964. private _updateColor3ForEffect;
  94965. private _updateColor3ForUniform;
  94966. private _updateColor4ForEffect;
  94967. private _updateColor4ForUniform;
  94968. /**
  94969. * Sets a sampler uniform on the effect.
  94970. * @param name Define the name of the sampler.
  94971. * @param texture Define the texture to set in the sampler
  94972. */
  94973. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  94974. /**
  94975. * Directly updates the value of the uniform in the cache AND on the GPU.
  94976. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  94977. * @param data Define the flattened data
  94978. */
  94979. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  94980. /**
  94981. * Binds this uniform buffer to an effect.
  94982. * @param effect Define the effect to bind the buffer to
  94983. * @param name Name of the uniform block in the shader.
  94984. */
  94985. bindToEffect(effect: Effect, name: string): void;
  94986. /**
  94987. * Disposes the uniform buffer.
  94988. */
  94989. dispose(): void;
  94990. }
  94991. }
  94992. declare module BABYLON {
  94993. /**
  94994. * Class used to work with sound analyzer using fast fourier transform (FFT)
  94995. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  94996. */
  94997. export class Analyser {
  94998. /**
  94999. * Gets or sets the smoothing
  95000. * @ignorenaming
  95001. */
  95002. SMOOTHING: number;
  95003. /**
  95004. * Gets or sets the FFT table size
  95005. * @ignorenaming
  95006. */
  95007. FFT_SIZE: number;
  95008. /**
  95009. * Gets or sets the bar graph amplitude
  95010. * @ignorenaming
  95011. */
  95012. BARGRAPHAMPLITUDE: number;
  95013. /**
  95014. * Gets or sets the position of the debug canvas
  95015. * @ignorenaming
  95016. */
  95017. DEBUGCANVASPOS: {
  95018. x: number;
  95019. y: number;
  95020. };
  95021. /**
  95022. * Gets or sets the debug canvas size
  95023. * @ignorenaming
  95024. */
  95025. DEBUGCANVASSIZE: {
  95026. width: number;
  95027. height: number;
  95028. };
  95029. private _byteFreqs;
  95030. private _byteTime;
  95031. private _floatFreqs;
  95032. private _webAudioAnalyser;
  95033. private _debugCanvas;
  95034. private _debugCanvasContext;
  95035. private _scene;
  95036. private _registerFunc;
  95037. private _audioEngine;
  95038. /**
  95039. * Creates a new analyser
  95040. * @param scene defines hosting scene
  95041. */
  95042. constructor(scene: Scene);
  95043. /**
  95044. * Get the number of data values you will have to play with for the visualization
  95045. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  95046. * @returns a number
  95047. */
  95048. getFrequencyBinCount(): number;
  95049. /**
  95050. * Gets the current frequency data as a byte array
  95051. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  95052. * @returns a Uint8Array
  95053. */
  95054. getByteFrequencyData(): Uint8Array;
  95055. /**
  95056. * Gets the current waveform as a byte array
  95057. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  95058. * @returns a Uint8Array
  95059. */
  95060. getByteTimeDomainData(): Uint8Array;
  95061. /**
  95062. * Gets the current frequency data as a float array
  95063. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  95064. * @returns a Float32Array
  95065. */
  95066. getFloatFrequencyData(): Float32Array;
  95067. /**
  95068. * Renders the debug canvas
  95069. */
  95070. drawDebugCanvas(): void;
  95071. /**
  95072. * Stops rendering the debug canvas and removes it
  95073. */
  95074. stopDebugCanvas(): void;
  95075. /**
  95076. * Connects two audio nodes
  95077. * @param inputAudioNode defines first node to connect
  95078. * @param outputAudioNode defines second node to connect
  95079. */
  95080. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  95081. /**
  95082. * Releases all associated resources
  95083. */
  95084. dispose(): void;
  95085. }
  95086. }
  95087. declare module BABYLON {
  95088. /**
  95089. * This represents an audio engine and it is responsible
  95090. * to play, synchronize and analyse sounds throughout the application.
  95091. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95092. */
  95093. export interface IAudioEngine extends IDisposable {
  95094. /**
  95095. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  95096. */
  95097. readonly canUseWebAudio: boolean;
  95098. /**
  95099. * Gets the current AudioContext if available.
  95100. */
  95101. readonly audioContext: Nullable<AudioContext>;
  95102. /**
  95103. * The master gain node defines the global audio volume of your audio engine.
  95104. */
  95105. readonly masterGain: GainNode;
  95106. /**
  95107. * Gets whether or not mp3 are supported by your browser.
  95108. */
  95109. readonly isMP3supported: boolean;
  95110. /**
  95111. * Gets whether or not ogg are supported by your browser.
  95112. */
  95113. readonly isOGGsupported: boolean;
  95114. /**
  95115. * Defines if Babylon should emit a warning if WebAudio is not supported.
  95116. * @ignoreNaming
  95117. */
  95118. WarnedWebAudioUnsupported: boolean;
  95119. /**
  95120. * Defines if the audio engine relies on a custom unlocked button.
  95121. * In this case, the embedded button will not be displayed.
  95122. */
  95123. useCustomUnlockedButton: boolean;
  95124. /**
  95125. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  95126. */
  95127. readonly unlocked: boolean;
  95128. /**
  95129. * Event raised when audio has been unlocked on the browser.
  95130. */
  95131. onAudioUnlockedObservable: Observable<AudioEngine>;
  95132. /**
  95133. * Event raised when audio has been locked on the browser.
  95134. */
  95135. onAudioLockedObservable: Observable<AudioEngine>;
  95136. /**
  95137. * Flags the audio engine in Locked state.
  95138. * This happens due to new browser policies preventing audio to autoplay.
  95139. */
  95140. lock(): void;
  95141. /**
  95142. * Unlocks the audio engine once a user action has been done on the dom.
  95143. * This is helpful to resume play once browser policies have been satisfied.
  95144. */
  95145. unlock(): void;
  95146. }
  95147. /**
  95148. * This represents the default audio engine used in babylon.
  95149. * It is responsible to play, synchronize and analyse sounds throughout the application.
  95150. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95151. */
  95152. export class AudioEngine implements IAudioEngine {
  95153. private _audioContext;
  95154. private _audioContextInitialized;
  95155. private _muteButton;
  95156. private _hostElement;
  95157. /**
  95158. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  95159. */
  95160. canUseWebAudio: boolean;
  95161. /**
  95162. * The master gain node defines the global audio volume of your audio engine.
  95163. */
  95164. masterGain: GainNode;
  95165. /**
  95166. * Defines if Babylon should emit a warning if WebAudio is not supported.
  95167. * @ignoreNaming
  95168. */
  95169. WarnedWebAudioUnsupported: boolean;
  95170. /**
  95171. * Gets whether or not mp3 are supported by your browser.
  95172. */
  95173. isMP3supported: boolean;
  95174. /**
  95175. * Gets whether or not ogg are supported by your browser.
  95176. */
  95177. isOGGsupported: boolean;
  95178. /**
  95179. * Gets whether audio has been unlocked on the device.
  95180. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  95181. * a user interaction has happened.
  95182. */
  95183. unlocked: boolean;
  95184. /**
  95185. * Defines if the audio engine relies on a custom unlocked button.
  95186. * In this case, the embedded button will not be displayed.
  95187. */
  95188. useCustomUnlockedButton: boolean;
  95189. /**
  95190. * Event raised when audio has been unlocked on the browser.
  95191. */
  95192. onAudioUnlockedObservable: Observable<AudioEngine>;
  95193. /**
  95194. * Event raised when audio has been locked on the browser.
  95195. */
  95196. onAudioLockedObservable: Observable<AudioEngine>;
  95197. /**
  95198. * Gets the current AudioContext if available.
  95199. */
  95200. readonly audioContext: Nullable<AudioContext>;
  95201. private _connectedAnalyser;
  95202. /**
  95203. * Instantiates a new audio engine.
  95204. *
  95205. * There should be only one per page as some browsers restrict the number
  95206. * of audio contexts you can create.
  95207. * @param hostElement defines the host element where to display the mute icon if necessary
  95208. */
  95209. constructor(hostElement?: Nullable<HTMLElement>);
  95210. /**
  95211. * Flags the audio engine in Locked state.
  95212. * This happens due to new browser policies preventing audio to autoplay.
  95213. */
  95214. lock(): void;
  95215. /**
  95216. * Unlocks the audio engine once a user action has been done on the dom.
  95217. * This is helpful to resume play once browser policies have been satisfied.
  95218. */
  95219. unlock(): void;
  95220. private _resumeAudioContext;
  95221. private _initializeAudioContext;
  95222. private _tryToRun;
  95223. private _triggerRunningState;
  95224. private _triggerSuspendedState;
  95225. private _displayMuteButton;
  95226. private _moveButtonToTopLeft;
  95227. private _onResize;
  95228. private _hideMuteButton;
  95229. /**
  95230. * Destroy and release the resources associated with the audio ccontext.
  95231. */
  95232. dispose(): void;
  95233. /**
  95234. * Gets the global volume sets on the master gain.
  95235. * @returns the global volume if set or -1 otherwise
  95236. */
  95237. getGlobalVolume(): number;
  95238. /**
  95239. * Sets the global volume of your experience (sets on the master gain).
  95240. * @param newVolume Defines the new global volume of the application
  95241. */
  95242. setGlobalVolume(newVolume: number): void;
  95243. /**
  95244. * Connect the audio engine to an audio analyser allowing some amazing
  95245. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  95246. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  95247. * @param analyser The analyser to connect to the engine
  95248. */
  95249. connectToAnalyser(analyser: Analyser): void;
  95250. }
  95251. }
  95252. declare module BABYLON {
  95253. /**
  95254. * Interface used to present a loading screen while loading a scene
  95255. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95256. */
  95257. export interface ILoadingScreen {
  95258. /**
  95259. * Function called to display the loading screen
  95260. */
  95261. displayLoadingUI: () => void;
  95262. /**
  95263. * Function called to hide the loading screen
  95264. */
  95265. hideLoadingUI: () => void;
  95266. /**
  95267. * Gets or sets the color to use for the background
  95268. */
  95269. loadingUIBackgroundColor: string;
  95270. /**
  95271. * Gets or sets the text to display while loading
  95272. */
  95273. loadingUIText: string;
  95274. }
  95275. /**
  95276. * Class used for the default loading screen
  95277. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95278. */
  95279. export class DefaultLoadingScreen implements ILoadingScreen {
  95280. private _renderingCanvas;
  95281. private _loadingText;
  95282. private _loadingDivBackgroundColor;
  95283. private _loadingDiv;
  95284. private _loadingTextDiv;
  95285. /** Gets or sets the logo url to use for the default loading screen */
  95286. static DefaultLogoUrl: string;
  95287. /** Gets or sets the spinner url to use for the default loading screen */
  95288. static DefaultSpinnerUrl: string;
  95289. /**
  95290. * Creates a new default loading screen
  95291. * @param _renderingCanvas defines the canvas used to render the scene
  95292. * @param _loadingText defines the default text to display
  95293. * @param _loadingDivBackgroundColor defines the default background color
  95294. */
  95295. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  95296. /**
  95297. * Function called to display the loading screen
  95298. */
  95299. displayLoadingUI(): void;
  95300. /**
  95301. * Function called to hide the loading screen
  95302. */
  95303. hideLoadingUI(): void;
  95304. /**
  95305. * Gets or sets the text to display while loading
  95306. */
  95307. loadingUIText: string;
  95308. /**
  95309. * Gets or sets the color to use for the background
  95310. */
  95311. loadingUIBackgroundColor: string;
  95312. private _resizeLoadingUI;
  95313. }
  95314. }
  95315. declare module BABYLON {
  95316. /** @hidden */
  95317. export class WebGLPipelineContext implements IPipelineContext {
  95318. engine: Engine;
  95319. program: Nullable<WebGLProgram>;
  95320. context?: WebGLRenderingContext;
  95321. vertexShader?: WebGLShader;
  95322. fragmentShader?: WebGLShader;
  95323. isParallelCompiled: boolean;
  95324. onCompiled?: () => void;
  95325. transformFeedback?: WebGLTransformFeedback | null;
  95326. readonly isAsync: boolean;
  95327. readonly isReady: boolean;
  95328. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  95329. }
  95330. }
  95331. declare module BABYLON {
  95332. /** @hidden */
  95333. export class WebGLDataBuffer extends DataBuffer {
  95334. private _buffer;
  95335. constructor(resource: WebGLBuffer);
  95336. readonly underlyingResource: any;
  95337. }
  95338. }
  95339. declare module BABYLON {
  95340. /** @hidden */
  95341. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95342. attributeProcessor(attribute: string): string;
  95343. varyingProcessor(varying: string, isFragment: boolean): string;
  95344. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95345. }
  95346. }
  95347. declare module BABYLON {
  95348. /**
  95349. * This class is used to track a performance counter which is number based.
  95350. * The user has access to many properties which give statistics of different nature.
  95351. *
  95352. * The implementer can track two kinds of Performance Counter: time and count.
  95353. * 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.
  95354. * 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.
  95355. */
  95356. export class PerfCounter {
  95357. /**
  95358. * Gets or sets a global boolean to turn on and off all the counters
  95359. */
  95360. static Enabled: boolean;
  95361. /**
  95362. * Returns the smallest value ever
  95363. */
  95364. readonly min: number;
  95365. /**
  95366. * Returns the biggest value ever
  95367. */
  95368. readonly max: number;
  95369. /**
  95370. * Returns the average value since the performance counter is running
  95371. */
  95372. readonly average: number;
  95373. /**
  95374. * Returns the average value of the last second the counter was monitored
  95375. */
  95376. readonly lastSecAverage: number;
  95377. /**
  95378. * Returns the current value
  95379. */
  95380. readonly current: number;
  95381. /**
  95382. * Gets the accumulated total
  95383. */
  95384. readonly total: number;
  95385. /**
  95386. * Gets the total value count
  95387. */
  95388. readonly count: number;
  95389. /**
  95390. * Creates a new counter
  95391. */
  95392. constructor();
  95393. /**
  95394. * Call this method to start monitoring a new frame.
  95395. * 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.
  95396. */
  95397. fetchNewFrame(): void;
  95398. /**
  95399. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  95400. * @param newCount the count value to add to the monitored count
  95401. * @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.
  95402. */
  95403. addCount(newCount: number, fetchResult: boolean): void;
  95404. /**
  95405. * Start monitoring this performance counter
  95406. */
  95407. beginMonitoring(): void;
  95408. /**
  95409. * Compute the time lapsed since the previous beginMonitoring() call.
  95410. * @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
  95411. */
  95412. endMonitoring(newFrame?: boolean): void;
  95413. private _fetchResult;
  95414. private _startMonitoringTime;
  95415. private _min;
  95416. private _max;
  95417. private _average;
  95418. private _current;
  95419. private _totalValueCount;
  95420. private _totalAccumulated;
  95421. private _lastSecAverage;
  95422. private _lastSecAccumulated;
  95423. private _lastSecTime;
  95424. private _lastSecValueCount;
  95425. }
  95426. }
  95427. declare module BABYLON {
  95428. /**
  95429. * Interface for any object that can request an animation frame
  95430. */
  95431. export interface ICustomAnimationFrameRequester {
  95432. /**
  95433. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  95434. */
  95435. renderFunction?: Function;
  95436. /**
  95437. * Called to request the next frame to render to
  95438. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  95439. */
  95440. requestAnimationFrame: Function;
  95441. /**
  95442. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  95443. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  95444. */
  95445. requestID?: number;
  95446. }
  95447. }
  95448. declare module BABYLON {
  95449. /**
  95450. * Settings for finer control over video usage
  95451. */
  95452. export interface VideoTextureSettings {
  95453. /**
  95454. * Applies `autoplay` to video, if specified
  95455. */
  95456. autoPlay?: boolean;
  95457. /**
  95458. * Applies `loop` to video, if specified
  95459. */
  95460. loop?: boolean;
  95461. /**
  95462. * Automatically updates internal texture from video at every frame in the render loop
  95463. */
  95464. autoUpdateTexture: boolean;
  95465. /**
  95466. * Image src displayed during the video loading or until the user interacts with the video.
  95467. */
  95468. poster?: string;
  95469. }
  95470. /**
  95471. * If you want to display a video in your scene, this is the special texture for that.
  95472. * This special texture works similar to other textures, with the exception of a few parameters.
  95473. * @see https://doc.babylonjs.com/how_to/video_texture
  95474. */
  95475. export class VideoTexture extends Texture {
  95476. /**
  95477. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95478. */
  95479. readonly autoUpdateTexture: boolean;
  95480. /**
  95481. * The video instance used by the texture internally
  95482. */
  95483. readonly video: HTMLVideoElement;
  95484. private _onUserActionRequestedObservable;
  95485. /**
  95486. * Event triggerd when a dom action is required by the user to play the video.
  95487. * This happens due to recent changes in browser policies preventing video to auto start.
  95488. */
  95489. readonly onUserActionRequestedObservable: Observable<Texture>;
  95490. private _generateMipMaps;
  95491. private _engine;
  95492. private _stillImageCaptured;
  95493. private _displayingPosterTexture;
  95494. private _settings;
  95495. private _createInternalTextureOnEvent;
  95496. private _frameId;
  95497. /**
  95498. * Creates a video texture.
  95499. * If you want to display a video in your scene, this is the special texture for that.
  95500. * This special texture works similar to other textures, with the exception of a few parameters.
  95501. * @see https://doc.babylonjs.com/how_to/video_texture
  95502. * @param name optional name, will detect from video source, if not defined
  95503. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95504. * @param scene is obviously the current scene.
  95505. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95506. * @param invertY is false by default but can be used to invert video on Y axis
  95507. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95508. * @param settings allows finer control over video usage
  95509. */
  95510. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95511. private _getName;
  95512. private _getVideo;
  95513. private _createInternalTexture;
  95514. private reset;
  95515. /**
  95516. * @hidden Internal method to initiate `update`.
  95517. */
  95518. _rebuild(): void;
  95519. /**
  95520. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95521. */
  95522. update(): void;
  95523. /**
  95524. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95525. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95526. */
  95527. updateTexture(isVisible: boolean): void;
  95528. protected _updateInternalTexture: () => void;
  95529. /**
  95530. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95531. * @param url New url.
  95532. */
  95533. updateURL(url: string): void;
  95534. /**
  95535. * Dispose the texture and release its associated resources.
  95536. */
  95537. dispose(): void;
  95538. /**
  95539. * Creates a video texture straight from a stream.
  95540. * @param scene Define the scene the texture should be created in
  95541. * @param stream Define the stream the texture should be created from
  95542. * @returns The created video texture as a promise
  95543. */
  95544. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95545. /**
  95546. * Creates a video texture straight from your WebCam video feed.
  95547. * @param scene Define the scene the texture should be created in
  95548. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95549. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95550. * @returns The created video texture as a promise
  95551. */
  95552. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95553. minWidth: number;
  95554. maxWidth: number;
  95555. minHeight: number;
  95556. maxHeight: number;
  95557. deviceId: string;
  95558. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95559. /**
  95560. * Creates a video texture straight from your WebCam video feed.
  95561. * @param scene Define the scene the texture should be created in
  95562. * @param onReady Define a callback to triggered once the texture will be ready
  95563. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95564. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95565. */
  95566. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95567. minWidth: number;
  95568. maxWidth: number;
  95569. minHeight: number;
  95570. maxHeight: number;
  95571. deviceId: string;
  95572. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95573. }
  95574. }
  95575. declare module BABYLON {
  95576. /**
  95577. * Defines the interface used by objects containing a viewport (like a camera)
  95578. */
  95579. interface IViewportOwnerLike {
  95580. /**
  95581. * Gets or sets the viewport
  95582. */
  95583. viewport: IViewportLike;
  95584. }
  95585. /**
  95586. * Interface for attribute information associated with buffer instanciation
  95587. */
  95588. export class InstancingAttributeInfo {
  95589. /**
  95590. * Index/offset of the attribute in the vertex shader
  95591. */
  95592. index: number;
  95593. /**
  95594. * size of the attribute, 1, 2, 3 or 4
  95595. */
  95596. attributeSize: number;
  95597. /**
  95598. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95599. * default is FLOAT
  95600. */
  95601. attribyteType: number;
  95602. /**
  95603. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95604. */
  95605. normalized: boolean;
  95606. /**
  95607. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95608. */
  95609. offset: number;
  95610. /**
  95611. * Name of the GLSL attribute, for debugging purpose only
  95612. */
  95613. attributeName: string;
  95614. }
  95615. /**
  95616. * Define options used to create a depth texture
  95617. */
  95618. export class DepthTextureCreationOptions {
  95619. /** Specifies whether or not a stencil should be allocated in the texture */
  95620. generateStencil?: boolean;
  95621. /** Specifies whether or not bilinear filtering is enable on the texture */
  95622. bilinearFiltering?: boolean;
  95623. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  95624. comparisonFunction?: number;
  95625. /** Specifies if the created texture is a cube texture */
  95626. isCube?: boolean;
  95627. }
  95628. /**
  95629. * Class used to describe the capabilities of the engine relatively to the current browser
  95630. */
  95631. export class EngineCapabilities {
  95632. /** Maximum textures units per fragment shader */
  95633. maxTexturesImageUnits: number;
  95634. /** Maximum texture units per vertex shader */
  95635. maxVertexTextureImageUnits: number;
  95636. /** Maximum textures units in the entire pipeline */
  95637. maxCombinedTexturesImageUnits: number;
  95638. /** Maximum texture size */
  95639. maxTextureSize: number;
  95640. /** Maximum cube texture size */
  95641. maxCubemapTextureSize: number;
  95642. /** Maximum render texture size */
  95643. maxRenderTextureSize: number;
  95644. /** Maximum number of vertex attributes */
  95645. maxVertexAttribs: number;
  95646. /** Maximum number of varyings */
  95647. maxVaryingVectors: number;
  95648. /** Maximum number of uniforms per vertex shader */
  95649. maxVertexUniformVectors: number;
  95650. /** Maximum number of uniforms per fragment shader */
  95651. maxFragmentUniformVectors: number;
  95652. /** Defines if standard derivates (dx/dy) are supported */
  95653. standardDerivatives: boolean;
  95654. /** Defines if s3tc texture compression is supported */
  95655. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95656. /** Defines if pvrtc texture compression is supported */
  95657. pvrtc: any;
  95658. /** Defines if etc1 texture compression is supported */
  95659. etc1: any;
  95660. /** Defines if etc2 texture compression is supported */
  95661. etc2: any;
  95662. /** Defines if astc texture compression is supported */
  95663. astc: any;
  95664. /** Defines if float textures are supported */
  95665. textureFloat: boolean;
  95666. /** Defines if vertex array objects are supported */
  95667. vertexArrayObject: boolean;
  95668. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95669. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95670. /** Gets the maximum level of anisotropy supported */
  95671. maxAnisotropy: number;
  95672. /** Defines if instancing is supported */
  95673. instancedArrays: boolean;
  95674. /** Defines if 32 bits indices are supported */
  95675. uintIndices: boolean;
  95676. /** Defines if high precision shaders are supported */
  95677. highPrecisionShaderSupported: boolean;
  95678. /** Defines if depth reading in the fragment shader is supported */
  95679. fragmentDepthSupported: boolean;
  95680. /** Defines if float texture linear filtering is supported*/
  95681. textureFloatLinearFiltering: boolean;
  95682. /** Defines if rendering to float textures is supported */
  95683. textureFloatRender: boolean;
  95684. /** Defines if half float textures are supported*/
  95685. textureHalfFloat: boolean;
  95686. /** Defines if half float texture linear filtering is supported*/
  95687. textureHalfFloatLinearFiltering: boolean;
  95688. /** Defines if rendering to half float textures is supported */
  95689. textureHalfFloatRender: boolean;
  95690. /** Defines if textureLOD shader command is supported */
  95691. textureLOD: boolean;
  95692. /** Defines if draw buffers extension is supported */
  95693. drawBuffersExtension: boolean;
  95694. /** Defines if depth textures are supported */
  95695. depthTextureExtension: boolean;
  95696. /** Defines if float color buffer are supported */
  95697. colorBufferFloat: boolean;
  95698. /** Gets disjoint timer query extension (null if not supported) */
  95699. timerQuery: EXT_disjoint_timer_query;
  95700. /** Defines if timestamp can be used with timer query */
  95701. canUseTimestampForTimerQuery: boolean;
  95702. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95703. multiview: any;
  95704. /** Function used to let the system compiles shaders in background */
  95705. parallelShaderCompile: {
  95706. COMPLETION_STATUS_KHR: number;
  95707. };
  95708. /** Max number of texture samples for MSAA */
  95709. maxMSAASamples: number;
  95710. /** Defines if the blend min max extension is supported */
  95711. blendMinMax: boolean;
  95712. }
  95713. /** Interface defining initialization parameters for Engine class */
  95714. export interface EngineOptions extends WebGLContextAttributes {
  95715. /**
  95716. * Defines if the engine should no exceed a specified device ratio
  95717. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95718. */
  95719. limitDeviceRatio?: number;
  95720. /**
  95721. * Defines if webvr should be enabled automatically
  95722. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95723. */
  95724. autoEnableWebVR?: boolean;
  95725. /**
  95726. * Defines if webgl2 should be turned off even if supported
  95727. * @see http://doc.babylonjs.com/features/webgl2
  95728. */
  95729. disableWebGL2Support?: boolean;
  95730. /**
  95731. * Defines if webaudio should be initialized as well
  95732. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95733. */
  95734. audioEngine?: boolean;
  95735. /**
  95736. * Defines if animations should run using a deterministic lock step
  95737. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95738. */
  95739. deterministicLockstep?: boolean;
  95740. /** Defines the maximum steps to use with deterministic lock step mode */
  95741. lockstepMaxSteps?: number;
  95742. /**
  95743. * Defines that engine should ignore context lost events
  95744. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95745. */
  95746. doNotHandleContextLost?: boolean;
  95747. /**
  95748. * Defines that engine should ignore modifying touch action attribute and style
  95749. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95750. */
  95751. doNotHandleTouchAction?: boolean;
  95752. /**
  95753. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95754. */
  95755. useHighPrecisionFloats?: boolean;
  95756. }
  95757. /**
  95758. * Defines the interface used by display changed events
  95759. */
  95760. export interface IDisplayChangedEventArgs {
  95761. /** Gets the vrDisplay object (if any) */
  95762. vrDisplay: Nullable<any>;
  95763. /** Gets a boolean indicating if webVR is supported */
  95764. vrSupported: boolean;
  95765. }
  95766. /**
  95767. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  95768. */
  95769. export class Engine {
  95770. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95771. static ExceptionList: ({
  95772. key: string;
  95773. capture: string;
  95774. captureConstraint: number;
  95775. targets: string[];
  95776. } | {
  95777. key: string;
  95778. capture: null;
  95779. captureConstraint: null;
  95780. targets: string[];
  95781. })[];
  95782. /** Gets the list of created engines */
  95783. static readonly Instances: Engine[];
  95784. /**
  95785. * Gets the latest created engine
  95786. */
  95787. static readonly LastCreatedEngine: Nullable<Engine>;
  95788. /**
  95789. * Gets the latest created scene
  95790. */
  95791. static readonly LastCreatedScene: Nullable<Scene>;
  95792. /**
  95793. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  95794. * @param flag defines which part of the materials must be marked as dirty
  95795. * @param predicate defines a predicate used to filter which materials should be affected
  95796. */
  95797. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  95798. /** @hidden */
  95799. static _TextureLoaders: IInternalTextureLoader[];
  95800. /** Defines that alpha blending is disabled */
  95801. static readonly ALPHA_DISABLE: number;
  95802. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  95803. static readonly ALPHA_ADD: number;
  95804. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  95805. static readonly ALPHA_COMBINE: number;
  95806. /** Defines that alpha blending to DEST - SRC * DEST */
  95807. static readonly ALPHA_SUBTRACT: number;
  95808. /** Defines that alpha blending to SRC * DEST */
  95809. static readonly ALPHA_MULTIPLY: number;
  95810. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  95811. static readonly ALPHA_MAXIMIZED: number;
  95812. /** Defines that alpha blending to SRC + DEST */
  95813. static readonly ALPHA_ONEONE: number;
  95814. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  95815. static readonly ALPHA_PREMULTIPLIED: number;
  95816. /**
  95817. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  95818. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  95819. */
  95820. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  95821. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  95822. static readonly ALPHA_INTERPOLATE: number;
  95823. /**
  95824. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  95825. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  95826. */
  95827. static readonly ALPHA_SCREENMODE: number;
  95828. /** Defines that the ressource is not delayed*/
  95829. static readonly DELAYLOADSTATE_NONE: number;
  95830. /** Defines that the ressource was successfully delay loaded */
  95831. static readonly DELAYLOADSTATE_LOADED: number;
  95832. /** Defines that the ressource is currently delay loading */
  95833. static readonly DELAYLOADSTATE_LOADING: number;
  95834. /** Defines that the ressource is delayed and has not started loading */
  95835. static readonly DELAYLOADSTATE_NOTLOADED: number;
  95836. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  95837. static readonly NEVER: number;
  95838. /** 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 */
  95839. static readonly ALWAYS: number;
  95840. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  95841. static readonly LESS: number;
  95842. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  95843. static readonly EQUAL: number;
  95844. /** 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 */
  95845. static readonly LEQUAL: number;
  95846. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  95847. static readonly GREATER: number;
  95848. /** 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 */
  95849. static readonly GEQUAL: number;
  95850. /** 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 */
  95851. static readonly NOTEQUAL: number;
  95852. /** Passed to stencilOperation to specify that stencil value must be kept */
  95853. static readonly KEEP: number;
  95854. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95855. static readonly REPLACE: number;
  95856. /** Passed to stencilOperation to specify that stencil value must be incremented */
  95857. static readonly INCR: number;
  95858. /** Passed to stencilOperation to specify that stencil value must be decremented */
  95859. static readonly DECR: number;
  95860. /** Passed to stencilOperation to specify that stencil value must be inverted */
  95861. static readonly INVERT: number;
  95862. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  95863. static readonly INCR_WRAP: number;
  95864. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  95865. static readonly DECR_WRAP: number;
  95866. /** Texture is not repeating outside of 0..1 UVs */
  95867. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  95868. /** Texture is repeating outside of 0..1 UVs */
  95869. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  95870. /** Texture is repeating and mirrored */
  95871. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  95872. /** ALPHA */
  95873. static readonly TEXTUREFORMAT_ALPHA: number;
  95874. /** LUMINANCE */
  95875. static readonly TEXTUREFORMAT_LUMINANCE: number;
  95876. /** LUMINANCE_ALPHA */
  95877. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  95878. /** RGB */
  95879. static readonly TEXTUREFORMAT_RGB: number;
  95880. /** RGBA */
  95881. static readonly TEXTUREFORMAT_RGBA: number;
  95882. /** RED */
  95883. static readonly TEXTUREFORMAT_RED: number;
  95884. /** RED (2nd reference) */
  95885. static readonly TEXTUREFORMAT_R: number;
  95886. /** RG */
  95887. static readonly TEXTUREFORMAT_RG: number;
  95888. /** RED_INTEGER */
  95889. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  95890. /** RED_INTEGER (2nd reference) */
  95891. static readonly TEXTUREFORMAT_R_INTEGER: number;
  95892. /** RG_INTEGER */
  95893. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  95894. /** RGB_INTEGER */
  95895. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  95896. /** RGBA_INTEGER */
  95897. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  95898. /** UNSIGNED_BYTE */
  95899. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  95900. /** UNSIGNED_BYTE (2nd reference) */
  95901. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  95902. /** FLOAT */
  95903. static readonly TEXTURETYPE_FLOAT: number;
  95904. /** HALF_FLOAT */
  95905. static readonly TEXTURETYPE_HALF_FLOAT: number;
  95906. /** BYTE */
  95907. static readonly TEXTURETYPE_BYTE: number;
  95908. /** SHORT */
  95909. static readonly TEXTURETYPE_SHORT: number;
  95910. /** UNSIGNED_SHORT */
  95911. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  95912. /** INT */
  95913. static readonly TEXTURETYPE_INT: number;
  95914. /** UNSIGNED_INT */
  95915. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  95916. /** UNSIGNED_SHORT_4_4_4_4 */
  95917. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  95918. /** UNSIGNED_SHORT_5_5_5_1 */
  95919. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  95920. /** UNSIGNED_SHORT_5_6_5 */
  95921. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  95922. /** UNSIGNED_INT_2_10_10_10_REV */
  95923. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  95924. /** UNSIGNED_INT_24_8 */
  95925. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  95926. /** UNSIGNED_INT_10F_11F_11F_REV */
  95927. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  95928. /** UNSIGNED_INT_5_9_9_9_REV */
  95929. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  95930. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  95931. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  95932. /** nearest is mag = nearest and min = nearest and mip = linear */
  95933. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  95934. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95935. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  95936. /** Trilinear is mag = linear and min = linear and mip = linear */
  95937. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  95938. /** nearest is mag = nearest and min = nearest and mip = linear */
  95939. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  95940. /** Bilinear is mag = linear and min = linear and mip = nearest */
  95941. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  95942. /** Trilinear is mag = linear and min = linear and mip = linear */
  95943. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  95944. /** mag = nearest and min = nearest and mip = nearest */
  95945. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  95946. /** mag = nearest and min = linear and mip = nearest */
  95947. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  95948. /** mag = nearest and min = linear and mip = linear */
  95949. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  95950. /** mag = nearest and min = linear and mip = none */
  95951. static readonly TEXTURE_NEAREST_LINEAR: number;
  95952. /** mag = nearest and min = nearest and mip = none */
  95953. static readonly TEXTURE_NEAREST_NEAREST: number;
  95954. /** mag = linear and min = nearest and mip = nearest */
  95955. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  95956. /** mag = linear and min = nearest and mip = linear */
  95957. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  95958. /** mag = linear and min = linear and mip = none */
  95959. static readonly TEXTURE_LINEAR_LINEAR: number;
  95960. /** mag = linear and min = nearest and mip = none */
  95961. static readonly TEXTURE_LINEAR_NEAREST: number;
  95962. /** Explicit coordinates mode */
  95963. static readonly TEXTURE_EXPLICIT_MODE: number;
  95964. /** Spherical coordinates mode */
  95965. static readonly TEXTURE_SPHERICAL_MODE: number;
  95966. /** Planar coordinates mode */
  95967. static readonly TEXTURE_PLANAR_MODE: number;
  95968. /** Cubic coordinates mode */
  95969. static readonly TEXTURE_CUBIC_MODE: number;
  95970. /** Projection coordinates mode */
  95971. static readonly TEXTURE_PROJECTION_MODE: number;
  95972. /** Skybox coordinates mode */
  95973. static readonly TEXTURE_SKYBOX_MODE: number;
  95974. /** Inverse Cubic coordinates mode */
  95975. static readonly TEXTURE_INVCUBIC_MODE: number;
  95976. /** Equirectangular coordinates mode */
  95977. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  95978. /** Equirectangular Fixed coordinates mode */
  95979. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  95980. /** Equirectangular Fixed Mirrored coordinates mode */
  95981. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  95982. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  95983. static readonly SCALEMODE_FLOOR: number;
  95984. /** Defines that texture rescaling will look for the nearest power of 2 size */
  95985. static readonly SCALEMODE_NEAREST: number;
  95986. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  95987. static readonly SCALEMODE_CEILING: number;
  95988. /**
  95989. * Returns the current npm package of the sdk
  95990. */
  95991. static readonly NpmPackage: string;
  95992. /**
  95993. * Returns the current version of the framework
  95994. */
  95995. static readonly Version: string;
  95996. /**
  95997. * Returns a string describing the current engine
  95998. */
  95999. readonly description: string;
  96000. /**
  96001. * Gets or sets the epsilon value used by collision engine
  96002. */
  96003. static CollisionsEpsilon: number;
  96004. /**
  96005. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  96006. */
  96007. static ShadersRepository: string;
  96008. /**
  96009. * Method called to create the default loading screen.
  96010. * This can be overriden in your own app.
  96011. * @param canvas The rendering canvas element
  96012. * @returns The loading screen
  96013. */
  96014. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  96015. /**
  96016. * Method called to create the default rescale post process on each engine.
  96017. */
  96018. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  96019. /** @hidden */
  96020. _shaderProcessor: IShaderProcessor;
  96021. /**
  96022. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  96023. */
  96024. forcePOTTextures: boolean;
  96025. /**
  96026. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  96027. */
  96028. isFullscreen: boolean;
  96029. /**
  96030. * Gets a boolean indicating if the pointer is currently locked
  96031. */
  96032. isPointerLock: boolean;
  96033. /**
  96034. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  96035. */
  96036. cullBackFaces: boolean;
  96037. /**
  96038. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  96039. */
  96040. renderEvenInBackground: boolean;
  96041. /**
  96042. * Gets or sets a boolean indicating that cache can be kept between frames
  96043. */
  96044. preventCacheWipeBetweenFrames: boolean;
  96045. /**
  96046. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  96047. **/
  96048. enableOfflineSupport: boolean;
  96049. /**
  96050. * 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)
  96051. **/
  96052. disableManifestCheck: boolean;
  96053. /**
  96054. * Gets the list of created scenes
  96055. */
  96056. scenes: Scene[];
  96057. /**
  96058. * Event raised when a new scene is created
  96059. */
  96060. onNewSceneAddedObservable: Observable<Scene>;
  96061. /**
  96062. * Gets the list of created postprocesses
  96063. */
  96064. postProcesses: PostProcess[];
  96065. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  96066. validateShaderPrograms: boolean;
  96067. /**
  96068. * Observable event triggered each time the rendering canvas is resized
  96069. */
  96070. onResizeObservable: Observable<Engine>;
  96071. /**
  96072. * Observable event triggered each time the canvas loses focus
  96073. */
  96074. onCanvasBlurObservable: Observable<Engine>;
  96075. /**
  96076. * Observable event triggered each time the canvas gains focus
  96077. */
  96078. onCanvasFocusObservable: Observable<Engine>;
  96079. /**
  96080. * Observable event triggered each time the canvas receives pointerout event
  96081. */
  96082. onCanvasPointerOutObservable: Observable<PointerEvent>;
  96083. /**
  96084. * Observable event triggered before each texture is initialized
  96085. */
  96086. onBeforeTextureInitObservable: Observable<Texture>;
  96087. /**
  96088. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  96089. */
  96090. disableUniformBuffers: boolean;
  96091. /** @hidden */
  96092. _uniformBuffers: UniformBuffer[];
  96093. /**
  96094. * Gets a boolean indicating that the engine supports uniform buffers
  96095. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96096. */
  96097. readonly supportsUniformBuffers: boolean;
  96098. /**
  96099. * Observable raised when the engine begins a new frame
  96100. */
  96101. onBeginFrameObservable: Observable<Engine>;
  96102. /**
  96103. * If set, will be used to request the next animation frame for the render loop
  96104. */
  96105. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  96106. /**
  96107. * Observable raised when the engine ends the current frame
  96108. */
  96109. onEndFrameObservable: Observable<Engine>;
  96110. /**
  96111. * Observable raised when the engine is about to compile a shader
  96112. */
  96113. onBeforeShaderCompilationObservable: Observable<Engine>;
  96114. /**
  96115. * Observable raised when the engine has jsut compiled a shader
  96116. */
  96117. onAfterShaderCompilationObservable: Observable<Engine>;
  96118. /** @hidden */
  96119. _gl: WebGLRenderingContext;
  96120. private _renderingCanvas;
  96121. private _windowIsBackground;
  96122. protected _webGLVersion: number;
  96123. protected _highPrecisionShadersAllowed: boolean;
  96124. /** @hidden */
  96125. readonly _shouldUseHighPrecisionShader: boolean;
  96126. /**
  96127. * Gets a boolean indicating that only power of 2 textures are supported
  96128. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  96129. */
  96130. readonly needPOTTextures: boolean;
  96131. /** @hidden */
  96132. _badOS: boolean;
  96133. /** @hidden */
  96134. _badDesktopOS: boolean;
  96135. /**
  96136. * Gets the audio engine
  96137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96138. * @ignorenaming
  96139. */
  96140. static audioEngine: IAudioEngine;
  96141. /**
  96142. * Default AudioEngine factory responsible of creating the Audio Engine.
  96143. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  96144. */
  96145. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  96146. /**
  96147. * Default offline support factory responsible of creating a tool used to store data locally.
  96148. * By default, this will create a Database object if the workload has been embedded.
  96149. */
  96150. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  96151. private _onFocus;
  96152. private _onBlur;
  96153. private _onCanvasPointerOut;
  96154. private _onCanvasBlur;
  96155. private _onCanvasFocus;
  96156. private _onFullscreenChange;
  96157. private _onPointerLockChange;
  96158. private _hardwareScalingLevel;
  96159. /** @hidden */
  96160. _caps: EngineCapabilities;
  96161. private _pointerLockRequested;
  96162. private _isStencilEnable;
  96163. protected _colorWrite: boolean;
  96164. private _loadingScreen;
  96165. /** @hidden */
  96166. _drawCalls: PerfCounter;
  96167. private _glVersion;
  96168. private _glRenderer;
  96169. private _glVendor;
  96170. private _videoTextureSupported;
  96171. private _renderingQueueLaunched;
  96172. private _activeRenderLoops;
  96173. private _deterministicLockstep;
  96174. private _lockstepMaxSteps;
  96175. /**
  96176. * Observable signaled when a context lost event is raised
  96177. */
  96178. onContextLostObservable: Observable<Engine>;
  96179. /**
  96180. * Observable signaled when a context restored event is raised
  96181. */
  96182. onContextRestoredObservable: Observable<Engine>;
  96183. private _onContextLost;
  96184. private _onContextRestored;
  96185. private _contextWasLost;
  96186. /** @hidden */
  96187. _doNotHandleContextLost: boolean;
  96188. /**
  96189. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  96190. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  96191. */
  96192. doNotHandleContextLost: boolean;
  96193. private _performanceMonitor;
  96194. private _fps;
  96195. private _deltaTime;
  96196. /**
  96197. * Turn this value on if you want to pause FPS computation when in background
  96198. */
  96199. disablePerformanceMonitorInBackground: boolean;
  96200. /**
  96201. * Gets the performance monitor attached to this engine
  96202. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  96203. */
  96204. readonly performanceMonitor: PerformanceMonitor;
  96205. /**
  96206. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  96207. */
  96208. disableVertexArrayObjects: boolean;
  96209. /** @hidden */
  96210. protected _depthCullingState: _DepthCullingState;
  96211. /** @hidden */
  96212. protected _stencilState: _StencilState;
  96213. /** @hidden */
  96214. protected _alphaState: _AlphaState;
  96215. /** @hidden */
  96216. protected _alphaMode: number;
  96217. /** @hidden */
  96218. protected _alphaEquation: number;
  96219. /** @hidden */
  96220. _internalTexturesCache: InternalTexture[];
  96221. /** @hidden */
  96222. protected _activeChannel: number;
  96223. private _currentTextureChannel;
  96224. /** @hidden */
  96225. protected _boundTexturesCache: {
  96226. [key: string]: Nullable<InternalTexture>;
  96227. };
  96228. /** @hidden */
  96229. protected _currentEffect: Nullable<Effect>;
  96230. /** @hidden */
  96231. protected _currentProgram: Nullable<WebGLProgram>;
  96232. private _compiledEffects;
  96233. private _vertexAttribArraysEnabled;
  96234. /** @hidden */
  96235. protected _cachedViewport: Nullable<IViewportLike>;
  96236. private _cachedVertexArrayObject;
  96237. /** @hidden */
  96238. protected _cachedVertexBuffers: any;
  96239. /** @hidden */
  96240. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96241. /** @hidden */
  96242. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96243. /** @hidden */
  96244. _currentRenderTarget: Nullable<InternalTexture>;
  96245. private _uintIndicesCurrentlySet;
  96246. private _currentBoundBuffer;
  96247. /** @hidden */
  96248. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96249. private _currentBufferPointers;
  96250. private _currentInstanceLocations;
  96251. private _currentInstanceBuffers;
  96252. private _textureUnits;
  96253. /** @hidden */
  96254. _workingCanvas: Nullable<HTMLCanvasElement>;
  96255. /** @hidden */
  96256. _workingContext: Nullable<CanvasRenderingContext2D>;
  96257. private _rescalePostProcess;
  96258. private _dummyFramebuffer;
  96259. private _externalData;
  96260. /** @hidden */
  96261. _bindedRenderFunction: any;
  96262. private _vaoRecordInProgress;
  96263. private _mustWipeVertexAttributes;
  96264. private _emptyTexture;
  96265. private _emptyCubeTexture;
  96266. private _emptyTexture3D;
  96267. /** @hidden */
  96268. _frameHandler: number;
  96269. private _nextFreeTextureSlots;
  96270. private _maxSimultaneousTextures;
  96271. private _activeRequests;
  96272. private _texturesSupported;
  96273. /** @hidden */
  96274. _textureFormatInUse: Nullable<string>;
  96275. /**
  96276. * Gets the list of texture formats supported
  96277. */
  96278. readonly texturesSupported: Array<string>;
  96279. /**
  96280. * Gets the list of texture formats in use
  96281. */
  96282. readonly textureFormatInUse: Nullable<string>;
  96283. /**
  96284. * Gets the current viewport
  96285. */
  96286. readonly currentViewport: Nullable<IViewportLike>;
  96287. /**
  96288. * Gets the default empty texture
  96289. */
  96290. readonly emptyTexture: InternalTexture;
  96291. /**
  96292. * Gets the default empty 3D texture
  96293. */
  96294. readonly emptyTexture3D: InternalTexture;
  96295. /**
  96296. * Gets the default empty cube texture
  96297. */
  96298. readonly emptyCubeTexture: InternalTexture;
  96299. /**
  96300. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96301. */
  96302. readonly premultipliedAlpha: boolean;
  96303. /**
  96304. * Creates a new engine
  96305. * @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
  96306. * @param antialias defines enable antialiasing (default: false)
  96307. * @param options defines further options to be sent to the getContext() function
  96308. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96309. */
  96310. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96311. /**
  96312. * Initializes a webVR display and starts listening to display change events
  96313. * The onVRDisplayChangedObservable will be notified upon these changes
  96314. * @returns The onVRDisplayChangedObservable
  96315. */
  96316. initWebVR(): Observable<IDisplayChangedEventArgs>;
  96317. /** @hidden */
  96318. _prepareVRComponent(): void;
  96319. /** @hidden */
  96320. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  96321. /** @hidden */
  96322. _submitVRFrame(): void;
  96323. /**
  96324. * Call this function to leave webVR mode
  96325. * Will do nothing if webVR is not supported or if there is no webVR device
  96326. * @see http://doc.babylonjs.com/how_to/webvr_camera
  96327. */
  96328. disableVR(): void;
  96329. /**
  96330. * Gets a boolean indicating that the system is in VR mode and is presenting
  96331. * @returns true if VR mode is engaged
  96332. */
  96333. isVRPresenting(): boolean;
  96334. /** @hidden */
  96335. _requestVRFrame(): void;
  96336. private _disableTouchAction;
  96337. private _rebuildInternalTextures;
  96338. private _rebuildEffects;
  96339. /**
  96340. * Gets a boolean indicating if all created effects are ready
  96341. * @returns true if all effects are ready
  96342. */
  96343. areAllEffectsReady(): boolean;
  96344. private _rebuildBuffers;
  96345. private _initGLContext;
  96346. /**
  96347. * Gets version of the current webGL context
  96348. */
  96349. readonly webGLVersion: number;
  96350. /**
  96351. * Gets a string idenfifying the name of the class
  96352. * @returns "Engine" string
  96353. */
  96354. getClassName(): string;
  96355. /**
  96356. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96357. */
  96358. readonly isStencilEnable: boolean;
  96359. /** @hidden */
  96360. _prepareWorkingCanvas(): void;
  96361. /**
  96362. * Reset the texture cache to empty state
  96363. */
  96364. resetTextureCache(): void;
  96365. /**
  96366. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  96367. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96368. * @returns true if engine is in deterministic lock step mode
  96369. */
  96370. isDeterministicLockStep(): boolean;
  96371. /**
  96372. * Gets the max steps when engine is running in deterministic lock step
  96373. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96374. * @returns the max steps
  96375. */
  96376. getLockstepMaxSteps(): number;
  96377. /**
  96378. * Gets an object containing information about the current webGL context
  96379. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96380. */
  96381. getGlInfo(): {
  96382. vendor: string;
  96383. renderer: string;
  96384. version: string;
  96385. };
  96386. /**
  96387. * Gets current aspect ratio
  96388. * @param viewportOwner defines the camera to use to get the aspect ratio
  96389. * @param useScreen defines if screen size must be used (or the current render target if any)
  96390. * @returns a number defining the aspect ratio
  96391. */
  96392. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  96393. /**
  96394. * Gets current screen aspect ratio
  96395. * @returns a number defining the aspect ratio
  96396. */
  96397. getScreenAspectRatio(): number;
  96398. /**
  96399. * Gets the current render width
  96400. * @param useScreen defines if screen size must be used (or the current render target if any)
  96401. * @returns a number defining the current render width
  96402. */
  96403. getRenderWidth(useScreen?: boolean): number;
  96404. /**
  96405. * Gets the current render height
  96406. * @param useScreen defines if screen size must be used (or the current render target if any)
  96407. * @returns a number defining the current render height
  96408. */
  96409. getRenderHeight(useScreen?: boolean): number;
  96410. /**
  96411. * Gets the HTML canvas attached with the current webGL context
  96412. * @returns a HTML canvas
  96413. */
  96414. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96415. /**
  96416. * Gets host window
  96417. * @returns the host window object
  96418. */
  96419. getHostWindow(): Window;
  96420. /**
  96421. * Gets host document
  96422. * @returns the host document object
  96423. */
  96424. getHostDocument(): Document;
  96425. /**
  96426. * Gets the client rect of the HTML canvas attached with the current webGL context
  96427. * @returns a client rectanglee
  96428. */
  96429. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  96430. /**
  96431. * Defines the hardware scaling level.
  96432. * By default the hardware scaling level is computed from the window device ratio.
  96433. * 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.
  96434. * @param level defines the level to use
  96435. */
  96436. setHardwareScalingLevel(level: number): void;
  96437. /**
  96438. * Gets the current hardware scaling level.
  96439. * By default the hardware scaling level is computed from the window device ratio.
  96440. * 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.
  96441. * @returns a number indicating the current hardware scaling level
  96442. */
  96443. getHardwareScalingLevel(): number;
  96444. /**
  96445. * Gets the list of loaded textures
  96446. * @returns an array containing all loaded textures
  96447. */
  96448. getLoadedTexturesCache(): InternalTexture[];
  96449. /**
  96450. * Gets the object containing all engine capabilities
  96451. * @returns the EngineCapabilities object
  96452. */
  96453. getCaps(): EngineCapabilities;
  96454. /**
  96455. * Gets the current depth function
  96456. * @returns a number defining the depth function
  96457. */
  96458. getDepthFunction(): Nullable<number>;
  96459. /**
  96460. * Sets the current depth function
  96461. * @param depthFunc defines the function to use
  96462. */
  96463. setDepthFunction(depthFunc: number): void;
  96464. /**
  96465. * Sets the current depth function to GREATER
  96466. */
  96467. setDepthFunctionToGreater(): void;
  96468. /**
  96469. * Sets the current depth function to GEQUAL
  96470. */
  96471. setDepthFunctionToGreaterOrEqual(): void;
  96472. /**
  96473. * Sets the current depth function to LESS
  96474. */
  96475. setDepthFunctionToLess(): void;
  96476. private _cachedStencilBuffer;
  96477. private _cachedStencilFunction;
  96478. private _cachedStencilMask;
  96479. private _cachedStencilOperationPass;
  96480. private _cachedStencilOperationFail;
  96481. private _cachedStencilOperationDepthFail;
  96482. private _cachedStencilReference;
  96483. /**
  96484. * Caches the the state of the stencil buffer
  96485. */
  96486. cacheStencilState(): void;
  96487. /**
  96488. * Restores the state of the stencil buffer
  96489. */
  96490. restoreStencilState(): void;
  96491. /**
  96492. * Sets the current depth function to LEQUAL
  96493. */
  96494. setDepthFunctionToLessOrEqual(): void;
  96495. /**
  96496. * Gets a boolean indicating if stencil buffer is enabled
  96497. * @returns the current stencil buffer state
  96498. */
  96499. getStencilBuffer(): boolean;
  96500. /**
  96501. * Enable or disable the stencil buffer
  96502. * @param enable defines if the stencil buffer must be enabled or disabled
  96503. */
  96504. setStencilBuffer(enable: boolean): void;
  96505. /**
  96506. * Gets the current stencil mask
  96507. * @returns a number defining the new stencil mask to use
  96508. */
  96509. getStencilMask(): number;
  96510. /**
  96511. * Sets the current stencil mask
  96512. * @param mask defines the new stencil mask to use
  96513. */
  96514. setStencilMask(mask: number): void;
  96515. /**
  96516. * Gets the current stencil function
  96517. * @returns a number defining the stencil function to use
  96518. */
  96519. getStencilFunction(): number;
  96520. /**
  96521. * Gets the current stencil reference value
  96522. * @returns a number defining the stencil reference value to use
  96523. */
  96524. getStencilFunctionReference(): number;
  96525. /**
  96526. * Gets the current stencil mask
  96527. * @returns a number defining the stencil mask to use
  96528. */
  96529. getStencilFunctionMask(): number;
  96530. /**
  96531. * Sets the current stencil function
  96532. * @param stencilFunc defines the new stencil function to use
  96533. */
  96534. setStencilFunction(stencilFunc: number): void;
  96535. /**
  96536. * Sets the current stencil reference
  96537. * @param reference defines the new stencil reference to use
  96538. */
  96539. setStencilFunctionReference(reference: number): void;
  96540. /**
  96541. * Sets the current stencil mask
  96542. * @param mask defines the new stencil mask to use
  96543. */
  96544. setStencilFunctionMask(mask: number): void;
  96545. /**
  96546. * Gets the current stencil operation when stencil fails
  96547. * @returns a number defining stencil operation to use when stencil fails
  96548. */
  96549. getStencilOperationFail(): number;
  96550. /**
  96551. * Gets the current stencil operation when depth fails
  96552. * @returns a number defining stencil operation to use when depth fails
  96553. */
  96554. getStencilOperationDepthFail(): number;
  96555. /**
  96556. * Gets the current stencil operation when stencil passes
  96557. * @returns a number defining stencil operation to use when stencil passes
  96558. */
  96559. getStencilOperationPass(): number;
  96560. /**
  96561. * Sets the stencil operation to use when stencil fails
  96562. * @param operation defines the stencil operation to use when stencil fails
  96563. */
  96564. setStencilOperationFail(operation: number): void;
  96565. /**
  96566. * Sets the stencil operation to use when depth fails
  96567. * @param operation defines the stencil operation to use when depth fails
  96568. */
  96569. setStencilOperationDepthFail(operation: number): void;
  96570. /**
  96571. * Sets the stencil operation to use when stencil passes
  96572. * @param operation defines the stencil operation to use when stencil passes
  96573. */
  96574. setStencilOperationPass(operation: number): void;
  96575. /**
  96576. * Sets a boolean indicating if the dithering state is enabled or disabled
  96577. * @param value defines the dithering state
  96578. */
  96579. setDitheringState(value: boolean): void;
  96580. /**
  96581. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  96582. * @param value defines the rasterizer state
  96583. */
  96584. setRasterizerState(value: boolean): void;
  96585. /**
  96586. * stop executing a render loop function and remove it from the execution array
  96587. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96588. */
  96589. stopRenderLoop(renderFunction?: () => void): void;
  96590. /** @hidden */
  96591. _renderLoop(): void;
  96592. /**
  96593. * Can be used to override the current requestAnimationFrame requester.
  96594. * @hidden
  96595. */
  96596. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96597. /**
  96598. * Register and execute a render loop. The engine can have more than one render function
  96599. * @param renderFunction defines the function to continuously execute
  96600. */
  96601. runRenderLoop(renderFunction: () => void): void;
  96602. /**
  96603. * Toggle full screen mode
  96604. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96605. */
  96606. switchFullscreen(requestPointerLock: boolean): void;
  96607. /**
  96608. * Enters full screen mode
  96609. * @param requestPointerLock defines if a pointer lock should be requested from the user
  96610. */
  96611. enterFullscreen(requestPointerLock: boolean): void;
  96612. /**
  96613. * Exits full screen mode
  96614. */
  96615. exitFullscreen(): void;
  96616. /**
  96617. * Enters Pointerlock mode
  96618. */
  96619. enterPointerlock(): void;
  96620. /**
  96621. * Exits Pointerlock mode
  96622. */
  96623. exitPointerlock(): void;
  96624. /**
  96625. * Clear the current render buffer or the current render target (if any is set up)
  96626. * @param color defines the color to use
  96627. * @param backBuffer defines if the back buffer must be cleared
  96628. * @param depth defines if the depth buffer must be cleared
  96629. * @param stencil defines if the stencil buffer must be cleared
  96630. */
  96631. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96632. /**
  96633. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  96634. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96635. * @param y defines the y-coordinate of the corner of the clear rectangle
  96636. * @param width defines the width of the clear rectangle
  96637. * @param height defines the height of the clear rectangle
  96638. * @param clearColor defines the clear color
  96639. */
  96640. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  96641. /**
  96642. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  96643. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  96644. * @param y defines the y-coordinate of the corner of the clear rectangle
  96645. * @param width defines the width of the clear rectangle
  96646. * @param height defines the height of the clear rectangle
  96647. */
  96648. enableScissor(x: number, y: number, width: number, height: number): void;
  96649. /**
  96650. * Disable previously set scissor test rectangle
  96651. */
  96652. disableScissor(): void;
  96653. private _viewportCached;
  96654. /** @hidden */
  96655. _viewport(x: number, y: number, width: number, height: number): void;
  96656. /**
  96657. * Set the WebGL's viewport
  96658. * @param viewport defines the viewport element to be used
  96659. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96660. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96661. */
  96662. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96663. /**
  96664. * Directly set the WebGL Viewport
  96665. * @param x defines the x coordinate of the viewport (in screen space)
  96666. * @param y defines the y coordinate of the viewport (in screen space)
  96667. * @param width defines the width of the viewport (in screen space)
  96668. * @param height defines the height of the viewport (in screen space)
  96669. * @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
  96670. */
  96671. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  96672. /**
  96673. * Begin a new frame
  96674. */
  96675. beginFrame(): void;
  96676. /**
  96677. * Enf the current frame
  96678. */
  96679. endFrame(): void;
  96680. /**
  96681. * Resize the view according to the canvas' size
  96682. */
  96683. resize(): void;
  96684. /**
  96685. * Force a specific size of the canvas
  96686. * @param width defines the new canvas' width
  96687. * @param height defines the new canvas' height
  96688. */
  96689. setSize(width: number, height: number): void;
  96690. /**
  96691. * Binds the frame buffer to the specified texture.
  96692. * @param texture The texture to render to or null for the default canvas
  96693. * @param faceIndex The face of the texture to render to in case of cube texture
  96694. * @param requiredWidth The width of the target to render to
  96695. * @param requiredHeight The height of the target to render to
  96696. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96697. * @param depthStencilTexture The depth stencil texture to use to render
  96698. * @param lodLevel defines le lod level to bind to the frame buffer
  96699. */
  96700. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96701. /** @hidden */
  96702. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96703. /**
  96704. * Unbind the current render target texture from the webGL context
  96705. * @param texture defines the render target texture to unbind
  96706. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96707. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96708. */
  96709. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96710. /**
  96711. * Force the mipmap generation for the given render target texture
  96712. * @param texture defines the render target texture to use
  96713. */
  96714. generateMipMapsForCubemap(texture: InternalTexture): void;
  96715. /**
  96716. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96717. */
  96718. flushFramebuffer(): void;
  96719. /**
  96720. * Unbind the current render target and bind the default framebuffer
  96721. */
  96722. restoreDefaultFramebuffer(): void;
  96723. /**
  96724. * Create an uniform buffer
  96725. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96726. * @param elements defines the content of the uniform buffer
  96727. * @returns the webGL uniform buffer
  96728. */
  96729. createUniformBuffer(elements: FloatArray): DataBuffer;
  96730. /**
  96731. * Create a dynamic uniform buffer
  96732. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96733. * @param elements defines the content of the uniform buffer
  96734. * @returns the webGL uniform buffer
  96735. */
  96736. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  96737. /**
  96738. * Update an existing uniform buffer
  96739. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96740. * @param uniformBuffer defines the target uniform buffer
  96741. * @param elements defines the content to update
  96742. * @param offset defines the offset in the uniform buffer where update should start
  96743. * @param count defines the size of the data to update
  96744. */
  96745. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  96746. private _resetVertexBufferBinding;
  96747. /**
  96748. * Creates a vertex buffer
  96749. * @param data the data for the vertex buffer
  96750. * @returns the new WebGL static buffer
  96751. */
  96752. createVertexBuffer(data: DataArray): DataBuffer;
  96753. /**
  96754. * Creates a dynamic vertex buffer
  96755. * @param data the data for the dynamic vertex buffer
  96756. * @returns the new WebGL dynamic buffer
  96757. */
  96758. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96759. /**
  96760. * Update a dynamic index buffer
  96761. * @param indexBuffer defines the target index buffer
  96762. * @param indices defines the data to update
  96763. * @param offset defines the offset in the target index buffer where update should start
  96764. */
  96765. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  96766. /**
  96767. * Updates a dynamic vertex buffer.
  96768. * @param vertexBuffer the vertex buffer to update
  96769. * @param data the data used to update the vertex buffer
  96770. * @param byteOffset the byte offset of the data
  96771. * @param byteLength the byte length of the data
  96772. */
  96773. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96774. private _resetIndexBufferBinding;
  96775. /**
  96776. * Creates a new index buffer
  96777. * @param indices defines the content of the index buffer
  96778. * @param updatable defines if the index buffer must be updatable
  96779. * @returns a new webGL buffer
  96780. */
  96781. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96782. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96783. /**
  96784. * Bind a webGL buffer to the webGL context
  96785. * @param buffer defines the buffer to bind
  96786. */
  96787. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96788. /**
  96789. * Bind an uniform buffer to the current webGL context
  96790. * @param buffer defines the buffer to bind
  96791. */
  96792. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  96793. /**
  96794. * Bind a buffer to the current webGL context at a given location
  96795. * @param buffer defines the buffer to bind
  96796. * @param location defines the index where to bind the buffer
  96797. */
  96798. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  96799. /**
  96800. * Bind a specific block at a given index in a specific shader program
  96801. * @param pipelineContext defines the pipeline context to use
  96802. * @param blockName defines the block name
  96803. * @param index defines the index where to bind the block
  96804. */
  96805. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  96806. private bindIndexBuffer;
  96807. private bindBuffer;
  96808. /**
  96809. * update the bound buffer with the given data
  96810. * @param data defines the data to update
  96811. */
  96812. updateArrayBuffer(data: Float32Array): void;
  96813. private _vertexAttribPointer;
  96814. private _bindIndexBufferWithCache;
  96815. private _bindVertexBuffersAttributes;
  96816. /**
  96817. * Records a vertex array object
  96818. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96819. * @param vertexBuffers defines the list of vertex buffers to store
  96820. * @param indexBuffer defines the index buffer to store
  96821. * @param effect defines the effect to store
  96822. * @returns the new vertex array object
  96823. */
  96824. recordVertexArrayObject(vertexBuffers: {
  96825. [key: string]: VertexBuffer;
  96826. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96827. /**
  96828. * Bind a specific vertex array object
  96829. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96830. * @param vertexArrayObject defines the vertex array object to bind
  96831. * @param indexBuffer defines the index buffer to bind
  96832. */
  96833. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96834. /**
  96835. * Bind webGl buffers directly to the webGL context
  96836. * @param vertexBuffer defines the vertex buffer to bind
  96837. * @param indexBuffer defines the index buffer to bind
  96838. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96839. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96840. * @param effect defines the effect associated with the vertex buffer
  96841. */
  96842. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96843. private _unbindVertexArrayObject;
  96844. /**
  96845. * Bind a list of vertex buffers to the webGL context
  96846. * @param vertexBuffers defines the list of vertex buffers to bind
  96847. * @param indexBuffer defines the index buffer to bind
  96848. * @param effect defines the effect associated with the vertex buffers
  96849. */
  96850. bindBuffers(vertexBuffers: {
  96851. [key: string]: Nullable<VertexBuffer>;
  96852. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96853. /**
  96854. * Unbind all instance attributes
  96855. */
  96856. unbindInstanceAttributes(): void;
  96857. /**
  96858. * Release and free the memory of a vertex array object
  96859. * @param vao defines the vertex array object to delete
  96860. */
  96861. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96862. /** @hidden */
  96863. _releaseBuffer(buffer: DataBuffer): boolean;
  96864. protected _deleteBuffer(buffer: DataBuffer): void;
  96865. /**
  96866. * Creates a webGL buffer to use with instanciation
  96867. * @param capacity defines the size of the buffer
  96868. * @returns the webGL buffer
  96869. */
  96870. createInstancesBuffer(capacity: number): DataBuffer;
  96871. /**
  96872. * Delete a webGL buffer used with instanciation
  96873. * @param buffer defines the webGL buffer to delete
  96874. */
  96875. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96876. /**
  96877. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96878. * @param instancesBuffer defines the webGL buffer to update and bind
  96879. * @param data defines the data to store in the buffer
  96880. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96881. */
  96882. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96883. /**
  96884. * Apply all cached states (depth, culling, stencil and alpha)
  96885. */
  96886. applyStates(): void;
  96887. /**
  96888. * Send a draw order
  96889. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96890. * @param indexStart defines the starting index
  96891. * @param indexCount defines the number of index to draw
  96892. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96893. */
  96894. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96895. /**
  96896. * Draw a list of points
  96897. * @param verticesStart defines the index of first vertex to draw
  96898. * @param verticesCount defines the count of vertices to draw
  96899. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96900. */
  96901. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96902. /**
  96903. * Draw a list of unindexed primitives
  96904. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96905. * @param verticesStart defines the index of first vertex to draw
  96906. * @param verticesCount defines the count of vertices to draw
  96907. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96908. */
  96909. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96910. /**
  96911. * Draw a list of indexed primitives
  96912. * @param fillMode defines the primitive to use
  96913. * @param indexStart defines the starting index
  96914. * @param indexCount defines the number of index to draw
  96915. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96916. */
  96917. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96918. /**
  96919. * Draw a list of unindexed primitives
  96920. * @param fillMode defines the primitive to use
  96921. * @param verticesStart defines the index of first vertex to draw
  96922. * @param verticesCount defines the count of vertices to draw
  96923. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96924. */
  96925. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96926. private _drawMode;
  96927. /** @hidden */
  96928. _releaseEffect(effect: Effect): void;
  96929. /** @hidden */
  96930. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96931. /**
  96932. * Create a new effect (used to store vertex/fragment shaders)
  96933. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96934. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  96935. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96936. * @param samplers defines an array of string used to represent textures
  96937. * @param defines defines the string containing the defines to use to compile the shaders
  96938. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96939. * @param onCompiled defines a function to call when the effect creation is successful
  96940. * @param onError defines a function to call when the effect creation has failed
  96941. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96942. * @returns the new Effect
  96943. */
  96944. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  96945. protected static _concatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96946. private _compileShader;
  96947. private _compileRawShader;
  96948. /**
  96949. * Directly creates a webGL program
  96950. * @param pipelineContext defines the pipeline context to attach to
  96951. * @param vertexCode defines the vertex shader code to use
  96952. * @param fragmentCode defines the fragment shader code to use
  96953. * @param context defines the webGL context to use (if not set, the current one will be used)
  96954. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96955. * @returns the new webGL program
  96956. */
  96957. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96958. /**
  96959. * Creates a webGL program
  96960. * @param pipelineContext defines the pipeline context to attach to
  96961. * @param vertexCode defines the vertex shader code to use
  96962. * @param fragmentCode defines the fragment shader code to use
  96963. * @param defines defines the string containing the defines to use to compile the shaders
  96964. * @param context defines the webGL context to use (if not set, the current one will be used)
  96965. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96966. * @returns the new webGL program
  96967. */
  96968. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96969. /**
  96970. * Creates a new pipeline context
  96971. * @returns the new pipeline
  96972. */
  96973. createPipelineContext(): IPipelineContext;
  96974. private _createShaderProgram;
  96975. private _finalizePipelineContext;
  96976. /** @hidden */
  96977. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96978. /** @hidden */
  96979. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96980. /** @hidden */
  96981. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96982. /**
  96983. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96984. * @param pipelineContext defines the pipeline context to use
  96985. * @param uniformsNames defines the list of uniform names
  96986. * @returns an array of webGL uniform locations
  96987. */
  96988. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96989. /**
  96990. * Gets the lsit of active attributes for a given webGL program
  96991. * @param pipelineContext defines the pipeline context to use
  96992. * @param attributesNames defines the list of attribute names to get
  96993. * @returns an array of indices indicating the offset of each attribute
  96994. */
  96995. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96996. /**
  96997. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96998. * @param effect defines the effect to activate
  96999. */
  97000. enableEffect(effect: Nullable<Effect>): void;
  97001. /**
  97002. * Set the value of an uniform to an array of int32
  97003. * @param uniform defines the webGL uniform location where to store the value
  97004. * @param array defines the array of int32 to store
  97005. */
  97006. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97007. /**
  97008. * Set the value of an uniform to an array of int32 (stored as vec2)
  97009. * @param uniform defines the webGL uniform location where to store the value
  97010. * @param array defines the array of int32 to store
  97011. */
  97012. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97013. /**
  97014. * Set the value of an uniform to an array of int32 (stored as vec3)
  97015. * @param uniform defines the webGL uniform location where to store the value
  97016. * @param array defines the array of int32 to store
  97017. */
  97018. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97019. /**
  97020. * Set the value of an uniform to an array of int32 (stored as vec4)
  97021. * @param uniform defines the webGL uniform location where to store the value
  97022. * @param array defines the array of int32 to store
  97023. */
  97024. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  97025. /**
  97026. * Set the value of an uniform to an array of float32
  97027. * @param uniform defines the webGL uniform location where to store the value
  97028. * @param array defines the array of float32 to store
  97029. */
  97030. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97031. /**
  97032. * Set the value of an uniform to an array of float32 (stored as vec2)
  97033. * @param uniform defines the webGL uniform location where to store the value
  97034. * @param array defines the array of float32 to store
  97035. */
  97036. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97037. /**
  97038. * Set the value of an uniform to an array of float32 (stored as vec3)
  97039. * @param uniform defines the webGL uniform location where to store the value
  97040. * @param array defines the array of float32 to store
  97041. */
  97042. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97043. /**
  97044. * Set the value of an uniform to an array of float32 (stored as vec4)
  97045. * @param uniform defines the webGL uniform location where to store the value
  97046. * @param array defines the array of float32 to store
  97047. */
  97048. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  97049. /**
  97050. * Set the value of an uniform to an array of number
  97051. * @param uniform defines the webGL uniform location where to store the value
  97052. * @param array defines the array of number to store
  97053. */
  97054. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97055. /**
  97056. * Set the value of an uniform to an array of number (stored as vec2)
  97057. * @param uniform defines the webGL uniform location where to store the value
  97058. * @param array defines the array of number to store
  97059. */
  97060. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97061. /**
  97062. * Set the value of an uniform to an array of number (stored as vec3)
  97063. * @param uniform defines the webGL uniform location where to store the value
  97064. * @param array defines the array of number to store
  97065. */
  97066. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97067. /**
  97068. * Set the value of an uniform to an array of number (stored as vec4)
  97069. * @param uniform defines the webGL uniform location where to store the value
  97070. * @param array defines the array of number to store
  97071. */
  97072. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  97073. /**
  97074. * Set the value of an uniform to an array of float32 (stored as matrices)
  97075. * @param uniform defines the webGL uniform location where to store the value
  97076. * @param matrices defines the array of float32 to store
  97077. */
  97078. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  97079. /**
  97080. * Set the value of an uniform to a matrix (3x3)
  97081. * @param uniform defines the webGL uniform location where to store the value
  97082. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  97083. */
  97084. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97085. /**
  97086. * Set the value of an uniform to a matrix (2x2)
  97087. * @param uniform defines the webGL uniform location where to store the value
  97088. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  97089. */
  97090. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  97091. /**
  97092. * Set the value of an uniform to a number (int)
  97093. * @param uniform defines the webGL uniform location where to store the value
  97094. * @param value defines the int number to store
  97095. */
  97096. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97097. /**
  97098. * Set the value of an uniform to a number (float)
  97099. * @param uniform defines the webGL uniform location where to store the value
  97100. * @param value defines the float number to store
  97101. */
  97102. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  97103. /**
  97104. * Set the value of an uniform to a vec2
  97105. * @param uniform defines the webGL uniform location where to store the value
  97106. * @param x defines the 1st component of the value
  97107. * @param y defines the 2nd component of the value
  97108. */
  97109. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  97110. /**
  97111. * Set the value of an uniform to a vec3
  97112. * @param uniform defines the webGL uniform location where to store the value
  97113. * @param x defines the 1st component of the value
  97114. * @param y defines the 2nd component of the value
  97115. * @param z defines the 3rd component of the value
  97116. */
  97117. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  97118. /**
  97119. * Set the value of an uniform to a boolean
  97120. * @param uniform defines the webGL uniform location where to store the value
  97121. * @param bool defines the boolean to store
  97122. */
  97123. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  97124. /**
  97125. * Set the value of an uniform to a vec4
  97126. * @param uniform defines the webGL uniform location where to store the value
  97127. * @param x defines the 1st component of the value
  97128. * @param y defines the 2nd component of the value
  97129. * @param z defines the 3rd component of the value
  97130. * @param w defines the 4th component of the value
  97131. */
  97132. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  97133. /**
  97134. * Sets a Color4 on a uniform variable
  97135. * @param uniform defines the uniform location
  97136. * @param color4 defines the value to be set
  97137. */
  97138. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  97139. /**
  97140. * Set various states to the webGL context
  97141. * @param culling defines backface culling state
  97142. * @param zOffset defines the value to apply to zOffset (0 by default)
  97143. * @param force defines if states must be applied even if cache is up to date
  97144. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  97145. */
  97146. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  97147. /**
  97148. * Set the z offset to apply to current rendering
  97149. * @param value defines the offset to apply
  97150. */
  97151. setZOffset(value: number): void;
  97152. /**
  97153. * Gets the current value of the zOffset
  97154. * @returns the current zOffset state
  97155. */
  97156. getZOffset(): number;
  97157. /**
  97158. * Enable or disable depth buffering
  97159. * @param enable defines the state to set
  97160. */
  97161. setDepthBuffer(enable: boolean): void;
  97162. /**
  97163. * Gets a boolean indicating if depth writing is enabled
  97164. * @returns the current depth writing state
  97165. */
  97166. getDepthWrite(): boolean;
  97167. /**
  97168. * Enable or disable depth writing
  97169. * @param enable defines the state to set
  97170. */
  97171. setDepthWrite(enable: boolean): void;
  97172. /**
  97173. * Enable or disable color writing
  97174. * @param enable defines the state to set
  97175. */
  97176. setColorWrite(enable: boolean): void;
  97177. /**
  97178. * Gets a boolean indicating if color writing is enabled
  97179. * @returns the current color writing state
  97180. */
  97181. getColorWrite(): boolean;
  97182. /**
  97183. * Sets alpha constants used by some alpha blending modes
  97184. * @param r defines the red component
  97185. * @param g defines the green component
  97186. * @param b defines the blue component
  97187. * @param a defines the alpha component
  97188. */
  97189. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  97190. /**
  97191. * Sets the current alpha mode
  97192. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  97193. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  97194. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97195. */
  97196. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  97197. /**
  97198. * Gets the current alpha mode
  97199. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  97200. * @returns the current alpha mode
  97201. */
  97202. getAlphaMode(): number;
  97203. /**
  97204. * Sets the current alpha equation
  97205. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  97206. */
  97207. setAlphaEquation(equation: number): void;
  97208. /**
  97209. * Gets the current alpha equation.
  97210. * @returns the current alpha equation
  97211. */
  97212. getAlphaEquation(): number;
  97213. /**
  97214. * Clears the list of texture accessible through engine.
  97215. * This can help preventing texture load conflict due to name collision.
  97216. */
  97217. clearInternalTexturesCache(): void;
  97218. /**
  97219. * Force the entire cache to be cleared
  97220. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  97221. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  97222. */
  97223. wipeCaches(bruteForce?: boolean): void;
  97224. /**
  97225. * Set the compressed texture format to use, based on the formats you have, and the formats
  97226. * supported by the hardware / browser.
  97227. *
  97228. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  97229. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  97230. * to API arguments needed to compressed textures. This puts the burden on the container
  97231. * generator to house the arcane code for determining these for current & future formats.
  97232. *
  97233. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  97234. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  97235. *
  97236. * Note: The result of this call is not taken into account when a texture is base64.
  97237. *
  97238. * @param formatsAvailable defines the list of those format families you have created
  97239. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  97240. *
  97241. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  97242. * @returns The extension selected.
  97243. */
  97244. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  97245. /** @hidden */
  97246. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  97247. min: number;
  97248. mag: number;
  97249. };
  97250. /** @hidden */
  97251. _createTexture(): WebGLTexture;
  97252. /**
  97253. * Usually called from Texture.ts.
  97254. * Passed information to create a WebGLTexture
  97255. * @param urlArg defines a value which contains one of the following:
  97256. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  97257. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  97258. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  97259. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  97260. * @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)
  97261. * @param scene needed for loading to the correct scene
  97262. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  97263. * @param onLoad optional callback to be called upon successful completion
  97264. * @param onError optional callback to be called upon failure
  97265. * @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
  97266. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  97267. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  97268. * @param forcedExtension defines the extension to use to pick the right loader
  97269. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  97270. * @returns a InternalTexture for assignment back into BABYLON.Texture
  97271. */
  97272. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  97273. /**
  97274. * @hidden
  97275. * Rescales a texture
  97276. * @param source input texutre
  97277. * @param destination destination texture
  97278. * @param scene scene to use to render the resize
  97279. * @param internalFormat format to use when resizing
  97280. * @param onComplete callback to be called when resize has completed
  97281. */
  97282. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  97283. private _unpackFlipYCached;
  97284. /**
  97285. * In case you are sharing the context with other applications, it might
  97286. * be interested to not cache the unpack flip y state to ensure a consistent
  97287. * value would be set.
  97288. */
  97289. enableUnpackFlipYCached: boolean;
  97290. /** @hidden */
  97291. _unpackFlipY(value: boolean): void;
  97292. /** @hidden */
  97293. _getUnpackAlignement(): number;
  97294. /**
  97295. * Creates a dynamic texture
  97296. * @param width defines the width of the texture
  97297. * @param height defines the height of the texture
  97298. * @param generateMipMaps defines if the engine should generate the mip levels
  97299. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  97300. * @returns the dynamic texture inside an InternalTexture
  97301. */
  97302. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  97303. /**
  97304. * Update the sampling mode of a given texture
  97305. * @param samplingMode defines the required sampling mode
  97306. * @param texture defines the texture to update
  97307. */
  97308. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  97309. /**
  97310. * Update the content of a dynamic texture
  97311. * @param texture defines the texture to update
  97312. * @param canvas defines the canvas containing the source
  97313. * @param invertY defines if data must be stored with Y axis inverted
  97314. * @param premulAlpha defines if alpha is stored as premultiplied
  97315. * @param format defines the format of the data
  97316. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  97317. */
  97318. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  97319. /**
  97320. * Update a video texture
  97321. * @param texture defines the texture to update
  97322. * @param video defines the video element to use
  97323. * @param invertY defines if data must be stored with Y axis inverted
  97324. */
  97325. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  97326. /**
  97327. * Updates a depth texture Comparison Mode and Function.
  97328. * If the comparison Function is equal to 0, the mode will be set to none.
  97329. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  97330. * @param texture The texture to set the comparison function for
  97331. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  97332. */
  97333. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  97334. /** @hidden */
  97335. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  97336. width: number;
  97337. height: number;
  97338. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  97339. /**
  97340. * Creates a depth stencil texture.
  97341. * This is only available in WebGL 2 or with the depth texture extension available.
  97342. * @param size The size of face edge in the texture.
  97343. * @param options The options defining the texture.
  97344. * @returns The texture
  97345. */
  97346. createDepthStencilTexture(size: number | {
  97347. width: number;
  97348. height: number;
  97349. }, options: DepthTextureCreationOptions): InternalTexture;
  97350. /**
  97351. * Creates a depth stencil texture.
  97352. * This is only available in WebGL 2 or with the depth texture extension available.
  97353. * @param size The size of face edge in the texture.
  97354. * @param options The options defining the texture.
  97355. * @returns The texture
  97356. */
  97357. private _createDepthStencilTexture;
  97358. /**
  97359. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  97360. * @param renderTarget The render target to set the frame buffer for
  97361. */
  97362. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  97363. /**
  97364. * Creates a new render target texture
  97365. * @param size defines the size of the texture
  97366. * @param options defines the options used to create the texture
  97367. * @returns a new render target texture stored in an InternalTexture
  97368. */
  97369. createRenderTargetTexture(size: number | {
  97370. width: number;
  97371. height: number;
  97372. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  97373. /** @hidden */
  97374. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  97375. /**
  97376. * Updates the sample count of a render target texture
  97377. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  97378. * @param texture defines the texture to update
  97379. * @param samples defines the sample count to set
  97380. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  97381. */
  97382. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  97383. /** @hidden */
  97384. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97385. /** @hidden */
  97386. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  97387. /** @hidden */
  97388. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  97389. /** @hidden */
  97390. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  97391. /**
  97392. * @hidden
  97393. */
  97394. _setCubeMapTextureParams(loadMipmap: boolean): void;
  97395. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<Scene>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  97396. private _prepareWebGLTexture;
  97397. /** @hidden */
  97398. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  97399. /** @hidden */
  97400. _releaseFramebufferObjects(texture: InternalTexture): void;
  97401. /** @hidden */
  97402. _releaseTexture(texture: InternalTexture): void;
  97403. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  97404. protected _setProgram(program: WebGLProgram): void;
  97405. protected _boundUniforms: {
  97406. [key: number]: WebGLUniformLocation;
  97407. };
  97408. /**
  97409. * Binds an effect to the webGL context
  97410. * @param effect defines the effect to bind
  97411. */
  97412. bindSamplers(effect: Effect): void;
  97413. private _activateCurrentTexture;
  97414. /** @hidden */
  97415. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  97416. /** @hidden */
  97417. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  97418. /**
  97419. * Sets a texture to the webGL context from a postprocess
  97420. * @param channel defines the channel to use
  97421. * @param postProcess defines the source postprocess
  97422. */
  97423. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  97424. /**
  97425. * Binds the output of the passed in post process to the texture channel specified
  97426. * @param channel The channel the texture should be bound to
  97427. * @param postProcess The post process which's output should be bound
  97428. */
  97429. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  97430. /**
  97431. * Unbind all textures from the webGL context
  97432. */
  97433. unbindAllTextures(): void;
  97434. /**
  97435. * Sets a texture to the according uniform.
  97436. * @param channel The texture channel
  97437. * @param uniform The uniform to set
  97438. * @param texture The texture to apply
  97439. */
  97440. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  97441. /**
  97442. * Sets a depth stencil texture from a render target to the according uniform.
  97443. * @param channel The texture channel
  97444. * @param uniform The uniform to set
  97445. * @param texture The render target texture containing the depth stencil texture to apply
  97446. */
  97447. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  97448. private _bindSamplerUniformToChannel;
  97449. private _getTextureWrapMode;
  97450. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  97451. /**
  97452. * Sets an array of texture to the webGL context
  97453. * @param channel defines the channel where the texture array must be set
  97454. * @param uniform defines the associated uniform location
  97455. * @param textures defines the array of textures to bind
  97456. */
  97457. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  97458. /** @hidden */
  97459. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  97460. private _setTextureParameterFloat;
  97461. private _setTextureParameterInteger;
  97462. /**
  97463. * Reads pixels from the current frame buffer. Please note that this function can be slow
  97464. * @param x defines the x coordinate of the rectangle where pixels must be read
  97465. * @param y defines the y coordinate of the rectangle where pixels must be read
  97466. * @param width defines the width of the rectangle where pixels must be read
  97467. * @param height defines the height of the rectangle where pixels must be read
  97468. * @returns a Uint8Array containing RGBA colors
  97469. */
  97470. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  97471. /**
  97472. * Add an externaly attached data from its key.
  97473. * This method call will fail and return false, if such key already exists.
  97474. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  97475. * @param key the unique key that identifies the data
  97476. * @param data the data object to associate to the key for this Engine instance
  97477. * @return true if no such key were already present and the data was added successfully, false otherwise
  97478. */
  97479. addExternalData<T>(key: string, data: T): boolean;
  97480. /**
  97481. * Get an externaly attached data from its key
  97482. * @param key the unique key that identifies the data
  97483. * @return the associated data, if present (can be null), or undefined if not present
  97484. */
  97485. getExternalData<T>(key: string): T;
  97486. /**
  97487. * Get an externaly attached data from its key, create it using a factory if it's not already present
  97488. * @param key the unique key that identifies the data
  97489. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  97490. * @return the associated data, can be null if the factory returned null.
  97491. */
  97492. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  97493. /**
  97494. * Remove an externaly attached data from the Engine instance
  97495. * @param key the unique key that identifies the data
  97496. * @return true if the data was successfully removed, false if it doesn't exist
  97497. */
  97498. removeExternalData(key: string): boolean;
  97499. /**
  97500. * Unbind all vertex attributes from the webGL context
  97501. */
  97502. unbindAllAttributes(): void;
  97503. /**
  97504. * 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
  97505. */
  97506. releaseEffects(): void;
  97507. /**
  97508. * Dispose and release all associated resources
  97509. */
  97510. dispose(): void;
  97511. /**
  97512. * Display the loading screen
  97513. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97514. */
  97515. displayLoadingUI(): void;
  97516. /**
  97517. * Hide the loading screen
  97518. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97519. */
  97520. hideLoadingUI(): void;
  97521. /**
  97522. * Gets the current loading screen object
  97523. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97524. */
  97525. /**
  97526. * Sets the current loading screen object
  97527. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97528. */
  97529. loadingScreen: ILoadingScreen;
  97530. /**
  97531. * Sets the current loading screen text
  97532. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97533. */
  97534. loadingUIText: string;
  97535. /**
  97536. * Sets the current loading screen background color
  97537. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97538. */
  97539. loadingUIBackgroundColor: string;
  97540. /**
  97541. * Attach a new callback raised when context lost event is fired
  97542. * @param callback defines the callback to call
  97543. */
  97544. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97545. /**
  97546. * Attach a new callback raised when context restored event is fired
  97547. * @param callback defines the callback to call
  97548. */
  97549. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  97550. /**
  97551. * Gets the source code of the vertex shader associated with a specific webGL program
  97552. * @param program defines the program to use
  97553. * @returns a string containing the source code of the vertex shader associated with the program
  97554. */
  97555. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  97556. /**
  97557. * Gets the source code of the fragment shader associated with a specific webGL program
  97558. * @param program defines the program to use
  97559. * @returns a string containing the source code of the fragment shader associated with the program
  97560. */
  97561. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  97562. /**
  97563. * Get the current error code of the webGL context
  97564. * @returns the error code
  97565. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  97566. */
  97567. getError(): number;
  97568. /**
  97569. * Gets the current framerate
  97570. * @returns a number representing the framerate
  97571. */
  97572. getFps(): number;
  97573. /**
  97574. * Gets the time spent between current and previous frame
  97575. * @returns a number representing the delta time in ms
  97576. */
  97577. getDeltaTime(): number;
  97578. private _measureFps;
  97579. /** @hidden */
  97580. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  97581. private _canRenderToFloatFramebuffer;
  97582. private _canRenderToHalfFloatFramebuffer;
  97583. private _canRenderToFramebuffer;
  97584. /** @hidden */
  97585. _getWebGLTextureType(type: number): number;
  97586. /** @hidden */
  97587. _getInternalFormat(format: number): number;
  97588. /** @hidden */
  97589. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  97590. /** @hidden */
  97591. _getRGBAMultiSampleBufferFormat(type: number): number;
  97592. /** @hidden */
  97593. _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;
  97594. /** @hidden */
  97595. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  97596. /**
  97597. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  97598. * @returns true if the engine can be created
  97599. * @ignorenaming
  97600. */
  97601. static isSupported(): boolean;
  97602. /**
  97603. * Find the next highest power of two.
  97604. * @param x Number to start search from.
  97605. * @return Next highest power of two.
  97606. */
  97607. static CeilingPOT(x: number): number;
  97608. /**
  97609. * Find the next lowest power of two.
  97610. * @param x Number to start search from.
  97611. * @return Next lowest power of two.
  97612. */
  97613. static FloorPOT(x: number): number;
  97614. /**
  97615. * Find the nearest power of two.
  97616. * @param x Number to start search from.
  97617. * @return Next nearest power of two.
  97618. */
  97619. static NearestPOT(x: number): number;
  97620. /**
  97621. * Get the closest exponent of two
  97622. * @param value defines the value to approximate
  97623. * @param max defines the maximum value to return
  97624. * @param mode defines how to define the closest value
  97625. * @returns closest exponent of two of the given value
  97626. */
  97627. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  97628. /**
  97629. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  97630. * @param func - the function to be called
  97631. * @param requester - the object that will request the next frame. Falls back to window.
  97632. * @returns frame number
  97633. */
  97634. static QueueNewFrame(func: () => void, requester?: any): number;
  97635. /**
  97636. * Ask the browser to promote the current element to pointerlock mode
  97637. * @param element defines the DOM element to promote
  97638. */
  97639. static _RequestPointerlock(element: HTMLElement): void;
  97640. /**
  97641. * Asks the browser to exit pointerlock mode
  97642. */
  97643. static _ExitPointerlock(): void;
  97644. /**
  97645. * Ask the browser to promote the current element to fullscreen rendering mode
  97646. * @param element defines the DOM element to promote
  97647. */
  97648. static _RequestFullscreen(element: HTMLElement): void;
  97649. /**
  97650. * Asks the browser to exit fullscreen mode
  97651. */
  97652. static _ExitFullscreen(): void;
  97653. }
  97654. }
  97655. declare module BABYLON {
  97656. /**
  97657. * The engine store class is responsible to hold all the instances of Engine and Scene created
  97658. * during the life time of the application.
  97659. */
  97660. export class EngineStore {
  97661. /** Gets the list of created engines */
  97662. static Instances: Engine[];
  97663. /** @hidden */
  97664. static _LastCreatedScene: Nullable<Scene>;
  97665. /**
  97666. * Gets the latest created engine
  97667. */
  97668. static readonly LastCreatedEngine: Nullable<Engine>;
  97669. /**
  97670. * Gets the latest created scene
  97671. */
  97672. static readonly LastCreatedScene: Nullable<Scene>;
  97673. /**
  97674. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97675. * @ignorenaming
  97676. */
  97677. static UseFallbackTexture: boolean;
  97678. /**
  97679. * Texture content used if a texture cannot loaded
  97680. * @ignorenaming
  97681. */
  97682. static FallbackTexture: string;
  97683. }
  97684. }
  97685. declare module BABYLON {
  97686. /**
  97687. * Helper class that provides a small promise polyfill
  97688. */
  97689. export class PromisePolyfill {
  97690. /**
  97691. * Static function used to check if the polyfill is required
  97692. * If this is the case then the function will inject the polyfill to window.Promise
  97693. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  97694. */
  97695. static Apply(force?: boolean): void;
  97696. }
  97697. }
  97698. declare module BABYLON {
  97699. /**
  97700. * Interface for screenshot methods with describe argument called `size` as object with options
  97701. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  97702. */
  97703. export interface IScreenshotSize {
  97704. /**
  97705. * number in pixels for canvas height
  97706. */
  97707. height?: number;
  97708. /**
  97709. * multiplier allowing render at a higher or lower resolution
  97710. * If value is defined then height and width will be ignored and taken from camera
  97711. */
  97712. precision?: number;
  97713. /**
  97714. * number in pixels for canvas width
  97715. */
  97716. width?: number;
  97717. }
  97718. }
  97719. declare module BABYLON {
  97720. interface IColor4Like {
  97721. r: float;
  97722. g: float;
  97723. b: float;
  97724. a: float;
  97725. }
  97726. /**
  97727. * Class containing a set of static utilities functions
  97728. */
  97729. export class Tools {
  97730. /**
  97731. * Gets or sets the base URL to use to load assets
  97732. */
  97733. static BaseUrl: string;
  97734. /**
  97735. * Enable/Disable Custom HTTP Request Headers globally.
  97736. * default = false
  97737. * @see CustomRequestHeaders
  97738. */
  97739. static UseCustomRequestHeaders: boolean;
  97740. /**
  97741. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  97742. * i.e. when loading files, where the server/service expects an Authorization header
  97743. */
  97744. static CustomRequestHeaders: {
  97745. [key: string]: string;
  97746. };
  97747. /**
  97748. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  97749. */
  97750. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  97751. /**
  97752. * Default behaviour for cors in the application.
  97753. * It can be a string if the expected behavior is identical in the entire app.
  97754. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  97755. */
  97756. static CorsBehavior: string | ((url: string | string[]) => string);
  97757. /**
  97758. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  97759. * @ignorenaming
  97760. */
  97761. static UseFallbackTexture: boolean;
  97762. /**
  97763. * Use this object to register external classes like custom textures or material
  97764. * to allow the laoders to instantiate them
  97765. */
  97766. static RegisteredExternalClasses: {
  97767. [key: string]: Object;
  97768. };
  97769. /**
  97770. * Texture content used if a texture cannot loaded
  97771. * @ignorenaming
  97772. */
  97773. static fallbackTexture: string;
  97774. /**
  97775. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  97776. * @param u defines the coordinate on X axis
  97777. * @param v defines the coordinate on Y axis
  97778. * @param width defines the width of the source data
  97779. * @param height defines the height of the source data
  97780. * @param pixels defines the source byte array
  97781. * @param color defines the output color
  97782. */
  97783. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  97784. /**
  97785. * Interpolates between a and b via alpha
  97786. * @param a The lower value (returned when alpha = 0)
  97787. * @param b The upper value (returned when alpha = 1)
  97788. * @param alpha The interpolation-factor
  97789. * @return The mixed value
  97790. */
  97791. static Mix(a: number, b: number, alpha: number): number;
  97792. /**
  97793. * Tries to instantiate a new object from a given class name
  97794. * @param className defines the class name to instantiate
  97795. * @returns the new object or null if the system was not able to do the instantiation
  97796. */
  97797. static Instantiate(className: string): any;
  97798. /**
  97799. * Provides a slice function that will work even on IE
  97800. * @param data defines the array to slice
  97801. * @param start defines the start of the data (optional)
  97802. * @param end defines the end of the data (optional)
  97803. * @returns the new sliced array
  97804. */
  97805. static Slice<T>(data: T, start?: number, end?: number): T;
  97806. /**
  97807. * Polyfill for setImmediate
  97808. * @param action defines the action to execute after the current execution block
  97809. */
  97810. static SetImmediate(action: () => void): void;
  97811. /**
  97812. * Function indicating if a number is an exponent of 2
  97813. * @param value defines the value to test
  97814. * @returns true if the value is an exponent of 2
  97815. */
  97816. static IsExponentOfTwo(value: number): boolean;
  97817. private static _tmpFloatArray;
  97818. /**
  97819. * Returns the nearest 32-bit single precision float representation of a Number
  97820. * @param value A Number. If the parameter is of a different type, it will get converted
  97821. * to a number or to NaN if it cannot be converted
  97822. * @returns number
  97823. */
  97824. static FloatRound(value: number): number;
  97825. /**
  97826. * Extracts the filename from a path
  97827. * @param path defines the path to use
  97828. * @returns the filename
  97829. */
  97830. static GetFilename(path: string): string;
  97831. /**
  97832. * Extracts the "folder" part of a path (everything before the filename).
  97833. * @param uri The URI to extract the info from
  97834. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  97835. * @returns The "folder" part of the path
  97836. */
  97837. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  97838. /**
  97839. * Extracts text content from a DOM element hierarchy
  97840. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  97841. */
  97842. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  97843. /**
  97844. * Convert an angle in radians to degrees
  97845. * @param angle defines the angle to convert
  97846. * @returns the angle in degrees
  97847. */
  97848. static ToDegrees(angle: number): number;
  97849. /**
  97850. * Convert an angle in degrees to radians
  97851. * @param angle defines the angle to convert
  97852. * @returns the angle in radians
  97853. */
  97854. static ToRadians(angle: number): number;
  97855. /**
  97856. * Encode a buffer to a base64 string
  97857. * @param buffer defines the buffer to encode
  97858. * @returns the encoded string
  97859. */
  97860. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  97861. /**
  97862. * Returns an array if obj is not an array
  97863. * @param obj defines the object to evaluate as an array
  97864. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  97865. * @returns either obj directly if obj is an array or a new array containing obj
  97866. */
  97867. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  97868. /**
  97869. * Gets the pointer prefix to use
  97870. * @returns "pointer" if touch is enabled. Else returns "mouse"
  97871. */
  97872. static GetPointerPrefix(): string;
  97873. /**
  97874. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  97875. * @param url define the url we are trying
  97876. * @param element define the dom element where to configure the cors policy
  97877. */
  97878. static SetCorsBehavior(url: string | string[], element: {
  97879. crossOrigin: string | null;
  97880. }): void;
  97881. /**
  97882. * Removes unwanted characters from an url
  97883. * @param url defines the url to clean
  97884. * @returns the cleaned url
  97885. */
  97886. static CleanUrl(url: string): string;
  97887. /**
  97888. * Gets or sets a function used to pre-process url before using them to load assets
  97889. */
  97890. static PreprocessUrl: (url: string) => string;
  97891. /**
  97892. * Loads an image as an HTMLImageElement.
  97893. * @param input url string, ArrayBuffer, or Blob to load
  97894. * @param onLoad callback called when the image successfully loads
  97895. * @param onError callback called when the image fails to load
  97896. * @param offlineProvider offline provider for caching
  97897. * @returns the HTMLImageElement of the loaded image
  97898. */
  97899. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  97900. /**
  97901. * Loads a file
  97902. * @param url url string, ArrayBuffer, or Blob to load
  97903. * @param onSuccess callback called when the file successfully loads
  97904. * @param onProgress callback called while file is loading (if the server supports this mode)
  97905. * @param offlineProvider defines the offline provider for caching
  97906. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  97907. * @param onError callback called when the file fails to load
  97908. * @returns a file request object
  97909. */
  97910. 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;
  97911. /**
  97912. * Loads a file from a url
  97913. * @param url the file url to load
  97914. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  97915. */
  97916. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  97917. /**
  97918. * Load a script (identified by an url). When the url returns, the
  97919. * content of this file is added into a new script element, attached to the DOM (body element)
  97920. * @param scriptUrl defines the url of the script to laod
  97921. * @param onSuccess defines the callback called when the script is loaded
  97922. * @param onError defines the callback to call if an error occurs
  97923. * @param scriptId defines the id of the script element
  97924. */
  97925. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  97926. /**
  97927. * Load an asynchronous script (identified by an url). When the url returns, the
  97928. * content of this file is added into a new script element, attached to the DOM (body element)
  97929. * @param scriptUrl defines the url of the script to laod
  97930. * @param scriptId defines the id of the script element
  97931. * @returns a promise request object
  97932. */
  97933. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  97934. /**
  97935. * Loads a file from a blob
  97936. * @param fileToLoad defines the blob to use
  97937. * @param callback defines the callback to call when data is loaded
  97938. * @param progressCallback defines the callback to call during loading process
  97939. * @returns a file request object
  97940. */
  97941. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  97942. /**
  97943. * Loads a file
  97944. * @param fileToLoad defines the file to load
  97945. * @param callback defines the callback to call when data is loaded
  97946. * @param progressCallBack defines the callback to call during loading process
  97947. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  97948. * @returns a file request object
  97949. */
  97950. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  97951. /**
  97952. * Creates a data url from a given string content
  97953. * @param content defines the content to convert
  97954. * @returns the new data url link
  97955. */
  97956. static FileAsURL(content: string): string;
  97957. /**
  97958. * Format the given number to a specific decimal format
  97959. * @param value defines the number to format
  97960. * @param decimals defines the number of decimals to use
  97961. * @returns the formatted string
  97962. */
  97963. static Format(value: number, decimals?: number): string;
  97964. /**
  97965. * Tries to copy an object by duplicating every property
  97966. * @param source defines the source object
  97967. * @param destination defines the target object
  97968. * @param doNotCopyList defines a list of properties to avoid
  97969. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  97970. */
  97971. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  97972. /**
  97973. * Gets a boolean indicating if the given object has no own property
  97974. * @param obj defines the object to test
  97975. * @returns true if object has no own property
  97976. */
  97977. static IsEmpty(obj: any): boolean;
  97978. /**
  97979. * Function used to register events at window level
  97980. * @param windowElement defines the Window object to use
  97981. * @param events defines the events to register
  97982. */
  97983. static RegisterTopRootEvents(windowElement: Window, events: {
  97984. name: string;
  97985. handler: Nullable<(e: FocusEvent) => any>;
  97986. }[]): void;
  97987. /**
  97988. * Function used to unregister events from window level
  97989. * @param windowElement defines the Window object to use
  97990. * @param events defines the events to unregister
  97991. */
  97992. static UnregisterTopRootEvents(windowElement: Window, events: {
  97993. name: string;
  97994. handler: Nullable<(e: FocusEvent) => any>;
  97995. }[]): void;
  97996. /**
  97997. * @ignore
  97998. */
  97999. static _ScreenshotCanvas: HTMLCanvasElement;
  98000. /**
  98001. * Dumps the current bound framebuffer
  98002. * @param width defines the rendering width
  98003. * @param height defines the rendering height
  98004. * @param engine defines the hosting engine
  98005. * @param successCallback defines the callback triggered once the data are available
  98006. * @param mimeType defines the mime type of the result
  98007. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  98008. */
  98009. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98010. /**
  98011. * Converts the canvas data to blob.
  98012. * This acts as a polyfill for browsers not supporting the to blob function.
  98013. * @param canvas Defines the canvas to extract the data from
  98014. * @param successCallback Defines the callback triggered once the data are available
  98015. * @param mimeType Defines the mime type of the result
  98016. */
  98017. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  98018. /**
  98019. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  98020. * @param successCallback defines the callback triggered once the data are available
  98021. * @param mimeType defines the mime type of the result
  98022. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  98023. */
  98024. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98025. /**
  98026. * Downloads a blob in the browser
  98027. * @param blob defines the blob to download
  98028. * @param fileName defines the name of the downloaded file
  98029. */
  98030. static Download(blob: Blob, fileName: string): void;
  98031. /**
  98032. * Captures a screenshot of the current rendering
  98033. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98034. * @param engine defines the rendering engine
  98035. * @param camera defines the source camera
  98036. * @param size This parameter can be set to a single number or to an object with the
  98037. * following (optional) properties: precision, width, height. If a single number is passed,
  98038. * it will be used for both width and height. If an object is passed, the screenshot size
  98039. * will be derived from the parameters. The precision property is a multiplier allowing
  98040. * rendering at a higher or lower resolution
  98041. * @param successCallback defines the callback receives a single parameter which contains the
  98042. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98043. * src parameter of an <img> to display it
  98044. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98045. * Check your browser for supported MIME types
  98046. */
  98047. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  98048. /**
  98049. * Captures a screenshot of the current rendering
  98050. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98051. * @param engine defines the rendering engine
  98052. * @param camera defines the source camera
  98053. * @param size This parameter can be set to a single number or to an object with the
  98054. * following (optional) properties: precision, width, height. If a single number is passed,
  98055. * it will be used for both width and height. If an object is passed, the screenshot size
  98056. * will be derived from the parameters. The precision property is a multiplier allowing
  98057. * rendering at a higher or lower resolution
  98058. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98059. * Check your browser for supported MIME types
  98060. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  98061. * to the src parameter of an <img> to display it
  98062. */
  98063. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  98064. /**
  98065. * Generates an image screenshot from the specified camera.
  98066. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98067. * @param engine The engine to use for rendering
  98068. * @param camera The camera to use for rendering
  98069. * @param size This parameter can be set to a single number or to an object with the
  98070. * following (optional) properties: precision, width, height. If a single number is passed,
  98071. * it will be used for both width and height. If an object is passed, the screenshot size
  98072. * will be derived from the parameters. The precision property is a multiplier allowing
  98073. * rendering at a higher or lower resolution
  98074. * @param successCallback The callback receives a single parameter which contains the
  98075. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98076. * src parameter of an <img> to display it
  98077. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98078. * Check your browser for supported MIME types
  98079. * @param samples Texture samples (default: 1)
  98080. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98081. * @param fileName A name for for the downloaded file.
  98082. */
  98083. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  98084. /**
  98085. * Generates an image screenshot from the specified camera.
  98086. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98087. * @param engine The engine to use for rendering
  98088. * @param camera The camera to use for rendering
  98089. * @param size This parameter can be set to a single number or to an object with the
  98090. * following (optional) properties: precision, width, height. If a single number is passed,
  98091. * it will be used for both width and height. If an object is passed, the screenshot size
  98092. * will be derived from the parameters. The precision property is a multiplier allowing
  98093. * rendering at a higher or lower resolution
  98094. * @param mimeType The MIME type of the screenshot image (default: image/png).
  98095. * Check your browser for supported MIME types
  98096. * @param samples Texture samples (default: 1)
  98097. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  98098. * @param fileName A name for for the downloaded file.
  98099. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  98100. * to the src parameter of an <img> to display it
  98101. */
  98102. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  98103. /**
  98104. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  98105. * Be aware Math.random() could cause collisions, but:
  98106. * "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"
  98107. * @returns a pseudo random id
  98108. */
  98109. static RandomId(): string;
  98110. /**
  98111. * Test if the given uri is a base64 string
  98112. * @param uri The uri to test
  98113. * @return True if the uri is a base64 string or false otherwise
  98114. */
  98115. static IsBase64(uri: string): boolean;
  98116. /**
  98117. * Decode the given base64 uri.
  98118. * @param uri The uri to decode
  98119. * @return The decoded base64 data.
  98120. */
  98121. static DecodeBase64(uri: string): ArrayBuffer;
  98122. /**
  98123. * Gets the absolute url.
  98124. * @param url the input url
  98125. * @return the absolute url
  98126. */
  98127. static GetAbsoluteUrl(url: string): string;
  98128. /**
  98129. * No log
  98130. */
  98131. static readonly NoneLogLevel: number;
  98132. /**
  98133. * Only message logs
  98134. */
  98135. static readonly MessageLogLevel: number;
  98136. /**
  98137. * Only warning logs
  98138. */
  98139. static readonly WarningLogLevel: number;
  98140. /**
  98141. * Only error logs
  98142. */
  98143. static readonly ErrorLogLevel: number;
  98144. /**
  98145. * All logs
  98146. */
  98147. static readonly AllLogLevel: number;
  98148. /**
  98149. * Gets a value indicating the number of loading errors
  98150. * @ignorenaming
  98151. */
  98152. static readonly errorsCount: number;
  98153. /**
  98154. * Callback called when a new log is added
  98155. */
  98156. static OnNewCacheEntry: (entry: string) => void;
  98157. /**
  98158. * Log a message to the console
  98159. * @param message defines the message to log
  98160. */
  98161. static Log(message: string): void;
  98162. /**
  98163. * Write a warning message to the console
  98164. * @param message defines the message to log
  98165. */
  98166. static Warn(message: string): void;
  98167. /**
  98168. * Write an error message to the console
  98169. * @param message defines the message to log
  98170. */
  98171. static Error(message: string): void;
  98172. /**
  98173. * Gets current log cache (list of logs)
  98174. */
  98175. static readonly LogCache: string;
  98176. /**
  98177. * Clears the log cache
  98178. */
  98179. static ClearLogCache(): void;
  98180. /**
  98181. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  98182. */
  98183. static LogLevels: number;
  98184. /**
  98185. * Checks if the window object exists
  98186. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  98187. */
  98188. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  98189. /**
  98190. * No performance log
  98191. */
  98192. static readonly PerformanceNoneLogLevel: number;
  98193. /**
  98194. * Use user marks to log performance
  98195. */
  98196. static readonly PerformanceUserMarkLogLevel: number;
  98197. /**
  98198. * Log performance to the console
  98199. */
  98200. static readonly PerformanceConsoleLogLevel: number;
  98201. private static _performance;
  98202. /**
  98203. * Sets the current performance log level
  98204. */
  98205. static PerformanceLogLevel: number;
  98206. private static _StartPerformanceCounterDisabled;
  98207. private static _EndPerformanceCounterDisabled;
  98208. private static _StartUserMark;
  98209. private static _EndUserMark;
  98210. private static _StartPerformanceConsole;
  98211. private static _EndPerformanceConsole;
  98212. /**
  98213. * Starts a performance counter
  98214. */
  98215. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98216. /**
  98217. * Ends a specific performance coutner
  98218. */
  98219. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  98220. /**
  98221. * Gets either window.performance.now() if supported or Date.now() else
  98222. */
  98223. static readonly Now: number;
  98224. /**
  98225. * This method will return the name of the class used to create the instance of the given object.
  98226. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  98227. * @param object the object to get the class name from
  98228. * @param isType defines if the object is actually a type
  98229. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  98230. */
  98231. static GetClassName(object: any, isType?: boolean): string;
  98232. /**
  98233. * Gets the first element of an array satisfying a given predicate
  98234. * @param array defines the array to browse
  98235. * @param predicate defines the predicate to use
  98236. * @returns null if not found or the element
  98237. */
  98238. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  98239. /**
  98240. * This method will return the name of the full name of the class, including its owning module (if any).
  98241. * 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).
  98242. * @param object the object to get the class name from
  98243. * @param isType defines if the object is actually a type
  98244. * @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.
  98245. * @ignorenaming
  98246. */
  98247. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  98248. /**
  98249. * Returns a promise that resolves after the given amount of time.
  98250. * @param delay Number of milliseconds to delay
  98251. * @returns Promise that resolves after the given amount of time
  98252. */
  98253. static DelayAsync(delay: number): Promise<void>;
  98254. }
  98255. /**
  98256. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  98257. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  98258. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  98259. * @param name The name of the class, case should be preserved
  98260. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  98261. */
  98262. export function className(name: string, module?: string): (target: Object) => void;
  98263. /**
  98264. * An implementation of a loop for asynchronous functions.
  98265. */
  98266. export class AsyncLoop {
  98267. /**
  98268. * Defines the number of iterations for the loop
  98269. */
  98270. iterations: number;
  98271. /**
  98272. * Defines the current index of the loop.
  98273. */
  98274. index: number;
  98275. private _done;
  98276. private _fn;
  98277. private _successCallback;
  98278. /**
  98279. * Constructor.
  98280. * @param iterations the number of iterations.
  98281. * @param func the function to run each iteration
  98282. * @param successCallback the callback that will be called upon succesful execution
  98283. * @param offset starting offset.
  98284. */
  98285. constructor(
  98286. /**
  98287. * Defines the number of iterations for the loop
  98288. */
  98289. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  98290. /**
  98291. * Execute the next iteration. Must be called after the last iteration was finished.
  98292. */
  98293. executeNext(): void;
  98294. /**
  98295. * Break the loop and run the success callback.
  98296. */
  98297. breakLoop(): void;
  98298. /**
  98299. * Create and run an async loop.
  98300. * @param iterations the number of iterations.
  98301. * @param fn the function to run each iteration
  98302. * @param successCallback the callback that will be called upon succesful execution
  98303. * @param offset starting offset.
  98304. * @returns the created async loop object
  98305. */
  98306. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  98307. /**
  98308. * A for-loop that will run a given number of iterations synchronous and the rest async.
  98309. * @param iterations total number of iterations
  98310. * @param syncedIterations number of synchronous iterations in each async iteration.
  98311. * @param fn the function to call each iteration.
  98312. * @param callback a success call back that will be called when iterating stops.
  98313. * @param breakFunction a break condition (optional)
  98314. * @param timeout timeout settings for the setTimeout function. default - 0.
  98315. * @returns the created async loop object
  98316. */
  98317. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  98318. }
  98319. }
  98320. declare module BABYLON {
  98321. /** @hidden */
  98322. export interface ICollisionCoordinator {
  98323. createCollider(): Collider;
  98324. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98325. init(scene: Scene): void;
  98326. }
  98327. /** @hidden */
  98328. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  98329. private _scene;
  98330. private _scaledPosition;
  98331. private _scaledVelocity;
  98332. private _finalPosition;
  98333. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  98334. createCollider(): Collider;
  98335. init(scene: Scene): void;
  98336. private _collideWithWorld;
  98337. }
  98338. }
  98339. declare module BABYLON {
  98340. /**
  98341. * Class used to manage all inputs for the scene.
  98342. */
  98343. export class InputManager {
  98344. /** The distance in pixel that you have to move to prevent some events */
  98345. static DragMovementThreshold: number;
  98346. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  98347. static LongPressDelay: number;
  98348. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  98349. static DoubleClickDelay: number;
  98350. /** If you need to check double click without raising a single click at first click, enable this flag */
  98351. static ExclusiveDoubleClickMode: boolean;
  98352. private _wheelEventName;
  98353. private _onPointerMove;
  98354. private _onPointerDown;
  98355. private _onPointerUp;
  98356. private _initClickEvent;
  98357. private _initActionManager;
  98358. private _delayedSimpleClick;
  98359. private _delayedSimpleClickTimeout;
  98360. private _previousDelayedSimpleClickTimeout;
  98361. private _meshPickProceed;
  98362. private _previousButtonPressed;
  98363. private _currentPickResult;
  98364. private _previousPickResult;
  98365. private _totalPointersPressed;
  98366. private _doubleClickOccured;
  98367. private _pointerOverMesh;
  98368. private _pickedDownMesh;
  98369. private _pickedUpMesh;
  98370. private _pointerX;
  98371. private _pointerY;
  98372. private _unTranslatedPointerX;
  98373. private _unTranslatedPointerY;
  98374. private _startingPointerPosition;
  98375. private _previousStartingPointerPosition;
  98376. private _startingPointerTime;
  98377. private _previousStartingPointerTime;
  98378. private _pointerCaptures;
  98379. private _onKeyDown;
  98380. private _onKeyUp;
  98381. private _onCanvasFocusObserver;
  98382. private _onCanvasBlurObserver;
  98383. private _scene;
  98384. /**
  98385. * Creates a new InputManager
  98386. * @param scene defines the hosting scene
  98387. */
  98388. constructor(scene: Scene);
  98389. /**
  98390. * Gets the mesh that is currently under the pointer
  98391. */
  98392. readonly meshUnderPointer: Nullable<AbstractMesh>;
  98393. /**
  98394. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  98395. */
  98396. readonly unTranslatedPointer: Vector2;
  98397. /**
  98398. * Gets or sets the current on-screen X position of the pointer
  98399. */
  98400. pointerX: number;
  98401. /**
  98402. * Gets or sets the current on-screen Y position of the pointer
  98403. */
  98404. pointerY: number;
  98405. private _updatePointerPosition;
  98406. private _processPointerMove;
  98407. private _setRayOnPointerInfo;
  98408. private _checkPrePointerObservable;
  98409. /**
  98410. * Use this method to simulate a pointer move on a mesh
  98411. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98412. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98413. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98414. */
  98415. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98416. /**
  98417. * Use this method to simulate a pointer down on a mesh
  98418. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98419. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98420. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98421. */
  98422. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  98423. private _processPointerDown;
  98424. /** @hidden */
  98425. _isPointerSwiping(): boolean;
  98426. /**
  98427. * Use this method to simulate a pointer up on a mesh
  98428. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  98429. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  98430. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  98431. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  98432. */
  98433. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  98434. private _processPointerUp;
  98435. /**
  98436. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  98437. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  98438. * @returns true if the pointer was captured
  98439. */
  98440. isPointerCaptured(pointerId?: number): boolean;
  98441. /**
  98442. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  98443. * @param attachUp defines if you want to attach events to pointerup
  98444. * @param attachDown defines if you want to attach events to pointerdown
  98445. * @param attachMove defines if you want to attach events to pointermove
  98446. */
  98447. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  98448. /**
  98449. * Detaches all event handlers
  98450. */
  98451. detachControl(): void;
  98452. /**
  98453. * Force the value of meshUnderPointer
  98454. * @param mesh defines the mesh to use
  98455. */
  98456. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  98457. /**
  98458. * Gets the mesh under the pointer
  98459. * @returns a Mesh or null if no mesh is under the pointer
  98460. */
  98461. getPointerOverMesh(): Nullable<AbstractMesh>;
  98462. }
  98463. }
  98464. declare module BABYLON {
  98465. /**
  98466. * Helper class used to generate session unique ID
  98467. */
  98468. export class UniqueIdGenerator {
  98469. private static _UniqueIdCounter;
  98470. /**
  98471. * Gets an unique (relatively to the current scene) Id
  98472. */
  98473. static readonly UniqueId: number;
  98474. }
  98475. }
  98476. declare module BABYLON {
  98477. /**
  98478. * This class defines the direct association between an animation and a target
  98479. */
  98480. export class TargetedAnimation {
  98481. /**
  98482. * Animation to perform
  98483. */
  98484. animation: Animation;
  98485. /**
  98486. * Target to animate
  98487. */
  98488. target: any;
  98489. /**
  98490. * Serialize the object
  98491. * @returns the JSON object representing the current entity
  98492. */
  98493. serialize(): any;
  98494. }
  98495. /**
  98496. * Use this class to create coordinated animations on multiple targets
  98497. */
  98498. export class AnimationGroup implements IDisposable {
  98499. /** The name of the animation group */
  98500. name: string;
  98501. private _scene;
  98502. private _targetedAnimations;
  98503. private _animatables;
  98504. private _from;
  98505. private _to;
  98506. private _isStarted;
  98507. private _isPaused;
  98508. private _speedRatio;
  98509. private _loopAnimation;
  98510. /**
  98511. * Gets or sets the unique id of the node
  98512. */
  98513. uniqueId: number;
  98514. /**
  98515. * This observable will notify when one animation have ended
  98516. */
  98517. onAnimationEndObservable: Observable<TargetedAnimation>;
  98518. /**
  98519. * Observer raised when one animation loops
  98520. */
  98521. onAnimationLoopObservable: Observable<TargetedAnimation>;
  98522. /**
  98523. * This observable will notify when all animations have ended.
  98524. */
  98525. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  98526. /**
  98527. * This observable will notify when all animations have paused.
  98528. */
  98529. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  98530. /**
  98531. * This observable will notify when all animations are playing.
  98532. */
  98533. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  98534. /**
  98535. * Gets the first frame
  98536. */
  98537. readonly from: number;
  98538. /**
  98539. * Gets the last frame
  98540. */
  98541. readonly to: number;
  98542. /**
  98543. * Define if the animations are started
  98544. */
  98545. readonly isStarted: boolean;
  98546. /**
  98547. * Gets a value indicating that the current group is playing
  98548. */
  98549. readonly isPlaying: boolean;
  98550. /**
  98551. * Gets or sets the speed ratio to use for all animations
  98552. */
  98553. /**
  98554. * Gets or sets the speed ratio to use for all animations
  98555. */
  98556. speedRatio: number;
  98557. /**
  98558. * Gets or sets if all animations should loop or not
  98559. */
  98560. loopAnimation: boolean;
  98561. /**
  98562. * Gets the targeted animations for this animation group
  98563. */
  98564. readonly targetedAnimations: Array<TargetedAnimation>;
  98565. /**
  98566. * returning the list of animatables controlled by this animation group.
  98567. */
  98568. readonly animatables: Array<Animatable>;
  98569. /**
  98570. * Instantiates a new Animation Group.
  98571. * This helps managing several animations at once.
  98572. * @see http://doc.babylonjs.com/how_to/group
  98573. * @param name Defines the name of the group
  98574. * @param scene Defines the scene the group belongs to
  98575. */
  98576. constructor(
  98577. /** The name of the animation group */
  98578. name: string, scene?: Nullable<Scene>);
  98579. /**
  98580. * Add an animation (with its target) in the group
  98581. * @param animation defines the animation we want to add
  98582. * @param target defines the target of the animation
  98583. * @returns the TargetedAnimation object
  98584. */
  98585. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  98586. /**
  98587. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  98588. * It can add constant keys at begin or end
  98589. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  98590. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  98591. * @returns the animation group
  98592. */
  98593. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  98594. /**
  98595. * Start all animations on given targets
  98596. * @param loop defines if animations must loop
  98597. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  98598. * @param from defines the from key (optional)
  98599. * @param to defines the to key (optional)
  98600. * @returns the current animation group
  98601. */
  98602. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  98603. /**
  98604. * Pause all animations
  98605. * @returns the animation group
  98606. */
  98607. pause(): AnimationGroup;
  98608. /**
  98609. * Play all animations to initial state
  98610. * This function will start() the animations if they were not started or will restart() them if they were paused
  98611. * @param loop defines if animations must loop
  98612. * @returns the animation group
  98613. */
  98614. play(loop?: boolean): AnimationGroup;
  98615. /**
  98616. * Reset all animations to initial state
  98617. * @returns the animation group
  98618. */
  98619. reset(): AnimationGroup;
  98620. /**
  98621. * Restart animations from key 0
  98622. * @returns the animation group
  98623. */
  98624. restart(): AnimationGroup;
  98625. /**
  98626. * Stop all animations
  98627. * @returns the animation group
  98628. */
  98629. stop(): AnimationGroup;
  98630. /**
  98631. * Set animation weight for all animatables
  98632. * @param weight defines the weight to use
  98633. * @return the animationGroup
  98634. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98635. */
  98636. setWeightForAllAnimatables(weight: number): AnimationGroup;
  98637. /**
  98638. * Synchronize and normalize all animatables with a source animatable
  98639. * @param root defines the root animatable to synchronize with
  98640. * @return the animationGroup
  98641. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  98642. */
  98643. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  98644. /**
  98645. * Goes to a specific frame in this animation group
  98646. * @param frame the frame number to go to
  98647. * @return the animationGroup
  98648. */
  98649. goToFrame(frame: number): AnimationGroup;
  98650. /**
  98651. * Dispose all associated resources
  98652. */
  98653. dispose(): void;
  98654. private _checkAnimationGroupEnded;
  98655. /**
  98656. * Clone the current animation group and returns a copy
  98657. * @param newName defines the name of the new group
  98658. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  98659. * @returns the new aniamtion group
  98660. */
  98661. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  98662. /**
  98663. * Serializes the animationGroup to an object
  98664. * @returns Serialized object
  98665. */
  98666. serialize(): any;
  98667. /**
  98668. * Returns a new AnimationGroup object parsed from the source provided.
  98669. * @param parsedAnimationGroup defines the source
  98670. * @param scene defines the scene that will receive the animationGroup
  98671. * @returns a new AnimationGroup
  98672. */
  98673. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  98674. /**
  98675. * Returns the string "AnimationGroup"
  98676. * @returns "AnimationGroup"
  98677. */
  98678. getClassName(): string;
  98679. /**
  98680. * Creates a detailled string about the object
  98681. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  98682. * @returns a string representing the object
  98683. */
  98684. toString(fullDetails?: boolean): string;
  98685. }
  98686. }
  98687. declare module BABYLON {
  98688. /**
  98689. * Define an interface for all classes that will hold resources
  98690. */
  98691. export interface IDisposable {
  98692. /**
  98693. * Releases all held resources
  98694. */
  98695. dispose(): void;
  98696. }
  98697. /** Interface defining initialization parameters for Scene class */
  98698. export interface SceneOptions {
  98699. /**
  98700. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  98701. * It will improve performance when the number of geometries becomes important.
  98702. */
  98703. useGeometryUniqueIdsMap?: boolean;
  98704. /**
  98705. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  98706. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98707. */
  98708. useMaterialMeshMap?: boolean;
  98709. /**
  98710. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  98711. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  98712. */
  98713. useClonedMeshhMap?: boolean;
  98714. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  98715. virtual?: boolean;
  98716. }
  98717. /**
  98718. * Represents a scene to be rendered by the engine.
  98719. * @see http://doc.babylonjs.com/features/scene
  98720. */
  98721. export class Scene extends AbstractScene implements IAnimatable {
  98722. /** The fog is deactivated */
  98723. static readonly FOGMODE_NONE: number;
  98724. /** The fog density is following an exponential function */
  98725. static readonly FOGMODE_EXP: number;
  98726. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  98727. static readonly FOGMODE_EXP2: number;
  98728. /** The fog density is following a linear function. */
  98729. static readonly FOGMODE_LINEAR: number;
  98730. /**
  98731. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  98732. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98733. */
  98734. static MinDeltaTime: number;
  98735. /**
  98736. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  98737. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98738. */
  98739. static MaxDeltaTime: number;
  98740. /**
  98741. * Factory used to create the default material.
  98742. * @param name The name of the material to create
  98743. * @param scene The scene to create the material for
  98744. * @returns The default material
  98745. */
  98746. static DefaultMaterialFactory(scene: Scene): Material;
  98747. /**
  98748. * Factory used to create the a collision coordinator.
  98749. * @returns The collision coordinator
  98750. */
  98751. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  98752. /** @hidden */
  98753. _inputManager: InputManager;
  98754. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  98755. cameraToUseForPointers: Nullable<Camera>;
  98756. /** @hidden */
  98757. readonly _isScene: boolean;
  98758. /**
  98759. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  98760. */
  98761. autoClear: boolean;
  98762. /**
  98763. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  98764. */
  98765. autoClearDepthAndStencil: boolean;
  98766. /**
  98767. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  98768. */
  98769. clearColor: Color4;
  98770. /**
  98771. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  98772. */
  98773. ambientColor: Color3;
  98774. /**
  98775. * This is use to store the default BRDF lookup for PBR materials in your scene.
  98776. * It should only be one of the following (if not the default embedded one):
  98777. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  98778. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  98779. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  98780. * The material properties need to be setup according to the type of texture in use.
  98781. */
  98782. environmentBRDFTexture: BaseTexture;
  98783. /** @hidden */
  98784. protected _environmentTexture: Nullable<BaseTexture>;
  98785. /**
  98786. * Texture used in all pbr material as the reflection texture.
  98787. * As in the majority of the scene they are the same (exception for multi room and so on),
  98788. * this is easier to reference from here than from all the materials.
  98789. */
  98790. /**
  98791. * Texture used in all pbr material as the reflection texture.
  98792. * As in the majority of the scene they are the same (exception for multi room and so on),
  98793. * this is easier to set here than in all the materials.
  98794. */
  98795. environmentTexture: Nullable<BaseTexture>;
  98796. /** @hidden */
  98797. protected _environmentIntensity: number;
  98798. /**
  98799. * Intensity of the environment in all pbr material.
  98800. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98801. * As in the majority of the scene they are the same (exception for multi room and so on),
  98802. * this is easier to reference from here than from all the materials.
  98803. */
  98804. /**
  98805. * Intensity of the environment in all pbr material.
  98806. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  98807. * As in the majority of the scene they are the same (exception for multi room and so on),
  98808. * this is easier to set here than in all the materials.
  98809. */
  98810. environmentIntensity: number;
  98811. /** @hidden */
  98812. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98813. /**
  98814. * Default image processing configuration used either in the rendering
  98815. * Forward main pass or through the imageProcessingPostProcess if present.
  98816. * As in the majority of the scene they are the same (exception for multi camera),
  98817. * this is easier to reference from here than from all the materials and post process.
  98818. *
  98819. * No setter as we it is a shared configuration, you can set the values instead.
  98820. */
  98821. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  98822. private _forceWireframe;
  98823. /**
  98824. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  98825. */
  98826. forceWireframe: boolean;
  98827. private _forcePointsCloud;
  98828. /**
  98829. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  98830. */
  98831. forcePointsCloud: boolean;
  98832. /**
  98833. * Gets or sets the active clipplane 1
  98834. */
  98835. clipPlane: Nullable<Plane>;
  98836. /**
  98837. * Gets or sets the active clipplane 2
  98838. */
  98839. clipPlane2: Nullable<Plane>;
  98840. /**
  98841. * Gets or sets the active clipplane 3
  98842. */
  98843. clipPlane3: Nullable<Plane>;
  98844. /**
  98845. * Gets or sets the active clipplane 4
  98846. */
  98847. clipPlane4: Nullable<Plane>;
  98848. /**
  98849. * Gets or sets a boolean indicating if animations are enabled
  98850. */
  98851. animationsEnabled: boolean;
  98852. private _animationPropertiesOverride;
  98853. /**
  98854. * Gets or sets the animation properties override
  98855. */
  98856. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  98857. /**
  98858. * Gets or sets a boolean indicating if a constant deltatime has to be used
  98859. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  98860. */
  98861. useConstantAnimationDeltaTime: boolean;
  98862. /**
  98863. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  98864. * Please note that it requires to run a ray cast through the scene on every frame
  98865. */
  98866. constantlyUpdateMeshUnderPointer: boolean;
  98867. /**
  98868. * Defines the HTML cursor to use when hovering over interactive elements
  98869. */
  98870. hoverCursor: string;
  98871. /**
  98872. * Defines the HTML default cursor to use (empty by default)
  98873. */
  98874. defaultCursor: string;
  98875. /**
  98876. * This is used to call preventDefault() on pointer down
  98877. * in order to block unwanted artifacts like system double clicks
  98878. */
  98879. preventDefaultOnPointerDown: boolean;
  98880. /**
  98881. * This is used to call preventDefault() on pointer up
  98882. * in order to block unwanted artifacts like system double clicks
  98883. */
  98884. preventDefaultOnPointerUp: boolean;
  98885. /**
  98886. * Gets or sets user defined metadata
  98887. */
  98888. metadata: any;
  98889. /**
  98890. * For internal use only. Please do not use.
  98891. */
  98892. reservedDataStore: any;
  98893. /**
  98894. * Gets the name of the plugin used to load this scene (null by default)
  98895. */
  98896. loadingPluginName: string;
  98897. /**
  98898. * Use this array to add regular expressions used to disable offline support for specific urls
  98899. */
  98900. disableOfflineSupportExceptionRules: RegExp[];
  98901. /**
  98902. * An event triggered when the scene is disposed.
  98903. */
  98904. onDisposeObservable: Observable<Scene>;
  98905. private _onDisposeObserver;
  98906. /** Sets a function to be executed when this scene is disposed. */
  98907. onDispose: () => void;
  98908. /**
  98909. * An event triggered before rendering the scene (right after animations and physics)
  98910. */
  98911. onBeforeRenderObservable: Observable<Scene>;
  98912. private _onBeforeRenderObserver;
  98913. /** Sets a function to be executed before rendering this scene */
  98914. beforeRender: Nullable<() => void>;
  98915. /**
  98916. * An event triggered after rendering the scene
  98917. */
  98918. onAfterRenderObservable: Observable<Scene>;
  98919. /**
  98920. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  98921. */
  98922. onAfterRenderCameraObservable: Observable<Camera>;
  98923. private _onAfterRenderObserver;
  98924. /** Sets a function to be executed after rendering this scene */
  98925. afterRender: Nullable<() => void>;
  98926. /**
  98927. * An event triggered before animating the scene
  98928. */
  98929. onBeforeAnimationsObservable: Observable<Scene>;
  98930. /**
  98931. * An event triggered after animations processing
  98932. */
  98933. onAfterAnimationsObservable: Observable<Scene>;
  98934. /**
  98935. * An event triggered before draw calls are ready to be sent
  98936. */
  98937. onBeforeDrawPhaseObservable: Observable<Scene>;
  98938. /**
  98939. * An event triggered after draw calls have been sent
  98940. */
  98941. onAfterDrawPhaseObservable: Observable<Scene>;
  98942. /**
  98943. * An event triggered when the scene is ready
  98944. */
  98945. onReadyObservable: Observable<Scene>;
  98946. /**
  98947. * An event triggered before rendering a camera
  98948. */
  98949. onBeforeCameraRenderObservable: Observable<Camera>;
  98950. private _onBeforeCameraRenderObserver;
  98951. /** Sets a function to be executed before rendering a camera*/
  98952. beforeCameraRender: () => void;
  98953. /**
  98954. * An event triggered after rendering a camera
  98955. */
  98956. onAfterCameraRenderObservable: Observable<Camera>;
  98957. private _onAfterCameraRenderObserver;
  98958. /** Sets a function to be executed after rendering a camera*/
  98959. afterCameraRender: () => void;
  98960. /**
  98961. * An event triggered when active meshes evaluation is about to start
  98962. */
  98963. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  98964. /**
  98965. * An event triggered when active meshes evaluation is done
  98966. */
  98967. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  98968. /**
  98969. * An event triggered when particles rendering is about to start
  98970. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98971. */
  98972. onBeforeParticlesRenderingObservable: Observable<Scene>;
  98973. /**
  98974. * An event triggered when particles rendering is done
  98975. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  98976. */
  98977. onAfterParticlesRenderingObservable: Observable<Scene>;
  98978. /**
  98979. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  98980. */
  98981. onDataLoadedObservable: Observable<Scene>;
  98982. /**
  98983. * An event triggered when a camera is created
  98984. */
  98985. onNewCameraAddedObservable: Observable<Camera>;
  98986. /**
  98987. * An event triggered when a camera is removed
  98988. */
  98989. onCameraRemovedObservable: Observable<Camera>;
  98990. /**
  98991. * An event triggered when a light is created
  98992. */
  98993. onNewLightAddedObservable: Observable<Light>;
  98994. /**
  98995. * An event triggered when a light is removed
  98996. */
  98997. onLightRemovedObservable: Observable<Light>;
  98998. /**
  98999. * An event triggered when a geometry is created
  99000. */
  99001. onNewGeometryAddedObservable: Observable<Geometry>;
  99002. /**
  99003. * An event triggered when a geometry is removed
  99004. */
  99005. onGeometryRemovedObservable: Observable<Geometry>;
  99006. /**
  99007. * An event triggered when a transform node is created
  99008. */
  99009. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  99010. /**
  99011. * An event triggered when a transform node is removed
  99012. */
  99013. onTransformNodeRemovedObservable: Observable<TransformNode>;
  99014. /**
  99015. * An event triggered when a mesh is created
  99016. */
  99017. onNewMeshAddedObservable: Observable<AbstractMesh>;
  99018. /**
  99019. * An event triggered when a mesh is removed
  99020. */
  99021. onMeshRemovedObservable: Observable<AbstractMesh>;
  99022. /**
  99023. * An event triggered when a skeleton is created
  99024. */
  99025. onNewSkeletonAddedObservable: Observable<Skeleton>;
  99026. /**
  99027. * An event triggered when a skeleton is removed
  99028. */
  99029. onSkeletonRemovedObservable: Observable<Skeleton>;
  99030. /**
  99031. * An event triggered when a material is created
  99032. */
  99033. onNewMaterialAddedObservable: Observable<Material>;
  99034. /**
  99035. * An event triggered when a material is removed
  99036. */
  99037. onMaterialRemovedObservable: Observable<Material>;
  99038. /**
  99039. * An event triggered when a texture is created
  99040. */
  99041. onNewTextureAddedObservable: Observable<BaseTexture>;
  99042. /**
  99043. * An event triggered when a texture is removed
  99044. */
  99045. onTextureRemovedObservable: Observable<BaseTexture>;
  99046. /**
  99047. * An event triggered when render targets are about to be rendered
  99048. * Can happen multiple times per frame.
  99049. */
  99050. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  99051. /**
  99052. * An event triggered when render targets were rendered.
  99053. * Can happen multiple times per frame.
  99054. */
  99055. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  99056. /**
  99057. * An event triggered before calculating deterministic simulation step
  99058. */
  99059. onBeforeStepObservable: Observable<Scene>;
  99060. /**
  99061. * An event triggered after calculating deterministic simulation step
  99062. */
  99063. onAfterStepObservable: Observable<Scene>;
  99064. /**
  99065. * An event triggered when the activeCamera property is updated
  99066. */
  99067. onActiveCameraChanged: Observable<Scene>;
  99068. /**
  99069. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  99070. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  99071. * 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)
  99072. */
  99073. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  99074. /**
  99075. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  99076. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  99077. * 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)
  99078. */
  99079. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  99080. /**
  99081. * This Observable will when a mesh has been imported into the scene.
  99082. */
  99083. onMeshImportedObservable: Observable<AbstractMesh>;
  99084. /**
  99085. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  99086. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  99087. */
  99088. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  99089. /** @hidden */
  99090. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  99091. /**
  99092. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  99093. */
  99094. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  99095. /**
  99096. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  99097. */
  99098. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  99099. /**
  99100. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  99101. */
  99102. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  99103. /** Callback called when a pointer move is detected */
  99104. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  99105. /** Callback called when a pointer down is detected */
  99106. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  99107. /** Callback called when a pointer up is detected */
  99108. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  99109. /** Callback called when a pointer pick is detected */
  99110. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  99111. /**
  99112. * 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).
  99113. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  99114. */
  99115. onPrePointerObservable: Observable<PointerInfoPre>;
  99116. /**
  99117. * Observable event triggered each time an input event is received from the rendering canvas
  99118. */
  99119. onPointerObservable: Observable<PointerInfo>;
  99120. /**
  99121. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  99122. */
  99123. readonly unTranslatedPointer: Vector2;
  99124. /**
  99125. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  99126. */
  99127. static DragMovementThreshold: number;
  99128. /**
  99129. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  99130. */
  99131. static LongPressDelay: number;
  99132. /**
  99133. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  99134. */
  99135. static DoubleClickDelay: number;
  99136. /** If you need to check double click without raising a single click at first click, enable this flag */
  99137. static ExclusiveDoubleClickMode: boolean;
  99138. /** @hidden */
  99139. _mirroredCameraPosition: Nullable<Vector3>;
  99140. /**
  99141. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  99142. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  99143. */
  99144. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  99145. /**
  99146. * Observable event triggered each time an keyboard event is received from the hosting window
  99147. */
  99148. onKeyboardObservable: Observable<KeyboardInfo>;
  99149. private _useRightHandedSystem;
  99150. /**
  99151. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  99152. */
  99153. useRightHandedSystem: boolean;
  99154. private _timeAccumulator;
  99155. private _currentStepId;
  99156. private _currentInternalStep;
  99157. /**
  99158. * Sets the step Id used by deterministic lock step
  99159. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99160. * @param newStepId defines the step Id
  99161. */
  99162. setStepId(newStepId: number): void;
  99163. /**
  99164. * Gets the step Id used by deterministic lock step
  99165. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99166. * @returns the step Id
  99167. */
  99168. getStepId(): number;
  99169. /**
  99170. * Gets the internal step used by deterministic lock step
  99171. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99172. * @returns the internal step
  99173. */
  99174. getInternalStep(): number;
  99175. private _fogEnabled;
  99176. /**
  99177. * Gets or sets a boolean indicating if fog is enabled on this scene
  99178. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99179. * (Default is true)
  99180. */
  99181. fogEnabled: boolean;
  99182. private _fogMode;
  99183. /**
  99184. * Gets or sets the fog mode to use
  99185. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99186. * | mode | value |
  99187. * | --- | --- |
  99188. * | FOGMODE_NONE | 0 |
  99189. * | FOGMODE_EXP | 1 |
  99190. * | FOGMODE_EXP2 | 2 |
  99191. * | FOGMODE_LINEAR | 3 |
  99192. */
  99193. fogMode: number;
  99194. /**
  99195. * Gets or sets the fog color to use
  99196. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99197. * (Default is Color3(0.2, 0.2, 0.3))
  99198. */
  99199. fogColor: Color3;
  99200. /**
  99201. * Gets or sets the fog density to use
  99202. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99203. * (Default is 0.1)
  99204. */
  99205. fogDensity: number;
  99206. /**
  99207. * Gets or sets the fog start distance to use
  99208. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99209. * (Default is 0)
  99210. */
  99211. fogStart: number;
  99212. /**
  99213. * Gets or sets the fog end distance to use
  99214. * @see http://doc.babylonjs.com/babylon101/environment#fog
  99215. * (Default is 1000)
  99216. */
  99217. fogEnd: number;
  99218. private _shadowsEnabled;
  99219. /**
  99220. * Gets or sets a boolean indicating if shadows are enabled on this scene
  99221. */
  99222. shadowsEnabled: boolean;
  99223. private _lightsEnabled;
  99224. /**
  99225. * Gets or sets a boolean indicating if lights are enabled on this scene
  99226. */
  99227. lightsEnabled: boolean;
  99228. /** All of the active cameras added to this scene. */
  99229. activeCameras: Camera[];
  99230. /** @hidden */
  99231. _activeCamera: Nullable<Camera>;
  99232. /** Gets or sets the current active camera */
  99233. activeCamera: Nullable<Camera>;
  99234. private _defaultMaterial;
  99235. /** The default material used on meshes when no material is affected */
  99236. /** The default material used on meshes when no material is affected */
  99237. defaultMaterial: Material;
  99238. private _texturesEnabled;
  99239. /**
  99240. * Gets or sets a boolean indicating if textures are enabled on this scene
  99241. */
  99242. texturesEnabled: boolean;
  99243. /**
  99244. * Gets or sets a boolean indicating if particles are enabled on this scene
  99245. */
  99246. particlesEnabled: boolean;
  99247. /**
  99248. * Gets or sets a boolean indicating if sprites are enabled on this scene
  99249. */
  99250. spritesEnabled: boolean;
  99251. private _skeletonsEnabled;
  99252. /**
  99253. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  99254. */
  99255. skeletonsEnabled: boolean;
  99256. /**
  99257. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  99258. */
  99259. lensFlaresEnabled: boolean;
  99260. /**
  99261. * Gets or sets a boolean indicating if collisions are enabled on this scene
  99262. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99263. */
  99264. collisionsEnabled: boolean;
  99265. private _collisionCoordinator;
  99266. /** @hidden */
  99267. readonly collisionCoordinator: ICollisionCoordinator;
  99268. /**
  99269. * Defines the gravity applied to this scene (used only for collisions)
  99270. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99271. */
  99272. gravity: Vector3;
  99273. /**
  99274. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  99275. */
  99276. postProcessesEnabled: boolean;
  99277. /**
  99278. * The list of postprocesses added to the scene
  99279. */
  99280. postProcesses: PostProcess[];
  99281. /**
  99282. * Gets the current postprocess manager
  99283. */
  99284. postProcessManager: PostProcessManager;
  99285. /**
  99286. * Gets or sets a boolean indicating if render targets are enabled on this scene
  99287. */
  99288. renderTargetsEnabled: boolean;
  99289. /**
  99290. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  99291. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  99292. */
  99293. dumpNextRenderTargets: boolean;
  99294. /**
  99295. * The list of user defined render targets added to the scene
  99296. */
  99297. customRenderTargets: RenderTargetTexture[];
  99298. /**
  99299. * Defines if texture loading must be delayed
  99300. * If true, textures will only be loaded when they need to be rendered
  99301. */
  99302. useDelayedTextureLoading: boolean;
  99303. /**
  99304. * Gets the list of meshes imported to the scene through SceneLoader
  99305. */
  99306. importedMeshesFiles: String[];
  99307. /**
  99308. * Gets or sets a boolean indicating if probes are enabled on this scene
  99309. */
  99310. probesEnabled: boolean;
  99311. /**
  99312. * Gets or sets the current offline provider to use to store scene data
  99313. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  99314. */
  99315. offlineProvider: IOfflineProvider;
  99316. /**
  99317. * Gets or sets the action manager associated with the scene
  99318. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99319. */
  99320. actionManager: AbstractActionManager;
  99321. private _meshesForIntersections;
  99322. /**
  99323. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  99324. */
  99325. proceduralTexturesEnabled: boolean;
  99326. private _engine;
  99327. private _totalVertices;
  99328. /** @hidden */
  99329. _activeIndices: PerfCounter;
  99330. /** @hidden */
  99331. _activeParticles: PerfCounter;
  99332. /** @hidden */
  99333. _activeBones: PerfCounter;
  99334. private _animationRatio;
  99335. /** @hidden */
  99336. _animationTimeLast: number;
  99337. /** @hidden */
  99338. _animationTime: number;
  99339. /**
  99340. * Gets or sets a general scale for animation speed
  99341. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  99342. */
  99343. animationTimeScale: number;
  99344. /** @hidden */
  99345. _cachedMaterial: Nullable<Material>;
  99346. /** @hidden */
  99347. _cachedEffect: Nullable<Effect>;
  99348. /** @hidden */
  99349. _cachedVisibility: Nullable<number>;
  99350. private _renderId;
  99351. private _frameId;
  99352. private _executeWhenReadyTimeoutId;
  99353. private _intermediateRendering;
  99354. private _viewUpdateFlag;
  99355. private _projectionUpdateFlag;
  99356. /** @hidden */
  99357. _toBeDisposed: Nullable<IDisposable>[];
  99358. private _activeRequests;
  99359. /** @hidden */
  99360. _pendingData: any[];
  99361. private _isDisposed;
  99362. /**
  99363. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  99364. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  99365. */
  99366. dispatchAllSubMeshesOfActiveMeshes: boolean;
  99367. private _activeMeshes;
  99368. private _processedMaterials;
  99369. private _renderTargets;
  99370. /** @hidden */
  99371. _activeParticleSystems: SmartArray<IParticleSystem>;
  99372. private _activeSkeletons;
  99373. private _softwareSkinnedMeshes;
  99374. private _renderingManager;
  99375. /** @hidden */
  99376. _activeAnimatables: Animatable[];
  99377. private _transformMatrix;
  99378. private _sceneUbo;
  99379. /** @hidden */
  99380. _viewMatrix: Matrix;
  99381. private _projectionMatrix;
  99382. /** @hidden */
  99383. _forcedViewPosition: Nullable<Vector3>;
  99384. /** @hidden */
  99385. _frustumPlanes: Plane[];
  99386. /**
  99387. * Gets the list of frustum planes (built from the active camera)
  99388. */
  99389. readonly frustumPlanes: Plane[];
  99390. /**
  99391. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  99392. * This is useful if there are more lights that the maximum simulteanous authorized
  99393. */
  99394. requireLightSorting: boolean;
  99395. /** @hidden */
  99396. readonly useMaterialMeshMap: boolean;
  99397. /** @hidden */
  99398. readonly useClonedMeshhMap: boolean;
  99399. private _externalData;
  99400. private _uid;
  99401. /**
  99402. * @hidden
  99403. * Backing store of defined scene components.
  99404. */
  99405. _components: ISceneComponent[];
  99406. /**
  99407. * @hidden
  99408. * Backing store of defined scene components.
  99409. */
  99410. _serializableComponents: ISceneSerializableComponent[];
  99411. /**
  99412. * List of components to register on the next registration step.
  99413. */
  99414. private _transientComponents;
  99415. /**
  99416. * Registers the transient components if needed.
  99417. */
  99418. private _registerTransientComponents;
  99419. /**
  99420. * @hidden
  99421. * Add a component to the scene.
  99422. * Note that the ccomponent could be registered on th next frame if this is called after
  99423. * the register component stage.
  99424. * @param component Defines the component to add to the scene
  99425. */
  99426. _addComponent(component: ISceneComponent): void;
  99427. /**
  99428. * @hidden
  99429. * Gets a component from the scene.
  99430. * @param name defines the name of the component to retrieve
  99431. * @returns the component or null if not present
  99432. */
  99433. _getComponent(name: string): Nullable<ISceneComponent>;
  99434. /**
  99435. * @hidden
  99436. * Defines the actions happening before camera updates.
  99437. */
  99438. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  99439. /**
  99440. * @hidden
  99441. * Defines the actions happening before clear the canvas.
  99442. */
  99443. _beforeClearStage: Stage<SimpleStageAction>;
  99444. /**
  99445. * @hidden
  99446. * Defines the actions when collecting render targets for the frame.
  99447. */
  99448. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99449. /**
  99450. * @hidden
  99451. * Defines the actions happening for one camera in the frame.
  99452. */
  99453. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  99454. /**
  99455. * @hidden
  99456. * Defines the actions happening during the per mesh ready checks.
  99457. */
  99458. _isReadyForMeshStage: Stage<MeshStageAction>;
  99459. /**
  99460. * @hidden
  99461. * Defines the actions happening before evaluate active mesh checks.
  99462. */
  99463. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  99464. /**
  99465. * @hidden
  99466. * Defines the actions happening during the evaluate sub mesh checks.
  99467. */
  99468. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  99469. /**
  99470. * @hidden
  99471. * Defines the actions happening during the active mesh stage.
  99472. */
  99473. _activeMeshStage: Stage<ActiveMeshStageAction>;
  99474. /**
  99475. * @hidden
  99476. * Defines the actions happening during the per camera render target step.
  99477. */
  99478. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  99479. /**
  99480. * @hidden
  99481. * Defines the actions happening just before the active camera is drawing.
  99482. */
  99483. _beforeCameraDrawStage: Stage<CameraStageAction>;
  99484. /**
  99485. * @hidden
  99486. * Defines the actions happening just before a render target is drawing.
  99487. */
  99488. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99489. /**
  99490. * @hidden
  99491. * Defines the actions happening just before a rendering group is drawing.
  99492. */
  99493. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99494. /**
  99495. * @hidden
  99496. * Defines the actions happening just before a mesh is drawing.
  99497. */
  99498. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99499. /**
  99500. * @hidden
  99501. * Defines the actions happening just after a mesh has been drawn.
  99502. */
  99503. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  99504. /**
  99505. * @hidden
  99506. * Defines the actions happening just after a rendering group has been drawn.
  99507. */
  99508. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  99509. /**
  99510. * @hidden
  99511. * Defines the actions happening just after the active camera has been drawn.
  99512. */
  99513. _afterCameraDrawStage: Stage<CameraStageAction>;
  99514. /**
  99515. * @hidden
  99516. * Defines the actions happening just after a render target has been drawn.
  99517. */
  99518. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  99519. /**
  99520. * @hidden
  99521. * Defines the actions happening just after rendering all cameras and computing intersections.
  99522. */
  99523. _afterRenderStage: Stage<SimpleStageAction>;
  99524. /**
  99525. * @hidden
  99526. * Defines the actions happening when a pointer move event happens.
  99527. */
  99528. _pointerMoveStage: Stage<PointerMoveStageAction>;
  99529. /**
  99530. * @hidden
  99531. * Defines the actions happening when a pointer down event happens.
  99532. */
  99533. _pointerDownStage: Stage<PointerUpDownStageAction>;
  99534. /**
  99535. * @hidden
  99536. * Defines the actions happening when a pointer up event happens.
  99537. */
  99538. _pointerUpStage: Stage<PointerUpDownStageAction>;
  99539. /**
  99540. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  99541. */
  99542. private geometriesByUniqueId;
  99543. /**
  99544. * Creates a new Scene
  99545. * @param engine defines the engine to use to render this scene
  99546. * @param options defines the scene options
  99547. */
  99548. constructor(engine: Engine, options?: SceneOptions);
  99549. /**
  99550. * Gets a string idenfifying the name of the class
  99551. * @returns "Scene" string
  99552. */
  99553. getClassName(): string;
  99554. private _defaultMeshCandidates;
  99555. /**
  99556. * @hidden
  99557. */
  99558. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99559. private _defaultSubMeshCandidates;
  99560. /**
  99561. * @hidden
  99562. */
  99563. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99564. /**
  99565. * Sets the default candidate providers for the scene.
  99566. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  99567. * and getCollidingSubMeshCandidates to their default function
  99568. */
  99569. setDefaultCandidateProviders(): void;
  99570. /**
  99571. * Gets the mesh that is currently under the pointer
  99572. */
  99573. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99574. /**
  99575. * Gets or sets the current on-screen X position of the pointer
  99576. */
  99577. pointerX: number;
  99578. /**
  99579. * Gets or sets the current on-screen Y position of the pointer
  99580. */
  99581. pointerY: number;
  99582. /**
  99583. * Gets the cached material (ie. the latest rendered one)
  99584. * @returns the cached material
  99585. */
  99586. getCachedMaterial(): Nullable<Material>;
  99587. /**
  99588. * Gets the cached effect (ie. the latest rendered one)
  99589. * @returns the cached effect
  99590. */
  99591. getCachedEffect(): Nullable<Effect>;
  99592. /**
  99593. * Gets the cached visibility state (ie. the latest rendered one)
  99594. * @returns the cached visibility state
  99595. */
  99596. getCachedVisibility(): Nullable<number>;
  99597. /**
  99598. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  99599. * @param material defines the current material
  99600. * @param effect defines the current effect
  99601. * @param visibility defines the current visibility state
  99602. * @returns true if one parameter is not cached
  99603. */
  99604. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  99605. /**
  99606. * Gets the engine associated with the scene
  99607. * @returns an Engine
  99608. */
  99609. getEngine(): Engine;
  99610. /**
  99611. * Gets the total number of vertices rendered per frame
  99612. * @returns the total number of vertices rendered per frame
  99613. */
  99614. getTotalVertices(): number;
  99615. /**
  99616. * Gets the performance counter for total vertices
  99617. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99618. */
  99619. readonly totalVerticesPerfCounter: PerfCounter;
  99620. /**
  99621. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  99622. * @returns the total number of active indices rendered per frame
  99623. */
  99624. getActiveIndices(): number;
  99625. /**
  99626. * Gets the performance counter for active indices
  99627. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99628. */
  99629. readonly totalActiveIndicesPerfCounter: PerfCounter;
  99630. /**
  99631. * Gets the total number of active particles rendered per frame
  99632. * @returns the total number of active particles rendered per frame
  99633. */
  99634. getActiveParticles(): number;
  99635. /**
  99636. * Gets the performance counter for active particles
  99637. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99638. */
  99639. readonly activeParticlesPerfCounter: PerfCounter;
  99640. /**
  99641. * Gets the total number of active bones rendered per frame
  99642. * @returns the total number of active bones rendered per frame
  99643. */
  99644. getActiveBones(): number;
  99645. /**
  99646. * Gets the performance counter for active bones
  99647. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  99648. */
  99649. readonly activeBonesPerfCounter: PerfCounter;
  99650. /**
  99651. * Gets the array of active meshes
  99652. * @returns an array of AbstractMesh
  99653. */
  99654. getActiveMeshes(): SmartArray<AbstractMesh>;
  99655. /**
  99656. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  99657. * @returns a number
  99658. */
  99659. getAnimationRatio(): number;
  99660. /**
  99661. * Gets an unique Id for the current render phase
  99662. * @returns a number
  99663. */
  99664. getRenderId(): number;
  99665. /**
  99666. * Gets an unique Id for the current frame
  99667. * @returns a number
  99668. */
  99669. getFrameId(): number;
  99670. /** Call this function if you want to manually increment the render Id*/
  99671. incrementRenderId(): void;
  99672. private _createUbo;
  99673. /**
  99674. * Use this method to simulate a pointer move on a mesh
  99675. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99676. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99677. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99678. * @returns the current scene
  99679. */
  99680. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99681. /**
  99682. * Use this method to simulate a pointer down on a mesh
  99683. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99684. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99685. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99686. * @returns the current scene
  99687. */
  99688. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  99689. /**
  99690. * Use this method to simulate a pointer up on a mesh
  99691. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99692. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99693. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99694. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99695. * @returns the current scene
  99696. */
  99697. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  99698. /**
  99699. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99700. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99701. * @returns true if the pointer was captured
  99702. */
  99703. isPointerCaptured(pointerId?: number): boolean;
  99704. /**
  99705. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99706. * @param attachUp defines if you want to attach events to pointerup
  99707. * @param attachDown defines if you want to attach events to pointerdown
  99708. * @param attachMove defines if you want to attach events to pointermove
  99709. */
  99710. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99711. /** Detaches all event handlers*/
  99712. detachControl(): void;
  99713. /**
  99714. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  99715. * Delay loaded resources are not taking in account
  99716. * @return true if all required resources are ready
  99717. */
  99718. isReady(): boolean;
  99719. /** Resets all cached information relative to material (including effect and visibility) */
  99720. resetCachedMaterial(): void;
  99721. /**
  99722. * Registers a function to be called before every frame render
  99723. * @param func defines the function to register
  99724. */
  99725. registerBeforeRender(func: () => void): void;
  99726. /**
  99727. * Unregisters a function called before every frame render
  99728. * @param func defines the function to unregister
  99729. */
  99730. unregisterBeforeRender(func: () => void): void;
  99731. /**
  99732. * Registers a function to be called after every frame render
  99733. * @param func defines the function to register
  99734. */
  99735. registerAfterRender(func: () => void): void;
  99736. /**
  99737. * Unregisters a function called after every frame render
  99738. * @param func defines the function to unregister
  99739. */
  99740. unregisterAfterRender(func: () => void): void;
  99741. private _executeOnceBeforeRender;
  99742. /**
  99743. * The provided function will run before render once and will be disposed afterwards.
  99744. * A timeout delay can be provided so that the function will be executed in N ms.
  99745. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  99746. * @param func The function to be executed.
  99747. * @param timeout optional delay in ms
  99748. */
  99749. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  99750. /** @hidden */
  99751. _addPendingData(data: any): void;
  99752. /** @hidden */
  99753. _removePendingData(data: any): void;
  99754. /**
  99755. * Returns the number of items waiting to be loaded
  99756. * @returns the number of items waiting to be loaded
  99757. */
  99758. getWaitingItemsCount(): number;
  99759. /**
  99760. * Returns a boolean indicating if the scene is still loading data
  99761. */
  99762. readonly isLoading: boolean;
  99763. /**
  99764. * Registers a function to be executed when the scene is ready
  99765. * @param {Function} func - the function to be executed
  99766. */
  99767. executeWhenReady(func: () => void): void;
  99768. /**
  99769. * Returns a promise that resolves when the scene is ready
  99770. * @returns A promise that resolves when the scene is ready
  99771. */
  99772. whenReadyAsync(): Promise<void>;
  99773. /** @hidden */
  99774. _checkIsReady(): void;
  99775. /**
  99776. * Gets all animatable attached to the scene
  99777. */
  99778. readonly animatables: Animatable[];
  99779. /**
  99780. * Resets the last animation time frame.
  99781. * Useful to override when animations start running when loading a scene for the first time.
  99782. */
  99783. resetLastAnimationTimeFrame(): void;
  99784. /**
  99785. * Gets the current view matrix
  99786. * @returns a Matrix
  99787. */
  99788. getViewMatrix(): Matrix;
  99789. /**
  99790. * Gets the current projection matrix
  99791. * @returns a Matrix
  99792. */
  99793. getProjectionMatrix(): Matrix;
  99794. /**
  99795. * Gets the current transform matrix
  99796. * @returns a Matrix made of View * Projection
  99797. */
  99798. getTransformMatrix(): Matrix;
  99799. /**
  99800. * Sets the current transform matrix
  99801. * @param viewL defines the View matrix to use
  99802. * @param projectionL defines the Projection matrix to use
  99803. * @param viewR defines the right View matrix to use (if provided)
  99804. * @param projectionR defines the right Projection matrix to use (if provided)
  99805. */
  99806. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  99807. /**
  99808. * Gets the uniform buffer used to store scene data
  99809. * @returns a UniformBuffer
  99810. */
  99811. getSceneUniformBuffer(): UniformBuffer;
  99812. /**
  99813. * Gets an unique (relatively to the current scene) Id
  99814. * @returns an unique number for the scene
  99815. */
  99816. getUniqueId(): number;
  99817. /**
  99818. * Add a mesh to the list of scene's meshes
  99819. * @param newMesh defines the mesh to add
  99820. * @param recursive if all child meshes should also be added to the scene
  99821. */
  99822. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  99823. /**
  99824. * Remove a mesh for the list of scene's meshes
  99825. * @param toRemove defines the mesh to remove
  99826. * @param recursive if all child meshes should also be removed from the scene
  99827. * @returns the index where the mesh was in the mesh list
  99828. */
  99829. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  99830. /**
  99831. * Add a transform node to the list of scene's transform nodes
  99832. * @param newTransformNode defines the transform node to add
  99833. */
  99834. addTransformNode(newTransformNode: TransformNode): void;
  99835. /**
  99836. * Remove a transform node for the list of scene's transform nodes
  99837. * @param toRemove defines the transform node to remove
  99838. * @returns the index where the transform node was in the transform node list
  99839. */
  99840. removeTransformNode(toRemove: TransformNode): number;
  99841. /**
  99842. * Remove a skeleton for the list of scene's skeletons
  99843. * @param toRemove defines the skeleton to remove
  99844. * @returns the index where the skeleton was in the skeleton list
  99845. */
  99846. removeSkeleton(toRemove: Skeleton): number;
  99847. /**
  99848. * Remove a morph target for the list of scene's morph targets
  99849. * @param toRemove defines the morph target to remove
  99850. * @returns the index where the morph target was in the morph target list
  99851. */
  99852. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  99853. /**
  99854. * Remove a light for the list of scene's lights
  99855. * @param toRemove defines the light to remove
  99856. * @returns the index where the light was in the light list
  99857. */
  99858. removeLight(toRemove: Light): number;
  99859. /**
  99860. * Remove a camera for the list of scene's cameras
  99861. * @param toRemove defines the camera to remove
  99862. * @returns the index where the camera was in the camera list
  99863. */
  99864. removeCamera(toRemove: Camera): number;
  99865. /**
  99866. * Remove a particle system for the list of scene's particle systems
  99867. * @param toRemove defines the particle system to remove
  99868. * @returns the index where the particle system was in the particle system list
  99869. */
  99870. removeParticleSystem(toRemove: IParticleSystem): number;
  99871. /**
  99872. * Remove a animation for the list of scene's animations
  99873. * @param toRemove defines the animation to remove
  99874. * @returns the index where the animation was in the animation list
  99875. */
  99876. removeAnimation(toRemove: Animation): number;
  99877. /**
  99878. * Will stop the animation of the given target
  99879. * @param target - the target
  99880. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  99881. * @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)
  99882. */
  99883. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  99884. /**
  99885. * Removes the given animation group from this scene.
  99886. * @param toRemove The animation group to remove
  99887. * @returns The index of the removed animation group
  99888. */
  99889. removeAnimationGroup(toRemove: AnimationGroup): number;
  99890. /**
  99891. * Removes the given multi-material from this scene.
  99892. * @param toRemove The multi-material to remove
  99893. * @returns The index of the removed multi-material
  99894. */
  99895. removeMultiMaterial(toRemove: MultiMaterial): number;
  99896. /**
  99897. * Removes the given material from this scene.
  99898. * @param toRemove The material to remove
  99899. * @returns The index of the removed material
  99900. */
  99901. removeMaterial(toRemove: Material): number;
  99902. /**
  99903. * Removes the given action manager from this scene.
  99904. * @param toRemove The action manager to remove
  99905. * @returns The index of the removed action manager
  99906. */
  99907. removeActionManager(toRemove: AbstractActionManager): number;
  99908. /**
  99909. * Removes the given texture from this scene.
  99910. * @param toRemove The texture to remove
  99911. * @returns The index of the removed texture
  99912. */
  99913. removeTexture(toRemove: BaseTexture): number;
  99914. /**
  99915. * Adds the given light to this scene
  99916. * @param newLight The light to add
  99917. */
  99918. addLight(newLight: Light): void;
  99919. /**
  99920. * Sorts the list list based on light priorities
  99921. */
  99922. sortLightsByPriority(): void;
  99923. /**
  99924. * Adds the given camera to this scene
  99925. * @param newCamera The camera to add
  99926. */
  99927. addCamera(newCamera: Camera): void;
  99928. /**
  99929. * Adds the given skeleton to this scene
  99930. * @param newSkeleton The skeleton to add
  99931. */
  99932. addSkeleton(newSkeleton: Skeleton): void;
  99933. /**
  99934. * Adds the given particle system to this scene
  99935. * @param newParticleSystem The particle system to add
  99936. */
  99937. addParticleSystem(newParticleSystem: IParticleSystem): void;
  99938. /**
  99939. * Adds the given animation to this scene
  99940. * @param newAnimation The animation to add
  99941. */
  99942. addAnimation(newAnimation: Animation): void;
  99943. /**
  99944. * Adds the given animation group to this scene.
  99945. * @param newAnimationGroup The animation group to add
  99946. */
  99947. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  99948. /**
  99949. * Adds the given multi-material to this scene
  99950. * @param newMultiMaterial The multi-material to add
  99951. */
  99952. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  99953. /**
  99954. * Adds the given material to this scene
  99955. * @param newMaterial The material to add
  99956. */
  99957. addMaterial(newMaterial: Material): void;
  99958. /**
  99959. * Adds the given morph target to this scene
  99960. * @param newMorphTargetManager The morph target to add
  99961. */
  99962. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  99963. /**
  99964. * Adds the given geometry to this scene
  99965. * @param newGeometry The geometry to add
  99966. */
  99967. addGeometry(newGeometry: Geometry): void;
  99968. /**
  99969. * Adds the given action manager to this scene
  99970. * @param newActionManager The action manager to add
  99971. */
  99972. addActionManager(newActionManager: AbstractActionManager): void;
  99973. /**
  99974. * Adds the given texture to this scene.
  99975. * @param newTexture The texture to add
  99976. */
  99977. addTexture(newTexture: BaseTexture): void;
  99978. /**
  99979. * Switch active camera
  99980. * @param newCamera defines the new active camera
  99981. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  99982. */
  99983. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  99984. /**
  99985. * sets the active camera of the scene using its ID
  99986. * @param id defines the camera's ID
  99987. * @return the new active camera or null if none found.
  99988. */
  99989. setActiveCameraByID(id: string): Nullable<Camera>;
  99990. /**
  99991. * sets the active camera of the scene using its name
  99992. * @param name defines the camera's name
  99993. * @returns the new active camera or null if none found.
  99994. */
  99995. setActiveCameraByName(name: string): Nullable<Camera>;
  99996. /**
  99997. * get an animation group using its name
  99998. * @param name defines the material's name
  99999. * @return the animation group or null if none found.
  100000. */
  100001. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  100002. /**
  100003. * Get a material using its unique id
  100004. * @param uniqueId defines the material's unique id
  100005. * @return the material or null if none found.
  100006. */
  100007. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  100008. /**
  100009. * get a material using its id
  100010. * @param id defines the material's ID
  100011. * @return the material or null if none found.
  100012. */
  100013. getMaterialByID(id: string): Nullable<Material>;
  100014. /**
  100015. * Gets a the last added material using a given id
  100016. * @param id defines the material's ID
  100017. * @return the last material with the given id or null if none found.
  100018. */
  100019. getLastMaterialByID(id: string): Nullable<Material>;
  100020. /**
  100021. * Gets a material using its name
  100022. * @param name defines the material's name
  100023. * @return the material or null if none found.
  100024. */
  100025. getMaterialByName(name: string): Nullable<Material>;
  100026. /**
  100027. * Get a texture using its unique id
  100028. * @param uniqueId defines the texture's unique id
  100029. * @return the texture or null if none found.
  100030. */
  100031. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  100032. /**
  100033. * Gets a camera using its id
  100034. * @param id defines the id to look for
  100035. * @returns the camera or null if not found
  100036. */
  100037. getCameraByID(id: string): Nullable<Camera>;
  100038. /**
  100039. * Gets a camera using its unique id
  100040. * @param uniqueId defines the unique id to look for
  100041. * @returns the camera or null if not found
  100042. */
  100043. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  100044. /**
  100045. * Gets a camera using its name
  100046. * @param name defines the camera's name
  100047. * @return the camera or null if none found.
  100048. */
  100049. getCameraByName(name: string): Nullable<Camera>;
  100050. /**
  100051. * Gets a bone using its id
  100052. * @param id defines the bone's id
  100053. * @return the bone or null if not found
  100054. */
  100055. getBoneByID(id: string): Nullable<Bone>;
  100056. /**
  100057. * Gets a bone using its id
  100058. * @param name defines the bone's name
  100059. * @return the bone or null if not found
  100060. */
  100061. getBoneByName(name: string): Nullable<Bone>;
  100062. /**
  100063. * Gets a light node using its name
  100064. * @param name defines the the light's name
  100065. * @return the light or null if none found.
  100066. */
  100067. getLightByName(name: string): Nullable<Light>;
  100068. /**
  100069. * Gets a light node using its id
  100070. * @param id defines the light's id
  100071. * @return the light or null if none found.
  100072. */
  100073. getLightByID(id: string): Nullable<Light>;
  100074. /**
  100075. * Gets a light node using its scene-generated unique ID
  100076. * @param uniqueId defines the light's unique id
  100077. * @return the light or null if none found.
  100078. */
  100079. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  100080. /**
  100081. * Gets a particle system by id
  100082. * @param id defines the particle system id
  100083. * @return the corresponding system or null if none found
  100084. */
  100085. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  100086. /**
  100087. * Gets a geometry using its ID
  100088. * @param id defines the geometry's id
  100089. * @return the geometry or null if none found.
  100090. */
  100091. getGeometryByID(id: string): Nullable<Geometry>;
  100092. private _getGeometryByUniqueID;
  100093. /**
  100094. * Add a new geometry to this scene
  100095. * @param geometry defines the geometry to be added to the scene.
  100096. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  100097. * @return a boolean defining if the geometry was added or not
  100098. */
  100099. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  100100. /**
  100101. * Removes an existing geometry
  100102. * @param geometry defines the geometry to be removed from the scene
  100103. * @return a boolean defining if the geometry was removed or not
  100104. */
  100105. removeGeometry(geometry: Geometry): boolean;
  100106. /**
  100107. * Gets the list of geometries attached to the scene
  100108. * @returns an array of Geometry
  100109. */
  100110. getGeometries(): Geometry[];
  100111. /**
  100112. * Gets the first added mesh found of a given ID
  100113. * @param id defines the id to search for
  100114. * @return the mesh found or null if not found at all
  100115. */
  100116. getMeshByID(id: string): Nullable<AbstractMesh>;
  100117. /**
  100118. * Gets a list of meshes using their id
  100119. * @param id defines the id to search for
  100120. * @returns a list of meshes
  100121. */
  100122. getMeshesByID(id: string): Array<AbstractMesh>;
  100123. /**
  100124. * Gets the first added transform node found of a given ID
  100125. * @param id defines the id to search for
  100126. * @return the found transform node or null if not found at all.
  100127. */
  100128. getTransformNodeByID(id: string): Nullable<TransformNode>;
  100129. /**
  100130. * Gets a transform node with its auto-generated unique id
  100131. * @param uniqueId efines the unique id to search for
  100132. * @return the found transform node or null if not found at all.
  100133. */
  100134. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  100135. /**
  100136. * Gets a list of transform nodes using their id
  100137. * @param id defines the id to search for
  100138. * @returns a list of transform nodes
  100139. */
  100140. getTransformNodesByID(id: string): Array<TransformNode>;
  100141. /**
  100142. * Gets a mesh with its auto-generated unique id
  100143. * @param uniqueId defines the unique id to search for
  100144. * @return the found mesh or null if not found at all.
  100145. */
  100146. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  100147. /**
  100148. * Gets a the last added mesh using a given id
  100149. * @param id defines the id to search for
  100150. * @return the found mesh or null if not found at all.
  100151. */
  100152. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  100153. /**
  100154. * Gets a the last added node (Mesh, Camera, Light) using a given id
  100155. * @param id defines the id to search for
  100156. * @return the found node or null if not found at all
  100157. */
  100158. getLastEntryByID(id: string): Nullable<Node>;
  100159. /**
  100160. * Gets a node (Mesh, Camera, Light) using a given id
  100161. * @param id defines the id to search for
  100162. * @return the found node or null if not found at all
  100163. */
  100164. getNodeByID(id: string): Nullable<Node>;
  100165. /**
  100166. * Gets a node (Mesh, Camera, Light) using a given name
  100167. * @param name defines the name to search for
  100168. * @return the found node or null if not found at all.
  100169. */
  100170. getNodeByName(name: string): Nullable<Node>;
  100171. /**
  100172. * Gets a mesh using a given name
  100173. * @param name defines the name to search for
  100174. * @return the found mesh or null if not found at all.
  100175. */
  100176. getMeshByName(name: string): Nullable<AbstractMesh>;
  100177. /**
  100178. * Gets a transform node using a given name
  100179. * @param name defines the name to search for
  100180. * @return the found transform node or null if not found at all.
  100181. */
  100182. getTransformNodeByName(name: string): Nullable<TransformNode>;
  100183. /**
  100184. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  100185. * @param id defines the id to search for
  100186. * @return the found skeleton or null if not found at all.
  100187. */
  100188. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  100189. /**
  100190. * Gets a skeleton using a given auto generated unique id
  100191. * @param uniqueId defines the unique id to search for
  100192. * @return the found skeleton or null if not found at all.
  100193. */
  100194. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  100195. /**
  100196. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  100197. * @param id defines the id to search for
  100198. * @return the found skeleton or null if not found at all.
  100199. */
  100200. getSkeletonById(id: string): Nullable<Skeleton>;
  100201. /**
  100202. * Gets a skeleton using a given name
  100203. * @param name defines the name to search for
  100204. * @return the found skeleton or null if not found at all.
  100205. */
  100206. getSkeletonByName(name: string): Nullable<Skeleton>;
  100207. /**
  100208. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  100209. * @param id defines the id to search for
  100210. * @return the found morph target manager or null if not found at all.
  100211. */
  100212. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  100213. /**
  100214. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  100215. * @param id defines the id to search for
  100216. * @return the found morph target or null if not found at all.
  100217. */
  100218. getMorphTargetById(id: string): Nullable<MorphTarget>;
  100219. /**
  100220. * Gets a boolean indicating if the given mesh is active
  100221. * @param mesh defines the mesh to look for
  100222. * @returns true if the mesh is in the active list
  100223. */
  100224. isActiveMesh(mesh: AbstractMesh): boolean;
  100225. /**
  100226. * Return a unique id as a string which can serve as an identifier for the scene
  100227. */
  100228. readonly uid: string;
  100229. /**
  100230. * Add an externaly attached data from its key.
  100231. * This method call will fail and return false, if such key already exists.
  100232. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  100233. * @param key the unique key that identifies the data
  100234. * @param data the data object to associate to the key for this Engine instance
  100235. * @return true if no such key were already present and the data was added successfully, false otherwise
  100236. */
  100237. addExternalData<T>(key: string, data: T): boolean;
  100238. /**
  100239. * Get an externaly attached data from its key
  100240. * @param key the unique key that identifies the data
  100241. * @return the associated data, if present (can be null), or undefined if not present
  100242. */
  100243. getExternalData<T>(key: string): Nullable<T>;
  100244. /**
  100245. * Get an externaly attached data from its key, create it using a factory if it's not already present
  100246. * @param key the unique key that identifies the data
  100247. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  100248. * @return the associated data, can be null if the factory returned null.
  100249. */
  100250. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  100251. /**
  100252. * Remove an externaly attached data from the Engine instance
  100253. * @param key the unique key that identifies the data
  100254. * @return true if the data was successfully removed, false if it doesn't exist
  100255. */
  100256. removeExternalData(key: string): boolean;
  100257. private _evaluateSubMesh;
  100258. /**
  100259. * Clear the processed materials smart array preventing retention point in material dispose.
  100260. */
  100261. freeProcessedMaterials(): void;
  100262. private _preventFreeActiveMeshesAndRenderingGroups;
  100263. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  100264. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  100265. * when disposing several meshes in a row or a hierarchy of meshes.
  100266. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  100267. */
  100268. blockfreeActiveMeshesAndRenderingGroups: boolean;
  100269. /**
  100270. * Clear the active meshes smart array preventing retention point in mesh dispose.
  100271. */
  100272. freeActiveMeshes(): void;
  100273. /**
  100274. * Clear the info related to rendering groups preventing retention points during dispose.
  100275. */
  100276. freeRenderingGroups(): void;
  100277. /** @hidden */
  100278. _isInIntermediateRendering(): boolean;
  100279. /**
  100280. * Lambda returning the list of potentially active meshes.
  100281. */
  100282. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  100283. /**
  100284. * Lambda returning the list of potentially active sub meshes.
  100285. */
  100286. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  100287. /**
  100288. * Lambda returning the list of potentially intersecting sub meshes.
  100289. */
  100290. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  100291. /**
  100292. * Lambda returning the list of potentially colliding sub meshes.
  100293. */
  100294. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  100295. private _activeMeshesFrozen;
  100296. /**
  100297. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  100298. * @returns the current scene
  100299. */
  100300. freezeActiveMeshes(): Scene;
  100301. /**
  100302. * Use this function to restart evaluating active meshes on every frame
  100303. * @returns the current scene
  100304. */
  100305. unfreezeActiveMeshes(): Scene;
  100306. private _evaluateActiveMeshes;
  100307. private _activeMesh;
  100308. /**
  100309. * Update the transform matrix to update from the current active camera
  100310. * @param force defines a boolean used to force the update even if cache is up to date
  100311. */
  100312. updateTransformMatrix(force?: boolean): void;
  100313. private _bindFrameBuffer;
  100314. /** @hidden */
  100315. _allowPostProcessClearColor: boolean;
  100316. /** @hidden */
  100317. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  100318. private _processSubCameras;
  100319. private _checkIntersections;
  100320. /** @hidden */
  100321. _advancePhysicsEngineStep(step: number): void;
  100322. /**
  100323. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  100324. */
  100325. getDeterministicFrameTime: () => number;
  100326. /** @hidden */
  100327. _animate(): void;
  100328. /** Execute all animations (for a frame) */
  100329. animate(): void;
  100330. /**
  100331. * Render the scene
  100332. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  100333. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  100334. */
  100335. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  100336. /**
  100337. * Freeze all materials
  100338. * A frozen material will not be updatable but should be faster to render
  100339. */
  100340. freezeMaterials(): void;
  100341. /**
  100342. * Unfreeze all materials
  100343. * A frozen material will not be updatable but should be faster to render
  100344. */
  100345. unfreezeMaterials(): void;
  100346. /**
  100347. * Releases all held ressources
  100348. */
  100349. dispose(): void;
  100350. /**
  100351. * Gets if the scene is already disposed
  100352. */
  100353. readonly isDisposed: boolean;
  100354. /**
  100355. * Call this function to reduce memory footprint of the scene.
  100356. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  100357. */
  100358. clearCachedVertexData(): void;
  100359. /**
  100360. * This function will remove the local cached buffer data from texture.
  100361. * It will save memory but will prevent the texture from being rebuilt
  100362. */
  100363. cleanCachedTextureBuffer(): void;
  100364. /**
  100365. * Get the world extend vectors with an optional filter
  100366. *
  100367. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  100368. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  100369. */
  100370. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  100371. min: Vector3;
  100372. max: Vector3;
  100373. };
  100374. /**
  100375. * Creates a ray that can be used to pick in the scene
  100376. * @param x defines the x coordinate of the origin (on-screen)
  100377. * @param y defines the y coordinate of the origin (on-screen)
  100378. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  100379. * @param camera defines the camera to use for the picking
  100380. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  100381. * @returns a Ray
  100382. */
  100383. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  100384. /**
  100385. * Creates a ray that can be used to pick in the scene
  100386. * @param x defines the x coordinate of the origin (on-screen)
  100387. * @param y defines the y coordinate of the origin (on-screen)
  100388. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  100389. * @param result defines the ray where to store the picking ray
  100390. * @param camera defines the camera to use for the picking
  100391. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  100392. * @returns the current scene
  100393. */
  100394. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  100395. /**
  100396. * Creates a ray that can be used to pick in the scene
  100397. * @param x defines the x coordinate of the origin (on-screen)
  100398. * @param y defines the y coordinate of the origin (on-screen)
  100399. * @param camera defines the camera to use for the picking
  100400. * @returns a Ray
  100401. */
  100402. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  100403. /**
  100404. * Creates a ray that can be used to pick in the scene
  100405. * @param x defines the x coordinate of the origin (on-screen)
  100406. * @param y defines the y coordinate of the origin (on-screen)
  100407. * @param result defines the ray where to store the picking ray
  100408. * @param camera defines the camera to use for the picking
  100409. * @returns the current scene
  100410. */
  100411. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  100412. /** Launch a ray to try to pick a mesh in the scene
  100413. * @param x position on screen
  100414. * @param y position on screen
  100415. * @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
  100416. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  100417. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100418. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100419. * @returns a PickingInfo
  100420. */
  100421. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100422. /** Use the given ray to pick a mesh in the scene
  100423. * @param ray The ray to use to pick meshes
  100424. * @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
  100425. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  100426. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100427. * @returns a PickingInfo
  100428. */
  100429. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  100430. /**
  100431. * Launch a ray to try to pick a mesh in the scene
  100432. * @param x X position on screen
  100433. * @param y Y position on screen
  100434. * @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
  100435. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  100436. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100437. * @returns an array of PickingInfo
  100438. */
  100439. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100440. /**
  100441. * Launch a ray to try to pick a mesh in the scene
  100442. * @param ray Ray to use
  100443. * @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
  100444. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  100445. * @returns an array of PickingInfo
  100446. */
  100447. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  100448. /**
  100449. * Force the value of meshUnderPointer
  100450. * @param mesh defines the mesh to use
  100451. */
  100452. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  100453. /**
  100454. * Gets the mesh under the pointer
  100455. * @returns a Mesh or null if no mesh is under the pointer
  100456. */
  100457. getPointerOverMesh(): Nullable<AbstractMesh>;
  100458. /** @hidden */
  100459. _rebuildGeometries(): void;
  100460. /** @hidden */
  100461. _rebuildTextures(): void;
  100462. private _getByTags;
  100463. /**
  100464. * Get a list of meshes by tags
  100465. * @param tagsQuery defines the tags query to use
  100466. * @param forEach defines a predicate used to filter results
  100467. * @returns an array of Mesh
  100468. */
  100469. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  100470. /**
  100471. * Get a list of cameras by tags
  100472. * @param tagsQuery defines the tags query to use
  100473. * @param forEach defines a predicate used to filter results
  100474. * @returns an array of Camera
  100475. */
  100476. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  100477. /**
  100478. * Get a list of lights by tags
  100479. * @param tagsQuery defines the tags query to use
  100480. * @param forEach defines a predicate used to filter results
  100481. * @returns an array of Light
  100482. */
  100483. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  100484. /**
  100485. * Get a list of materials by tags
  100486. * @param tagsQuery defines the tags query to use
  100487. * @param forEach defines a predicate used to filter results
  100488. * @returns an array of Material
  100489. */
  100490. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  100491. /**
  100492. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  100493. * This allowed control for front to back rendering or reversly depending of the special needs.
  100494. *
  100495. * @param renderingGroupId The rendering group id corresponding to its index
  100496. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  100497. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  100498. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  100499. */
  100500. 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;
  100501. /**
  100502. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  100503. *
  100504. * @param renderingGroupId The rendering group id corresponding to its index
  100505. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  100506. * @param depth Automatically clears depth between groups if true and autoClear is true.
  100507. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  100508. */
  100509. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  100510. /**
  100511. * Gets the current auto clear configuration for one rendering group of the rendering
  100512. * manager.
  100513. * @param index the rendering group index to get the information for
  100514. * @returns The auto clear setup for the requested rendering group
  100515. */
  100516. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  100517. private _blockMaterialDirtyMechanism;
  100518. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  100519. blockMaterialDirtyMechanism: boolean;
  100520. /**
  100521. * Will flag all materials as dirty to trigger new shader compilation
  100522. * @param flag defines the flag used to specify which material part must be marked as dirty
  100523. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  100524. */
  100525. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  100526. /** @hidden */
  100527. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  100528. /** @hidden */
  100529. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  100530. }
  100531. }
  100532. declare module BABYLON {
  100533. /**
  100534. * Set of assets to keep when moving a scene into an asset container.
  100535. */
  100536. export class KeepAssets extends AbstractScene {
  100537. }
  100538. /**
  100539. * Container with a set of assets that can be added or removed from a scene.
  100540. */
  100541. export class AssetContainer extends AbstractScene {
  100542. /**
  100543. * The scene the AssetContainer belongs to.
  100544. */
  100545. scene: Scene;
  100546. /**
  100547. * Instantiates an AssetContainer.
  100548. * @param scene The scene the AssetContainer belongs to.
  100549. */
  100550. constructor(scene: Scene);
  100551. /**
  100552. * Adds all the assets from the container to the scene.
  100553. */
  100554. addAllToScene(): void;
  100555. /**
  100556. * Removes all the assets in the container from the scene
  100557. */
  100558. removeAllFromScene(): void;
  100559. /**
  100560. * Disposes all the assets in the container
  100561. */
  100562. dispose(): void;
  100563. private _moveAssets;
  100564. /**
  100565. * Removes all the assets contained in the scene and adds them to the container.
  100566. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  100567. */
  100568. moveAllFromScene(keepAssets?: KeepAssets): void;
  100569. /**
  100570. * 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.
  100571. * @returns the root mesh
  100572. */
  100573. createRootMesh(): Mesh;
  100574. }
  100575. }
  100576. declare module BABYLON {
  100577. /**
  100578. * Defines how the parser contract is defined.
  100579. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  100580. */
  100581. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  100582. /**
  100583. * Defines how the individual parser contract is defined.
  100584. * These parser can parse an individual asset
  100585. */
  100586. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  100587. /**
  100588. * Base class of the scene acting as a container for the different elements composing a scene.
  100589. * This class is dynamically extended by the different components of the scene increasing
  100590. * flexibility and reducing coupling
  100591. */
  100592. export abstract class AbstractScene {
  100593. /**
  100594. * Stores the list of available parsers in the application.
  100595. */
  100596. private static _BabylonFileParsers;
  100597. /**
  100598. * Stores the list of available individual parsers in the application.
  100599. */
  100600. private static _IndividualBabylonFileParsers;
  100601. /**
  100602. * Adds a parser in the list of available ones
  100603. * @param name Defines the name of the parser
  100604. * @param parser Defines the parser to add
  100605. */
  100606. static AddParser(name: string, parser: BabylonFileParser): void;
  100607. /**
  100608. * Gets a general parser from the list of avaialble ones
  100609. * @param name Defines the name of the parser
  100610. * @returns the requested parser or null
  100611. */
  100612. static GetParser(name: string): Nullable<BabylonFileParser>;
  100613. /**
  100614. * Adds n individual parser in the list of available ones
  100615. * @param name Defines the name of the parser
  100616. * @param parser Defines the parser to add
  100617. */
  100618. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  100619. /**
  100620. * Gets an individual parser from the list of avaialble ones
  100621. * @param name Defines the name of the parser
  100622. * @returns the requested parser or null
  100623. */
  100624. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  100625. /**
  100626. * Parser json data and populate both a scene and its associated container object
  100627. * @param jsonData Defines the data to parse
  100628. * @param scene Defines the scene to parse the data for
  100629. * @param container Defines the container attached to the parsing sequence
  100630. * @param rootUrl Defines the root url of the data
  100631. */
  100632. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  100633. /**
  100634. * Gets the list of root nodes (ie. nodes with no parent)
  100635. */
  100636. rootNodes: Node[];
  100637. /** All of the cameras added to this scene
  100638. * @see http://doc.babylonjs.com/babylon101/cameras
  100639. */
  100640. cameras: Camera[];
  100641. /**
  100642. * All of the lights added to this scene
  100643. * @see http://doc.babylonjs.com/babylon101/lights
  100644. */
  100645. lights: Light[];
  100646. /**
  100647. * All of the (abstract) meshes added to this scene
  100648. */
  100649. meshes: AbstractMesh[];
  100650. /**
  100651. * The list of skeletons added to the scene
  100652. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  100653. */
  100654. skeletons: Skeleton[];
  100655. /**
  100656. * All of the particle systems added to this scene
  100657. * @see http://doc.babylonjs.com/babylon101/particles
  100658. */
  100659. particleSystems: IParticleSystem[];
  100660. /**
  100661. * Gets a list of Animations associated with the scene
  100662. */
  100663. animations: Animation[];
  100664. /**
  100665. * All of the animation groups added to this scene
  100666. * @see http://doc.babylonjs.com/how_to/group
  100667. */
  100668. animationGroups: AnimationGroup[];
  100669. /**
  100670. * All of the multi-materials added to this scene
  100671. * @see http://doc.babylonjs.com/how_to/multi_materials
  100672. */
  100673. multiMaterials: MultiMaterial[];
  100674. /**
  100675. * All of the materials added to this scene
  100676. * In the context of a Scene, it is not supposed to be modified manually.
  100677. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  100678. * Note also that the order of the Material wihin the array is not significant and might change.
  100679. * @see http://doc.babylonjs.com/babylon101/materials
  100680. */
  100681. materials: Material[];
  100682. /**
  100683. * The list of morph target managers added to the scene
  100684. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  100685. */
  100686. morphTargetManagers: MorphTargetManager[];
  100687. /**
  100688. * The list of geometries used in the scene.
  100689. */
  100690. geometries: Geometry[];
  100691. /**
  100692. * All of the tranform nodes added to this scene
  100693. * In the context of a Scene, it is not supposed to be modified manually.
  100694. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  100695. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  100696. * @see http://doc.babylonjs.com/how_to/transformnode
  100697. */
  100698. transformNodes: TransformNode[];
  100699. /**
  100700. * ActionManagers available on the scene.
  100701. */
  100702. actionManagers: AbstractActionManager[];
  100703. /**
  100704. * Textures to keep.
  100705. */
  100706. textures: BaseTexture[];
  100707. /**
  100708. * Environment texture for the scene
  100709. */
  100710. environmentTexture: Nullable<BaseTexture>;
  100711. }
  100712. }
  100713. declare module BABYLON {
  100714. /**
  100715. * Interface used to define options for Sound class
  100716. */
  100717. export interface ISoundOptions {
  100718. /**
  100719. * Does the sound autoplay once loaded.
  100720. */
  100721. autoplay?: boolean;
  100722. /**
  100723. * Does the sound loop after it finishes playing once.
  100724. */
  100725. loop?: boolean;
  100726. /**
  100727. * Sound's volume
  100728. */
  100729. volume?: number;
  100730. /**
  100731. * Is it a spatial sound?
  100732. */
  100733. spatialSound?: boolean;
  100734. /**
  100735. * Maximum distance to hear that sound
  100736. */
  100737. maxDistance?: number;
  100738. /**
  100739. * Uses user defined attenuation function
  100740. */
  100741. useCustomAttenuation?: boolean;
  100742. /**
  100743. * Define the roll off factor of spatial sounds.
  100744. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100745. */
  100746. rolloffFactor?: number;
  100747. /**
  100748. * Define the reference distance the sound should be heard perfectly.
  100749. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100750. */
  100751. refDistance?: number;
  100752. /**
  100753. * Define the distance attenuation model the sound will follow.
  100754. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100755. */
  100756. distanceModel?: string;
  100757. /**
  100758. * Defines the playback speed (1 by default)
  100759. */
  100760. playbackRate?: number;
  100761. /**
  100762. * Defines if the sound is from a streaming source
  100763. */
  100764. streaming?: boolean;
  100765. /**
  100766. * Defines an optional length (in seconds) inside the sound file
  100767. */
  100768. length?: number;
  100769. /**
  100770. * Defines an optional offset (in seconds) inside the sound file
  100771. */
  100772. offset?: number;
  100773. /**
  100774. * If true, URLs will not be required to state the audio file codec to use.
  100775. */
  100776. skipCodecCheck?: boolean;
  100777. }
  100778. /**
  100779. * Defines a sound that can be played in the application.
  100780. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  100781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  100782. */
  100783. export class Sound {
  100784. /**
  100785. * The name of the sound in the scene.
  100786. */
  100787. name: string;
  100788. /**
  100789. * Does the sound autoplay once loaded.
  100790. */
  100791. autoplay: boolean;
  100792. /**
  100793. * Does the sound loop after it finishes playing once.
  100794. */
  100795. loop: boolean;
  100796. /**
  100797. * Does the sound use a custom attenuation curve to simulate the falloff
  100798. * happening when the source gets further away from the camera.
  100799. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100800. */
  100801. useCustomAttenuation: boolean;
  100802. /**
  100803. * The sound track id this sound belongs to.
  100804. */
  100805. soundTrackId: number;
  100806. /**
  100807. * Is this sound currently played.
  100808. */
  100809. isPlaying: boolean;
  100810. /**
  100811. * Is this sound currently paused.
  100812. */
  100813. isPaused: boolean;
  100814. /**
  100815. * Does this sound enables spatial sound.
  100816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100817. */
  100818. spatialSound: boolean;
  100819. /**
  100820. * Define the reference distance the sound should be heard perfectly.
  100821. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100822. */
  100823. refDistance: number;
  100824. /**
  100825. * Define the roll off factor of spatial sounds.
  100826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100827. */
  100828. rolloffFactor: number;
  100829. /**
  100830. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  100831. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100832. */
  100833. maxDistance: number;
  100834. /**
  100835. * Define the distance attenuation model the sound will follow.
  100836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100837. */
  100838. distanceModel: string;
  100839. /**
  100840. * @hidden
  100841. * Back Compat
  100842. **/
  100843. onended: () => any;
  100844. /**
  100845. * Observable event when the current playing sound finishes.
  100846. */
  100847. onEndedObservable: Observable<Sound>;
  100848. private _panningModel;
  100849. private _playbackRate;
  100850. private _streaming;
  100851. private _startTime;
  100852. private _startOffset;
  100853. private _position;
  100854. /** @hidden */
  100855. _positionInEmitterSpace: boolean;
  100856. private _localDirection;
  100857. private _volume;
  100858. private _isReadyToPlay;
  100859. private _isDirectional;
  100860. private _readyToPlayCallback;
  100861. private _audioBuffer;
  100862. private _soundSource;
  100863. private _streamingSource;
  100864. private _soundPanner;
  100865. private _soundGain;
  100866. private _inputAudioNode;
  100867. private _outputAudioNode;
  100868. private _coneInnerAngle;
  100869. private _coneOuterAngle;
  100870. private _coneOuterGain;
  100871. private _scene;
  100872. private _connectedTransformNode;
  100873. private _customAttenuationFunction;
  100874. private _registerFunc;
  100875. private _isOutputConnected;
  100876. private _htmlAudioElement;
  100877. private _urlType;
  100878. private _length?;
  100879. private _offset?;
  100880. /** @hidden */
  100881. static _SceneComponentInitialization: (scene: Scene) => void;
  100882. /**
  100883. * Create a sound and attach it to a scene
  100884. * @param name Name of your sound
  100885. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  100886. * @param scene defines the scene the sound belongs to
  100887. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  100888. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  100889. */
  100890. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  100891. /**
  100892. * Release the sound and its associated resources
  100893. */
  100894. dispose(): void;
  100895. /**
  100896. * Gets if the sounds is ready to be played or not.
  100897. * @returns true if ready, otherwise false
  100898. */
  100899. isReady(): boolean;
  100900. private _soundLoaded;
  100901. /**
  100902. * Sets the data of the sound from an audiobuffer
  100903. * @param audioBuffer The audioBuffer containing the data
  100904. */
  100905. setAudioBuffer(audioBuffer: AudioBuffer): void;
  100906. /**
  100907. * Updates the current sounds options such as maxdistance, loop...
  100908. * @param options A JSON object containing values named as the object properties
  100909. */
  100910. updateOptions(options: ISoundOptions): void;
  100911. private _createSpatialParameters;
  100912. private _updateSpatialParameters;
  100913. /**
  100914. * Switch the panning model to HRTF:
  100915. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  100916. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100917. */
  100918. switchPanningModelToHRTF(): void;
  100919. /**
  100920. * Switch the panning model to Equal Power:
  100921. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  100922. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  100923. */
  100924. switchPanningModelToEqualPower(): void;
  100925. private _switchPanningModel;
  100926. /**
  100927. * Connect this sound to a sound track audio node like gain...
  100928. * @param soundTrackAudioNode the sound track audio node to connect to
  100929. */
  100930. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  100931. /**
  100932. * Transform this sound into a directional source
  100933. * @param coneInnerAngle Size of the inner cone in degree
  100934. * @param coneOuterAngle Size of the outer cone in degree
  100935. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  100936. */
  100937. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  100938. /**
  100939. * Gets or sets the inner angle for the directional cone.
  100940. */
  100941. /**
  100942. * Gets or sets the inner angle for the directional cone.
  100943. */
  100944. directionalConeInnerAngle: number;
  100945. /**
  100946. * Gets or sets the outer angle for the directional cone.
  100947. */
  100948. /**
  100949. * Gets or sets the outer angle for the directional cone.
  100950. */
  100951. directionalConeOuterAngle: number;
  100952. /**
  100953. * Sets the position of the emitter if spatial sound is enabled
  100954. * @param newPosition Defines the new posisiton
  100955. */
  100956. setPosition(newPosition: Vector3): void;
  100957. /**
  100958. * Sets the local direction of the emitter if spatial sound is enabled
  100959. * @param newLocalDirection Defines the new local direction
  100960. */
  100961. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  100962. private _updateDirection;
  100963. /** @hidden */
  100964. updateDistanceFromListener(): void;
  100965. /**
  100966. * Sets a new custom attenuation function for the sound.
  100967. * @param callback Defines the function used for the attenuation
  100968. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  100969. */
  100970. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  100971. /**
  100972. * Play the sound
  100973. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  100974. * @param offset (optional) Start the sound at a specific time in seconds
  100975. * @param length (optional) Sound duration (in seconds)
  100976. */
  100977. play(time?: number, offset?: number, length?: number): void;
  100978. private _onended;
  100979. /**
  100980. * Stop the sound
  100981. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  100982. */
  100983. stop(time?: number): void;
  100984. /**
  100985. * Put the sound in pause
  100986. */
  100987. pause(): void;
  100988. /**
  100989. * Sets a dedicated volume for this sounds
  100990. * @param newVolume Define the new volume of the sound
  100991. * @param time Define time for gradual change to new volume
  100992. */
  100993. setVolume(newVolume: number, time?: number): void;
  100994. /**
  100995. * Set the sound play back rate
  100996. * @param newPlaybackRate Define the playback rate the sound should be played at
  100997. */
  100998. setPlaybackRate(newPlaybackRate: number): void;
  100999. /**
  101000. * Gets the volume of the sound.
  101001. * @returns the volume of the sound
  101002. */
  101003. getVolume(): number;
  101004. /**
  101005. * Attach the sound to a dedicated mesh
  101006. * @param transformNode The transform node to connect the sound with
  101007. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  101008. */
  101009. attachToMesh(transformNode: TransformNode): void;
  101010. /**
  101011. * Detach the sound from the previously attached mesh
  101012. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  101013. */
  101014. detachFromMesh(): void;
  101015. private _onRegisterAfterWorldMatrixUpdate;
  101016. /**
  101017. * Clone the current sound in the scene.
  101018. * @returns the new sound clone
  101019. */
  101020. clone(): Nullable<Sound>;
  101021. /**
  101022. * Gets the current underlying audio buffer containing the data
  101023. * @returns the audio buffer
  101024. */
  101025. getAudioBuffer(): Nullable<AudioBuffer>;
  101026. /**
  101027. * Serializes the Sound in a JSON representation
  101028. * @returns the JSON representation of the sound
  101029. */
  101030. serialize(): any;
  101031. /**
  101032. * Parse a JSON representation of a sound to innstantiate in a given scene
  101033. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  101034. * @param scene Define the scene the new parsed sound should be created in
  101035. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  101036. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  101037. * @returns the newly parsed sound
  101038. */
  101039. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  101040. }
  101041. }
  101042. declare module BABYLON {
  101043. /**
  101044. * This defines an action helpful to play a defined sound on a triggered action.
  101045. */
  101046. export class PlaySoundAction extends Action {
  101047. private _sound;
  101048. /**
  101049. * Instantiate the action
  101050. * @param triggerOptions defines the trigger options
  101051. * @param sound defines the sound to play
  101052. * @param condition defines the trigger related conditions
  101053. */
  101054. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  101055. /** @hidden */
  101056. _prepare(): void;
  101057. /**
  101058. * Execute the action and play the sound.
  101059. */
  101060. execute(): void;
  101061. /**
  101062. * Serializes the actions and its related information.
  101063. * @param parent defines the object to serialize in
  101064. * @returns the serialized object
  101065. */
  101066. serialize(parent: any): any;
  101067. }
  101068. /**
  101069. * This defines an action helpful to stop a defined sound on a triggered action.
  101070. */
  101071. export class StopSoundAction extends Action {
  101072. private _sound;
  101073. /**
  101074. * Instantiate the action
  101075. * @param triggerOptions defines the trigger options
  101076. * @param sound defines the sound to stop
  101077. * @param condition defines the trigger related conditions
  101078. */
  101079. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  101080. /** @hidden */
  101081. _prepare(): void;
  101082. /**
  101083. * Execute the action and stop the sound.
  101084. */
  101085. execute(): void;
  101086. /**
  101087. * Serializes the actions and its related information.
  101088. * @param parent defines the object to serialize in
  101089. * @returns the serialized object
  101090. */
  101091. serialize(parent: any): any;
  101092. }
  101093. }
  101094. declare module BABYLON {
  101095. /**
  101096. * This defines an action responsible to change the value of a property
  101097. * by interpolating between its current value and the newly set one once triggered.
  101098. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101099. */
  101100. export class InterpolateValueAction extends Action {
  101101. /**
  101102. * Defines the path of the property where the value should be interpolated
  101103. */
  101104. propertyPath: string;
  101105. /**
  101106. * Defines the target value at the end of the interpolation.
  101107. */
  101108. value: any;
  101109. /**
  101110. * Defines the time it will take for the property to interpolate to the value.
  101111. */
  101112. duration: number;
  101113. /**
  101114. * Defines if the other scene animations should be stopped when the action has been triggered
  101115. */
  101116. stopOtherAnimations?: boolean;
  101117. /**
  101118. * Defines a callback raised once the interpolation animation has been done.
  101119. */
  101120. onInterpolationDone?: () => void;
  101121. /**
  101122. * Observable triggered once the interpolation animation has been done.
  101123. */
  101124. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  101125. private _target;
  101126. private _effectiveTarget;
  101127. private _property;
  101128. /**
  101129. * Instantiate the action
  101130. * @param triggerOptions defines the trigger options
  101131. * @param target defines the object containing the value to interpolate
  101132. * @param propertyPath defines the path to the property in the target object
  101133. * @param value defines the target value at the end of the interpolation
  101134. * @param duration deines the time it will take for the property to interpolate to the value.
  101135. * @param condition defines the trigger related conditions
  101136. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  101137. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  101138. */
  101139. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  101140. /** @hidden */
  101141. _prepare(): void;
  101142. /**
  101143. * Execute the action starts the value interpolation.
  101144. */
  101145. execute(): void;
  101146. /**
  101147. * Serializes the actions and its related information.
  101148. * @param parent defines the object to serialize in
  101149. * @returns the serialized object
  101150. */
  101151. serialize(parent: any): any;
  101152. }
  101153. }
  101154. declare module BABYLON {
  101155. /**
  101156. * Options allowed during the creation of a sound track.
  101157. */
  101158. export interface ISoundTrackOptions {
  101159. /**
  101160. * The volume the sound track should take during creation
  101161. */
  101162. volume?: number;
  101163. /**
  101164. * Define if the sound track is the main sound track of the scene
  101165. */
  101166. mainTrack?: boolean;
  101167. }
  101168. /**
  101169. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  101170. * It will be also used in a future release to apply effects on a specific track.
  101171. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101172. */
  101173. export class SoundTrack {
  101174. /**
  101175. * The unique identifier of the sound track in the scene.
  101176. */
  101177. id: number;
  101178. /**
  101179. * The list of sounds included in the sound track.
  101180. */
  101181. soundCollection: Array<Sound>;
  101182. private _outputAudioNode;
  101183. private _scene;
  101184. private _isMainTrack;
  101185. private _connectedAnalyser;
  101186. private _options;
  101187. private _isInitialized;
  101188. /**
  101189. * Creates a new sound track.
  101190. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  101191. * @param scene Define the scene the sound track belongs to
  101192. * @param options
  101193. */
  101194. constructor(scene: Scene, options?: ISoundTrackOptions);
  101195. private _initializeSoundTrackAudioGraph;
  101196. /**
  101197. * Release the sound track and its associated resources
  101198. */
  101199. dispose(): void;
  101200. /**
  101201. * Adds a sound to this sound track
  101202. * @param sound define the cound to add
  101203. * @ignoreNaming
  101204. */
  101205. AddSound(sound: Sound): void;
  101206. /**
  101207. * Removes a sound to this sound track
  101208. * @param sound define the cound to remove
  101209. * @ignoreNaming
  101210. */
  101211. RemoveSound(sound: Sound): void;
  101212. /**
  101213. * Set a global volume for the full sound track.
  101214. * @param newVolume Define the new volume of the sound track
  101215. */
  101216. setVolume(newVolume: number): void;
  101217. /**
  101218. * Switch the panning model to HRTF:
  101219. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101220. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101221. */
  101222. switchPanningModelToHRTF(): void;
  101223. /**
  101224. * Switch the panning model to Equal Power:
  101225. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101226. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101227. */
  101228. switchPanningModelToEqualPower(): void;
  101229. /**
  101230. * Connect the sound track to an audio analyser allowing some amazing
  101231. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  101232. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  101233. * @param analyser The analyser to connect to the engine
  101234. */
  101235. connectToAnalyser(analyser: Analyser): void;
  101236. }
  101237. }
  101238. declare module BABYLON {
  101239. interface AbstractScene {
  101240. /**
  101241. * The list of sounds used in the scene.
  101242. */
  101243. sounds: Nullable<Array<Sound>>;
  101244. }
  101245. interface Scene {
  101246. /**
  101247. * @hidden
  101248. * Backing field
  101249. */
  101250. _mainSoundTrack: SoundTrack;
  101251. /**
  101252. * The main sound track played by the scene.
  101253. * It cotains your primary collection of sounds.
  101254. */
  101255. mainSoundTrack: SoundTrack;
  101256. /**
  101257. * The list of sound tracks added to the scene
  101258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101259. */
  101260. soundTracks: Nullable<Array<SoundTrack>>;
  101261. /**
  101262. * Gets a sound using a given name
  101263. * @param name defines the name to search for
  101264. * @return the found sound or null if not found at all.
  101265. */
  101266. getSoundByName(name: string): Nullable<Sound>;
  101267. /**
  101268. * Gets or sets if audio support is enabled
  101269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101270. */
  101271. audioEnabled: boolean;
  101272. /**
  101273. * Gets or sets if audio will be output to headphones
  101274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101275. */
  101276. headphone: boolean;
  101277. /**
  101278. * Gets or sets custom audio listener position provider
  101279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101280. */
  101281. audioListenerPositionProvider: Nullable<() => Vector3>;
  101282. }
  101283. /**
  101284. * Defines the sound scene component responsible to manage any sounds
  101285. * in a given scene.
  101286. */
  101287. export class AudioSceneComponent implements ISceneSerializableComponent {
  101288. /**
  101289. * The component name helpfull to identify the component in the list of scene components.
  101290. */
  101291. readonly name: string;
  101292. /**
  101293. * The scene the component belongs to.
  101294. */
  101295. scene: Scene;
  101296. private _audioEnabled;
  101297. /**
  101298. * Gets whether audio is enabled or not.
  101299. * Please use related enable/disable method to switch state.
  101300. */
  101301. readonly audioEnabled: boolean;
  101302. private _headphone;
  101303. /**
  101304. * Gets whether audio is outputing to headphone or not.
  101305. * Please use the according Switch methods to change output.
  101306. */
  101307. readonly headphone: boolean;
  101308. private _audioListenerPositionProvider;
  101309. /**
  101310. * Gets the current audio listener position provider
  101311. */
  101312. /**
  101313. * Sets a custom listener position for all sounds in the scene
  101314. * By default, this is the position of the first active camera
  101315. */
  101316. audioListenerPositionProvider: Nullable<() => Vector3>;
  101317. /**
  101318. * Creates a new instance of the component for the given scene
  101319. * @param scene Defines the scene to register the component in
  101320. */
  101321. constructor(scene: Scene);
  101322. /**
  101323. * Registers the component in a given scene
  101324. */
  101325. register(): void;
  101326. /**
  101327. * Rebuilds the elements related to this component in case of
  101328. * context lost for instance.
  101329. */
  101330. rebuild(): void;
  101331. /**
  101332. * Serializes the component data to the specified json object
  101333. * @param serializationObject The object to serialize to
  101334. */
  101335. serialize(serializationObject: any): void;
  101336. /**
  101337. * Adds all the elements from the container to the scene
  101338. * @param container the container holding the elements
  101339. */
  101340. addFromContainer(container: AbstractScene): void;
  101341. /**
  101342. * Removes all the elements in the container from the scene
  101343. * @param container contains the elements to remove
  101344. * @param dispose if the removed element should be disposed (default: false)
  101345. */
  101346. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  101347. /**
  101348. * Disposes the component and the associated ressources.
  101349. */
  101350. dispose(): void;
  101351. /**
  101352. * Disables audio in the associated scene.
  101353. */
  101354. disableAudio(): void;
  101355. /**
  101356. * Enables audio in the associated scene.
  101357. */
  101358. enableAudio(): void;
  101359. /**
  101360. * Switch audio to headphone output.
  101361. */
  101362. switchAudioModeForHeadphones(): void;
  101363. /**
  101364. * Switch audio to normal speakers.
  101365. */
  101366. switchAudioModeForNormalSpeakers(): void;
  101367. private _afterRender;
  101368. }
  101369. }
  101370. declare module BABYLON {
  101371. /**
  101372. * Wraps one or more Sound objects and selects one with random weight for playback.
  101373. */
  101374. export class WeightedSound {
  101375. /** When true a Sound will be selected and played when the current playing Sound completes. */
  101376. loop: boolean;
  101377. private _coneInnerAngle;
  101378. private _coneOuterAngle;
  101379. private _volume;
  101380. /** A Sound is currently playing. */
  101381. isPlaying: boolean;
  101382. /** A Sound is currently paused. */
  101383. isPaused: boolean;
  101384. private _sounds;
  101385. private _weights;
  101386. private _currentIndex?;
  101387. /**
  101388. * Creates a new WeightedSound from the list of sounds given.
  101389. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  101390. * @param sounds Array of Sounds that will be selected from.
  101391. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  101392. */
  101393. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  101394. /**
  101395. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  101396. */
  101397. /**
  101398. * The size of cone in degress for a directional sound in which there will be no attenuation.
  101399. */
  101400. directionalConeInnerAngle: number;
  101401. /**
  101402. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101403. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101404. */
  101405. /**
  101406. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  101407. * Listener angles between innerAngle and outerAngle will falloff linearly.
  101408. */
  101409. directionalConeOuterAngle: number;
  101410. /**
  101411. * Playback volume.
  101412. */
  101413. /**
  101414. * Playback volume.
  101415. */
  101416. volume: number;
  101417. private _onended;
  101418. /**
  101419. * Suspend playback
  101420. */
  101421. pause(): void;
  101422. /**
  101423. * Stop playback
  101424. */
  101425. stop(): void;
  101426. /**
  101427. * Start playback.
  101428. * @param startOffset Position the clip head at a specific time in seconds.
  101429. */
  101430. play(startOffset?: number): void;
  101431. }
  101432. }
  101433. declare module BABYLON {
  101434. /**
  101435. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  101436. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  101437. */
  101438. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  101439. /**
  101440. * Gets the name of the behavior.
  101441. */
  101442. readonly name: string;
  101443. /**
  101444. * The easing function used by animations
  101445. */
  101446. static EasingFunction: BackEase;
  101447. /**
  101448. * The easing mode used by animations
  101449. */
  101450. static EasingMode: number;
  101451. /**
  101452. * The duration of the animation, in milliseconds
  101453. */
  101454. transitionDuration: number;
  101455. /**
  101456. * Length of the distance animated by the transition when lower radius is reached
  101457. */
  101458. lowerRadiusTransitionRange: number;
  101459. /**
  101460. * Length of the distance animated by the transition when upper radius is reached
  101461. */
  101462. upperRadiusTransitionRange: number;
  101463. private _autoTransitionRange;
  101464. /**
  101465. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101466. */
  101467. /**
  101468. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  101469. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  101470. */
  101471. autoTransitionRange: boolean;
  101472. private _attachedCamera;
  101473. private _onAfterCheckInputsObserver;
  101474. private _onMeshTargetChangedObserver;
  101475. /**
  101476. * Initializes the behavior.
  101477. */
  101478. init(): void;
  101479. /**
  101480. * Attaches the behavior to its arc rotate camera.
  101481. * @param camera Defines the camera to attach the behavior to
  101482. */
  101483. attach(camera: ArcRotateCamera): void;
  101484. /**
  101485. * Detaches the behavior from its current arc rotate camera.
  101486. */
  101487. detach(): void;
  101488. private _radiusIsAnimating;
  101489. private _radiusBounceTransition;
  101490. private _animatables;
  101491. private _cachedWheelPrecision;
  101492. /**
  101493. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  101494. * @param radiusLimit The limit to check against.
  101495. * @return Bool to indicate if at limit.
  101496. */
  101497. private _isRadiusAtLimit;
  101498. /**
  101499. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  101500. * @param radiusDelta The delta by which to animate to. Can be negative.
  101501. */
  101502. private _applyBoundRadiusAnimation;
  101503. /**
  101504. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  101505. */
  101506. protected _clearAnimationLocks(): void;
  101507. /**
  101508. * Stops and removes all animations that have been applied to the camera
  101509. */
  101510. stopAllAnimations(): void;
  101511. }
  101512. }
  101513. declare module BABYLON {
  101514. /**
  101515. * 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.
  101516. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  101517. */
  101518. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  101519. /**
  101520. * Gets the name of the behavior.
  101521. */
  101522. readonly name: string;
  101523. private _mode;
  101524. private _radiusScale;
  101525. private _positionScale;
  101526. private _defaultElevation;
  101527. private _elevationReturnTime;
  101528. private _elevationReturnWaitTime;
  101529. private _zoomStopsAnimation;
  101530. private _framingTime;
  101531. /**
  101532. * The easing function used by animations
  101533. */
  101534. static EasingFunction: ExponentialEase;
  101535. /**
  101536. * The easing mode used by animations
  101537. */
  101538. static EasingMode: number;
  101539. /**
  101540. * Sets the current mode used by the behavior
  101541. */
  101542. /**
  101543. * Gets current mode used by the behavior.
  101544. */
  101545. mode: number;
  101546. /**
  101547. * Sets the scale applied to the radius (1 by default)
  101548. */
  101549. /**
  101550. * Gets the scale applied to the radius
  101551. */
  101552. radiusScale: number;
  101553. /**
  101554. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101555. */
  101556. /**
  101557. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  101558. */
  101559. positionScale: number;
  101560. /**
  101561. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101562. * behaviour is triggered, in radians.
  101563. */
  101564. /**
  101565. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  101566. * behaviour is triggered, in radians.
  101567. */
  101568. defaultElevation: number;
  101569. /**
  101570. * Sets the time (in milliseconds) taken to return to the default beta position.
  101571. * Negative value indicates camera should not return to default.
  101572. */
  101573. /**
  101574. * Gets the time (in milliseconds) taken to return to the default beta position.
  101575. * Negative value indicates camera should not return to default.
  101576. */
  101577. elevationReturnTime: number;
  101578. /**
  101579. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101580. */
  101581. /**
  101582. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  101583. */
  101584. elevationReturnWaitTime: number;
  101585. /**
  101586. * Sets the flag that indicates if user zooming should stop animation.
  101587. */
  101588. /**
  101589. * Gets the flag that indicates if user zooming should stop animation.
  101590. */
  101591. zoomStopsAnimation: boolean;
  101592. /**
  101593. * Sets the transition time when framing the mesh, in milliseconds
  101594. */
  101595. /**
  101596. * Gets the transition time when framing the mesh, in milliseconds
  101597. */
  101598. framingTime: number;
  101599. /**
  101600. * Define if the behavior should automatically change the configured
  101601. * camera limits and sensibilities.
  101602. */
  101603. autoCorrectCameraLimitsAndSensibility: boolean;
  101604. private _onPrePointerObservableObserver;
  101605. private _onAfterCheckInputsObserver;
  101606. private _onMeshTargetChangedObserver;
  101607. private _attachedCamera;
  101608. private _isPointerDown;
  101609. private _lastInteractionTime;
  101610. /**
  101611. * Initializes the behavior.
  101612. */
  101613. init(): void;
  101614. /**
  101615. * Attaches the behavior to its arc rotate camera.
  101616. * @param camera Defines the camera to attach the behavior to
  101617. */
  101618. attach(camera: ArcRotateCamera): void;
  101619. /**
  101620. * Detaches the behavior from its current arc rotate camera.
  101621. */
  101622. detach(): void;
  101623. private _animatables;
  101624. private _betaIsAnimating;
  101625. private _betaTransition;
  101626. private _radiusTransition;
  101627. private _vectorTransition;
  101628. /**
  101629. * Targets the given mesh and updates zoom level accordingly.
  101630. * @param mesh The mesh to target.
  101631. * @param radius Optional. If a cached radius position already exists, overrides default.
  101632. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101633. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101634. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101635. */
  101636. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101637. /**
  101638. * Targets the given mesh with its children and updates zoom level accordingly.
  101639. * @param mesh The mesh to target.
  101640. * @param radius Optional. If a cached radius position already exists, overrides default.
  101641. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101642. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101643. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101644. */
  101645. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101646. /**
  101647. * Targets the given meshes with their children and updates zoom level accordingly.
  101648. * @param meshes The mesh to target.
  101649. * @param radius Optional. If a cached radius position already exists, overrides default.
  101650. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  101651. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101652. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101653. */
  101654. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101655. /**
  101656. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  101657. * @param minimumWorld Determines the smaller position of the bounding box extend
  101658. * @param maximumWorld Determines the bigger position of the bounding box extend
  101659. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  101660. * @param onAnimationEnd Callback triggered at the end of the framing animation
  101661. */
  101662. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  101663. /**
  101664. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  101665. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  101666. * frustum width.
  101667. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  101668. * to fully enclose the mesh in the viewing frustum.
  101669. */
  101670. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  101671. /**
  101672. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  101673. * is automatically returned to its default position (expected to be above ground plane).
  101674. */
  101675. private _maintainCameraAboveGround;
  101676. /**
  101677. * Returns the frustum slope based on the canvas ratio and camera FOV
  101678. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  101679. */
  101680. private _getFrustumSlope;
  101681. /**
  101682. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  101683. */
  101684. private _clearAnimationLocks;
  101685. /**
  101686. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  101687. */
  101688. private _applyUserInteraction;
  101689. /**
  101690. * Stops and removes all animations that have been applied to the camera
  101691. */
  101692. stopAllAnimations(): void;
  101693. /**
  101694. * Gets a value indicating if the user is moving the camera
  101695. */
  101696. readonly isUserIsMoving: boolean;
  101697. /**
  101698. * The camera can move all the way towards the mesh.
  101699. */
  101700. static IgnoreBoundsSizeMode: number;
  101701. /**
  101702. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  101703. */
  101704. static FitFrustumSidesMode: number;
  101705. }
  101706. }
  101707. declare module BABYLON {
  101708. /**
  101709. * Base class for Camera Pointer Inputs.
  101710. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  101711. * for example usage.
  101712. */
  101713. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  101714. /**
  101715. * Defines the camera the input is attached to.
  101716. */
  101717. abstract camera: Camera;
  101718. /**
  101719. * Whether keyboard modifier keys are pressed at time of last mouse event.
  101720. */
  101721. protected _altKey: boolean;
  101722. protected _ctrlKey: boolean;
  101723. protected _metaKey: boolean;
  101724. protected _shiftKey: boolean;
  101725. /**
  101726. * Which mouse buttons were pressed at time of last mouse event.
  101727. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  101728. */
  101729. protected _buttonsPressed: number;
  101730. /**
  101731. * Defines the buttons associated with the input to handle camera move.
  101732. */
  101733. buttons: number[];
  101734. /**
  101735. * Attach the input controls to a specific dom element to get the input from.
  101736. * @param element Defines the element the controls should be listened from
  101737. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101738. */
  101739. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101740. /**
  101741. * Detach the current controls from the specified dom element.
  101742. * @param element Defines the element to stop listening the inputs from
  101743. */
  101744. detachControl(element: Nullable<HTMLElement>): void;
  101745. /**
  101746. * Gets the class name of the current input.
  101747. * @returns the class name
  101748. */
  101749. getClassName(): string;
  101750. /**
  101751. * Get the friendly name associated with the input class.
  101752. * @returns the input friendly name
  101753. */
  101754. getSimpleName(): string;
  101755. /**
  101756. * Called on pointer POINTERDOUBLETAP event.
  101757. * Override this method to provide functionality on POINTERDOUBLETAP event.
  101758. */
  101759. protected onDoubleTap(type: string): void;
  101760. /**
  101761. * Called on pointer POINTERMOVE event if only a single touch is active.
  101762. * Override this method to provide functionality.
  101763. */
  101764. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101765. /**
  101766. * Called on pointer POINTERMOVE event if multiple touches are active.
  101767. * Override this method to provide functionality.
  101768. */
  101769. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101770. /**
  101771. * Called on JS contextmenu event.
  101772. * Override this method to provide functionality.
  101773. */
  101774. protected onContextMenu(evt: PointerEvent): void;
  101775. /**
  101776. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101777. * press.
  101778. * Override this method to provide functionality.
  101779. */
  101780. protected onButtonDown(evt: PointerEvent): void;
  101781. /**
  101782. * Called each time a new POINTERUP event occurs. Ie, for each button
  101783. * release.
  101784. * Override this method to provide functionality.
  101785. */
  101786. protected onButtonUp(evt: PointerEvent): void;
  101787. /**
  101788. * Called when window becomes inactive.
  101789. * Override this method to provide functionality.
  101790. */
  101791. protected onLostFocus(): void;
  101792. private _pointerInput;
  101793. private _observer;
  101794. private _onLostFocus;
  101795. private pointA;
  101796. private pointB;
  101797. }
  101798. }
  101799. declare module BABYLON {
  101800. /**
  101801. * Manage the pointers inputs to control an arc rotate camera.
  101802. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101803. */
  101804. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  101805. /**
  101806. * Defines the camera the input is attached to.
  101807. */
  101808. camera: ArcRotateCamera;
  101809. /**
  101810. * Gets the class name of the current input.
  101811. * @returns the class name
  101812. */
  101813. getClassName(): string;
  101814. /**
  101815. * Defines the buttons associated with the input to handle camera move.
  101816. */
  101817. buttons: number[];
  101818. /**
  101819. * Defines the pointer angular sensibility along the X axis or how fast is
  101820. * the camera rotating.
  101821. */
  101822. angularSensibilityX: number;
  101823. /**
  101824. * Defines the pointer angular sensibility along the Y axis or how fast is
  101825. * the camera rotating.
  101826. */
  101827. angularSensibilityY: number;
  101828. /**
  101829. * Defines the pointer pinch precision or how fast is the camera zooming.
  101830. */
  101831. pinchPrecision: number;
  101832. /**
  101833. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  101834. * from 0.
  101835. * It defines the percentage of current camera.radius to use as delta when
  101836. * pinch zoom is used.
  101837. */
  101838. pinchDeltaPercentage: number;
  101839. /**
  101840. * Defines the pointer panning sensibility or how fast is the camera moving.
  101841. */
  101842. panningSensibility: number;
  101843. /**
  101844. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  101845. */
  101846. multiTouchPanning: boolean;
  101847. /**
  101848. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  101849. * zoom (pinch) through multitouch.
  101850. */
  101851. multiTouchPanAndZoom: boolean;
  101852. /**
  101853. * Revers pinch action direction.
  101854. */
  101855. pinchInwards: boolean;
  101856. private _isPanClick;
  101857. private _twoFingerActivityCount;
  101858. private _isPinching;
  101859. /**
  101860. * Called on pointer POINTERMOVE event if only a single touch is active.
  101861. */
  101862. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101863. /**
  101864. * Called on pointer POINTERDOUBLETAP event.
  101865. */
  101866. protected onDoubleTap(type: string): void;
  101867. /**
  101868. * Called on pointer POINTERMOVE event if multiple touches are active.
  101869. */
  101870. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101871. /**
  101872. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  101873. * press.
  101874. */
  101875. protected onButtonDown(evt: PointerEvent): void;
  101876. /**
  101877. * Called each time a new POINTERUP event occurs. Ie, for each button
  101878. * release.
  101879. */
  101880. protected onButtonUp(evt: PointerEvent): void;
  101881. /**
  101882. * Called when window becomes inactive.
  101883. */
  101884. protected onLostFocus(): void;
  101885. }
  101886. }
  101887. declare module BABYLON {
  101888. /**
  101889. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  101890. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101891. */
  101892. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  101893. /**
  101894. * Defines the camera the input is attached to.
  101895. */
  101896. camera: ArcRotateCamera;
  101897. /**
  101898. * Defines the list of key codes associated with the up action (increase alpha)
  101899. */
  101900. keysUp: number[];
  101901. /**
  101902. * Defines the list of key codes associated with the down action (decrease alpha)
  101903. */
  101904. keysDown: number[];
  101905. /**
  101906. * Defines the list of key codes associated with the left action (increase beta)
  101907. */
  101908. keysLeft: number[];
  101909. /**
  101910. * Defines the list of key codes associated with the right action (decrease beta)
  101911. */
  101912. keysRight: number[];
  101913. /**
  101914. * Defines the list of key codes associated with the reset action.
  101915. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  101916. */
  101917. keysReset: number[];
  101918. /**
  101919. * Defines the panning sensibility of the inputs.
  101920. * (How fast is the camera paning)
  101921. */
  101922. panningSensibility: number;
  101923. /**
  101924. * Defines the zooming sensibility of the inputs.
  101925. * (How fast is the camera zooming)
  101926. */
  101927. zoomingSensibility: number;
  101928. /**
  101929. * Defines wether maintaining the alt key down switch the movement mode from
  101930. * orientation to zoom.
  101931. */
  101932. useAltToZoom: boolean;
  101933. /**
  101934. * Rotation speed of the camera
  101935. */
  101936. angularSpeed: number;
  101937. private _keys;
  101938. private _ctrlPressed;
  101939. private _altPressed;
  101940. private _onCanvasBlurObserver;
  101941. private _onKeyboardObserver;
  101942. private _engine;
  101943. private _scene;
  101944. /**
  101945. * Attach the input controls to a specific dom element to get the input from.
  101946. * @param element Defines the element the controls should be listened from
  101947. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101948. */
  101949. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101950. /**
  101951. * Detach the current controls from the specified dom element.
  101952. * @param element Defines the element to stop listening the inputs from
  101953. */
  101954. detachControl(element: Nullable<HTMLElement>): void;
  101955. /**
  101956. * Update the current camera state depending on the inputs that have been used this frame.
  101957. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101958. */
  101959. checkInputs(): void;
  101960. /**
  101961. * Gets the class name of the current intput.
  101962. * @returns the class name
  101963. */
  101964. getClassName(): string;
  101965. /**
  101966. * Get the friendly name associated with the input class.
  101967. * @returns the input friendly name
  101968. */
  101969. getSimpleName(): string;
  101970. }
  101971. }
  101972. declare module BABYLON {
  101973. /**
  101974. * Manage the mouse wheel inputs to control an arc rotate camera.
  101975. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101976. */
  101977. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  101978. /**
  101979. * Defines the camera the input is attached to.
  101980. */
  101981. camera: ArcRotateCamera;
  101982. /**
  101983. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  101984. */
  101985. wheelPrecision: number;
  101986. /**
  101987. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  101988. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  101989. */
  101990. wheelDeltaPercentage: number;
  101991. private _wheel;
  101992. private _observer;
  101993. private computeDeltaFromMouseWheelLegacyEvent;
  101994. /**
  101995. * Attach the input controls to a specific dom element to get the input from.
  101996. * @param element Defines the element the controls should be listened from
  101997. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101998. */
  101999. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102000. /**
  102001. * Detach the current controls from the specified dom element.
  102002. * @param element Defines the element to stop listening the inputs from
  102003. */
  102004. detachControl(element: Nullable<HTMLElement>): void;
  102005. /**
  102006. * Gets the class name of the current intput.
  102007. * @returns the class name
  102008. */
  102009. getClassName(): string;
  102010. /**
  102011. * Get the friendly name associated with the input class.
  102012. * @returns the input friendly name
  102013. */
  102014. getSimpleName(): string;
  102015. }
  102016. }
  102017. declare module BABYLON {
  102018. /**
  102019. * Default Inputs manager for the ArcRotateCamera.
  102020. * It groups all the default supported inputs for ease of use.
  102021. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102022. */
  102023. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  102024. /**
  102025. * Instantiates a new ArcRotateCameraInputsManager.
  102026. * @param camera Defines the camera the inputs belong to
  102027. */
  102028. constructor(camera: ArcRotateCamera);
  102029. /**
  102030. * Add mouse wheel input support to the input manager.
  102031. * @returns the current input manager
  102032. */
  102033. addMouseWheel(): ArcRotateCameraInputsManager;
  102034. /**
  102035. * Add pointers input support to the input manager.
  102036. * @returns the current input manager
  102037. */
  102038. addPointers(): ArcRotateCameraInputsManager;
  102039. /**
  102040. * Add keyboard input support to the input manager.
  102041. * @returns the current input manager
  102042. */
  102043. addKeyboard(): ArcRotateCameraInputsManager;
  102044. }
  102045. }
  102046. declare module BABYLON {
  102047. /**
  102048. * This represents an orbital type of camera.
  102049. *
  102050. * 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.
  102051. * 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.
  102052. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  102053. */
  102054. export class ArcRotateCamera extends TargetCamera {
  102055. /**
  102056. * Defines the rotation angle of the camera along the longitudinal axis.
  102057. */
  102058. alpha: number;
  102059. /**
  102060. * Defines the rotation angle of the camera along the latitudinal axis.
  102061. */
  102062. beta: number;
  102063. /**
  102064. * Defines the radius of the camera from it s target point.
  102065. */
  102066. radius: number;
  102067. protected _target: Vector3;
  102068. protected _targetHost: Nullable<AbstractMesh>;
  102069. /**
  102070. * Defines the target point of the camera.
  102071. * The camera looks towards it form the radius distance.
  102072. */
  102073. target: Vector3;
  102074. /**
  102075. * Define the current local position of the camera in the scene
  102076. */
  102077. position: Vector3;
  102078. protected _upVector: Vector3;
  102079. protected _upToYMatrix: Matrix;
  102080. protected _YToUpMatrix: Matrix;
  102081. /**
  102082. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  102083. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  102084. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  102085. */
  102086. upVector: Vector3;
  102087. /**
  102088. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  102089. */
  102090. setMatUp(): void;
  102091. /**
  102092. * Current inertia value on the longitudinal axis.
  102093. * The bigger this number the longer it will take for the camera to stop.
  102094. */
  102095. inertialAlphaOffset: number;
  102096. /**
  102097. * Current inertia value on the latitudinal axis.
  102098. * The bigger this number the longer it will take for the camera to stop.
  102099. */
  102100. inertialBetaOffset: number;
  102101. /**
  102102. * Current inertia value on the radius axis.
  102103. * The bigger this number the longer it will take for the camera to stop.
  102104. */
  102105. inertialRadiusOffset: number;
  102106. /**
  102107. * Minimum allowed angle on the longitudinal axis.
  102108. * This can help limiting how the Camera is able to move in the scene.
  102109. */
  102110. lowerAlphaLimit: Nullable<number>;
  102111. /**
  102112. * Maximum allowed angle on the longitudinal axis.
  102113. * This can help limiting how the Camera is able to move in the scene.
  102114. */
  102115. upperAlphaLimit: Nullable<number>;
  102116. /**
  102117. * Minimum allowed angle on the latitudinal axis.
  102118. * This can help limiting how the Camera is able to move in the scene.
  102119. */
  102120. lowerBetaLimit: number;
  102121. /**
  102122. * Maximum allowed angle on the latitudinal axis.
  102123. * This can help limiting how the Camera is able to move in the scene.
  102124. */
  102125. upperBetaLimit: number;
  102126. /**
  102127. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  102128. * This can help limiting how the Camera is able to move in the scene.
  102129. */
  102130. lowerRadiusLimit: Nullable<number>;
  102131. /**
  102132. * Maximum allowed distance of the camera to the target (The camera can not get further).
  102133. * This can help limiting how the Camera is able to move in the scene.
  102134. */
  102135. upperRadiusLimit: Nullable<number>;
  102136. /**
  102137. * Defines the current inertia value used during panning of the camera along the X axis.
  102138. */
  102139. inertialPanningX: number;
  102140. /**
  102141. * Defines the current inertia value used during panning of the camera along the Y axis.
  102142. */
  102143. inertialPanningY: number;
  102144. /**
  102145. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  102146. * Basically if your fingers moves away from more than this distance you will be considered
  102147. * in pinch mode.
  102148. */
  102149. pinchToPanMaxDistance: number;
  102150. /**
  102151. * Defines the maximum distance the camera can pan.
  102152. * This could help keeping the cammera always in your scene.
  102153. */
  102154. panningDistanceLimit: Nullable<number>;
  102155. /**
  102156. * Defines the target of the camera before paning.
  102157. */
  102158. panningOriginTarget: Vector3;
  102159. /**
  102160. * Defines the value of the inertia used during panning.
  102161. * 0 would mean stop inertia and one would mean no decelleration at all.
  102162. */
  102163. panningInertia: number;
  102164. /**
  102165. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  102166. */
  102167. angularSensibilityX: number;
  102168. /**
  102169. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  102170. */
  102171. angularSensibilityY: number;
  102172. /**
  102173. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  102174. */
  102175. pinchPrecision: number;
  102176. /**
  102177. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  102178. * It will be used instead of pinchDeltaPrecision if different from 0.
  102179. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102180. */
  102181. pinchDeltaPercentage: number;
  102182. /**
  102183. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  102184. */
  102185. panningSensibility: number;
  102186. /**
  102187. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  102188. */
  102189. keysUp: number[];
  102190. /**
  102191. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  102192. */
  102193. keysDown: number[];
  102194. /**
  102195. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  102196. */
  102197. keysLeft: number[];
  102198. /**
  102199. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  102200. */
  102201. keysRight: number[];
  102202. /**
  102203. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  102204. */
  102205. wheelPrecision: number;
  102206. /**
  102207. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  102208. * It will be used instead of pinchDeltaPrecision if different from 0.
  102209. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  102210. */
  102211. wheelDeltaPercentage: number;
  102212. /**
  102213. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  102214. */
  102215. zoomOnFactor: number;
  102216. /**
  102217. * Defines a screen offset for the camera position.
  102218. */
  102219. targetScreenOffset: Vector2;
  102220. /**
  102221. * Allows the camera to be completely reversed.
  102222. * If false the camera can not arrive upside down.
  102223. */
  102224. allowUpsideDown: boolean;
  102225. /**
  102226. * Define if double tap/click is used to restore the previously saved state of the camera.
  102227. */
  102228. useInputToRestoreState: boolean;
  102229. /** @hidden */
  102230. _viewMatrix: Matrix;
  102231. /** @hidden */
  102232. _useCtrlForPanning: boolean;
  102233. /** @hidden */
  102234. _panningMouseButton: number;
  102235. /**
  102236. * Defines the input associated to the camera.
  102237. */
  102238. inputs: ArcRotateCameraInputsManager;
  102239. /** @hidden */
  102240. _reset: () => void;
  102241. /**
  102242. * Defines the allowed panning axis.
  102243. */
  102244. panningAxis: Vector3;
  102245. protected _localDirection: Vector3;
  102246. protected _transformedDirection: Vector3;
  102247. private _bouncingBehavior;
  102248. /**
  102249. * Gets the bouncing behavior of the camera if it has been enabled.
  102250. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102251. */
  102252. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  102253. /**
  102254. * Defines if the bouncing behavior of the camera is enabled on the camera.
  102255. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102256. */
  102257. useBouncingBehavior: boolean;
  102258. private _framingBehavior;
  102259. /**
  102260. * Gets the framing behavior of the camera if it has been enabled.
  102261. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102262. */
  102263. readonly framingBehavior: Nullable<FramingBehavior>;
  102264. /**
  102265. * Defines if the framing behavior of the camera is enabled on the camera.
  102266. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102267. */
  102268. useFramingBehavior: boolean;
  102269. private _autoRotationBehavior;
  102270. /**
  102271. * Gets the auto rotation behavior of the camera if it has been enabled.
  102272. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102273. */
  102274. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  102275. /**
  102276. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  102277. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102278. */
  102279. useAutoRotationBehavior: boolean;
  102280. /**
  102281. * Observable triggered when the mesh target has been changed on the camera.
  102282. */
  102283. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  102284. /**
  102285. * Event raised when the camera is colliding with a mesh.
  102286. */
  102287. onCollide: (collidedMesh: AbstractMesh) => void;
  102288. /**
  102289. * Defines whether the camera should check collision with the objects oh the scene.
  102290. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  102291. */
  102292. checkCollisions: boolean;
  102293. /**
  102294. * Defines the collision radius of the camera.
  102295. * This simulates a sphere around the camera.
  102296. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  102297. */
  102298. collisionRadius: Vector3;
  102299. protected _collider: Collider;
  102300. protected _previousPosition: Vector3;
  102301. protected _collisionVelocity: Vector3;
  102302. protected _newPosition: Vector3;
  102303. protected _previousAlpha: number;
  102304. protected _previousBeta: number;
  102305. protected _previousRadius: number;
  102306. protected _collisionTriggered: boolean;
  102307. protected _targetBoundingCenter: Nullable<Vector3>;
  102308. private _computationVector;
  102309. /**
  102310. * Instantiates a new ArcRotateCamera in a given scene
  102311. * @param name Defines the name of the camera
  102312. * @param alpha Defines the camera rotation along the logitudinal axis
  102313. * @param beta Defines the camera rotation along the latitudinal axis
  102314. * @param radius Defines the camera distance from its target
  102315. * @param target Defines the camera target
  102316. * @param scene Defines the scene the camera belongs to
  102317. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  102318. */
  102319. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  102320. /** @hidden */
  102321. _initCache(): void;
  102322. /** @hidden */
  102323. _updateCache(ignoreParentClass?: boolean): void;
  102324. protected _getTargetPosition(): Vector3;
  102325. private _storedAlpha;
  102326. private _storedBeta;
  102327. private _storedRadius;
  102328. private _storedTarget;
  102329. private _storedTargetScreenOffset;
  102330. /**
  102331. * Stores the current state of the camera (alpha, beta, radius and target)
  102332. * @returns the camera itself
  102333. */
  102334. storeState(): Camera;
  102335. /**
  102336. * @hidden
  102337. * Restored camera state. You must call storeState() first
  102338. */
  102339. _restoreStateValues(): boolean;
  102340. /** @hidden */
  102341. _isSynchronizedViewMatrix(): boolean;
  102342. /**
  102343. * Attached controls to the current camera.
  102344. * @param element Defines the element the controls should be listened from
  102345. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102346. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  102347. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  102348. */
  102349. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  102350. /**
  102351. * Detach the current controls from the camera.
  102352. * The camera will stop reacting to inputs.
  102353. * @param element Defines the element to stop listening the inputs from
  102354. */
  102355. detachControl(element: HTMLElement): void;
  102356. /** @hidden */
  102357. _checkInputs(): void;
  102358. protected _checkLimits(): void;
  102359. /**
  102360. * Rebuilds angles (alpha, beta) and radius from the give position and target
  102361. */
  102362. rebuildAnglesAndRadius(): void;
  102363. /**
  102364. * Use a position to define the current camera related information like aplha, beta and radius
  102365. * @param position Defines the position to set the camera at
  102366. */
  102367. setPosition(position: Vector3): void;
  102368. /**
  102369. * Defines the target the camera should look at.
  102370. * This will automatically adapt alpha beta and radius to fit within the new target.
  102371. * @param target Defines the new target as a Vector or a mesh
  102372. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  102373. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  102374. */
  102375. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  102376. /** @hidden */
  102377. _getViewMatrix(): Matrix;
  102378. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  102379. /**
  102380. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  102381. * @param meshes Defines the mesh to zoom on
  102382. * @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)
  102383. */
  102384. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  102385. /**
  102386. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  102387. * The target will be changed but the radius
  102388. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  102389. * @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)
  102390. */
  102391. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  102392. min: Vector3;
  102393. max: Vector3;
  102394. distance: number;
  102395. }, doNotUpdateMaxZ?: boolean): void;
  102396. /**
  102397. * @override
  102398. * Override Camera.createRigCamera
  102399. */
  102400. createRigCamera(name: string, cameraIndex: number): Camera;
  102401. /**
  102402. * @hidden
  102403. * @override
  102404. * Override Camera._updateRigCameras
  102405. */
  102406. _updateRigCameras(): void;
  102407. /**
  102408. * Destroy the camera and release the current resources hold by it.
  102409. */
  102410. dispose(): void;
  102411. /**
  102412. * Gets the current object class name.
  102413. * @return the class name
  102414. */
  102415. getClassName(): string;
  102416. }
  102417. }
  102418. declare module BABYLON {
  102419. /**
  102420. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  102421. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  102422. */
  102423. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  102424. /**
  102425. * Gets the name of the behavior.
  102426. */
  102427. readonly name: string;
  102428. private _zoomStopsAnimation;
  102429. private _idleRotationSpeed;
  102430. private _idleRotationWaitTime;
  102431. private _idleRotationSpinupTime;
  102432. /**
  102433. * Sets the flag that indicates if user zooming should stop animation.
  102434. */
  102435. /**
  102436. * Gets the flag that indicates if user zooming should stop animation.
  102437. */
  102438. zoomStopsAnimation: boolean;
  102439. /**
  102440. * Sets the default speed at which the camera rotates around the model.
  102441. */
  102442. /**
  102443. * Gets the default speed at which the camera rotates around the model.
  102444. */
  102445. idleRotationSpeed: number;
  102446. /**
  102447. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  102448. */
  102449. /**
  102450. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  102451. */
  102452. idleRotationWaitTime: number;
  102453. /**
  102454. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102455. */
  102456. /**
  102457. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  102458. */
  102459. idleRotationSpinupTime: number;
  102460. /**
  102461. * Gets a value indicating if the camera is currently rotating because of this behavior
  102462. */
  102463. readonly rotationInProgress: boolean;
  102464. private _onPrePointerObservableObserver;
  102465. private _onAfterCheckInputsObserver;
  102466. private _attachedCamera;
  102467. private _isPointerDown;
  102468. private _lastFrameTime;
  102469. private _lastInteractionTime;
  102470. private _cameraRotationSpeed;
  102471. /**
  102472. * Initializes the behavior.
  102473. */
  102474. init(): void;
  102475. /**
  102476. * Attaches the behavior to its arc rotate camera.
  102477. * @param camera Defines the camera to attach the behavior to
  102478. */
  102479. attach(camera: ArcRotateCamera): void;
  102480. /**
  102481. * Detaches the behavior from its current arc rotate camera.
  102482. */
  102483. detach(): void;
  102484. /**
  102485. * Returns true if user is scrolling.
  102486. * @return true if user is scrolling.
  102487. */
  102488. private _userIsZooming;
  102489. private _lastFrameRadius;
  102490. private _shouldAnimationStopForInteraction;
  102491. /**
  102492. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102493. */
  102494. private _applyUserInteraction;
  102495. private _userIsMoving;
  102496. }
  102497. }
  102498. declare module BABYLON {
  102499. /**
  102500. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  102501. */
  102502. export class AttachToBoxBehavior implements Behavior<Mesh> {
  102503. private ui;
  102504. /**
  102505. * The name of the behavior
  102506. */
  102507. name: string;
  102508. /**
  102509. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  102510. */
  102511. distanceAwayFromFace: number;
  102512. /**
  102513. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  102514. */
  102515. distanceAwayFromBottomOfFace: number;
  102516. private _faceVectors;
  102517. private _target;
  102518. private _scene;
  102519. private _onRenderObserver;
  102520. private _tmpMatrix;
  102521. private _tmpVector;
  102522. /**
  102523. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  102524. * @param ui The transform node that should be attched to the mesh
  102525. */
  102526. constructor(ui: TransformNode);
  102527. /**
  102528. * Initializes the behavior
  102529. */
  102530. init(): void;
  102531. private _closestFace;
  102532. private _zeroVector;
  102533. private _lookAtTmpMatrix;
  102534. private _lookAtToRef;
  102535. /**
  102536. * Attaches the AttachToBoxBehavior to the passed in mesh
  102537. * @param target The mesh that the specified node will be attached to
  102538. */
  102539. attach(target: Mesh): void;
  102540. /**
  102541. * Detaches the behavior from the mesh
  102542. */
  102543. detach(): void;
  102544. }
  102545. }
  102546. declare module BABYLON {
  102547. /**
  102548. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  102549. */
  102550. export class FadeInOutBehavior implements Behavior<Mesh> {
  102551. /**
  102552. * Time in milliseconds to delay before fading in (Default: 0)
  102553. */
  102554. delay: number;
  102555. /**
  102556. * Time in milliseconds for the mesh to fade in (Default: 300)
  102557. */
  102558. fadeInTime: number;
  102559. private _millisecondsPerFrame;
  102560. private _hovered;
  102561. private _hoverValue;
  102562. private _ownerNode;
  102563. /**
  102564. * Instatiates the FadeInOutBehavior
  102565. */
  102566. constructor();
  102567. /**
  102568. * The name of the behavior
  102569. */
  102570. readonly name: string;
  102571. /**
  102572. * Initializes the behavior
  102573. */
  102574. init(): void;
  102575. /**
  102576. * Attaches the fade behavior on the passed in mesh
  102577. * @param ownerNode The mesh that will be faded in/out once attached
  102578. */
  102579. attach(ownerNode: Mesh): void;
  102580. /**
  102581. * Detaches the behavior from the mesh
  102582. */
  102583. detach(): void;
  102584. /**
  102585. * Triggers the mesh to begin fading in or out
  102586. * @param value if the object should fade in or out (true to fade in)
  102587. */
  102588. fadeIn(value: boolean): void;
  102589. private _update;
  102590. private _setAllVisibility;
  102591. }
  102592. }
  102593. declare module BABYLON {
  102594. /**
  102595. * Class containing a set of static utilities functions for managing Pivots
  102596. * @hidden
  102597. */
  102598. export class PivotTools {
  102599. private static _PivotCached;
  102600. private static _OldPivotPoint;
  102601. private static _PivotTranslation;
  102602. private static _PivotTmpVector;
  102603. /** @hidden */
  102604. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  102605. /** @hidden */
  102606. static _RestorePivotPoint(mesh: AbstractMesh): void;
  102607. }
  102608. }
  102609. declare module BABYLON {
  102610. /**
  102611. * Class containing static functions to help procedurally build meshes
  102612. */
  102613. export class PlaneBuilder {
  102614. /**
  102615. * Creates a plane mesh
  102616. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  102617. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  102618. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  102619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102620. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102622. * @param name defines the name of the mesh
  102623. * @param options defines the options used to create the mesh
  102624. * @param scene defines the hosting scene
  102625. * @returns the plane mesh
  102626. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  102627. */
  102628. static CreatePlane(name: string, options: {
  102629. size?: number;
  102630. width?: number;
  102631. height?: number;
  102632. sideOrientation?: number;
  102633. frontUVs?: Vector4;
  102634. backUVs?: Vector4;
  102635. updatable?: boolean;
  102636. sourcePlane?: Plane;
  102637. }, scene?: Nullable<Scene>): Mesh;
  102638. }
  102639. }
  102640. declare module BABYLON {
  102641. /**
  102642. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  102643. */
  102644. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  102645. private static _AnyMouseID;
  102646. /**
  102647. * Abstract mesh the behavior is set on
  102648. */
  102649. attachedNode: AbstractMesh;
  102650. private _dragPlane;
  102651. private _scene;
  102652. private _pointerObserver;
  102653. private _beforeRenderObserver;
  102654. private static _planeScene;
  102655. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  102656. /**
  102657. * 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)
  102658. */
  102659. maxDragAngle: number;
  102660. /**
  102661. * @hidden
  102662. */
  102663. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  102664. /**
  102665. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102666. */
  102667. currentDraggingPointerID: number;
  102668. /**
  102669. * The last position where the pointer hit the drag plane in world space
  102670. */
  102671. lastDragPosition: Vector3;
  102672. /**
  102673. * If the behavior is currently in a dragging state
  102674. */
  102675. dragging: boolean;
  102676. /**
  102677. * 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)
  102678. */
  102679. dragDeltaRatio: number;
  102680. /**
  102681. * If the drag plane orientation should be updated during the dragging (Default: true)
  102682. */
  102683. updateDragPlane: boolean;
  102684. private _debugMode;
  102685. private _moving;
  102686. /**
  102687. * Fires each time the attached mesh is dragged with the pointer
  102688. * * delta between last drag position and current drag position in world space
  102689. * * dragDistance along the drag axis
  102690. * * dragPlaneNormal normal of the current drag plane used during the drag
  102691. * * dragPlanePoint in world space where the drag intersects the drag plane
  102692. */
  102693. onDragObservable: Observable<{
  102694. delta: Vector3;
  102695. dragPlanePoint: Vector3;
  102696. dragPlaneNormal: Vector3;
  102697. dragDistance: number;
  102698. pointerId: number;
  102699. }>;
  102700. /**
  102701. * Fires each time a drag begins (eg. mouse down on mesh)
  102702. */
  102703. onDragStartObservable: Observable<{
  102704. dragPlanePoint: Vector3;
  102705. pointerId: number;
  102706. }>;
  102707. /**
  102708. * Fires each time a drag ends (eg. mouse release after drag)
  102709. */
  102710. onDragEndObservable: Observable<{
  102711. dragPlanePoint: Vector3;
  102712. pointerId: number;
  102713. }>;
  102714. /**
  102715. * If the attached mesh should be moved when dragged
  102716. */
  102717. moveAttached: boolean;
  102718. /**
  102719. * If the drag behavior will react to drag events (Default: true)
  102720. */
  102721. enabled: boolean;
  102722. /**
  102723. * If pointer events should start and release the drag (Default: true)
  102724. */
  102725. startAndReleaseDragOnPointerEvents: boolean;
  102726. /**
  102727. * If camera controls should be detached during the drag
  102728. */
  102729. detachCameraControls: boolean;
  102730. /**
  102731. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  102732. */
  102733. useObjectOrienationForDragging: boolean;
  102734. private _options;
  102735. /**
  102736. * Creates a pointer drag behavior that can be attached to a mesh
  102737. * @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)
  102738. */
  102739. constructor(options?: {
  102740. dragAxis?: Vector3;
  102741. dragPlaneNormal?: Vector3;
  102742. });
  102743. /**
  102744. * Predicate to determine if it is valid to move the object to a new position when it is moved
  102745. */
  102746. validateDrag: (targetPosition: Vector3) => boolean;
  102747. /**
  102748. * The name of the behavior
  102749. */
  102750. readonly name: string;
  102751. /**
  102752. * Initializes the behavior
  102753. */
  102754. init(): void;
  102755. private _tmpVector;
  102756. private _alternatePickedPoint;
  102757. private _worldDragAxis;
  102758. private _targetPosition;
  102759. private _attachedElement;
  102760. /**
  102761. * Attaches the drag behavior the passed in mesh
  102762. * @param ownerNode The mesh that will be dragged around once attached
  102763. * @param predicate Predicate to use for pick filtering
  102764. */
  102765. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  102766. /**
  102767. * Force relase the drag action by code.
  102768. */
  102769. releaseDrag(): void;
  102770. private _startDragRay;
  102771. private _lastPointerRay;
  102772. /**
  102773. * Simulates the start of a pointer drag event on the behavior
  102774. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  102775. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  102776. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  102777. */
  102778. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  102779. private _startDrag;
  102780. private _dragDelta;
  102781. private _moveDrag;
  102782. private _pickWithRayOnDragPlane;
  102783. private _pointA;
  102784. private _pointB;
  102785. private _pointC;
  102786. private _lineA;
  102787. private _lineB;
  102788. private _localAxis;
  102789. private _lookAt;
  102790. private _updateDragPlanePosition;
  102791. /**
  102792. * Detaches the behavior from the mesh
  102793. */
  102794. detach(): void;
  102795. }
  102796. }
  102797. declare module BABYLON {
  102798. /**
  102799. * A behavior that when attached to a mesh will allow the mesh to be scaled
  102800. */
  102801. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  102802. private _dragBehaviorA;
  102803. private _dragBehaviorB;
  102804. private _startDistance;
  102805. private _initialScale;
  102806. private _targetScale;
  102807. private _ownerNode;
  102808. private _sceneRenderObserver;
  102809. /**
  102810. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  102811. */
  102812. constructor();
  102813. /**
  102814. * The name of the behavior
  102815. */
  102816. readonly name: string;
  102817. /**
  102818. * Initializes the behavior
  102819. */
  102820. init(): void;
  102821. private _getCurrentDistance;
  102822. /**
  102823. * Attaches the scale behavior the passed in mesh
  102824. * @param ownerNode The mesh that will be scaled around once attached
  102825. */
  102826. attach(ownerNode: Mesh): void;
  102827. /**
  102828. * Detaches the behavior from the mesh
  102829. */
  102830. detach(): void;
  102831. }
  102832. }
  102833. declare module BABYLON {
  102834. /**
  102835. * 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
  102836. */
  102837. export class SixDofDragBehavior implements Behavior<Mesh> {
  102838. private static _virtualScene;
  102839. private _ownerNode;
  102840. private _sceneRenderObserver;
  102841. private _scene;
  102842. private _targetPosition;
  102843. private _virtualOriginMesh;
  102844. private _virtualDragMesh;
  102845. private _pointerObserver;
  102846. private _moving;
  102847. private _startingOrientation;
  102848. /**
  102849. * 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)
  102850. */
  102851. private zDragFactor;
  102852. /**
  102853. * If the object should rotate to face the drag origin
  102854. */
  102855. rotateDraggedObject: boolean;
  102856. /**
  102857. * If the behavior is currently in a dragging state
  102858. */
  102859. dragging: boolean;
  102860. /**
  102861. * 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)
  102862. */
  102863. dragDeltaRatio: number;
  102864. /**
  102865. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  102866. */
  102867. currentDraggingPointerID: number;
  102868. /**
  102869. * If camera controls should be detached during the drag
  102870. */
  102871. detachCameraControls: boolean;
  102872. /**
  102873. * Fires each time a drag starts
  102874. */
  102875. onDragStartObservable: Observable<{}>;
  102876. /**
  102877. * Fires each time a drag ends (eg. mouse release after drag)
  102878. */
  102879. onDragEndObservable: Observable<{}>;
  102880. /**
  102881. * 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
  102882. */
  102883. constructor();
  102884. /**
  102885. * The name of the behavior
  102886. */
  102887. readonly name: string;
  102888. /**
  102889. * Initializes the behavior
  102890. */
  102891. init(): void;
  102892. /**
  102893. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  102894. */
  102895. private readonly _pointerCamera;
  102896. /**
  102897. * Attaches the scale behavior the passed in mesh
  102898. * @param ownerNode The mesh that will be scaled around once attached
  102899. */
  102900. attach(ownerNode: Mesh): void;
  102901. /**
  102902. * Detaches the behavior from the mesh
  102903. */
  102904. detach(): void;
  102905. }
  102906. }
  102907. declare module BABYLON {
  102908. /**
  102909. * Class used to apply inverse kinematics to bones
  102910. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  102911. */
  102912. export class BoneIKController {
  102913. private static _tmpVecs;
  102914. private static _tmpQuat;
  102915. private static _tmpMats;
  102916. /**
  102917. * Gets or sets the target mesh
  102918. */
  102919. targetMesh: AbstractMesh;
  102920. /** Gets or sets the mesh used as pole */
  102921. poleTargetMesh: AbstractMesh;
  102922. /**
  102923. * Gets or sets the bone used as pole
  102924. */
  102925. poleTargetBone: Nullable<Bone>;
  102926. /**
  102927. * Gets or sets the target position
  102928. */
  102929. targetPosition: Vector3;
  102930. /**
  102931. * Gets or sets the pole target position
  102932. */
  102933. poleTargetPosition: Vector3;
  102934. /**
  102935. * Gets or sets the pole target local offset
  102936. */
  102937. poleTargetLocalOffset: Vector3;
  102938. /**
  102939. * Gets or sets the pole angle
  102940. */
  102941. poleAngle: number;
  102942. /**
  102943. * Gets or sets the mesh associated with the controller
  102944. */
  102945. mesh: AbstractMesh;
  102946. /**
  102947. * 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)
  102948. */
  102949. slerpAmount: number;
  102950. private _bone1Quat;
  102951. private _bone1Mat;
  102952. private _bone2Ang;
  102953. private _bone1;
  102954. private _bone2;
  102955. private _bone1Length;
  102956. private _bone2Length;
  102957. private _maxAngle;
  102958. private _maxReach;
  102959. private _rightHandedSystem;
  102960. private _bendAxis;
  102961. private _slerping;
  102962. private _adjustRoll;
  102963. /**
  102964. * Gets or sets maximum allowed angle
  102965. */
  102966. maxAngle: number;
  102967. /**
  102968. * Creates a new BoneIKController
  102969. * @param mesh defines the mesh to control
  102970. * @param bone defines the bone to control
  102971. * @param options defines options to set up the controller
  102972. */
  102973. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  102974. targetMesh?: AbstractMesh;
  102975. poleTargetMesh?: AbstractMesh;
  102976. poleTargetBone?: Bone;
  102977. poleTargetLocalOffset?: Vector3;
  102978. poleAngle?: number;
  102979. bendAxis?: Vector3;
  102980. maxAngle?: number;
  102981. slerpAmount?: number;
  102982. });
  102983. private _setMaxAngle;
  102984. /**
  102985. * Force the controller to update the bones
  102986. */
  102987. update(): void;
  102988. }
  102989. }
  102990. declare module BABYLON {
  102991. /**
  102992. * Class used to make a bone look toward a point in space
  102993. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  102994. */
  102995. export class BoneLookController {
  102996. private static _tmpVecs;
  102997. private static _tmpQuat;
  102998. private static _tmpMats;
  102999. /**
  103000. * The target Vector3 that the bone will look at
  103001. */
  103002. target: Vector3;
  103003. /**
  103004. * The mesh that the bone is attached to
  103005. */
  103006. mesh: AbstractMesh;
  103007. /**
  103008. * The bone that will be looking to the target
  103009. */
  103010. bone: Bone;
  103011. /**
  103012. * The up axis of the coordinate system that is used when the bone is rotated
  103013. */
  103014. upAxis: Vector3;
  103015. /**
  103016. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  103017. */
  103018. upAxisSpace: Space;
  103019. /**
  103020. * Used to make an adjustment to the yaw of the bone
  103021. */
  103022. adjustYaw: number;
  103023. /**
  103024. * Used to make an adjustment to the pitch of the bone
  103025. */
  103026. adjustPitch: number;
  103027. /**
  103028. * Used to make an adjustment to the roll of the bone
  103029. */
  103030. adjustRoll: number;
  103031. /**
  103032. * 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)
  103033. */
  103034. slerpAmount: number;
  103035. private _minYaw;
  103036. private _maxYaw;
  103037. private _minPitch;
  103038. private _maxPitch;
  103039. private _minYawSin;
  103040. private _minYawCos;
  103041. private _maxYawSin;
  103042. private _maxYawCos;
  103043. private _midYawConstraint;
  103044. private _minPitchTan;
  103045. private _maxPitchTan;
  103046. private _boneQuat;
  103047. private _slerping;
  103048. private _transformYawPitch;
  103049. private _transformYawPitchInv;
  103050. private _firstFrameSkipped;
  103051. private _yawRange;
  103052. private _fowardAxis;
  103053. /**
  103054. * Gets or sets the minimum yaw angle that the bone can look to
  103055. */
  103056. minYaw: number;
  103057. /**
  103058. * Gets or sets the maximum yaw angle that the bone can look to
  103059. */
  103060. maxYaw: number;
  103061. /**
  103062. * Gets or sets the minimum pitch angle that the bone can look to
  103063. */
  103064. minPitch: number;
  103065. /**
  103066. * Gets or sets the maximum pitch angle that the bone can look to
  103067. */
  103068. maxPitch: number;
  103069. /**
  103070. * Create a BoneLookController
  103071. * @param mesh the mesh that the bone belongs to
  103072. * @param bone the bone that will be looking to the target
  103073. * @param target the target Vector3 to look at
  103074. * @param options optional settings:
  103075. * * maxYaw: the maximum angle the bone will yaw to
  103076. * * minYaw: the minimum angle the bone will yaw to
  103077. * * maxPitch: the maximum angle the bone will pitch to
  103078. * * minPitch: the minimum angle the bone will yaw to
  103079. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  103080. * * upAxis: the up axis of the coordinate system
  103081. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  103082. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  103083. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  103084. * * adjustYaw: used to make an adjustment to the yaw of the bone
  103085. * * adjustPitch: used to make an adjustment to the pitch of the bone
  103086. * * adjustRoll: used to make an adjustment to the roll of the bone
  103087. **/
  103088. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  103089. maxYaw?: number;
  103090. minYaw?: number;
  103091. maxPitch?: number;
  103092. minPitch?: number;
  103093. slerpAmount?: number;
  103094. upAxis?: Vector3;
  103095. upAxisSpace?: Space;
  103096. yawAxis?: Vector3;
  103097. pitchAxis?: Vector3;
  103098. adjustYaw?: number;
  103099. adjustPitch?: number;
  103100. adjustRoll?: number;
  103101. });
  103102. /**
  103103. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  103104. */
  103105. update(): void;
  103106. private _getAngleDiff;
  103107. private _getAngleBetween;
  103108. private _isAngleBetween;
  103109. }
  103110. }
  103111. declare module BABYLON {
  103112. /**
  103113. * Manage the gamepad inputs to control an arc rotate camera.
  103114. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103115. */
  103116. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  103117. /**
  103118. * Defines the camera the input is attached to.
  103119. */
  103120. camera: ArcRotateCamera;
  103121. /**
  103122. * Defines the gamepad the input is gathering event from.
  103123. */
  103124. gamepad: Nullable<Gamepad>;
  103125. /**
  103126. * Defines the gamepad rotation sensiblity.
  103127. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  103128. */
  103129. gamepadRotationSensibility: number;
  103130. /**
  103131. * Defines the gamepad move sensiblity.
  103132. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  103133. */
  103134. gamepadMoveSensibility: number;
  103135. private _onGamepadConnectedObserver;
  103136. private _onGamepadDisconnectedObserver;
  103137. /**
  103138. * Attach the input controls to a specific dom element to get the input from.
  103139. * @param element Defines the element the controls should be listened from
  103140. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103141. */
  103142. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103143. /**
  103144. * Detach the current controls from the specified dom element.
  103145. * @param element Defines the element to stop listening the inputs from
  103146. */
  103147. detachControl(element: Nullable<HTMLElement>): void;
  103148. /**
  103149. * Update the current camera state depending on the inputs that have been used this frame.
  103150. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103151. */
  103152. checkInputs(): void;
  103153. /**
  103154. * Gets the class name of the current intput.
  103155. * @returns the class name
  103156. */
  103157. getClassName(): string;
  103158. /**
  103159. * Get the friendly name associated with the input class.
  103160. * @returns the input friendly name
  103161. */
  103162. getSimpleName(): string;
  103163. }
  103164. }
  103165. declare module BABYLON {
  103166. interface ArcRotateCameraInputsManager {
  103167. /**
  103168. * Add orientation input support to the input manager.
  103169. * @returns the current input manager
  103170. */
  103171. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  103172. }
  103173. /**
  103174. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  103175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103176. */
  103177. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  103178. /**
  103179. * Defines the camera the input is attached to.
  103180. */
  103181. camera: ArcRotateCamera;
  103182. /**
  103183. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  103184. */
  103185. alphaCorrection: number;
  103186. /**
  103187. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  103188. */
  103189. gammaCorrection: number;
  103190. private _alpha;
  103191. private _gamma;
  103192. private _dirty;
  103193. private _deviceOrientationHandler;
  103194. /**
  103195. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  103196. */
  103197. constructor();
  103198. /**
  103199. * Attach the input controls to a specific dom element to get the input from.
  103200. * @param element Defines the element the controls should be listened from
  103201. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103202. */
  103203. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103204. /** @hidden */
  103205. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  103206. /**
  103207. * Update the current camera state depending on the inputs that have been used this frame.
  103208. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103209. */
  103210. checkInputs(): void;
  103211. /**
  103212. * Detach the current controls from the specified dom element.
  103213. * @param element Defines the element to stop listening the inputs from
  103214. */
  103215. detachControl(element: Nullable<HTMLElement>): void;
  103216. /**
  103217. * Gets the class name of the current intput.
  103218. * @returns the class name
  103219. */
  103220. getClassName(): string;
  103221. /**
  103222. * Get the friendly name associated with the input class.
  103223. * @returns the input friendly name
  103224. */
  103225. getSimpleName(): string;
  103226. }
  103227. }
  103228. declare module BABYLON {
  103229. /**
  103230. * Listen to mouse events to control the camera.
  103231. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103232. */
  103233. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  103234. /**
  103235. * Defines the camera the input is attached to.
  103236. */
  103237. camera: FlyCamera;
  103238. /**
  103239. * Defines if touch is enabled. (Default is true.)
  103240. */
  103241. touchEnabled: boolean;
  103242. /**
  103243. * Defines the buttons associated with the input to handle camera rotation.
  103244. */
  103245. buttons: number[];
  103246. /**
  103247. * Assign buttons for Yaw control.
  103248. */
  103249. buttonsYaw: number[];
  103250. /**
  103251. * Assign buttons for Pitch control.
  103252. */
  103253. buttonsPitch: number[];
  103254. /**
  103255. * Assign buttons for Roll control.
  103256. */
  103257. buttonsRoll: number[];
  103258. /**
  103259. * Detect if any button is being pressed while mouse is moved.
  103260. * -1 = Mouse locked.
  103261. * 0 = Left button.
  103262. * 1 = Middle Button.
  103263. * 2 = Right Button.
  103264. */
  103265. activeButton: number;
  103266. /**
  103267. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  103268. * Higher values reduce its sensitivity.
  103269. */
  103270. angularSensibility: number;
  103271. private _mousemoveCallback;
  103272. private _observer;
  103273. private _rollObserver;
  103274. private previousPosition;
  103275. private noPreventDefault;
  103276. private element;
  103277. /**
  103278. * Listen to mouse events to control the camera.
  103279. * @param touchEnabled Define if touch is enabled. (Default is true.)
  103280. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103281. */
  103282. constructor(touchEnabled?: boolean);
  103283. /**
  103284. * Attach the mouse control to the HTML DOM element.
  103285. * @param element Defines the element that listens to the input events.
  103286. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  103287. */
  103288. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103289. /**
  103290. * Detach the current controls from the specified dom element.
  103291. * @param element Defines the element to stop listening the inputs from
  103292. */
  103293. detachControl(element: Nullable<HTMLElement>): void;
  103294. /**
  103295. * Gets the class name of the current input.
  103296. * @returns the class name.
  103297. */
  103298. getClassName(): string;
  103299. /**
  103300. * Get the friendly name associated with the input class.
  103301. * @returns the input's friendly name.
  103302. */
  103303. getSimpleName(): string;
  103304. private _pointerInput;
  103305. private _onMouseMove;
  103306. /**
  103307. * Rotate camera by mouse offset.
  103308. */
  103309. private rotateCamera;
  103310. }
  103311. }
  103312. declare module BABYLON {
  103313. /**
  103314. * Default Inputs manager for the FlyCamera.
  103315. * It groups all the default supported inputs for ease of use.
  103316. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103317. */
  103318. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  103319. /**
  103320. * Instantiates a new FlyCameraInputsManager.
  103321. * @param camera Defines the camera the inputs belong to.
  103322. */
  103323. constructor(camera: FlyCamera);
  103324. /**
  103325. * Add keyboard input support to the input manager.
  103326. * @returns the new FlyCameraKeyboardMoveInput().
  103327. */
  103328. addKeyboard(): FlyCameraInputsManager;
  103329. /**
  103330. * Add mouse input support to the input manager.
  103331. * @param touchEnabled Enable touch screen support.
  103332. * @returns the new FlyCameraMouseInput().
  103333. */
  103334. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  103335. }
  103336. }
  103337. declare module BABYLON {
  103338. /**
  103339. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103340. * such as in a 3D Space Shooter or a Flight Simulator.
  103341. */
  103342. export class FlyCamera extends TargetCamera {
  103343. /**
  103344. * Define the collision ellipsoid of the camera.
  103345. * This is helpful for simulating a camera body, like a player's body.
  103346. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103347. */
  103348. ellipsoid: Vector3;
  103349. /**
  103350. * Define an offset for the position of the ellipsoid around the camera.
  103351. * This can be helpful if the camera is attached away from the player's body center,
  103352. * such as at its head.
  103353. */
  103354. ellipsoidOffset: Vector3;
  103355. /**
  103356. * Enable or disable collisions of the camera with the rest of the scene objects.
  103357. */
  103358. checkCollisions: boolean;
  103359. /**
  103360. * Enable or disable gravity on the camera.
  103361. */
  103362. applyGravity: boolean;
  103363. /**
  103364. * Define the current direction the camera is moving to.
  103365. */
  103366. cameraDirection: Vector3;
  103367. /**
  103368. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  103369. * This overrides and empties cameraRotation.
  103370. */
  103371. rotationQuaternion: Quaternion;
  103372. /**
  103373. * Track Roll to maintain the wanted Rolling when looking around.
  103374. */
  103375. _trackRoll: number;
  103376. /**
  103377. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  103378. */
  103379. rollCorrect: number;
  103380. /**
  103381. * Mimic a banked turn, Rolling the camera when Yawing.
  103382. * It's recommended to use rollCorrect = 10 for faster banking correction.
  103383. */
  103384. bankedTurn: boolean;
  103385. /**
  103386. * Limit in radians for how much Roll banking will add. (Default: 90°)
  103387. */
  103388. bankedTurnLimit: number;
  103389. /**
  103390. * Value of 0 disables the banked Roll.
  103391. * Value of 1 is equal to the Yaw angle in radians.
  103392. */
  103393. bankedTurnMultiplier: number;
  103394. /**
  103395. * The inputs manager loads all the input sources, such as keyboard and mouse.
  103396. */
  103397. inputs: FlyCameraInputsManager;
  103398. /**
  103399. * Gets the input sensibility for mouse input.
  103400. * Higher values reduce sensitivity.
  103401. */
  103402. /**
  103403. * Sets the input sensibility for a mouse input.
  103404. * Higher values reduce sensitivity.
  103405. */
  103406. angularSensibility: number;
  103407. /**
  103408. * Get the keys for camera movement forward.
  103409. */
  103410. /**
  103411. * Set the keys for camera movement forward.
  103412. */
  103413. keysForward: number[];
  103414. /**
  103415. * Get the keys for camera movement backward.
  103416. */
  103417. keysBackward: number[];
  103418. /**
  103419. * Get the keys for camera movement up.
  103420. */
  103421. /**
  103422. * Set the keys for camera movement up.
  103423. */
  103424. keysUp: number[];
  103425. /**
  103426. * Get the keys for camera movement down.
  103427. */
  103428. /**
  103429. * Set the keys for camera movement down.
  103430. */
  103431. keysDown: number[];
  103432. /**
  103433. * Get the keys for camera movement left.
  103434. */
  103435. /**
  103436. * Set the keys for camera movement left.
  103437. */
  103438. keysLeft: number[];
  103439. /**
  103440. * Set the keys for camera movement right.
  103441. */
  103442. /**
  103443. * Set the keys for camera movement right.
  103444. */
  103445. keysRight: number[];
  103446. /**
  103447. * Event raised when the camera collides with a mesh in the scene.
  103448. */
  103449. onCollide: (collidedMesh: AbstractMesh) => void;
  103450. private _collider;
  103451. private _needMoveForGravity;
  103452. private _oldPosition;
  103453. private _diffPosition;
  103454. private _newPosition;
  103455. /** @hidden */
  103456. _localDirection: Vector3;
  103457. /** @hidden */
  103458. _transformedDirection: Vector3;
  103459. /**
  103460. * Instantiates a FlyCamera.
  103461. * This is a flying camera, designed for 3D movement and rotation in all directions,
  103462. * such as in a 3D Space Shooter or a Flight Simulator.
  103463. * @param name Define the name of the camera in the scene.
  103464. * @param position Define the starting position of the camera in the scene.
  103465. * @param scene Define the scene the camera belongs to.
  103466. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  103467. */
  103468. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103469. /**
  103470. * Attach a control to the HTML DOM element.
  103471. * @param element Defines the element that listens to the input events.
  103472. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  103473. */
  103474. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103475. /**
  103476. * Detach a control from the HTML DOM element.
  103477. * The camera will stop reacting to that input.
  103478. * @param element Defines the element that listens to the input events.
  103479. */
  103480. detachControl(element: HTMLElement): void;
  103481. private _collisionMask;
  103482. /**
  103483. * Get the mask that the camera ignores in collision events.
  103484. */
  103485. /**
  103486. * Set the mask that the camera ignores in collision events.
  103487. */
  103488. collisionMask: number;
  103489. /** @hidden */
  103490. _collideWithWorld(displacement: Vector3): void;
  103491. /** @hidden */
  103492. private _onCollisionPositionChange;
  103493. /** @hidden */
  103494. _checkInputs(): void;
  103495. /** @hidden */
  103496. _decideIfNeedsToMove(): boolean;
  103497. /** @hidden */
  103498. _updatePosition(): void;
  103499. /**
  103500. * Restore the Roll to its target value at the rate specified.
  103501. * @param rate - Higher means slower restoring.
  103502. * @hidden
  103503. */
  103504. restoreRoll(rate: number): void;
  103505. /**
  103506. * Destroy the camera and release the current resources held by it.
  103507. */
  103508. dispose(): void;
  103509. /**
  103510. * Get the current object class name.
  103511. * @returns the class name.
  103512. */
  103513. getClassName(): string;
  103514. }
  103515. }
  103516. declare module BABYLON {
  103517. /**
  103518. * Listen to keyboard events to control the camera.
  103519. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103520. */
  103521. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  103522. /**
  103523. * Defines the camera the input is attached to.
  103524. */
  103525. camera: FlyCamera;
  103526. /**
  103527. * The list of keyboard keys used to control the forward move of the camera.
  103528. */
  103529. keysForward: number[];
  103530. /**
  103531. * The list of keyboard keys used to control the backward move of the camera.
  103532. */
  103533. keysBackward: number[];
  103534. /**
  103535. * The list of keyboard keys used to control the forward move of the camera.
  103536. */
  103537. keysUp: number[];
  103538. /**
  103539. * The list of keyboard keys used to control the backward move of the camera.
  103540. */
  103541. keysDown: number[];
  103542. /**
  103543. * The list of keyboard keys used to control the right strafe move of the camera.
  103544. */
  103545. keysRight: number[];
  103546. /**
  103547. * The list of keyboard keys used to control the left strafe move of the camera.
  103548. */
  103549. keysLeft: number[];
  103550. private _keys;
  103551. private _onCanvasBlurObserver;
  103552. private _onKeyboardObserver;
  103553. private _engine;
  103554. private _scene;
  103555. /**
  103556. * Attach the input controls to a specific dom element to get the input from.
  103557. * @param element Defines the element the controls should be listened from
  103558. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103559. */
  103560. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103561. /**
  103562. * Detach the current controls from the specified dom element.
  103563. * @param element Defines the element to stop listening the inputs from
  103564. */
  103565. detachControl(element: Nullable<HTMLElement>): void;
  103566. /**
  103567. * Gets the class name of the current intput.
  103568. * @returns the class name
  103569. */
  103570. getClassName(): string;
  103571. /** @hidden */
  103572. _onLostFocus(e: FocusEvent): void;
  103573. /**
  103574. * Get the friendly name associated with the input class.
  103575. * @returns the input friendly name
  103576. */
  103577. getSimpleName(): string;
  103578. /**
  103579. * Update the current camera state depending on the inputs that have been used this frame.
  103580. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103581. */
  103582. checkInputs(): void;
  103583. }
  103584. }
  103585. declare module BABYLON {
  103586. /**
  103587. * Manage the mouse wheel inputs to control a follow camera.
  103588. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103589. */
  103590. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  103591. /**
  103592. * Defines the camera the input is attached to.
  103593. */
  103594. camera: FollowCamera;
  103595. /**
  103596. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  103597. */
  103598. axisControlRadius: boolean;
  103599. /**
  103600. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  103601. */
  103602. axisControlHeight: boolean;
  103603. /**
  103604. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  103605. */
  103606. axisControlRotation: boolean;
  103607. /**
  103608. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  103609. * relation to mouseWheel events.
  103610. */
  103611. wheelPrecision: number;
  103612. /**
  103613. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103614. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103615. */
  103616. wheelDeltaPercentage: number;
  103617. private _wheel;
  103618. private _observer;
  103619. /**
  103620. * Attach the input controls to a specific dom element to get the input from.
  103621. * @param element Defines the element the controls should be listened from
  103622. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103623. */
  103624. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103625. /**
  103626. * Detach the current controls from the specified dom element.
  103627. * @param element Defines the element to stop listening the inputs from
  103628. */
  103629. detachControl(element: Nullable<HTMLElement>): void;
  103630. /**
  103631. * Gets the class name of the current intput.
  103632. * @returns the class name
  103633. */
  103634. getClassName(): string;
  103635. /**
  103636. * Get the friendly name associated with the input class.
  103637. * @returns the input friendly name
  103638. */
  103639. getSimpleName(): string;
  103640. }
  103641. }
  103642. declare module BABYLON {
  103643. /**
  103644. * Manage the pointers inputs to control an follow camera.
  103645. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103646. */
  103647. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  103648. /**
  103649. * Defines the camera the input is attached to.
  103650. */
  103651. camera: FollowCamera;
  103652. /**
  103653. * Gets the class name of the current input.
  103654. * @returns the class name
  103655. */
  103656. getClassName(): string;
  103657. /**
  103658. * Defines the pointer angular sensibility along the X axis or how fast is
  103659. * the camera rotating.
  103660. * A negative number will reverse the axis direction.
  103661. */
  103662. angularSensibilityX: number;
  103663. /**
  103664. * Defines the pointer angular sensibility along the Y axis or how fast is
  103665. * the camera rotating.
  103666. * A negative number will reverse the axis direction.
  103667. */
  103668. angularSensibilityY: number;
  103669. /**
  103670. * Defines the pointer pinch precision or how fast is the camera zooming.
  103671. * A negative number will reverse the axis direction.
  103672. */
  103673. pinchPrecision: number;
  103674. /**
  103675. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  103676. * from 0.
  103677. * It defines the percentage of current camera.radius to use as delta when
  103678. * pinch zoom is used.
  103679. */
  103680. pinchDeltaPercentage: number;
  103681. /**
  103682. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  103683. */
  103684. axisXControlRadius: boolean;
  103685. /**
  103686. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  103687. */
  103688. axisXControlHeight: boolean;
  103689. /**
  103690. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  103691. */
  103692. axisXControlRotation: boolean;
  103693. /**
  103694. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  103695. */
  103696. axisYControlRadius: boolean;
  103697. /**
  103698. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  103699. */
  103700. axisYControlHeight: boolean;
  103701. /**
  103702. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  103703. */
  103704. axisYControlRotation: boolean;
  103705. /**
  103706. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  103707. */
  103708. axisPinchControlRadius: boolean;
  103709. /**
  103710. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  103711. */
  103712. axisPinchControlHeight: boolean;
  103713. /**
  103714. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  103715. */
  103716. axisPinchControlRotation: boolean;
  103717. /**
  103718. * Log error messages if basic misconfiguration has occurred.
  103719. */
  103720. warningEnable: boolean;
  103721. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  103722. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  103723. private _warningCounter;
  103724. private _warning;
  103725. }
  103726. }
  103727. declare module BABYLON {
  103728. /**
  103729. * Default Inputs manager for the FollowCamera.
  103730. * It groups all the default supported inputs for ease of use.
  103731. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103732. */
  103733. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  103734. /**
  103735. * Instantiates a new FollowCameraInputsManager.
  103736. * @param camera Defines the camera the inputs belong to
  103737. */
  103738. constructor(camera: FollowCamera);
  103739. /**
  103740. * Add keyboard input support to the input manager.
  103741. * @returns the current input manager
  103742. */
  103743. addKeyboard(): FollowCameraInputsManager;
  103744. /**
  103745. * Add mouse wheel input support to the input manager.
  103746. * @returns the current input manager
  103747. */
  103748. addMouseWheel(): FollowCameraInputsManager;
  103749. /**
  103750. * Add pointers input support to the input manager.
  103751. * @returns the current input manager
  103752. */
  103753. addPointers(): FollowCameraInputsManager;
  103754. /**
  103755. * Add orientation input support to the input manager.
  103756. * @returns the current input manager
  103757. */
  103758. addVRDeviceOrientation(): FollowCameraInputsManager;
  103759. }
  103760. }
  103761. declare module BABYLON {
  103762. /**
  103763. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  103764. * an arc rotate version arcFollowCamera are available.
  103765. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103766. */
  103767. export class FollowCamera extends TargetCamera {
  103768. /**
  103769. * Distance the follow camera should follow an object at
  103770. */
  103771. radius: number;
  103772. /**
  103773. * Minimum allowed distance of the camera to the axis of rotation
  103774. * (The camera can not get closer).
  103775. * This can help limiting how the Camera is able to move in the scene.
  103776. */
  103777. lowerRadiusLimit: Nullable<number>;
  103778. /**
  103779. * Maximum allowed distance of the camera to the axis of rotation
  103780. * (The camera can not get further).
  103781. * This can help limiting how the Camera is able to move in the scene.
  103782. */
  103783. upperRadiusLimit: Nullable<number>;
  103784. /**
  103785. * Define a rotation offset between the camera and the object it follows
  103786. */
  103787. rotationOffset: number;
  103788. /**
  103789. * Minimum allowed angle to camera position relative to target object.
  103790. * This can help limiting how the Camera is able to move in the scene.
  103791. */
  103792. lowerRotationOffsetLimit: Nullable<number>;
  103793. /**
  103794. * Maximum allowed angle to camera position relative to target object.
  103795. * This can help limiting how the Camera is able to move in the scene.
  103796. */
  103797. upperRotationOffsetLimit: Nullable<number>;
  103798. /**
  103799. * Define a height offset between the camera and the object it follows.
  103800. * It can help following an object from the top (like a car chaing a plane)
  103801. */
  103802. heightOffset: number;
  103803. /**
  103804. * Minimum allowed height of camera position relative to target object.
  103805. * This can help limiting how the Camera is able to move in the scene.
  103806. */
  103807. lowerHeightOffsetLimit: Nullable<number>;
  103808. /**
  103809. * Maximum allowed height of camera position relative to target object.
  103810. * This can help limiting how the Camera is able to move in the scene.
  103811. */
  103812. upperHeightOffsetLimit: Nullable<number>;
  103813. /**
  103814. * Define how fast the camera can accelerate to follow it s target.
  103815. */
  103816. cameraAcceleration: number;
  103817. /**
  103818. * Define the speed limit of the camera following an object.
  103819. */
  103820. maxCameraSpeed: number;
  103821. /**
  103822. * Define the target of the camera.
  103823. */
  103824. lockedTarget: Nullable<AbstractMesh>;
  103825. /**
  103826. * Defines the input associated with the camera.
  103827. */
  103828. inputs: FollowCameraInputsManager;
  103829. /**
  103830. * Instantiates the follow camera.
  103831. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103832. * @param name Define the name of the camera in the scene
  103833. * @param position Define the position of the camera
  103834. * @param scene Define the scene the camera belong to
  103835. * @param lockedTarget Define the target of the camera
  103836. */
  103837. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  103838. private _follow;
  103839. /**
  103840. * Attached controls to the current camera.
  103841. * @param element Defines the element the controls should be listened from
  103842. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103843. */
  103844. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103845. /**
  103846. * Detach the current controls from the camera.
  103847. * The camera will stop reacting to inputs.
  103848. * @param element Defines the element to stop listening the inputs from
  103849. */
  103850. detachControl(element: HTMLElement): void;
  103851. /** @hidden */
  103852. _checkInputs(): void;
  103853. private _checkLimits;
  103854. /**
  103855. * Gets the camera class name.
  103856. * @returns the class name
  103857. */
  103858. getClassName(): string;
  103859. }
  103860. /**
  103861. * Arc Rotate version of the follow camera.
  103862. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  103863. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103864. */
  103865. export class ArcFollowCamera extends TargetCamera {
  103866. /** The longitudinal angle of the camera */
  103867. alpha: number;
  103868. /** The latitudinal angle of the camera */
  103869. beta: number;
  103870. /** The radius of the camera from its target */
  103871. radius: number;
  103872. /** Define the camera target (the messh it should follow) */
  103873. target: Nullable<AbstractMesh>;
  103874. private _cartesianCoordinates;
  103875. /**
  103876. * Instantiates a new ArcFollowCamera
  103877. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  103878. * @param name Define the name of the camera
  103879. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  103880. * @param beta Define the rotation angle of the camera around the elevation axis
  103881. * @param radius Define the radius of the camera from its target point
  103882. * @param target Define the target of the camera
  103883. * @param scene Define the scene the camera belongs to
  103884. */
  103885. constructor(name: string,
  103886. /** The longitudinal angle of the camera */
  103887. alpha: number,
  103888. /** The latitudinal angle of the camera */
  103889. beta: number,
  103890. /** The radius of the camera from its target */
  103891. radius: number,
  103892. /** Define the camera target (the messh it should follow) */
  103893. target: Nullable<AbstractMesh>, scene: Scene);
  103894. private _follow;
  103895. /** @hidden */
  103896. _checkInputs(): void;
  103897. /**
  103898. * Returns the class name of the object.
  103899. * It is mostly used internally for serialization purposes.
  103900. */
  103901. getClassName(): string;
  103902. }
  103903. }
  103904. declare module BABYLON {
  103905. /**
  103906. * Manage the keyboard inputs to control the movement of a follow camera.
  103907. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103908. */
  103909. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  103910. /**
  103911. * Defines the camera the input is attached to.
  103912. */
  103913. camera: FollowCamera;
  103914. /**
  103915. * Defines the list of key codes associated with the up action (increase heightOffset)
  103916. */
  103917. keysHeightOffsetIncr: number[];
  103918. /**
  103919. * Defines the list of key codes associated with the down action (decrease heightOffset)
  103920. */
  103921. keysHeightOffsetDecr: number[];
  103922. /**
  103923. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  103924. */
  103925. keysHeightOffsetModifierAlt: boolean;
  103926. /**
  103927. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  103928. */
  103929. keysHeightOffsetModifierCtrl: boolean;
  103930. /**
  103931. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  103932. */
  103933. keysHeightOffsetModifierShift: boolean;
  103934. /**
  103935. * Defines the list of key codes associated with the left action (increase rotationOffset)
  103936. */
  103937. keysRotationOffsetIncr: number[];
  103938. /**
  103939. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  103940. */
  103941. keysRotationOffsetDecr: number[];
  103942. /**
  103943. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  103944. */
  103945. keysRotationOffsetModifierAlt: boolean;
  103946. /**
  103947. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  103948. */
  103949. keysRotationOffsetModifierCtrl: boolean;
  103950. /**
  103951. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  103952. */
  103953. keysRotationOffsetModifierShift: boolean;
  103954. /**
  103955. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  103956. */
  103957. keysRadiusIncr: number[];
  103958. /**
  103959. * Defines the list of key codes associated with the zoom-out action (increase radius)
  103960. */
  103961. keysRadiusDecr: number[];
  103962. /**
  103963. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  103964. */
  103965. keysRadiusModifierAlt: boolean;
  103966. /**
  103967. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  103968. */
  103969. keysRadiusModifierCtrl: boolean;
  103970. /**
  103971. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  103972. */
  103973. keysRadiusModifierShift: boolean;
  103974. /**
  103975. * Defines the rate of change of heightOffset.
  103976. */
  103977. heightSensibility: number;
  103978. /**
  103979. * Defines the rate of change of rotationOffset.
  103980. */
  103981. rotationSensibility: number;
  103982. /**
  103983. * Defines the rate of change of radius.
  103984. */
  103985. radiusSensibility: number;
  103986. private _keys;
  103987. private _ctrlPressed;
  103988. private _altPressed;
  103989. private _shiftPressed;
  103990. private _onCanvasBlurObserver;
  103991. private _onKeyboardObserver;
  103992. private _engine;
  103993. private _scene;
  103994. /**
  103995. * Attach the input controls to a specific dom element to get the input from.
  103996. * @param element Defines the element the controls should be listened from
  103997. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103998. */
  103999. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104000. /**
  104001. * Detach the current controls from the specified dom element.
  104002. * @param element Defines the element to stop listening the inputs from
  104003. */
  104004. detachControl(element: Nullable<HTMLElement>): void;
  104005. /**
  104006. * Update the current camera state depending on the inputs that have been used this frame.
  104007. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104008. */
  104009. checkInputs(): void;
  104010. /**
  104011. * Gets the class name of the current input.
  104012. * @returns the class name
  104013. */
  104014. getClassName(): string;
  104015. /**
  104016. * Get the friendly name associated with the input class.
  104017. * @returns the input friendly name
  104018. */
  104019. getSimpleName(): string;
  104020. /**
  104021. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104022. * allow modification of the heightOffset value.
  104023. */
  104024. private _modifierHeightOffset;
  104025. /**
  104026. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104027. * allow modification of the rotationOffset value.
  104028. */
  104029. private _modifierRotationOffset;
  104030. /**
  104031. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  104032. * allow modification of the radius value.
  104033. */
  104034. private _modifierRadius;
  104035. }
  104036. }
  104037. declare module BABYLON {
  104038. interface FreeCameraInputsManager {
  104039. /**
  104040. * @hidden
  104041. */
  104042. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  104043. /**
  104044. * Add orientation input support to the input manager.
  104045. * @returns the current input manager
  104046. */
  104047. addDeviceOrientation(): FreeCameraInputsManager;
  104048. }
  104049. /**
  104050. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  104051. * Screen rotation is taken into account.
  104052. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104053. */
  104054. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  104055. private _camera;
  104056. private _screenOrientationAngle;
  104057. private _constantTranform;
  104058. private _screenQuaternion;
  104059. private _alpha;
  104060. private _beta;
  104061. private _gamma;
  104062. /**
  104063. * Can be used to detect if a device orientation sensor is availible on a device
  104064. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  104065. * @returns a promise that will resolve on orientation change
  104066. */
  104067. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  104068. /**
  104069. * @hidden
  104070. */
  104071. _onDeviceOrientationChangedObservable: Observable<void>;
  104072. /**
  104073. * Instantiates a new input
  104074. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104075. */
  104076. constructor();
  104077. /**
  104078. * Define the camera controlled by the input.
  104079. */
  104080. camera: FreeCamera;
  104081. /**
  104082. * Attach the input controls to a specific dom element to get the input from.
  104083. * @param element Defines the element the controls should be listened from
  104084. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104085. */
  104086. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104087. private _orientationChanged;
  104088. private _deviceOrientation;
  104089. /**
  104090. * Detach the current controls from the specified dom element.
  104091. * @param element Defines the element to stop listening the inputs from
  104092. */
  104093. detachControl(element: Nullable<HTMLElement>): void;
  104094. /**
  104095. * Update the current camera state depending on the inputs that have been used this frame.
  104096. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104097. */
  104098. checkInputs(): void;
  104099. /**
  104100. * Gets the class name of the current intput.
  104101. * @returns the class name
  104102. */
  104103. getClassName(): string;
  104104. /**
  104105. * Get the friendly name associated with the input class.
  104106. * @returns the input friendly name
  104107. */
  104108. getSimpleName(): string;
  104109. }
  104110. }
  104111. declare module BABYLON {
  104112. /**
  104113. * Manage the gamepad inputs to control a free camera.
  104114. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104115. */
  104116. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  104117. /**
  104118. * Define the camera the input is attached to.
  104119. */
  104120. camera: FreeCamera;
  104121. /**
  104122. * Define the Gamepad controlling the input
  104123. */
  104124. gamepad: Nullable<Gamepad>;
  104125. /**
  104126. * Defines the gamepad rotation sensiblity.
  104127. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104128. */
  104129. gamepadAngularSensibility: number;
  104130. /**
  104131. * Defines the gamepad move sensiblity.
  104132. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104133. */
  104134. gamepadMoveSensibility: number;
  104135. private _onGamepadConnectedObserver;
  104136. private _onGamepadDisconnectedObserver;
  104137. private _cameraTransform;
  104138. private _deltaTransform;
  104139. private _vector3;
  104140. private _vector2;
  104141. /**
  104142. * Attach the input controls to a specific dom element to get the input from.
  104143. * @param element Defines the element the controls should be listened from
  104144. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104145. */
  104146. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104147. /**
  104148. * Detach the current controls from the specified dom element.
  104149. * @param element Defines the element to stop listening the inputs from
  104150. */
  104151. detachControl(element: Nullable<HTMLElement>): void;
  104152. /**
  104153. * Update the current camera state depending on the inputs that have been used this frame.
  104154. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104155. */
  104156. checkInputs(): void;
  104157. /**
  104158. * Gets the class name of the current intput.
  104159. * @returns the class name
  104160. */
  104161. getClassName(): string;
  104162. /**
  104163. * Get the friendly name associated with the input class.
  104164. * @returns the input friendly name
  104165. */
  104166. getSimpleName(): string;
  104167. }
  104168. }
  104169. declare module BABYLON {
  104170. /**
  104171. * Defines the potential axis of a Joystick
  104172. */
  104173. export enum JoystickAxis {
  104174. /** X axis */
  104175. X = 0,
  104176. /** Y axis */
  104177. Y = 1,
  104178. /** Z axis */
  104179. Z = 2
  104180. }
  104181. /**
  104182. * Class used to define virtual joystick (used in touch mode)
  104183. */
  104184. export class VirtualJoystick {
  104185. /**
  104186. * Gets or sets a boolean indicating that left and right values must be inverted
  104187. */
  104188. reverseLeftRight: boolean;
  104189. /**
  104190. * Gets or sets a boolean indicating that up and down values must be inverted
  104191. */
  104192. reverseUpDown: boolean;
  104193. /**
  104194. * Gets the offset value for the position (ie. the change of the position value)
  104195. */
  104196. deltaPosition: Vector3;
  104197. /**
  104198. * Gets a boolean indicating if the virtual joystick was pressed
  104199. */
  104200. pressed: boolean;
  104201. /**
  104202. * Canvas the virtual joystick will render onto, default z-index of this is 5
  104203. */
  104204. static Canvas: Nullable<HTMLCanvasElement>;
  104205. private static _globalJoystickIndex;
  104206. private static vjCanvasContext;
  104207. private static vjCanvasWidth;
  104208. private static vjCanvasHeight;
  104209. private static halfWidth;
  104210. private _action;
  104211. private _axisTargetedByLeftAndRight;
  104212. private _axisTargetedByUpAndDown;
  104213. private _joystickSensibility;
  104214. private _inversedSensibility;
  104215. private _joystickPointerID;
  104216. private _joystickColor;
  104217. private _joystickPointerPos;
  104218. private _joystickPreviousPointerPos;
  104219. private _joystickPointerStartPos;
  104220. private _deltaJoystickVector;
  104221. private _leftJoystick;
  104222. private _touches;
  104223. private _onPointerDownHandlerRef;
  104224. private _onPointerMoveHandlerRef;
  104225. private _onPointerUpHandlerRef;
  104226. private _onResize;
  104227. /**
  104228. * Creates a new virtual joystick
  104229. * @param leftJoystick defines that the joystick is for left hand (false by default)
  104230. */
  104231. constructor(leftJoystick?: boolean);
  104232. /**
  104233. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  104234. * @param newJoystickSensibility defines the new sensibility
  104235. */
  104236. setJoystickSensibility(newJoystickSensibility: number): void;
  104237. private _onPointerDown;
  104238. private _onPointerMove;
  104239. private _onPointerUp;
  104240. /**
  104241. * Change the color of the virtual joystick
  104242. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  104243. */
  104244. setJoystickColor(newColor: string): void;
  104245. /**
  104246. * Defines a callback to call when the joystick is touched
  104247. * @param action defines the callback
  104248. */
  104249. setActionOnTouch(action: () => any): void;
  104250. /**
  104251. * Defines which axis you'd like to control for left & right
  104252. * @param axis defines the axis to use
  104253. */
  104254. setAxisForLeftRight(axis: JoystickAxis): void;
  104255. /**
  104256. * Defines which axis you'd like to control for up & down
  104257. * @param axis defines the axis to use
  104258. */
  104259. setAxisForUpDown(axis: JoystickAxis): void;
  104260. private _drawVirtualJoystick;
  104261. /**
  104262. * Release internal HTML canvas
  104263. */
  104264. releaseCanvas(): void;
  104265. }
  104266. }
  104267. declare module BABYLON {
  104268. interface FreeCameraInputsManager {
  104269. /**
  104270. * Add virtual joystick input support to the input manager.
  104271. * @returns the current input manager
  104272. */
  104273. addVirtualJoystick(): FreeCameraInputsManager;
  104274. }
  104275. /**
  104276. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  104277. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104278. */
  104279. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  104280. /**
  104281. * Defines the camera the input is attached to.
  104282. */
  104283. camera: FreeCamera;
  104284. private _leftjoystick;
  104285. private _rightjoystick;
  104286. /**
  104287. * Gets the left stick of the virtual joystick.
  104288. * @returns The virtual Joystick
  104289. */
  104290. getLeftJoystick(): VirtualJoystick;
  104291. /**
  104292. * Gets the right stick of the virtual joystick.
  104293. * @returns The virtual Joystick
  104294. */
  104295. getRightJoystick(): VirtualJoystick;
  104296. /**
  104297. * Update the current camera state depending on the inputs that have been used this frame.
  104298. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104299. */
  104300. checkInputs(): void;
  104301. /**
  104302. * Attach the input controls to a specific dom element to get the input from.
  104303. * @param element Defines the element the controls should be listened from
  104304. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104305. */
  104306. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104307. /**
  104308. * Detach the current controls from the specified dom element.
  104309. * @param element Defines the element to stop listening the inputs from
  104310. */
  104311. detachControl(element: Nullable<HTMLElement>): void;
  104312. /**
  104313. * Gets the class name of the current intput.
  104314. * @returns the class name
  104315. */
  104316. getClassName(): string;
  104317. /**
  104318. * Get the friendly name associated with the input class.
  104319. * @returns the input friendly name
  104320. */
  104321. getSimpleName(): string;
  104322. }
  104323. }
  104324. declare module BABYLON {
  104325. /**
  104326. * This represents a FPS type of camera controlled by touch.
  104327. * This is like a universal camera minus the Gamepad controls.
  104328. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104329. */
  104330. export class TouchCamera extends FreeCamera {
  104331. /**
  104332. * Defines the touch sensibility for rotation.
  104333. * The higher the faster.
  104334. */
  104335. touchAngularSensibility: number;
  104336. /**
  104337. * Defines the touch sensibility for move.
  104338. * The higher the faster.
  104339. */
  104340. touchMoveSensibility: number;
  104341. /**
  104342. * Instantiates a new touch camera.
  104343. * This represents a FPS type of camera controlled by touch.
  104344. * This is like a universal camera minus the Gamepad controls.
  104345. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104346. * @param name Define the name of the camera in the scene
  104347. * @param position Define the start position of the camera in the scene
  104348. * @param scene Define the scene the camera belongs to
  104349. */
  104350. constructor(name: string, position: Vector3, scene: Scene);
  104351. /**
  104352. * Gets the current object class name.
  104353. * @return the class name
  104354. */
  104355. getClassName(): string;
  104356. /** @hidden */
  104357. _setupInputs(): void;
  104358. }
  104359. }
  104360. declare module BABYLON {
  104361. /**
  104362. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  104363. * being tilted forward or back and left or right.
  104364. */
  104365. export class DeviceOrientationCamera extends FreeCamera {
  104366. private _initialQuaternion;
  104367. private _quaternionCache;
  104368. private _tmpDragQuaternion;
  104369. private _disablePointerInputWhenUsingDeviceOrientation;
  104370. /**
  104371. * Creates a new device orientation camera
  104372. * @param name The name of the camera
  104373. * @param position The start position camera
  104374. * @param scene The scene the camera belongs to
  104375. */
  104376. constructor(name: string, position: Vector3, scene: Scene);
  104377. /**
  104378. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  104379. */
  104380. disablePointerInputWhenUsingDeviceOrientation: boolean;
  104381. private _dragFactor;
  104382. /**
  104383. * Enabled turning on the y axis when the orientation sensor is active
  104384. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  104385. */
  104386. enableHorizontalDragging(dragFactor?: number): void;
  104387. /**
  104388. * Gets the current instance class name ("DeviceOrientationCamera").
  104389. * This helps avoiding instanceof at run time.
  104390. * @returns the class name
  104391. */
  104392. getClassName(): string;
  104393. /**
  104394. * @hidden
  104395. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  104396. */
  104397. _checkInputs(): void;
  104398. /**
  104399. * Reset the camera to its default orientation on the specified axis only.
  104400. * @param axis The axis to reset
  104401. */
  104402. resetToCurrentRotation(axis?: Axis): void;
  104403. }
  104404. }
  104405. declare module BABYLON {
  104406. /**
  104407. * Defines supported buttons for XBox360 compatible gamepads
  104408. */
  104409. export enum Xbox360Button {
  104410. /** A */
  104411. A = 0,
  104412. /** B */
  104413. B = 1,
  104414. /** X */
  104415. X = 2,
  104416. /** Y */
  104417. Y = 3,
  104418. /** Start */
  104419. Start = 4,
  104420. /** Back */
  104421. Back = 5,
  104422. /** Left button */
  104423. LB = 6,
  104424. /** Right button */
  104425. RB = 7,
  104426. /** Left stick */
  104427. LeftStick = 8,
  104428. /** Right stick */
  104429. RightStick = 9
  104430. }
  104431. /** Defines values for XBox360 DPad */
  104432. export enum Xbox360Dpad {
  104433. /** Up */
  104434. Up = 0,
  104435. /** Down */
  104436. Down = 1,
  104437. /** Left */
  104438. Left = 2,
  104439. /** Right */
  104440. Right = 3
  104441. }
  104442. /**
  104443. * Defines a XBox360 gamepad
  104444. */
  104445. export class Xbox360Pad extends Gamepad {
  104446. private _leftTrigger;
  104447. private _rightTrigger;
  104448. private _onlefttriggerchanged;
  104449. private _onrighttriggerchanged;
  104450. private _onbuttondown;
  104451. private _onbuttonup;
  104452. private _ondpaddown;
  104453. private _ondpadup;
  104454. /** Observable raised when a button is pressed */
  104455. onButtonDownObservable: Observable<Xbox360Button>;
  104456. /** Observable raised when a button is released */
  104457. onButtonUpObservable: Observable<Xbox360Button>;
  104458. /** Observable raised when a pad is pressed */
  104459. onPadDownObservable: Observable<Xbox360Dpad>;
  104460. /** Observable raised when a pad is released */
  104461. onPadUpObservable: Observable<Xbox360Dpad>;
  104462. private _buttonA;
  104463. private _buttonB;
  104464. private _buttonX;
  104465. private _buttonY;
  104466. private _buttonBack;
  104467. private _buttonStart;
  104468. private _buttonLB;
  104469. private _buttonRB;
  104470. private _buttonLeftStick;
  104471. private _buttonRightStick;
  104472. private _dPadUp;
  104473. private _dPadDown;
  104474. private _dPadLeft;
  104475. private _dPadRight;
  104476. private _isXboxOnePad;
  104477. /**
  104478. * Creates a new XBox360 gamepad object
  104479. * @param id defines the id of this gamepad
  104480. * @param index defines its index
  104481. * @param gamepad defines the internal HTML gamepad object
  104482. * @param xboxOne defines if it is a XBox One gamepad
  104483. */
  104484. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  104485. /**
  104486. * Defines the callback to call when left trigger is pressed
  104487. * @param callback defines the callback to use
  104488. */
  104489. onlefttriggerchanged(callback: (value: number) => void): void;
  104490. /**
  104491. * Defines the callback to call when right trigger is pressed
  104492. * @param callback defines the callback to use
  104493. */
  104494. onrighttriggerchanged(callback: (value: number) => void): void;
  104495. /**
  104496. * Gets the left trigger value
  104497. */
  104498. /**
  104499. * Sets the left trigger value
  104500. */
  104501. leftTrigger: number;
  104502. /**
  104503. * Gets the right trigger value
  104504. */
  104505. /**
  104506. * Sets the right trigger value
  104507. */
  104508. rightTrigger: number;
  104509. /**
  104510. * Defines the callback to call when a button is pressed
  104511. * @param callback defines the callback to use
  104512. */
  104513. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  104514. /**
  104515. * Defines the callback to call when a button is released
  104516. * @param callback defines the callback to use
  104517. */
  104518. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  104519. /**
  104520. * Defines the callback to call when a pad is pressed
  104521. * @param callback defines the callback to use
  104522. */
  104523. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  104524. /**
  104525. * Defines the callback to call when a pad is released
  104526. * @param callback defines the callback to use
  104527. */
  104528. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  104529. private _setButtonValue;
  104530. private _setDPadValue;
  104531. /**
  104532. * Gets the value of the `A` button
  104533. */
  104534. /**
  104535. * Sets the value of the `A` button
  104536. */
  104537. buttonA: number;
  104538. /**
  104539. * Gets the value of the `B` button
  104540. */
  104541. /**
  104542. * Sets the value of the `B` button
  104543. */
  104544. buttonB: number;
  104545. /**
  104546. * Gets the value of the `X` button
  104547. */
  104548. /**
  104549. * Sets the value of the `X` button
  104550. */
  104551. buttonX: number;
  104552. /**
  104553. * Gets the value of the `Y` button
  104554. */
  104555. /**
  104556. * Sets the value of the `Y` button
  104557. */
  104558. buttonY: number;
  104559. /**
  104560. * Gets the value of the `Start` button
  104561. */
  104562. /**
  104563. * Sets the value of the `Start` button
  104564. */
  104565. buttonStart: number;
  104566. /**
  104567. * Gets the value of the `Back` button
  104568. */
  104569. /**
  104570. * Sets the value of the `Back` button
  104571. */
  104572. buttonBack: number;
  104573. /**
  104574. * Gets the value of the `Left` button
  104575. */
  104576. /**
  104577. * Sets the value of the `Left` button
  104578. */
  104579. buttonLB: number;
  104580. /**
  104581. * Gets the value of the `Right` button
  104582. */
  104583. /**
  104584. * Sets the value of the `Right` button
  104585. */
  104586. buttonRB: number;
  104587. /**
  104588. * Gets the value of the Left joystick
  104589. */
  104590. /**
  104591. * Sets the value of the Left joystick
  104592. */
  104593. buttonLeftStick: number;
  104594. /**
  104595. * Gets the value of the Right joystick
  104596. */
  104597. /**
  104598. * Sets the value of the Right joystick
  104599. */
  104600. buttonRightStick: number;
  104601. /**
  104602. * Gets the value of D-pad up
  104603. */
  104604. /**
  104605. * Sets the value of D-pad up
  104606. */
  104607. dPadUp: number;
  104608. /**
  104609. * Gets the value of D-pad down
  104610. */
  104611. /**
  104612. * Sets the value of D-pad down
  104613. */
  104614. dPadDown: number;
  104615. /**
  104616. * Gets the value of D-pad left
  104617. */
  104618. /**
  104619. * Sets the value of D-pad left
  104620. */
  104621. dPadLeft: number;
  104622. /**
  104623. * Gets the value of D-pad right
  104624. */
  104625. /**
  104626. * Sets the value of D-pad right
  104627. */
  104628. dPadRight: number;
  104629. /**
  104630. * Force the gamepad to synchronize with device values
  104631. */
  104632. update(): void;
  104633. /**
  104634. * Disposes the gamepad
  104635. */
  104636. dispose(): void;
  104637. }
  104638. }
  104639. declare module BABYLON {
  104640. /**
  104641. * Defines supported buttons for DualShock compatible gamepads
  104642. */
  104643. export enum DualShockButton {
  104644. /** Cross */
  104645. Cross = 0,
  104646. /** Circle */
  104647. Circle = 1,
  104648. /** Square */
  104649. Square = 2,
  104650. /** Triangle */
  104651. Triangle = 3,
  104652. /** Options */
  104653. Options = 4,
  104654. /** Share */
  104655. Share = 5,
  104656. /** L1 */
  104657. L1 = 6,
  104658. /** R1 */
  104659. R1 = 7,
  104660. /** Left stick */
  104661. LeftStick = 8,
  104662. /** Right stick */
  104663. RightStick = 9
  104664. }
  104665. /** Defines values for DualShock DPad */
  104666. export enum DualShockDpad {
  104667. /** Up */
  104668. Up = 0,
  104669. /** Down */
  104670. Down = 1,
  104671. /** Left */
  104672. Left = 2,
  104673. /** Right */
  104674. Right = 3
  104675. }
  104676. /**
  104677. * Defines a DualShock gamepad
  104678. */
  104679. export class DualShockPad extends Gamepad {
  104680. private _leftTrigger;
  104681. private _rightTrigger;
  104682. private _onlefttriggerchanged;
  104683. private _onrighttriggerchanged;
  104684. private _onbuttondown;
  104685. private _onbuttonup;
  104686. private _ondpaddown;
  104687. private _ondpadup;
  104688. /** Observable raised when a button is pressed */
  104689. onButtonDownObservable: Observable<DualShockButton>;
  104690. /** Observable raised when a button is released */
  104691. onButtonUpObservable: Observable<DualShockButton>;
  104692. /** Observable raised when a pad is pressed */
  104693. onPadDownObservable: Observable<DualShockDpad>;
  104694. /** Observable raised when a pad is released */
  104695. onPadUpObservable: Observable<DualShockDpad>;
  104696. private _buttonCross;
  104697. private _buttonCircle;
  104698. private _buttonSquare;
  104699. private _buttonTriangle;
  104700. private _buttonShare;
  104701. private _buttonOptions;
  104702. private _buttonL1;
  104703. private _buttonR1;
  104704. private _buttonLeftStick;
  104705. private _buttonRightStick;
  104706. private _dPadUp;
  104707. private _dPadDown;
  104708. private _dPadLeft;
  104709. private _dPadRight;
  104710. /**
  104711. * Creates a new DualShock gamepad object
  104712. * @param id defines the id of this gamepad
  104713. * @param index defines its index
  104714. * @param gamepad defines the internal HTML gamepad object
  104715. */
  104716. constructor(id: string, index: number, gamepad: any);
  104717. /**
  104718. * Defines the callback to call when left trigger is pressed
  104719. * @param callback defines the callback to use
  104720. */
  104721. onlefttriggerchanged(callback: (value: number) => void): void;
  104722. /**
  104723. * Defines the callback to call when right trigger is pressed
  104724. * @param callback defines the callback to use
  104725. */
  104726. onrighttriggerchanged(callback: (value: number) => void): void;
  104727. /**
  104728. * Gets the left trigger value
  104729. */
  104730. /**
  104731. * Sets the left trigger value
  104732. */
  104733. leftTrigger: number;
  104734. /**
  104735. * Gets the right trigger value
  104736. */
  104737. /**
  104738. * Sets the right trigger value
  104739. */
  104740. rightTrigger: number;
  104741. /**
  104742. * Defines the callback to call when a button is pressed
  104743. * @param callback defines the callback to use
  104744. */
  104745. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  104746. /**
  104747. * Defines the callback to call when a button is released
  104748. * @param callback defines the callback to use
  104749. */
  104750. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  104751. /**
  104752. * Defines the callback to call when a pad is pressed
  104753. * @param callback defines the callback to use
  104754. */
  104755. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  104756. /**
  104757. * Defines the callback to call when a pad is released
  104758. * @param callback defines the callback to use
  104759. */
  104760. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  104761. private _setButtonValue;
  104762. private _setDPadValue;
  104763. /**
  104764. * Gets the value of the `Cross` button
  104765. */
  104766. /**
  104767. * Sets the value of the `Cross` button
  104768. */
  104769. buttonCross: number;
  104770. /**
  104771. * Gets the value of the `Circle` button
  104772. */
  104773. /**
  104774. * Sets the value of the `Circle` button
  104775. */
  104776. buttonCircle: number;
  104777. /**
  104778. * Gets the value of the `Square` button
  104779. */
  104780. /**
  104781. * Sets the value of the `Square` button
  104782. */
  104783. buttonSquare: number;
  104784. /**
  104785. * Gets the value of the `Triangle` button
  104786. */
  104787. /**
  104788. * Sets the value of the `Triangle` button
  104789. */
  104790. buttonTriangle: number;
  104791. /**
  104792. * Gets the value of the `Options` button
  104793. */
  104794. /**
  104795. * Sets the value of the `Options` button
  104796. */
  104797. buttonOptions: number;
  104798. /**
  104799. * Gets the value of the `Share` button
  104800. */
  104801. /**
  104802. * Sets the value of the `Share` button
  104803. */
  104804. buttonShare: number;
  104805. /**
  104806. * Gets the value of the `L1` button
  104807. */
  104808. /**
  104809. * Sets the value of the `L1` button
  104810. */
  104811. buttonL1: number;
  104812. /**
  104813. * Gets the value of the `R1` button
  104814. */
  104815. /**
  104816. * Sets the value of the `R1` button
  104817. */
  104818. buttonR1: number;
  104819. /**
  104820. * Gets the value of the Left joystick
  104821. */
  104822. /**
  104823. * Sets the value of the Left joystick
  104824. */
  104825. buttonLeftStick: number;
  104826. /**
  104827. * Gets the value of the Right joystick
  104828. */
  104829. /**
  104830. * Sets the value of the Right joystick
  104831. */
  104832. buttonRightStick: number;
  104833. /**
  104834. * Gets the value of D-pad up
  104835. */
  104836. /**
  104837. * Sets the value of D-pad up
  104838. */
  104839. dPadUp: number;
  104840. /**
  104841. * Gets the value of D-pad down
  104842. */
  104843. /**
  104844. * Sets the value of D-pad down
  104845. */
  104846. dPadDown: number;
  104847. /**
  104848. * Gets the value of D-pad left
  104849. */
  104850. /**
  104851. * Sets the value of D-pad left
  104852. */
  104853. dPadLeft: number;
  104854. /**
  104855. * Gets the value of D-pad right
  104856. */
  104857. /**
  104858. * Sets the value of D-pad right
  104859. */
  104860. dPadRight: number;
  104861. /**
  104862. * Force the gamepad to synchronize with device values
  104863. */
  104864. update(): void;
  104865. /**
  104866. * Disposes the gamepad
  104867. */
  104868. dispose(): void;
  104869. }
  104870. }
  104871. declare module BABYLON {
  104872. /**
  104873. * Manager for handling gamepads
  104874. */
  104875. export class GamepadManager {
  104876. private _scene?;
  104877. private _babylonGamepads;
  104878. private _oneGamepadConnected;
  104879. /** @hidden */
  104880. _isMonitoring: boolean;
  104881. private _gamepadEventSupported;
  104882. private _gamepadSupport;
  104883. /**
  104884. * observable to be triggered when the gamepad controller has been connected
  104885. */
  104886. onGamepadConnectedObservable: Observable<Gamepad>;
  104887. /**
  104888. * observable to be triggered when the gamepad controller has been disconnected
  104889. */
  104890. onGamepadDisconnectedObservable: Observable<Gamepad>;
  104891. private _onGamepadConnectedEvent;
  104892. private _onGamepadDisconnectedEvent;
  104893. /**
  104894. * Initializes the gamepad manager
  104895. * @param _scene BabylonJS scene
  104896. */
  104897. constructor(_scene?: Scene | undefined);
  104898. /**
  104899. * The gamepads in the game pad manager
  104900. */
  104901. readonly gamepads: Gamepad[];
  104902. /**
  104903. * Get the gamepad controllers based on type
  104904. * @param type The type of gamepad controller
  104905. * @returns Nullable gamepad
  104906. */
  104907. getGamepadByType(type?: number): Nullable<Gamepad>;
  104908. /**
  104909. * Disposes the gamepad manager
  104910. */
  104911. dispose(): void;
  104912. private _addNewGamepad;
  104913. private _startMonitoringGamepads;
  104914. private _stopMonitoringGamepads;
  104915. /** @hidden */
  104916. _checkGamepadsStatus(): void;
  104917. private _updateGamepadObjects;
  104918. }
  104919. }
  104920. declare module BABYLON {
  104921. interface Scene {
  104922. /** @hidden */
  104923. _gamepadManager: Nullable<GamepadManager>;
  104924. /**
  104925. * Gets the gamepad manager associated with the scene
  104926. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  104927. */
  104928. gamepadManager: GamepadManager;
  104929. }
  104930. /**
  104931. * Interface representing a free camera inputs manager
  104932. */
  104933. interface FreeCameraInputsManager {
  104934. /**
  104935. * Adds gamepad input support to the FreeCameraInputsManager.
  104936. * @returns the FreeCameraInputsManager
  104937. */
  104938. addGamepad(): FreeCameraInputsManager;
  104939. }
  104940. /**
  104941. * Interface representing an arc rotate camera inputs manager
  104942. */
  104943. interface ArcRotateCameraInputsManager {
  104944. /**
  104945. * Adds gamepad input support to the ArcRotateCamera InputManager.
  104946. * @returns the camera inputs manager
  104947. */
  104948. addGamepad(): ArcRotateCameraInputsManager;
  104949. }
  104950. /**
  104951. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  104952. */
  104953. export class GamepadSystemSceneComponent implements ISceneComponent {
  104954. /**
  104955. * The component name helpfull to identify the component in the list of scene components.
  104956. */
  104957. readonly name: string;
  104958. /**
  104959. * The scene the component belongs to.
  104960. */
  104961. scene: Scene;
  104962. /**
  104963. * Creates a new instance of the component for the given scene
  104964. * @param scene Defines the scene to register the component in
  104965. */
  104966. constructor(scene: Scene);
  104967. /**
  104968. * Registers the component in a given scene
  104969. */
  104970. register(): void;
  104971. /**
  104972. * Rebuilds the elements related to this component in case of
  104973. * context lost for instance.
  104974. */
  104975. rebuild(): void;
  104976. /**
  104977. * Disposes the component and the associated ressources
  104978. */
  104979. dispose(): void;
  104980. private _beforeCameraUpdate;
  104981. }
  104982. }
  104983. declare module BABYLON {
  104984. /**
  104985. * 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,
  104986. * which still works and will still be found in many Playgrounds.
  104987. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  104988. */
  104989. export class UniversalCamera extends TouchCamera {
  104990. /**
  104991. * Defines the gamepad rotation sensiblity.
  104992. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104993. */
  104994. gamepadAngularSensibility: number;
  104995. /**
  104996. * Defines the gamepad move sensiblity.
  104997. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104998. */
  104999. gamepadMoveSensibility: number;
  105000. /**
  105001. * 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,
  105002. * which still works and will still be found in many Playgrounds.
  105003. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105004. * @param name Define the name of the camera in the scene
  105005. * @param position Define the start position of the camera in the scene
  105006. * @param scene Define the scene the camera belongs to
  105007. */
  105008. constructor(name: string, position: Vector3, scene: Scene);
  105009. /**
  105010. * Gets the current object class name.
  105011. * @return the class name
  105012. */
  105013. getClassName(): string;
  105014. }
  105015. }
  105016. declare module BABYLON {
  105017. /**
  105018. * This represents a FPS type of camera. This is only here for back compat purpose.
  105019. * Please use the UniversalCamera instead as both are identical.
  105020. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105021. */
  105022. export class GamepadCamera extends UniversalCamera {
  105023. /**
  105024. * Instantiates a new Gamepad Camera
  105025. * This represents a FPS type of camera. This is only here for back compat purpose.
  105026. * Please use the UniversalCamera instead as both are identical.
  105027. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105028. * @param name Define the name of the camera in the scene
  105029. * @param position Define the start position of the camera in the scene
  105030. * @param scene Define the scene the camera belongs to
  105031. */
  105032. constructor(name: string, position: Vector3, scene: Scene);
  105033. /**
  105034. * Gets the current object class name.
  105035. * @return the class name
  105036. */
  105037. getClassName(): string;
  105038. }
  105039. }
  105040. declare module BABYLON {
  105041. /** @hidden */
  105042. export var passPixelShader: {
  105043. name: string;
  105044. shader: string;
  105045. };
  105046. }
  105047. declare module BABYLON {
  105048. /** @hidden */
  105049. export var passCubePixelShader: {
  105050. name: string;
  105051. shader: string;
  105052. };
  105053. }
  105054. declare module BABYLON {
  105055. /**
  105056. * PassPostProcess which produces an output the same as it's input
  105057. */
  105058. export class PassPostProcess extends PostProcess {
  105059. /**
  105060. * Creates the PassPostProcess
  105061. * @param name The name of the effect.
  105062. * @param options The required width/height ratio to downsize to before computing the render pass.
  105063. * @param camera The camera to apply the render pass to.
  105064. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105065. * @param engine The engine which the post process will be applied. (default: current engine)
  105066. * @param reusable If the post process can be reused on the same frame. (default: false)
  105067. * @param textureType The type of texture to be used when performing the post processing.
  105068. * @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)
  105069. */
  105070. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105071. }
  105072. /**
  105073. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  105074. */
  105075. export class PassCubePostProcess extends PostProcess {
  105076. private _face;
  105077. /**
  105078. * Gets or sets the cube face to display.
  105079. * * 0 is +X
  105080. * * 1 is -X
  105081. * * 2 is +Y
  105082. * * 3 is -Y
  105083. * * 4 is +Z
  105084. * * 5 is -Z
  105085. */
  105086. face: number;
  105087. /**
  105088. * Creates the PassCubePostProcess
  105089. * @param name The name of the effect.
  105090. * @param options The required width/height ratio to downsize to before computing the render pass.
  105091. * @param camera The camera to apply the render pass to.
  105092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105093. * @param engine The engine which the post process will be applied. (default: current engine)
  105094. * @param reusable If the post process can be reused on the same frame. (default: false)
  105095. * @param textureType The type of texture to be used when performing the post processing.
  105096. * @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)
  105097. */
  105098. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105099. }
  105100. }
  105101. declare module BABYLON {
  105102. /** @hidden */
  105103. export var anaglyphPixelShader: {
  105104. name: string;
  105105. shader: string;
  105106. };
  105107. }
  105108. declare module BABYLON {
  105109. /**
  105110. * Postprocess used to generate anaglyphic rendering
  105111. */
  105112. export class AnaglyphPostProcess extends PostProcess {
  105113. private _passedProcess;
  105114. /**
  105115. * Creates a new AnaglyphPostProcess
  105116. * @param name defines postprocess name
  105117. * @param options defines creation options or target ratio scale
  105118. * @param rigCameras defines cameras using this postprocess
  105119. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  105120. * @param engine defines hosting engine
  105121. * @param reusable defines if the postprocess will be reused multiple times per frame
  105122. */
  105123. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  105124. }
  105125. }
  105126. declare module BABYLON {
  105127. /**
  105128. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  105129. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105130. */
  105131. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  105132. /**
  105133. * Creates a new AnaglyphArcRotateCamera
  105134. * @param name defines camera name
  105135. * @param alpha defines alpha angle (in radians)
  105136. * @param beta defines beta angle (in radians)
  105137. * @param radius defines radius
  105138. * @param target defines camera target
  105139. * @param interaxialDistance defines distance between each color axis
  105140. * @param scene defines the hosting scene
  105141. */
  105142. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  105143. /**
  105144. * Gets camera class name
  105145. * @returns AnaglyphArcRotateCamera
  105146. */
  105147. getClassName(): string;
  105148. }
  105149. }
  105150. declare module BABYLON {
  105151. /**
  105152. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  105153. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105154. */
  105155. export class AnaglyphFreeCamera extends FreeCamera {
  105156. /**
  105157. * Creates a new AnaglyphFreeCamera
  105158. * @param name defines camera name
  105159. * @param position defines initial position
  105160. * @param interaxialDistance defines distance between each color axis
  105161. * @param scene defines the hosting scene
  105162. */
  105163. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105164. /**
  105165. * Gets camera class name
  105166. * @returns AnaglyphFreeCamera
  105167. */
  105168. getClassName(): string;
  105169. }
  105170. }
  105171. declare module BABYLON {
  105172. /**
  105173. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  105174. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105175. */
  105176. export class AnaglyphGamepadCamera extends GamepadCamera {
  105177. /**
  105178. * Creates a new AnaglyphGamepadCamera
  105179. * @param name defines camera name
  105180. * @param position defines initial position
  105181. * @param interaxialDistance defines distance between each color axis
  105182. * @param scene defines the hosting scene
  105183. */
  105184. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105185. /**
  105186. * Gets camera class name
  105187. * @returns AnaglyphGamepadCamera
  105188. */
  105189. getClassName(): string;
  105190. }
  105191. }
  105192. declare module BABYLON {
  105193. /**
  105194. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  105195. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  105196. */
  105197. export class AnaglyphUniversalCamera extends UniversalCamera {
  105198. /**
  105199. * Creates a new AnaglyphUniversalCamera
  105200. * @param name defines camera name
  105201. * @param position defines initial position
  105202. * @param interaxialDistance defines distance between each color axis
  105203. * @param scene defines the hosting scene
  105204. */
  105205. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  105206. /**
  105207. * Gets camera class name
  105208. * @returns AnaglyphUniversalCamera
  105209. */
  105210. getClassName(): string;
  105211. }
  105212. }
  105213. declare module BABYLON {
  105214. /** @hidden */
  105215. export var stereoscopicInterlacePixelShader: {
  105216. name: string;
  105217. shader: string;
  105218. };
  105219. }
  105220. declare module BABYLON {
  105221. /**
  105222. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  105223. */
  105224. export class StereoscopicInterlacePostProcess extends PostProcess {
  105225. private _stepSize;
  105226. private _passedProcess;
  105227. /**
  105228. * Initializes a StereoscopicInterlacePostProcess
  105229. * @param name The name of the effect.
  105230. * @param rigCameras The rig cameras to be appled to the post process
  105231. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  105232. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105233. * @param engine The engine which the post process will be applied. (default: current engine)
  105234. * @param reusable If the post process can be reused on the same frame. (default: false)
  105235. */
  105236. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105237. }
  105238. }
  105239. declare module BABYLON {
  105240. /**
  105241. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  105242. * @see http://doc.babylonjs.com/features/cameras
  105243. */
  105244. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  105245. /**
  105246. * Creates a new StereoscopicArcRotateCamera
  105247. * @param name defines camera name
  105248. * @param alpha defines alpha angle (in radians)
  105249. * @param beta defines beta angle (in radians)
  105250. * @param radius defines radius
  105251. * @param target defines camera target
  105252. * @param interaxialDistance defines distance between each color axis
  105253. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105254. * @param scene defines the hosting scene
  105255. */
  105256. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105257. /**
  105258. * Gets camera class name
  105259. * @returns StereoscopicArcRotateCamera
  105260. */
  105261. getClassName(): string;
  105262. }
  105263. }
  105264. declare module BABYLON {
  105265. /**
  105266. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  105267. * @see http://doc.babylonjs.com/features/cameras
  105268. */
  105269. export class StereoscopicFreeCamera extends FreeCamera {
  105270. /**
  105271. * Creates a new StereoscopicFreeCamera
  105272. * @param name defines camera name
  105273. * @param position defines initial position
  105274. * @param interaxialDistance defines distance between each color axis
  105275. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105276. * @param scene defines the hosting scene
  105277. */
  105278. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105279. /**
  105280. * Gets camera class name
  105281. * @returns StereoscopicFreeCamera
  105282. */
  105283. getClassName(): string;
  105284. }
  105285. }
  105286. declare module BABYLON {
  105287. /**
  105288. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  105289. * @see http://doc.babylonjs.com/features/cameras
  105290. */
  105291. export class StereoscopicGamepadCamera extends GamepadCamera {
  105292. /**
  105293. * Creates a new StereoscopicGamepadCamera
  105294. * @param name defines camera name
  105295. * @param position defines initial position
  105296. * @param interaxialDistance defines distance between each color axis
  105297. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105298. * @param scene defines the hosting scene
  105299. */
  105300. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105301. /**
  105302. * Gets camera class name
  105303. * @returns StereoscopicGamepadCamera
  105304. */
  105305. getClassName(): string;
  105306. }
  105307. }
  105308. declare module BABYLON {
  105309. /**
  105310. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  105311. * @see http://doc.babylonjs.com/features/cameras
  105312. */
  105313. export class StereoscopicUniversalCamera extends UniversalCamera {
  105314. /**
  105315. * Creates a new StereoscopicUniversalCamera
  105316. * @param name defines camera name
  105317. * @param position defines initial position
  105318. * @param interaxialDistance defines distance between each color axis
  105319. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  105320. * @param scene defines the hosting scene
  105321. */
  105322. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  105323. /**
  105324. * Gets camera class name
  105325. * @returns StereoscopicUniversalCamera
  105326. */
  105327. getClassName(): string;
  105328. }
  105329. }
  105330. declare module BABYLON {
  105331. /**
  105332. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  105333. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105334. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105335. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105336. */
  105337. export class VirtualJoysticksCamera extends FreeCamera {
  105338. /**
  105339. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  105340. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  105341. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  105342. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  105343. * @param name Define the name of the camera in the scene
  105344. * @param position Define the start position of the camera in the scene
  105345. * @param scene Define the scene the camera belongs to
  105346. */
  105347. constructor(name: string, position: Vector3, scene: Scene);
  105348. /**
  105349. * Gets the current object class name.
  105350. * @return the class name
  105351. */
  105352. getClassName(): string;
  105353. }
  105354. }
  105355. declare module BABYLON {
  105356. /**
  105357. * This represents all the required metrics to create a VR camera.
  105358. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  105359. */
  105360. export class VRCameraMetrics {
  105361. /**
  105362. * Define the horizontal resolution off the screen.
  105363. */
  105364. hResolution: number;
  105365. /**
  105366. * Define the vertical resolution off the screen.
  105367. */
  105368. vResolution: number;
  105369. /**
  105370. * Define the horizontal screen size.
  105371. */
  105372. hScreenSize: number;
  105373. /**
  105374. * Define the vertical screen size.
  105375. */
  105376. vScreenSize: number;
  105377. /**
  105378. * Define the vertical screen center position.
  105379. */
  105380. vScreenCenter: number;
  105381. /**
  105382. * Define the distance of the eyes to the screen.
  105383. */
  105384. eyeToScreenDistance: number;
  105385. /**
  105386. * Define the distance between both lenses
  105387. */
  105388. lensSeparationDistance: number;
  105389. /**
  105390. * Define the distance between both viewer's eyes.
  105391. */
  105392. interpupillaryDistance: number;
  105393. /**
  105394. * Define the distortion factor of the VR postprocess.
  105395. * Please, touch with care.
  105396. */
  105397. distortionK: number[];
  105398. /**
  105399. * Define the chromatic aberration correction factors for the VR post process.
  105400. */
  105401. chromaAbCorrection: number[];
  105402. /**
  105403. * Define the scale factor of the post process.
  105404. * The smaller the better but the slower.
  105405. */
  105406. postProcessScaleFactor: number;
  105407. /**
  105408. * Define an offset for the lens center.
  105409. */
  105410. lensCenterOffset: number;
  105411. /**
  105412. * Define if the current vr camera should compensate the distortion of the lense or not.
  105413. */
  105414. compensateDistortion: boolean;
  105415. /**
  105416. * Defines if multiview should be enabled when rendering (Default: false)
  105417. */
  105418. multiviewEnabled: boolean;
  105419. /**
  105420. * Gets the rendering aspect ratio based on the provided resolutions.
  105421. */
  105422. readonly aspectRatio: number;
  105423. /**
  105424. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  105425. */
  105426. readonly aspectRatioFov: number;
  105427. /**
  105428. * @hidden
  105429. */
  105430. readonly leftHMatrix: Matrix;
  105431. /**
  105432. * @hidden
  105433. */
  105434. readonly rightHMatrix: Matrix;
  105435. /**
  105436. * @hidden
  105437. */
  105438. readonly leftPreViewMatrix: Matrix;
  105439. /**
  105440. * @hidden
  105441. */
  105442. readonly rightPreViewMatrix: Matrix;
  105443. /**
  105444. * Get the default VRMetrics based on the most generic setup.
  105445. * @returns the default vr metrics
  105446. */
  105447. static GetDefault(): VRCameraMetrics;
  105448. }
  105449. }
  105450. declare module BABYLON {
  105451. /** @hidden */
  105452. export var vrDistortionCorrectionPixelShader: {
  105453. name: string;
  105454. shader: string;
  105455. };
  105456. }
  105457. declare module BABYLON {
  105458. /**
  105459. * VRDistortionCorrectionPostProcess used for mobile VR
  105460. */
  105461. export class VRDistortionCorrectionPostProcess extends PostProcess {
  105462. private _isRightEye;
  105463. private _distortionFactors;
  105464. private _postProcessScaleFactor;
  105465. private _lensCenterOffset;
  105466. private _scaleIn;
  105467. private _scaleFactor;
  105468. private _lensCenter;
  105469. /**
  105470. * Initializes the VRDistortionCorrectionPostProcess
  105471. * @param name The name of the effect.
  105472. * @param camera The camera to apply the render pass to.
  105473. * @param isRightEye If this is for the right eye distortion
  105474. * @param vrMetrics All the required metrics for the VR camera
  105475. */
  105476. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  105477. }
  105478. }
  105479. declare module BABYLON {
  105480. /**
  105481. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  105482. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105483. */
  105484. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  105485. /**
  105486. * Creates a new VRDeviceOrientationArcRotateCamera
  105487. * @param name defines camera name
  105488. * @param alpha defines the camera rotation along the logitudinal axis
  105489. * @param beta defines the camera rotation along the latitudinal axis
  105490. * @param radius defines the camera distance from its target
  105491. * @param target defines the camera target
  105492. * @param scene defines the scene the camera belongs to
  105493. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105494. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105495. */
  105496. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105497. /**
  105498. * Gets camera class name
  105499. * @returns VRDeviceOrientationArcRotateCamera
  105500. */
  105501. getClassName(): string;
  105502. }
  105503. }
  105504. declare module BABYLON {
  105505. /**
  105506. * Camera used to simulate VR rendering (based on FreeCamera)
  105507. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105508. */
  105509. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  105510. /**
  105511. * Creates a new VRDeviceOrientationFreeCamera
  105512. * @param name defines camera name
  105513. * @param position defines the start position of the camera
  105514. * @param scene defines the scene the camera belongs to
  105515. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105516. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105517. */
  105518. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105519. /**
  105520. * Gets camera class name
  105521. * @returns VRDeviceOrientationFreeCamera
  105522. */
  105523. getClassName(): string;
  105524. }
  105525. }
  105526. declare module BABYLON {
  105527. /**
  105528. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  105529. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  105530. */
  105531. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  105532. /**
  105533. * Creates a new VRDeviceOrientationGamepadCamera
  105534. * @param name defines camera name
  105535. * @param position defines the start position of the camera
  105536. * @param scene defines the scene the camera belongs to
  105537. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  105538. * @param vrCameraMetrics defines the vr metrics associated to the camera
  105539. */
  105540. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  105541. /**
  105542. * Gets camera class name
  105543. * @returns VRDeviceOrientationGamepadCamera
  105544. */
  105545. getClassName(): string;
  105546. }
  105547. }
  105548. declare module BABYLON {
  105549. /**
  105550. * Base class of materials working in push mode in babylon JS
  105551. * @hidden
  105552. */
  105553. export class PushMaterial extends Material {
  105554. protected _activeEffect: Effect;
  105555. protected _normalMatrix: Matrix;
  105556. /**
  105557. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  105558. * This means that the material can keep using a previous shader while a new one is being compiled.
  105559. * This is mostly used when shader parallel compilation is supported (true by default)
  105560. */
  105561. allowShaderHotSwapping: boolean;
  105562. constructor(name: string, scene: Scene);
  105563. getEffect(): Effect;
  105564. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105565. /**
  105566. * Binds the given world matrix to the active effect
  105567. *
  105568. * @param world the matrix to bind
  105569. */
  105570. bindOnlyWorldMatrix(world: Matrix): void;
  105571. /**
  105572. * Binds the given normal matrix to the active effect
  105573. *
  105574. * @param normalMatrix the matrix to bind
  105575. */
  105576. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  105577. bind(world: Matrix, mesh?: Mesh): void;
  105578. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  105579. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  105580. }
  105581. }
  105582. declare module BABYLON {
  105583. /**
  105584. * This groups all the flags used to control the materials channel.
  105585. */
  105586. export class MaterialFlags {
  105587. private static _DiffuseTextureEnabled;
  105588. /**
  105589. * Are diffuse textures enabled in the application.
  105590. */
  105591. static DiffuseTextureEnabled: boolean;
  105592. private static _AmbientTextureEnabled;
  105593. /**
  105594. * Are ambient textures enabled in the application.
  105595. */
  105596. static AmbientTextureEnabled: boolean;
  105597. private static _OpacityTextureEnabled;
  105598. /**
  105599. * Are opacity textures enabled in the application.
  105600. */
  105601. static OpacityTextureEnabled: boolean;
  105602. private static _ReflectionTextureEnabled;
  105603. /**
  105604. * Are reflection textures enabled in the application.
  105605. */
  105606. static ReflectionTextureEnabled: boolean;
  105607. private static _EmissiveTextureEnabled;
  105608. /**
  105609. * Are emissive textures enabled in the application.
  105610. */
  105611. static EmissiveTextureEnabled: boolean;
  105612. private static _SpecularTextureEnabled;
  105613. /**
  105614. * Are specular textures enabled in the application.
  105615. */
  105616. static SpecularTextureEnabled: boolean;
  105617. private static _BumpTextureEnabled;
  105618. /**
  105619. * Are bump textures enabled in the application.
  105620. */
  105621. static BumpTextureEnabled: boolean;
  105622. private static _LightmapTextureEnabled;
  105623. /**
  105624. * Are lightmap textures enabled in the application.
  105625. */
  105626. static LightmapTextureEnabled: boolean;
  105627. private static _RefractionTextureEnabled;
  105628. /**
  105629. * Are refraction textures enabled in the application.
  105630. */
  105631. static RefractionTextureEnabled: boolean;
  105632. private static _ColorGradingTextureEnabled;
  105633. /**
  105634. * Are color grading textures enabled in the application.
  105635. */
  105636. static ColorGradingTextureEnabled: boolean;
  105637. private static _FresnelEnabled;
  105638. /**
  105639. * Are fresnels enabled in the application.
  105640. */
  105641. static FresnelEnabled: boolean;
  105642. private static _ClearCoatTextureEnabled;
  105643. /**
  105644. * Are clear coat textures enabled in the application.
  105645. */
  105646. static ClearCoatTextureEnabled: boolean;
  105647. private static _ClearCoatBumpTextureEnabled;
  105648. /**
  105649. * Are clear coat bump textures enabled in the application.
  105650. */
  105651. static ClearCoatBumpTextureEnabled: boolean;
  105652. private static _ClearCoatTintTextureEnabled;
  105653. /**
  105654. * Are clear coat tint textures enabled in the application.
  105655. */
  105656. static ClearCoatTintTextureEnabled: boolean;
  105657. private static _SheenTextureEnabled;
  105658. /**
  105659. * Are sheen textures enabled in the application.
  105660. */
  105661. static SheenTextureEnabled: boolean;
  105662. private static _AnisotropicTextureEnabled;
  105663. /**
  105664. * Are anisotropic textures enabled in the application.
  105665. */
  105666. static AnisotropicTextureEnabled: boolean;
  105667. private static _ThicknessTextureEnabled;
  105668. /**
  105669. * Are thickness textures enabled in the application.
  105670. */
  105671. static ThicknessTextureEnabled: boolean;
  105672. }
  105673. }
  105674. declare module BABYLON {
  105675. /** @hidden */
  105676. export var defaultFragmentDeclaration: {
  105677. name: string;
  105678. shader: string;
  105679. };
  105680. }
  105681. declare module BABYLON {
  105682. /** @hidden */
  105683. export var defaultUboDeclaration: {
  105684. name: string;
  105685. shader: string;
  105686. };
  105687. }
  105688. declare module BABYLON {
  105689. /** @hidden */
  105690. export var lightFragmentDeclaration: {
  105691. name: string;
  105692. shader: string;
  105693. };
  105694. }
  105695. declare module BABYLON {
  105696. /** @hidden */
  105697. export var lightUboDeclaration: {
  105698. name: string;
  105699. shader: string;
  105700. };
  105701. }
  105702. declare module BABYLON {
  105703. /** @hidden */
  105704. export var lightsFragmentFunctions: {
  105705. name: string;
  105706. shader: string;
  105707. };
  105708. }
  105709. declare module BABYLON {
  105710. /** @hidden */
  105711. export var shadowsFragmentFunctions: {
  105712. name: string;
  105713. shader: string;
  105714. };
  105715. }
  105716. declare module BABYLON {
  105717. /** @hidden */
  105718. export var fresnelFunction: {
  105719. name: string;
  105720. shader: string;
  105721. };
  105722. }
  105723. declare module BABYLON {
  105724. /** @hidden */
  105725. export var reflectionFunction: {
  105726. name: string;
  105727. shader: string;
  105728. };
  105729. }
  105730. declare module BABYLON {
  105731. /** @hidden */
  105732. export var bumpFragmentFunctions: {
  105733. name: string;
  105734. shader: string;
  105735. };
  105736. }
  105737. declare module BABYLON {
  105738. /** @hidden */
  105739. export var logDepthDeclaration: {
  105740. name: string;
  105741. shader: string;
  105742. };
  105743. }
  105744. declare module BABYLON {
  105745. /** @hidden */
  105746. export var bumpFragment: {
  105747. name: string;
  105748. shader: string;
  105749. };
  105750. }
  105751. declare module BABYLON {
  105752. /** @hidden */
  105753. export var depthPrePass: {
  105754. name: string;
  105755. shader: string;
  105756. };
  105757. }
  105758. declare module BABYLON {
  105759. /** @hidden */
  105760. export var lightFragment: {
  105761. name: string;
  105762. shader: string;
  105763. };
  105764. }
  105765. declare module BABYLON {
  105766. /** @hidden */
  105767. export var logDepthFragment: {
  105768. name: string;
  105769. shader: string;
  105770. };
  105771. }
  105772. declare module BABYLON {
  105773. /** @hidden */
  105774. export var defaultPixelShader: {
  105775. name: string;
  105776. shader: string;
  105777. };
  105778. }
  105779. declare module BABYLON {
  105780. /** @hidden */
  105781. export var defaultVertexDeclaration: {
  105782. name: string;
  105783. shader: string;
  105784. };
  105785. }
  105786. declare module BABYLON {
  105787. /** @hidden */
  105788. export var bumpVertexDeclaration: {
  105789. name: string;
  105790. shader: string;
  105791. };
  105792. }
  105793. declare module BABYLON {
  105794. /** @hidden */
  105795. export var bumpVertex: {
  105796. name: string;
  105797. shader: string;
  105798. };
  105799. }
  105800. declare module BABYLON {
  105801. /** @hidden */
  105802. export var fogVertex: {
  105803. name: string;
  105804. shader: string;
  105805. };
  105806. }
  105807. declare module BABYLON {
  105808. /** @hidden */
  105809. export var shadowsVertex: {
  105810. name: string;
  105811. shader: string;
  105812. };
  105813. }
  105814. declare module BABYLON {
  105815. /** @hidden */
  105816. export var pointCloudVertex: {
  105817. name: string;
  105818. shader: string;
  105819. };
  105820. }
  105821. declare module BABYLON {
  105822. /** @hidden */
  105823. export var logDepthVertex: {
  105824. name: string;
  105825. shader: string;
  105826. };
  105827. }
  105828. declare module BABYLON {
  105829. /** @hidden */
  105830. export var defaultVertexShader: {
  105831. name: string;
  105832. shader: string;
  105833. };
  105834. }
  105835. declare module BABYLON {
  105836. /** @hidden */
  105837. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  105838. MAINUV1: boolean;
  105839. MAINUV2: boolean;
  105840. DIFFUSE: boolean;
  105841. DIFFUSEDIRECTUV: number;
  105842. AMBIENT: boolean;
  105843. AMBIENTDIRECTUV: number;
  105844. OPACITY: boolean;
  105845. OPACITYDIRECTUV: number;
  105846. OPACITYRGB: boolean;
  105847. REFLECTION: boolean;
  105848. EMISSIVE: boolean;
  105849. EMISSIVEDIRECTUV: number;
  105850. SPECULAR: boolean;
  105851. SPECULARDIRECTUV: number;
  105852. BUMP: boolean;
  105853. BUMPDIRECTUV: number;
  105854. PARALLAX: boolean;
  105855. PARALLAXOCCLUSION: boolean;
  105856. SPECULAROVERALPHA: boolean;
  105857. CLIPPLANE: boolean;
  105858. CLIPPLANE2: boolean;
  105859. CLIPPLANE3: boolean;
  105860. CLIPPLANE4: boolean;
  105861. ALPHATEST: boolean;
  105862. DEPTHPREPASS: boolean;
  105863. ALPHAFROMDIFFUSE: boolean;
  105864. POINTSIZE: boolean;
  105865. FOG: boolean;
  105866. SPECULARTERM: boolean;
  105867. DIFFUSEFRESNEL: boolean;
  105868. OPACITYFRESNEL: boolean;
  105869. REFLECTIONFRESNEL: boolean;
  105870. REFRACTIONFRESNEL: boolean;
  105871. EMISSIVEFRESNEL: boolean;
  105872. FRESNEL: boolean;
  105873. NORMAL: boolean;
  105874. UV1: boolean;
  105875. UV2: boolean;
  105876. VERTEXCOLOR: boolean;
  105877. VERTEXALPHA: boolean;
  105878. NUM_BONE_INFLUENCERS: number;
  105879. BonesPerMesh: number;
  105880. BONETEXTURE: boolean;
  105881. INSTANCES: boolean;
  105882. GLOSSINESS: boolean;
  105883. ROUGHNESS: boolean;
  105884. EMISSIVEASILLUMINATION: boolean;
  105885. LINKEMISSIVEWITHDIFFUSE: boolean;
  105886. REFLECTIONFRESNELFROMSPECULAR: boolean;
  105887. LIGHTMAP: boolean;
  105888. LIGHTMAPDIRECTUV: number;
  105889. OBJECTSPACE_NORMALMAP: boolean;
  105890. USELIGHTMAPASSHADOWMAP: boolean;
  105891. REFLECTIONMAP_3D: boolean;
  105892. REFLECTIONMAP_SPHERICAL: boolean;
  105893. REFLECTIONMAP_PLANAR: boolean;
  105894. REFLECTIONMAP_CUBIC: boolean;
  105895. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  105896. REFLECTIONMAP_PROJECTION: boolean;
  105897. REFLECTIONMAP_SKYBOX: boolean;
  105898. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  105899. REFLECTIONMAP_EXPLICIT: boolean;
  105900. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  105901. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  105902. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  105903. INVERTCUBICMAP: boolean;
  105904. LOGARITHMICDEPTH: boolean;
  105905. REFRACTION: boolean;
  105906. REFRACTIONMAP_3D: boolean;
  105907. REFLECTIONOVERALPHA: boolean;
  105908. TWOSIDEDLIGHTING: boolean;
  105909. SHADOWFLOAT: boolean;
  105910. MORPHTARGETS: boolean;
  105911. MORPHTARGETS_NORMAL: boolean;
  105912. MORPHTARGETS_TANGENT: boolean;
  105913. MORPHTARGETS_UV: boolean;
  105914. NUM_MORPH_INFLUENCERS: number;
  105915. NONUNIFORMSCALING: boolean;
  105916. PREMULTIPLYALPHA: boolean;
  105917. IMAGEPROCESSING: boolean;
  105918. VIGNETTE: boolean;
  105919. VIGNETTEBLENDMODEMULTIPLY: boolean;
  105920. VIGNETTEBLENDMODEOPAQUE: boolean;
  105921. TONEMAPPING: boolean;
  105922. TONEMAPPING_ACES: boolean;
  105923. CONTRAST: boolean;
  105924. COLORCURVES: boolean;
  105925. COLORGRADING: boolean;
  105926. COLORGRADING3D: boolean;
  105927. SAMPLER3DGREENDEPTH: boolean;
  105928. SAMPLER3DBGRMAP: boolean;
  105929. IMAGEPROCESSINGPOSTPROCESS: boolean;
  105930. MULTIVIEW: boolean;
  105931. /**
  105932. * If the reflection texture on this material is in linear color space
  105933. * @hidden
  105934. */
  105935. IS_REFLECTION_LINEAR: boolean;
  105936. /**
  105937. * If the refraction texture on this material is in linear color space
  105938. * @hidden
  105939. */
  105940. IS_REFRACTION_LINEAR: boolean;
  105941. EXPOSURE: boolean;
  105942. constructor();
  105943. setReflectionMode(modeToEnable: string): void;
  105944. }
  105945. /**
  105946. * This is the default material used in Babylon. It is the best trade off between quality
  105947. * and performances.
  105948. * @see http://doc.babylonjs.com/babylon101/materials
  105949. */
  105950. export class StandardMaterial extends PushMaterial {
  105951. private _diffuseTexture;
  105952. /**
  105953. * The basic texture of the material as viewed under a light.
  105954. */
  105955. diffuseTexture: Nullable<BaseTexture>;
  105956. private _ambientTexture;
  105957. /**
  105958. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  105959. */
  105960. ambientTexture: Nullable<BaseTexture>;
  105961. private _opacityTexture;
  105962. /**
  105963. * Define the transparency of the material from a texture.
  105964. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  105965. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  105966. */
  105967. opacityTexture: Nullable<BaseTexture>;
  105968. private _reflectionTexture;
  105969. /**
  105970. * Define the texture used to display the reflection.
  105971. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105972. */
  105973. reflectionTexture: Nullable<BaseTexture>;
  105974. private _emissiveTexture;
  105975. /**
  105976. * Define texture of the material as if self lit.
  105977. * This will be mixed in the final result even in the absence of light.
  105978. */
  105979. emissiveTexture: Nullable<BaseTexture>;
  105980. private _specularTexture;
  105981. /**
  105982. * Define how the color and intensity of the highlight given by the light in the material.
  105983. */
  105984. specularTexture: Nullable<BaseTexture>;
  105985. private _bumpTexture;
  105986. /**
  105987. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  105988. * 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.
  105989. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  105990. */
  105991. bumpTexture: Nullable<BaseTexture>;
  105992. private _lightmapTexture;
  105993. /**
  105994. * Complex lighting can be computationally expensive to compute at runtime.
  105995. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  105996. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  105997. */
  105998. lightmapTexture: Nullable<BaseTexture>;
  105999. private _refractionTexture;
  106000. /**
  106001. * Define the texture used to display the refraction.
  106002. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106003. */
  106004. refractionTexture: Nullable<BaseTexture>;
  106005. /**
  106006. * The color of the material lit by the environmental background lighting.
  106007. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  106008. */
  106009. ambientColor: Color3;
  106010. /**
  106011. * The basic color of the material as viewed under a light.
  106012. */
  106013. diffuseColor: Color3;
  106014. /**
  106015. * Define how the color and intensity of the highlight given by the light in the material.
  106016. */
  106017. specularColor: Color3;
  106018. /**
  106019. * Define the color of the material as if self lit.
  106020. * This will be mixed in the final result even in the absence of light.
  106021. */
  106022. emissiveColor: Color3;
  106023. /**
  106024. * Defines how sharp are the highlights in the material.
  106025. * The bigger the value the sharper giving a more glossy feeling to the result.
  106026. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  106027. */
  106028. specularPower: number;
  106029. private _useAlphaFromDiffuseTexture;
  106030. /**
  106031. * Does the transparency come from the diffuse texture alpha channel.
  106032. */
  106033. useAlphaFromDiffuseTexture: boolean;
  106034. private _useEmissiveAsIllumination;
  106035. /**
  106036. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  106037. */
  106038. useEmissiveAsIllumination: boolean;
  106039. private _linkEmissiveWithDiffuse;
  106040. /**
  106041. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  106042. * the emissive level when the final color is close to one.
  106043. */
  106044. linkEmissiveWithDiffuse: boolean;
  106045. private _useSpecularOverAlpha;
  106046. /**
  106047. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  106048. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  106049. */
  106050. useSpecularOverAlpha: boolean;
  106051. private _useReflectionOverAlpha;
  106052. /**
  106053. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  106054. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  106055. */
  106056. useReflectionOverAlpha: boolean;
  106057. private _disableLighting;
  106058. /**
  106059. * Does lights from the scene impacts this material.
  106060. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  106061. */
  106062. disableLighting: boolean;
  106063. private _useObjectSpaceNormalMap;
  106064. /**
  106065. * Allows using an object space normal map (instead of tangent space).
  106066. */
  106067. useObjectSpaceNormalMap: boolean;
  106068. private _useParallax;
  106069. /**
  106070. * Is parallax enabled or not.
  106071. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106072. */
  106073. useParallax: boolean;
  106074. private _useParallaxOcclusion;
  106075. /**
  106076. * Is parallax occlusion enabled or not.
  106077. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  106078. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  106079. */
  106080. useParallaxOcclusion: boolean;
  106081. /**
  106082. * 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.
  106083. */
  106084. parallaxScaleBias: number;
  106085. private _roughness;
  106086. /**
  106087. * Helps to define how blurry the reflections should appears in the material.
  106088. */
  106089. roughness: number;
  106090. /**
  106091. * In case of refraction, define the value of the index of refraction.
  106092. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106093. */
  106094. indexOfRefraction: number;
  106095. /**
  106096. * Invert the refraction texture alongside the y axis.
  106097. * It can be useful with procedural textures or probe for instance.
  106098. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  106099. */
  106100. invertRefractionY: boolean;
  106101. /**
  106102. * Defines the alpha limits in alpha test mode.
  106103. */
  106104. alphaCutOff: number;
  106105. private _useLightmapAsShadowmap;
  106106. /**
  106107. * In case of light mapping, define whether the map contains light or shadow informations.
  106108. */
  106109. useLightmapAsShadowmap: boolean;
  106110. private _diffuseFresnelParameters;
  106111. /**
  106112. * Define the diffuse fresnel parameters of the material.
  106113. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106114. */
  106115. diffuseFresnelParameters: FresnelParameters;
  106116. private _opacityFresnelParameters;
  106117. /**
  106118. * Define the opacity fresnel parameters of the material.
  106119. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106120. */
  106121. opacityFresnelParameters: FresnelParameters;
  106122. private _reflectionFresnelParameters;
  106123. /**
  106124. * Define the reflection fresnel parameters of the material.
  106125. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106126. */
  106127. reflectionFresnelParameters: FresnelParameters;
  106128. private _refractionFresnelParameters;
  106129. /**
  106130. * Define the refraction fresnel parameters of the material.
  106131. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106132. */
  106133. refractionFresnelParameters: FresnelParameters;
  106134. private _emissiveFresnelParameters;
  106135. /**
  106136. * Define the emissive fresnel parameters of the material.
  106137. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106138. */
  106139. emissiveFresnelParameters: FresnelParameters;
  106140. private _useReflectionFresnelFromSpecular;
  106141. /**
  106142. * If true automatically deducts the fresnels values from the material specularity.
  106143. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  106144. */
  106145. useReflectionFresnelFromSpecular: boolean;
  106146. private _useGlossinessFromSpecularMapAlpha;
  106147. /**
  106148. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  106149. */
  106150. useGlossinessFromSpecularMapAlpha: boolean;
  106151. private _maxSimultaneousLights;
  106152. /**
  106153. * Defines the maximum number of lights that can be used in the material
  106154. */
  106155. maxSimultaneousLights: number;
  106156. private _invertNormalMapX;
  106157. /**
  106158. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  106159. */
  106160. invertNormalMapX: boolean;
  106161. private _invertNormalMapY;
  106162. /**
  106163. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  106164. */
  106165. invertNormalMapY: boolean;
  106166. private _twoSidedLighting;
  106167. /**
  106168. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  106169. */
  106170. twoSidedLighting: boolean;
  106171. /**
  106172. * Default configuration related to image processing available in the standard Material.
  106173. */
  106174. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106175. /**
  106176. * Gets the image processing configuration used either in this material.
  106177. */
  106178. /**
  106179. * Sets the Default image processing configuration used either in the this material.
  106180. *
  106181. * If sets to null, the scene one is in use.
  106182. */
  106183. imageProcessingConfiguration: ImageProcessingConfiguration;
  106184. /**
  106185. * Keep track of the image processing observer to allow dispose and replace.
  106186. */
  106187. private _imageProcessingObserver;
  106188. /**
  106189. * Attaches a new image processing configuration to the Standard Material.
  106190. * @param configuration
  106191. */
  106192. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106193. /**
  106194. * Gets wether the color curves effect is enabled.
  106195. */
  106196. /**
  106197. * Sets wether the color curves effect is enabled.
  106198. */
  106199. cameraColorCurvesEnabled: boolean;
  106200. /**
  106201. * Gets wether the color grading effect is enabled.
  106202. */
  106203. /**
  106204. * Gets wether the color grading effect is enabled.
  106205. */
  106206. cameraColorGradingEnabled: boolean;
  106207. /**
  106208. * Gets wether tonemapping is enabled or not.
  106209. */
  106210. /**
  106211. * Sets wether tonemapping is enabled or not
  106212. */
  106213. cameraToneMappingEnabled: boolean;
  106214. /**
  106215. * The camera exposure used on this material.
  106216. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106217. * This corresponds to a photographic exposure.
  106218. */
  106219. /**
  106220. * The camera exposure used on this material.
  106221. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106222. * This corresponds to a photographic exposure.
  106223. */
  106224. cameraExposure: number;
  106225. /**
  106226. * Gets The camera contrast used on this material.
  106227. */
  106228. /**
  106229. * Sets The camera contrast used on this material.
  106230. */
  106231. cameraContrast: number;
  106232. /**
  106233. * Gets the Color Grading 2D Lookup Texture.
  106234. */
  106235. /**
  106236. * Sets the Color Grading 2D Lookup Texture.
  106237. */
  106238. cameraColorGradingTexture: Nullable<BaseTexture>;
  106239. /**
  106240. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106241. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106242. * 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;
  106243. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106244. */
  106245. /**
  106246. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106247. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106248. * 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;
  106249. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106250. */
  106251. cameraColorCurves: Nullable<ColorCurves>;
  106252. /**
  106253. * Custom callback helping to override the default shader used in the material.
  106254. */
  106255. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  106256. protected _renderTargets: SmartArray<RenderTargetTexture>;
  106257. protected _worldViewProjectionMatrix: Matrix;
  106258. protected _globalAmbientColor: Color3;
  106259. protected _useLogarithmicDepth: boolean;
  106260. protected _rebuildInParallel: boolean;
  106261. /**
  106262. * Instantiates a new standard material.
  106263. * This is the default material used in Babylon. It is the best trade off between quality
  106264. * and performances.
  106265. * @see http://doc.babylonjs.com/babylon101/materials
  106266. * @param name Define the name of the material in the scene
  106267. * @param scene Define the scene the material belong to
  106268. */
  106269. constructor(name: string, scene: Scene);
  106270. /**
  106271. * Gets a boolean indicating that current material needs to register RTT
  106272. */
  106273. readonly hasRenderTargetTextures: boolean;
  106274. /**
  106275. * Gets the current class name of the material e.g. "StandardMaterial"
  106276. * Mainly use in serialization.
  106277. * @returns the class name
  106278. */
  106279. getClassName(): string;
  106280. /**
  106281. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  106282. * You can try switching to logarithmic depth.
  106283. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  106284. */
  106285. useLogarithmicDepth: boolean;
  106286. /**
  106287. * Specifies if the material will require alpha blending
  106288. * @returns a boolean specifying if alpha blending is needed
  106289. */
  106290. needAlphaBlending(): boolean;
  106291. /**
  106292. * Specifies if this material should be rendered in alpha test mode
  106293. * @returns a boolean specifying if an alpha test is needed.
  106294. */
  106295. needAlphaTesting(): boolean;
  106296. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  106297. /**
  106298. * Get the texture used for alpha test purpose.
  106299. * @returns the diffuse texture in case of the standard material.
  106300. */
  106301. getAlphaTestTexture(): Nullable<BaseTexture>;
  106302. /**
  106303. * Get if the submesh is ready to be used and all its information available.
  106304. * Child classes can use it to update shaders
  106305. * @param mesh defines the mesh to check
  106306. * @param subMesh defines which submesh to check
  106307. * @param useInstances specifies that instances should be used
  106308. * @returns a boolean indicating that the submesh is ready or not
  106309. */
  106310. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106311. /**
  106312. * Builds the material UBO layouts.
  106313. * Used internally during the effect preparation.
  106314. */
  106315. buildUniformLayout(): void;
  106316. /**
  106317. * Unbinds the material from the mesh
  106318. */
  106319. unbind(): void;
  106320. /**
  106321. * Binds the submesh to this material by preparing the effect and shader to draw
  106322. * @param world defines the world transformation matrix
  106323. * @param mesh defines the mesh containing the submesh
  106324. * @param subMesh defines the submesh to bind the material to
  106325. */
  106326. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106327. /**
  106328. * Get the list of animatables in the material.
  106329. * @returns the list of animatables object used in the material
  106330. */
  106331. getAnimatables(): IAnimatable[];
  106332. /**
  106333. * Gets the active textures from the material
  106334. * @returns an array of textures
  106335. */
  106336. getActiveTextures(): BaseTexture[];
  106337. /**
  106338. * Specifies if the material uses a texture
  106339. * @param texture defines the texture to check against the material
  106340. * @returns a boolean specifying if the material uses the texture
  106341. */
  106342. hasTexture(texture: BaseTexture): boolean;
  106343. /**
  106344. * Disposes the material
  106345. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  106346. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  106347. */
  106348. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106349. /**
  106350. * Makes a duplicate of the material, and gives it a new name
  106351. * @param name defines the new name for the duplicated material
  106352. * @returns the cloned material
  106353. */
  106354. clone(name: string): StandardMaterial;
  106355. /**
  106356. * Serializes this material in a JSON representation
  106357. * @returns the serialized material object
  106358. */
  106359. serialize(): any;
  106360. /**
  106361. * Creates a standard material from parsed material data
  106362. * @param source defines the JSON representation of the material
  106363. * @param scene defines the hosting scene
  106364. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  106365. * @returns a new standard material
  106366. */
  106367. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  106368. /**
  106369. * Are diffuse textures enabled in the application.
  106370. */
  106371. static DiffuseTextureEnabled: boolean;
  106372. /**
  106373. * Are ambient textures enabled in the application.
  106374. */
  106375. static AmbientTextureEnabled: boolean;
  106376. /**
  106377. * Are opacity textures enabled in the application.
  106378. */
  106379. static OpacityTextureEnabled: boolean;
  106380. /**
  106381. * Are reflection textures enabled in the application.
  106382. */
  106383. static ReflectionTextureEnabled: boolean;
  106384. /**
  106385. * Are emissive textures enabled in the application.
  106386. */
  106387. static EmissiveTextureEnabled: boolean;
  106388. /**
  106389. * Are specular textures enabled in the application.
  106390. */
  106391. static SpecularTextureEnabled: boolean;
  106392. /**
  106393. * Are bump textures enabled in the application.
  106394. */
  106395. static BumpTextureEnabled: boolean;
  106396. /**
  106397. * Are lightmap textures enabled in the application.
  106398. */
  106399. static LightmapTextureEnabled: boolean;
  106400. /**
  106401. * Are refraction textures enabled in the application.
  106402. */
  106403. static RefractionTextureEnabled: boolean;
  106404. /**
  106405. * Are color grading textures enabled in the application.
  106406. */
  106407. static ColorGradingTextureEnabled: boolean;
  106408. /**
  106409. * Are fresnels enabled in the application.
  106410. */
  106411. static FresnelEnabled: boolean;
  106412. }
  106413. }
  106414. declare module BABYLON {
  106415. /** @hidden */
  106416. export var imageProcessingPixelShader: {
  106417. name: string;
  106418. shader: string;
  106419. };
  106420. }
  106421. declare module BABYLON {
  106422. /**
  106423. * ImageProcessingPostProcess
  106424. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  106425. */
  106426. export class ImageProcessingPostProcess extends PostProcess {
  106427. /**
  106428. * Default configuration related to image processing available in the PBR Material.
  106429. */
  106430. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106431. /**
  106432. * Gets the image processing configuration used either in this material.
  106433. */
  106434. /**
  106435. * Sets the Default image processing configuration used either in the this material.
  106436. *
  106437. * If sets to null, the scene one is in use.
  106438. */
  106439. imageProcessingConfiguration: ImageProcessingConfiguration;
  106440. /**
  106441. * Keep track of the image processing observer to allow dispose and replace.
  106442. */
  106443. private _imageProcessingObserver;
  106444. /**
  106445. * Attaches a new image processing configuration to the PBR Material.
  106446. * @param configuration
  106447. */
  106448. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  106449. /**
  106450. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106451. */
  106452. /**
  106453. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  106454. */
  106455. colorCurves: Nullable<ColorCurves>;
  106456. /**
  106457. * Gets wether the color curves effect is enabled.
  106458. */
  106459. /**
  106460. * Sets wether the color curves effect is enabled.
  106461. */
  106462. colorCurvesEnabled: boolean;
  106463. /**
  106464. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106465. */
  106466. /**
  106467. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  106468. */
  106469. colorGradingTexture: Nullable<BaseTexture>;
  106470. /**
  106471. * Gets wether the color grading effect is enabled.
  106472. */
  106473. /**
  106474. * Gets wether the color grading effect is enabled.
  106475. */
  106476. colorGradingEnabled: boolean;
  106477. /**
  106478. * Gets exposure used in the effect.
  106479. */
  106480. /**
  106481. * Sets exposure used in the effect.
  106482. */
  106483. exposure: number;
  106484. /**
  106485. * Gets wether tonemapping is enabled or not.
  106486. */
  106487. /**
  106488. * Sets wether tonemapping is enabled or not
  106489. */
  106490. toneMappingEnabled: boolean;
  106491. /**
  106492. * Gets the type of tone mapping effect.
  106493. */
  106494. /**
  106495. * Sets the type of tone mapping effect.
  106496. */
  106497. toneMappingType: number;
  106498. /**
  106499. * Gets contrast used in the effect.
  106500. */
  106501. /**
  106502. * Sets contrast used in the effect.
  106503. */
  106504. contrast: number;
  106505. /**
  106506. * Gets Vignette stretch size.
  106507. */
  106508. /**
  106509. * Sets Vignette stretch size.
  106510. */
  106511. vignetteStretch: number;
  106512. /**
  106513. * Gets Vignette centre X Offset.
  106514. */
  106515. /**
  106516. * Sets Vignette centre X Offset.
  106517. */
  106518. vignetteCentreX: number;
  106519. /**
  106520. * Gets Vignette centre Y Offset.
  106521. */
  106522. /**
  106523. * Sets Vignette centre Y Offset.
  106524. */
  106525. vignetteCentreY: number;
  106526. /**
  106527. * Gets Vignette weight or intensity of the vignette effect.
  106528. */
  106529. /**
  106530. * Sets Vignette weight or intensity of the vignette effect.
  106531. */
  106532. vignetteWeight: number;
  106533. /**
  106534. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106535. * if vignetteEnabled is set to true.
  106536. */
  106537. /**
  106538. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  106539. * if vignetteEnabled is set to true.
  106540. */
  106541. vignetteColor: Color4;
  106542. /**
  106543. * Gets Camera field of view used by the Vignette effect.
  106544. */
  106545. /**
  106546. * Sets Camera field of view used by the Vignette effect.
  106547. */
  106548. vignetteCameraFov: number;
  106549. /**
  106550. * Gets the vignette blend mode allowing different kind of effect.
  106551. */
  106552. /**
  106553. * Sets the vignette blend mode allowing different kind of effect.
  106554. */
  106555. vignetteBlendMode: number;
  106556. /**
  106557. * Gets wether the vignette effect is enabled.
  106558. */
  106559. /**
  106560. * Sets wether the vignette effect is enabled.
  106561. */
  106562. vignetteEnabled: boolean;
  106563. private _fromLinearSpace;
  106564. /**
  106565. * Gets wether the input of the processing is in Gamma or Linear Space.
  106566. */
  106567. /**
  106568. * Sets wether the input of the processing is in Gamma or Linear Space.
  106569. */
  106570. fromLinearSpace: boolean;
  106571. /**
  106572. * Defines cache preventing GC.
  106573. */
  106574. private _defines;
  106575. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  106576. /**
  106577. * "ImageProcessingPostProcess"
  106578. * @returns "ImageProcessingPostProcess"
  106579. */
  106580. getClassName(): string;
  106581. protected _updateParameters(): void;
  106582. dispose(camera?: Camera): void;
  106583. }
  106584. }
  106585. declare module BABYLON {
  106586. /**
  106587. * Class containing static functions to help procedurally build meshes
  106588. */
  106589. export class GroundBuilder {
  106590. /**
  106591. * Creates a ground mesh
  106592. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  106593. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  106594. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106595. * @param name defines the name of the mesh
  106596. * @param options defines the options used to create the mesh
  106597. * @param scene defines the hosting scene
  106598. * @returns the ground mesh
  106599. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  106600. */
  106601. static CreateGround(name: string, options: {
  106602. width?: number;
  106603. height?: number;
  106604. subdivisions?: number;
  106605. subdivisionsX?: number;
  106606. subdivisionsY?: number;
  106607. updatable?: boolean;
  106608. }, scene: any): Mesh;
  106609. /**
  106610. * Creates a tiled ground mesh
  106611. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  106612. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  106613. * * 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
  106614. * * 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
  106615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106616. * @param name defines the name of the mesh
  106617. * @param options defines the options used to create the mesh
  106618. * @param scene defines the hosting scene
  106619. * @returns the tiled ground mesh
  106620. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  106621. */
  106622. static CreateTiledGround(name: string, options: {
  106623. xmin: number;
  106624. zmin: number;
  106625. xmax: number;
  106626. zmax: number;
  106627. subdivisions?: {
  106628. w: number;
  106629. h: number;
  106630. };
  106631. precision?: {
  106632. w: number;
  106633. h: number;
  106634. };
  106635. updatable?: boolean;
  106636. }, scene?: Nullable<Scene>): Mesh;
  106637. /**
  106638. * Creates a ground mesh from a height map
  106639. * * The parameter `url` sets the URL of the height map image resource.
  106640. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  106641. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  106642. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  106643. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  106644. * * 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.
  106645. * * 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).
  106646. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106648. * @param name defines the name of the mesh
  106649. * @param url defines the url to the height map
  106650. * @param options defines the options used to create the mesh
  106651. * @param scene defines the hosting scene
  106652. * @returns the ground mesh
  106653. * @see https://doc.babylonjs.com/babylon101/height_map
  106654. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  106655. */
  106656. static CreateGroundFromHeightMap(name: string, url: string, options: {
  106657. width?: number;
  106658. height?: number;
  106659. subdivisions?: number;
  106660. minHeight?: number;
  106661. maxHeight?: number;
  106662. colorFilter?: Color3;
  106663. alphaFilter?: number;
  106664. updatable?: boolean;
  106665. onReady?: (mesh: GroundMesh) => void;
  106666. }, scene?: Nullable<Scene>): GroundMesh;
  106667. }
  106668. }
  106669. declare module BABYLON {
  106670. /**
  106671. * Class containing static functions to help procedurally build meshes
  106672. */
  106673. export class TorusBuilder {
  106674. /**
  106675. * Creates a torus mesh
  106676. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  106677. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  106678. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  106679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106682. * @param name defines the name of the mesh
  106683. * @param options defines the options used to create the mesh
  106684. * @param scene defines the hosting scene
  106685. * @returns the torus mesh
  106686. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  106687. */
  106688. static CreateTorus(name: string, options: {
  106689. diameter?: number;
  106690. thickness?: number;
  106691. tessellation?: number;
  106692. updatable?: boolean;
  106693. sideOrientation?: number;
  106694. frontUVs?: Vector4;
  106695. backUVs?: Vector4;
  106696. }, scene: any): Mesh;
  106697. }
  106698. }
  106699. declare module BABYLON {
  106700. /**
  106701. * Class containing static functions to help procedurally build meshes
  106702. */
  106703. export class CylinderBuilder {
  106704. /**
  106705. * Creates a cylinder or a cone mesh
  106706. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  106707. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  106708. * * 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.
  106709. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  106710. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  106711. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  106712. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  106713. * * 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).
  106714. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  106715. * * 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).
  106716. * * 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
  106717. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  106718. * * 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
  106719. * * 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.
  106720. * * If `enclose` is false, a ring surface is one element.
  106721. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  106722. * * 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
  106723. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106724. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106726. * @param name defines the name of the mesh
  106727. * @param options defines the options used to create the mesh
  106728. * @param scene defines the hosting scene
  106729. * @returns the cylinder mesh
  106730. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  106731. */
  106732. static CreateCylinder(name: string, options: {
  106733. height?: number;
  106734. diameterTop?: number;
  106735. diameterBottom?: number;
  106736. diameter?: number;
  106737. tessellation?: number;
  106738. subdivisions?: number;
  106739. arc?: number;
  106740. faceColors?: Color4[];
  106741. faceUV?: Vector4[];
  106742. updatable?: boolean;
  106743. hasRings?: boolean;
  106744. enclose?: boolean;
  106745. cap?: number;
  106746. sideOrientation?: number;
  106747. frontUVs?: Vector4;
  106748. backUVs?: Vector4;
  106749. }, scene: any): Mesh;
  106750. }
  106751. }
  106752. declare module BABYLON {
  106753. /**
  106754. * Options to modify the vr teleportation behavior.
  106755. */
  106756. export interface VRTeleportationOptions {
  106757. /**
  106758. * The name of the mesh which should be used as the teleportation floor. (default: null)
  106759. */
  106760. floorMeshName?: string;
  106761. /**
  106762. * A list of meshes to be used as the teleportation floor. (default: empty)
  106763. */
  106764. floorMeshes?: Mesh[];
  106765. }
  106766. /**
  106767. * Options to modify the vr experience helper's behavior.
  106768. */
  106769. export interface VRExperienceHelperOptions extends WebVROptions {
  106770. /**
  106771. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  106772. */
  106773. createDeviceOrientationCamera?: boolean;
  106774. /**
  106775. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  106776. */
  106777. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  106778. /**
  106779. * Uses the main button on the controller to toggle the laser casted. (default: true)
  106780. */
  106781. laserToggle?: boolean;
  106782. /**
  106783. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  106784. */
  106785. floorMeshes?: Mesh[];
  106786. /**
  106787. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  106788. */
  106789. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  106790. }
  106791. /**
  106792. * Event containing information after VR has been entered
  106793. */
  106794. export class OnAfterEnteringVRObservableEvent {
  106795. /**
  106796. * If entering vr was successful
  106797. */
  106798. success: boolean;
  106799. }
  106800. /**
  106801. * Helps to quickly add VR support to an existing scene.
  106802. * See http://doc.babylonjs.com/how_to/webvr_helper
  106803. */
  106804. export class VRExperienceHelper {
  106805. /** Options to modify the vr experience helper's behavior. */
  106806. webVROptions: VRExperienceHelperOptions;
  106807. private _scene;
  106808. private _position;
  106809. private _btnVR;
  106810. private _btnVRDisplayed;
  106811. private _webVRsupported;
  106812. private _webVRready;
  106813. private _webVRrequesting;
  106814. private _webVRpresenting;
  106815. private _hasEnteredVR;
  106816. private _fullscreenVRpresenting;
  106817. private _canvas;
  106818. private _webVRCamera;
  106819. private _vrDeviceOrientationCamera;
  106820. private _deviceOrientationCamera;
  106821. private _existingCamera;
  106822. private _onKeyDown;
  106823. private _onVrDisplayPresentChange;
  106824. private _onVRDisplayChanged;
  106825. private _onVRRequestPresentStart;
  106826. private _onVRRequestPresentComplete;
  106827. /**
  106828. * 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)
  106829. */
  106830. enableGazeEvenWhenNoPointerLock: boolean;
  106831. /**
  106832. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  106833. */
  106834. exitVROnDoubleTap: boolean;
  106835. /**
  106836. * Observable raised right before entering VR.
  106837. */
  106838. onEnteringVRObservable: Observable<VRExperienceHelper>;
  106839. /**
  106840. * Observable raised when entering VR has completed.
  106841. */
  106842. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  106843. /**
  106844. * Observable raised when exiting VR.
  106845. */
  106846. onExitingVRObservable: Observable<VRExperienceHelper>;
  106847. /**
  106848. * Observable raised when controller mesh is loaded.
  106849. */
  106850. onControllerMeshLoadedObservable: Observable<WebVRController>;
  106851. /** Return this.onEnteringVRObservable
  106852. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  106853. */
  106854. readonly onEnteringVR: Observable<VRExperienceHelper>;
  106855. /** Return this.onExitingVRObservable
  106856. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  106857. */
  106858. readonly onExitingVR: Observable<VRExperienceHelper>;
  106859. /** Return this.onControllerMeshLoadedObservable
  106860. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  106861. */
  106862. readonly onControllerMeshLoaded: Observable<WebVRController>;
  106863. private _rayLength;
  106864. private _useCustomVRButton;
  106865. private _teleportationRequested;
  106866. private _teleportActive;
  106867. private _floorMeshName;
  106868. private _floorMeshesCollection;
  106869. private _rotationAllowed;
  106870. private _teleportBackwardsVector;
  106871. private _teleportationTarget;
  106872. private _isDefaultTeleportationTarget;
  106873. private _postProcessMove;
  106874. private _teleportationFillColor;
  106875. private _teleportationBorderColor;
  106876. private _rotationAngle;
  106877. private _haloCenter;
  106878. private _cameraGazer;
  106879. private _padSensibilityUp;
  106880. private _padSensibilityDown;
  106881. private _leftController;
  106882. private _rightController;
  106883. /**
  106884. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  106885. */
  106886. onNewMeshSelected: Observable<AbstractMesh>;
  106887. /**
  106888. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  106889. * This observable will provide the mesh and the controller used to select the mesh
  106890. */
  106891. onMeshSelectedWithController: Observable<{
  106892. mesh: AbstractMesh;
  106893. controller: WebVRController;
  106894. }>;
  106895. /**
  106896. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  106897. */
  106898. onNewMeshPicked: Observable<PickingInfo>;
  106899. private _circleEase;
  106900. /**
  106901. * Observable raised before camera teleportation
  106902. */
  106903. onBeforeCameraTeleport: Observable<Vector3>;
  106904. /**
  106905. * Observable raised after camera teleportation
  106906. */
  106907. onAfterCameraTeleport: Observable<Vector3>;
  106908. /**
  106909. * Observable raised when current selected mesh gets unselected
  106910. */
  106911. onSelectedMeshUnselected: Observable<AbstractMesh>;
  106912. private _raySelectionPredicate;
  106913. /**
  106914. * To be optionaly changed by user to define custom ray selection
  106915. */
  106916. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  106917. /**
  106918. * To be optionaly changed by user to define custom selection logic (after ray selection)
  106919. */
  106920. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106921. /**
  106922. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  106923. */
  106924. teleportationEnabled: boolean;
  106925. private _defaultHeight;
  106926. private _teleportationInitialized;
  106927. private _interactionsEnabled;
  106928. private _interactionsRequested;
  106929. private _displayGaze;
  106930. private _displayLaserPointer;
  106931. /**
  106932. * The mesh used to display where the user is going to teleport.
  106933. */
  106934. /**
  106935. * Sets the mesh to be used to display where the user is going to teleport.
  106936. */
  106937. teleportationTarget: Mesh;
  106938. /**
  106939. * 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
  106940. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  106941. * See http://doc.babylonjs.com/resources/baking_transformations
  106942. */
  106943. gazeTrackerMesh: Mesh;
  106944. /**
  106945. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  106946. */
  106947. updateGazeTrackerScale: boolean;
  106948. /**
  106949. * If the gaze trackers color should be updated when selecting meshes
  106950. */
  106951. updateGazeTrackerColor: boolean;
  106952. /**
  106953. * If the controller laser color should be updated when selecting meshes
  106954. */
  106955. updateControllerLaserColor: boolean;
  106956. /**
  106957. * The gaze tracking mesh corresponding to the left controller
  106958. */
  106959. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  106960. /**
  106961. * The gaze tracking mesh corresponding to the right controller
  106962. */
  106963. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  106964. /**
  106965. * If the ray of the gaze should be displayed.
  106966. */
  106967. /**
  106968. * Sets if the ray of the gaze should be displayed.
  106969. */
  106970. displayGaze: boolean;
  106971. /**
  106972. * If the ray of the LaserPointer should be displayed.
  106973. */
  106974. /**
  106975. * Sets if the ray of the LaserPointer should be displayed.
  106976. */
  106977. displayLaserPointer: boolean;
  106978. /**
  106979. * The deviceOrientationCamera used as the camera when not in VR.
  106980. */
  106981. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  106982. /**
  106983. * Based on the current WebVR support, returns the current VR camera used.
  106984. */
  106985. readonly currentVRCamera: Nullable<Camera>;
  106986. /**
  106987. * The webVRCamera which is used when in VR.
  106988. */
  106989. readonly webVRCamera: WebVRFreeCamera;
  106990. /**
  106991. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  106992. */
  106993. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  106994. /**
  106995. * The html button that is used to trigger entering into VR.
  106996. */
  106997. readonly vrButton: Nullable<HTMLButtonElement>;
  106998. private readonly _teleportationRequestInitiated;
  106999. /**
  107000. * Defines wether or not Pointer lock should be requested when switching to
  107001. * full screen.
  107002. */
  107003. requestPointerLockOnFullScreen: boolean;
  107004. /**
  107005. * Instantiates a VRExperienceHelper.
  107006. * Helps to quickly add VR support to an existing scene.
  107007. * @param scene The scene the VRExperienceHelper belongs to.
  107008. * @param webVROptions Options to modify the vr experience helper's behavior.
  107009. */
  107010. constructor(scene: Scene,
  107011. /** Options to modify the vr experience helper's behavior. */
  107012. webVROptions?: VRExperienceHelperOptions);
  107013. private _onDefaultMeshLoaded;
  107014. private _onResize;
  107015. private _onFullscreenChange;
  107016. /**
  107017. * Gets a value indicating if we are currently in VR mode.
  107018. */
  107019. readonly isInVRMode: boolean;
  107020. private onVrDisplayPresentChange;
  107021. private onVRDisplayChanged;
  107022. private moveButtonToBottomRight;
  107023. private displayVRButton;
  107024. private updateButtonVisibility;
  107025. private _cachedAngularSensibility;
  107026. /**
  107027. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  107028. * Otherwise, will use the fullscreen API.
  107029. */
  107030. enterVR(): void;
  107031. /**
  107032. * Attempt to exit VR, or fullscreen.
  107033. */
  107034. exitVR(): void;
  107035. /**
  107036. * The position of the vr experience helper.
  107037. */
  107038. /**
  107039. * Sets the position of the vr experience helper.
  107040. */
  107041. position: Vector3;
  107042. /**
  107043. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  107044. */
  107045. enableInteractions(): void;
  107046. private readonly _noControllerIsActive;
  107047. private beforeRender;
  107048. private _isTeleportationFloor;
  107049. /**
  107050. * Adds a floor mesh to be used for teleportation.
  107051. * @param floorMesh the mesh to be used for teleportation.
  107052. */
  107053. addFloorMesh(floorMesh: Mesh): void;
  107054. /**
  107055. * Removes a floor mesh from being used for teleportation.
  107056. * @param floorMesh the mesh to be removed.
  107057. */
  107058. removeFloorMesh(floorMesh: Mesh): void;
  107059. /**
  107060. * Enables interactions and teleportation using the VR controllers and gaze.
  107061. * @param vrTeleportationOptions options to modify teleportation behavior.
  107062. */
  107063. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  107064. private _onNewGamepadConnected;
  107065. private _tryEnableInteractionOnController;
  107066. private _onNewGamepadDisconnected;
  107067. private _enableInteractionOnController;
  107068. private _checkTeleportWithRay;
  107069. private _checkRotate;
  107070. private _checkTeleportBackwards;
  107071. private _enableTeleportationOnController;
  107072. private _createTeleportationCircles;
  107073. private _displayTeleportationTarget;
  107074. private _hideTeleportationTarget;
  107075. private _rotateCamera;
  107076. private _moveTeleportationSelectorTo;
  107077. private _workingVector;
  107078. private _workingQuaternion;
  107079. private _workingMatrix;
  107080. /**
  107081. * Teleports the users feet to the desired location
  107082. * @param location The location where the user's feet should be placed
  107083. */
  107084. teleportCamera(location: Vector3): void;
  107085. private _convertNormalToDirectionOfRay;
  107086. private _castRayAndSelectObject;
  107087. private _notifySelectedMeshUnselected;
  107088. /**
  107089. * Sets the color of the laser ray from the vr controllers.
  107090. * @param color new color for the ray.
  107091. */
  107092. changeLaserColor(color: Color3): void;
  107093. /**
  107094. * Sets the color of the ray from the vr headsets gaze.
  107095. * @param color new color for the ray.
  107096. */
  107097. changeGazeColor(color: Color3): void;
  107098. /**
  107099. * Exits VR and disposes of the vr experience helper
  107100. */
  107101. dispose(): void;
  107102. /**
  107103. * Gets the name of the VRExperienceHelper class
  107104. * @returns "VRExperienceHelper"
  107105. */
  107106. getClassName(): string;
  107107. }
  107108. }
  107109. declare module BABYLON {
  107110. /**
  107111. * Manages an XRSession to work with Babylon's engine
  107112. * @see https://doc.babylonjs.com/how_to/webxr
  107113. */
  107114. export class WebXRSessionManager implements IDisposable {
  107115. private scene;
  107116. /**
  107117. * Fires every time a new xrFrame arrives which can be used to update the camera
  107118. */
  107119. onXRFrameObservable: Observable<any>;
  107120. /**
  107121. * Fires when the xr session is ended either by the device or manually done
  107122. */
  107123. onXRSessionEnded: Observable<any>;
  107124. /**
  107125. * Underlying xr session
  107126. */
  107127. session: XRSession;
  107128. /**
  107129. * Type of reference space used when creating the session
  107130. */
  107131. referenceSpace: XRReferenceSpace;
  107132. /** @hidden */
  107133. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  107134. /**
  107135. * Current XR frame
  107136. */
  107137. currentFrame: Nullable<XRFrame>;
  107138. private _xrNavigator;
  107139. private baseLayer;
  107140. /**
  107141. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  107142. * @param scene The scene which the session should be created for
  107143. */
  107144. constructor(scene: Scene);
  107145. /**
  107146. * Initializes the manager
  107147. * After initialization enterXR can be called to start an XR session
  107148. * @returns Promise which resolves after it is initialized
  107149. */
  107150. initializeAsync(): Promise<void>;
  107151. /**
  107152. * Initializes an xr session
  107153. * @param xrSessionMode mode to initialize
  107154. * @returns a promise which will resolve once the session has been initialized
  107155. */
  107156. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  107157. /**
  107158. * Sets the reference space on the xr session
  107159. * @param referenceSpace space to set
  107160. * @returns a promise that will resolve once the reference space has been set
  107161. */
  107162. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  107163. /**
  107164. * Updates the render state of the session
  107165. * @param state state to set
  107166. * @returns a promise that resolves once the render state has been updated
  107167. */
  107168. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  107169. /**
  107170. * Starts rendering to the xr layer
  107171. * @returns a promise that will resolve once rendering has started
  107172. */
  107173. startRenderingToXRAsync(): Promise<void>;
  107174. /**
  107175. * Stops the xrSession and restores the renderloop
  107176. * @returns Promise which resolves after it exits XR
  107177. */
  107178. exitXRAsync(): Promise<unknown>;
  107179. /**
  107180. * Checks if a session would be supported for the creation options specified
  107181. * @param sessionMode session mode to check if supported eg. immersive-vr
  107182. * @returns true if supported
  107183. */
  107184. supportsSessionAsync(sessionMode: XRSessionMode): any;
  107185. /**
  107186. * @hidden
  107187. * Converts the render layer of xrSession to a render target
  107188. * @param session session to create render target for
  107189. * @param scene scene the new render target should be created for
  107190. */
  107191. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  107192. /**
  107193. * Disposes of the session manager
  107194. */
  107195. dispose(): void;
  107196. }
  107197. }
  107198. declare module BABYLON {
  107199. /**
  107200. * WebXR Camera which holds the views for the xrSession
  107201. * @see https://doc.babylonjs.com/how_to/webxr
  107202. */
  107203. export class WebXRCamera extends FreeCamera {
  107204. private static _TmpMatrix;
  107205. /**
  107206. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  107207. * @param name the name of the camera
  107208. * @param scene the scene to add the camera to
  107209. */
  107210. constructor(name: string, scene: Scene);
  107211. private _updateNumberOfRigCameras;
  107212. /** @hidden */
  107213. _updateForDualEyeDebugging(pupilDistance?: number): void;
  107214. /**
  107215. * Updates the cameras position from the current pose information of the XR session
  107216. * @param xrSessionManager the session containing pose information
  107217. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  107218. */
  107219. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  107220. }
  107221. }
  107222. declare module BABYLON {
  107223. /**
  107224. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  107225. */
  107226. export class WebXRManagedOutputCanvas implements IDisposable {
  107227. private helper;
  107228. private _canvas;
  107229. /**
  107230. * xrpresent context of the canvas which can be used to display/mirror xr content
  107231. */
  107232. canvasContext: WebGLRenderingContext;
  107233. /**
  107234. * xr layer for the canvas
  107235. */
  107236. xrLayer: Nullable<XRWebGLLayer>;
  107237. /**
  107238. * Initializes the xr layer for the session
  107239. * @param xrSession xr session
  107240. * @returns a promise that will resolve once the XR Layer has been created
  107241. */
  107242. initializeXRLayerAsync(xrSession: any): any;
  107243. /**
  107244. * Initializes the canvas to be added/removed upon entering/exiting xr
  107245. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  107246. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  107247. */
  107248. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  107249. /**
  107250. * Disposes of the object
  107251. */
  107252. dispose(): void;
  107253. private _setManagedOutputCanvas;
  107254. private _addCanvas;
  107255. private _removeCanvas;
  107256. }
  107257. }
  107258. declare module BABYLON {
  107259. /**
  107260. * States of the webXR experience
  107261. */
  107262. export enum WebXRState {
  107263. /**
  107264. * Transitioning to being in XR mode
  107265. */
  107266. ENTERING_XR = 0,
  107267. /**
  107268. * Transitioning to non XR mode
  107269. */
  107270. EXITING_XR = 1,
  107271. /**
  107272. * In XR mode and presenting
  107273. */
  107274. IN_XR = 2,
  107275. /**
  107276. * Not entered XR mode
  107277. */
  107278. NOT_IN_XR = 3
  107279. }
  107280. /**
  107281. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  107282. * @see https://doc.babylonjs.com/how_to/webxr
  107283. */
  107284. export class WebXRExperienceHelper implements IDisposable {
  107285. private scene;
  107286. /**
  107287. * Container which stores the xr camera and controllers as children. This can be used to move the camera/user as the camera's position is updated by the xr device
  107288. */
  107289. container: AbstractMesh;
  107290. /**
  107291. * Camera used to render xr content
  107292. */
  107293. camera: WebXRCamera;
  107294. /**
  107295. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  107296. */
  107297. state: WebXRState;
  107298. private _setState;
  107299. private static _TmpVector;
  107300. /**
  107301. * Fires when the state of the experience helper has changed
  107302. */
  107303. onStateChangedObservable: Observable<WebXRState>;
  107304. /** Session manager used to keep track of xr session */
  107305. sessionManager: WebXRSessionManager;
  107306. private _nonVRCamera;
  107307. private _originalSceneAutoClear;
  107308. private _supported;
  107309. /**
  107310. * Creates the experience helper
  107311. * @param scene the scene to attach the experience helper to
  107312. * @returns a promise for the experience helper
  107313. */
  107314. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  107315. /**
  107316. * Creates a WebXRExperienceHelper
  107317. * @param scene The scene the helper should be created in
  107318. */
  107319. private constructor();
  107320. /**
  107321. * Exits XR mode and returns the scene to its original state
  107322. * @returns promise that resolves after xr mode has exited
  107323. */
  107324. exitXRAsync(): Promise<unknown>;
  107325. /**
  107326. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  107327. * @param sessionCreationOptions options for the XR session
  107328. * @param referenceSpaceType frame of reference of the XR session
  107329. * @param outputCanvas the output canvas that will be used to enter XR mode
  107330. * @returns promise that resolves after xr mode has entered
  107331. */
  107332. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  107333. /**
  107334. * Updates the global position of the camera by moving the camera's container
  107335. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  107336. * @param position The desired global position of the camera
  107337. */
  107338. setPositionOfCameraUsingContainer(position: Vector3): void;
  107339. /**
  107340. * Rotates the xr camera by rotating the camera's container around the camera's position
  107341. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  107342. * @param rotation the desired quaternion rotation to apply to the camera
  107343. */
  107344. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  107345. /**
  107346. * Disposes of the experience helper
  107347. */
  107348. dispose(): void;
  107349. }
  107350. }
  107351. declare module BABYLON {
  107352. /**
  107353. * Button which can be used to enter a different mode of XR
  107354. */
  107355. export class WebXREnterExitUIButton {
  107356. /** button element */
  107357. element: HTMLElement;
  107358. /** XR initialization options for the button */
  107359. sessionMode: XRSessionMode;
  107360. /** Reference space type */
  107361. referenceSpaceType: XRReferenceSpaceType;
  107362. /**
  107363. * Creates a WebXREnterExitUIButton
  107364. * @param element button element
  107365. * @param sessionMode XR initialization session mode
  107366. * @param referenceSpaceType the type of reference space to be used
  107367. */
  107368. constructor(
  107369. /** button element */
  107370. element: HTMLElement,
  107371. /** XR initialization options for the button */
  107372. sessionMode: XRSessionMode,
  107373. /** Reference space type */
  107374. referenceSpaceType: XRReferenceSpaceType);
  107375. /**
  107376. * Overwritable function which can be used to update the button's visuals when the state changes
  107377. * @param activeButton the current active button in the UI
  107378. */
  107379. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  107380. }
  107381. /**
  107382. * Options to create the webXR UI
  107383. */
  107384. export class WebXREnterExitUIOptions {
  107385. /**
  107386. * Context to enter xr with
  107387. */
  107388. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  107389. /**
  107390. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  107391. */
  107392. customButtons?: Array<WebXREnterExitUIButton>;
  107393. }
  107394. /**
  107395. * UI to allow the user to enter/exit XR mode
  107396. */
  107397. export class WebXREnterExitUI implements IDisposable {
  107398. private scene;
  107399. private _overlay;
  107400. private _buttons;
  107401. private _activeButton;
  107402. /**
  107403. * Fired every time the active button is changed.
  107404. *
  107405. * When xr is entered via a button that launches xr that button will be the callback parameter
  107406. *
  107407. * When exiting xr the callback parameter will be null)
  107408. */
  107409. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  107410. /**
  107411. * Creates UI to allow the user to enter/exit XR mode
  107412. * @param scene the scene to add the ui to
  107413. * @param helper the xr experience helper to enter/exit xr with
  107414. * @param options options to configure the UI
  107415. * @returns the created ui
  107416. */
  107417. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  107418. private constructor();
  107419. private _updateButtons;
  107420. /**
  107421. * Disposes of the object
  107422. */
  107423. dispose(): void;
  107424. }
  107425. }
  107426. declare module BABYLON {
  107427. /**
  107428. * Represents an XR input
  107429. */
  107430. export class WebXRController {
  107431. private scene;
  107432. /** The underlying input source for the controller */
  107433. inputSource: XRInputSource;
  107434. private parentContainer;
  107435. /**
  107436. * 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
  107437. */
  107438. grip?: AbstractMesh;
  107439. /**
  107440. * Pointer which can be used to select objects or attach a visible laser to
  107441. */
  107442. pointer: AbstractMesh;
  107443. /**
  107444. * Event that fires when the controller is removed/disposed
  107445. */
  107446. onDisposeObservable: Observable<{}>;
  107447. private _tmpMatrix;
  107448. private _tmpQuaternion;
  107449. private _tmpVector;
  107450. /**
  107451. * Creates the controller
  107452. * @see https://doc.babylonjs.com/how_to/webxr
  107453. * @param scene the scene which the controller should be associated to
  107454. * @param inputSource the underlying input source for the controller
  107455. * @param parentContainer parent that the controller meshes should be children of
  107456. */
  107457. constructor(scene: Scene,
  107458. /** The underlying input source for the controller */
  107459. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  107460. /**
  107461. * Updates the controller pose based on the given XRFrame
  107462. * @param xrFrame xr frame to update the pose with
  107463. * @param referenceSpace reference space to use
  107464. */
  107465. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  107466. /**
  107467. * Gets a world space ray coming from the controller
  107468. * @param result the resulting ray
  107469. */
  107470. getWorldPointerRayToRef(result: Ray): void;
  107471. /**
  107472. * Disposes of the object
  107473. */
  107474. dispose(): void;
  107475. }
  107476. }
  107477. declare module BABYLON {
  107478. /**
  107479. * XR input used to track XR inputs such as controllers/rays
  107480. */
  107481. export class WebXRInput implements IDisposable {
  107482. /**
  107483. * Base experience the input listens to
  107484. */
  107485. baseExperience: WebXRExperienceHelper;
  107486. /**
  107487. * XR controllers being tracked
  107488. */
  107489. controllers: Array<WebXRController>;
  107490. private _frameObserver;
  107491. private _stateObserver;
  107492. /**
  107493. * Event when a controller has been connected/added
  107494. */
  107495. onControllerAddedObservable: Observable<WebXRController>;
  107496. /**
  107497. * Event when a controller has been removed/disconnected
  107498. */
  107499. onControllerRemovedObservable: Observable<WebXRController>;
  107500. /**
  107501. * Initializes the WebXRInput
  107502. * @param baseExperience experience helper which the input should be created for
  107503. */
  107504. constructor(
  107505. /**
  107506. * Base experience the input listens to
  107507. */
  107508. baseExperience: WebXRExperienceHelper);
  107509. private _onInputSourcesChange;
  107510. private _addAndRemoveControllers;
  107511. /**
  107512. * Disposes of the object
  107513. */
  107514. dispose(): void;
  107515. }
  107516. }
  107517. declare module BABYLON {
  107518. /**
  107519. * Enables teleportation
  107520. */
  107521. export class WebXRControllerTeleportation {
  107522. private _teleportationFillColor;
  107523. private _teleportationBorderColor;
  107524. private _tmpRay;
  107525. private _tmpVector;
  107526. /**
  107527. * Creates a WebXRControllerTeleportation
  107528. * @param input input manager to add teleportation to
  107529. * @param floorMeshes floormeshes which can be teleported to
  107530. */
  107531. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  107532. }
  107533. }
  107534. declare module BABYLON {
  107535. /**
  107536. * Handles pointer input automatically for the pointer of XR controllers
  107537. */
  107538. export class WebXRControllerPointerSelection {
  107539. private static _idCounter;
  107540. private _tmpRay;
  107541. /**
  107542. * Creates a WebXRControllerPointerSelection
  107543. * @param input input manager to setup pointer selection
  107544. */
  107545. constructor(input: WebXRInput);
  107546. private _convertNormalToDirectionOfRay;
  107547. private _updatePointerDistance;
  107548. }
  107549. }
  107550. declare module BABYLON {
  107551. /**
  107552. * Class used to represent data loading progression
  107553. */
  107554. export class SceneLoaderProgressEvent {
  107555. /** defines if data length to load can be evaluated */
  107556. readonly lengthComputable: boolean;
  107557. /** defines the loaded data length */
  107558. readonly loaded: number;
  107559. /** defines the data length to load */
  107560. readonly total: number;
  107561. /**
  107562. * Create a new progress event
  107563. * @param lengthComputable defines if data length to load can be evaluated
  107564. * @param loaded defines the loaded data length
  107565. * @param total defines the data length to load
  107566. */
  107567. constructor(
  107568. /** defines if data length to load can be evaluated */
  107569. lengthComputable: boolean,
  107570. /** defines the loaded data length */
  107571. loaded: number,
  107572. /** defines the data length to load */
  107573. total: number);
  107574. /**
  107575. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  107576. * @param event defines the source event
  107577. * @returns a new SceneLoaderProgressEvent
  107578. */
  107579. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  107580. }
  107581. /**
  107582. * Interface used by SceneLoader plugins to define supported file extensions
  107583. */
  107584. export interface ISceneLoaderPluginExtensions {
  107585. /**
  107586. * Defines the list of supported extensions
  107587. */
  107588. [extension: string]: {
  107589. isBinary: boolean;
  107590. };
  107591. }
  107592. /**
  107593. * Interface used by SceneLoader plugin factory
  107594. */
  107595. export interface ISceneLoaderPluginFactory {
  107596. /**
  107597. * Defines the name of the factory
  107598. */
  107599. name: string;
  107600. /**
  107601. * Function called to create a new plugin
  107602. * @return the new plugin
  107603. */
  107604. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  107605. /**
  107606. * Boolean indicating if the plugin can direct load specific data
  107607. */
  107608. canDirectLoad?: (data: string) => boolean;
  107609. }
  107610. /**
  107611. * Interface used to define a SceneLoader plugin
  107612. */
  107613. export interface ISceneLoaderPlugin {
  107614. /**
  107615. * The friendly name of this plugin.
  107616. */
  107617. name: string;
  107618. /**
  107619. * The file extensions supported by this plugin.
  107620. */
  107621. extensions: string | ISceneLoaderPluginExtensions;
  107622. /**
  107623. * Import meshes into a scene.
  107624. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107625. * @param scene The scene to import into
  107626. * @param data The data to import
  107627. * @param rootUrl The root url for scene and resources
  107628. * @param meshes The meshes array to import into
  107629. * @param particleSystems The particle systems array to import into
  107630. * @param skeletons The skeletons array to import into
  107631. * @param onError The callback when import fails
  107632. * @returns True if successful or false otherwise
  107633. */
  107634. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  107635. /**
  107636. * Load into a scene.
  107637. * @param scene The scene to load into
  107638. * @param data The data to import
  107639. * @param rootUrl The root url for scene and resources
  107640. * @param onError The callback when import fails
  107641. * @returns true if successful or false otherwise
  107642. */
  107643. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  107644. /**
  107645. * The callback that returns true if the data can be directly loaded.
  107646. */
  107647. canDirectLoad?: (data: string) => boolean;
  107648. /**
  107649. * The callback that allows custom handling of the root url based on the response url.
  107650. */
  107651. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107652. /**
  107653. * Load into an asset container.
  107654. * @param scene The scene to load into
  107655. * @param data The data to import
  107656. * @param rootUrl The root url for scene and resources
  107657. * @param onError The callback when import fails
  107658. * @returns The loaded asset container
  107659. */
  107660. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  107661. }
  107662. /**
  107663. * Interface used to define an async SceneLoader plugin
  107664. */
  107665. export interface ISceneLoaderPluginAsync {
  107666. /**
  107667. * The friendly name of this plugin.
  107668. */
  107669. name: string;
  107670. /**
  107671. * The file extensions supported by this plugin.
  107672. */
  107673. extensions: string | ISceneLoaderPluginExtensions;
  107674. /**
  107675. * Import meshes into a scene.
  107676. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107677. * @param scene The scene to import into
  107678. * @param data The data to import
  107679. * @param rootUrl The root url for scene and resources
  107680. * @param onProgress The callback when the load progresses
  107681. * @param fileName Defines the name of the file to load
  107682. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  107683. */
  107684. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  107685. meshes: AbstractMesh[];
  107686. particleSystems: IParticleSystem[];
  107687. skeletons: Skeleton[];
  107688. animationGroups: AnimationGroup[];
  107689. }>;
  107690. /**
  107691. * Load into a scene.
  107692. * @param scene The scene to load into
  107693. * @param data The data to import
  107694. * @param rootUrl The root url for scene and resources
  107695. * @param onProgress The callback when the load progresses
  107696. * @param fileName Defines the name of the file to load
  107697. * @returns Nothing
  107698. */
  107699. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  107700. /**
  107701. * The callback that returns true if the data can be directly loaded.
  107702. */
  107703. canDirectLoad?: (data: string) => boolean;
  107704. /**
  107705. * The callback that allows custom handling of the root url based on the response url.
  107706. */
  107707. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  107708. /**
  107709. * Load into an asset container.
  107710. * @param scene The scene to load into
  107711. * @param data The data to import
  107712. * @param rootUrl The root url for scene and resources
  107713. * @param onProgress The callback when the load progresses
  107714. * @param fileName Defines the name of the file to load
  107715. * @returns The loaded asset container
  107716. */
  107717. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  107718. }
  107719. /**
  107720. * Class used to load scene from various file formats using registered plugins
  107721. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  107722. */
  107723. export class SceneLoader {
  107724. /**
  107725. * No logging while loading
  107726. */
  107727. static readonly NO_LOGGING: number;
  107728. /**
  107729. * Minimal logging while loading
  107730. */
  107731. static readonly MINIMAL_LOGGING: number;
  107732. /**
  107733. * Summary logging while loading
  107734. */
  107735. static readonly SUMMARY_LOGGING: number;
  107736. /**
  107737. * Detailled logging while loading
  107738. */
  107739. static readonly DETAILED_LOGGING: number;
  107740. /**
  107741. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  107742. */
  107743. static ForceFullSceneLoadingForIncremental: boolean;
  107744. /**
  107745. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  107746. */
  107747. static ShowLoadingScreen: boolean;
  107748. /**
  107749. * Defines the current logging level (while loading the scene)
  107750. * @ignorenaming
  107751. */
  107752. static loggingLevel: number;
  107753. /**
  107754. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  107755. */
  107756. static CleanBoneMatrixWeights: boolean;
  107757. /**
  107758. * Event raised when a plugin is used to load a scene
  107759. */
  107760. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  107761. private static _registeredPlugins;
  107762. private static _getDefaultPlugin;
  107763. private static _getPluginForExtension;
  107764. private static _getPluginForDirectLoad;
  107765. private static _getPluginForFilename;
  107766. private static _getDirectLoad;
  107767. private static _loadData;
  107768. private static _getFileInfo;
  107769. /**
  107770. * Gets a plugin that can load the given extension
  107771. * @param extension defines the extension to load
  107772. * @returns a plugin or null if none works
  107773. */
  107774. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  107775. /**
  107776. * Gets a boolean indicating that the given extension can be loaded
  107777. * @param extension defines the extension to load
  107778. * @returns true if the extension is supported
  107779. */
  107780. static IsPluginForExtensionAvailable(extension: string): boolean;
  107781. /**
  107782. * Adds a new plugin to the list of registered plugins
  107783. * @param plugin defines the plugin to add
  107784. */
  107785. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  107786. /**
  107787. * Import meshes into a scene
  107788. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107789. * @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)
  107790. * @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)
  107791. * @param scene the instance of BABYLON.Scene to append to
  107792. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  107793. * @param onProgress a callback with a progress event for each file being loaded
  107794. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107795. * @param pluginExtension the extension used to determine the plugin
  107796. * @returns The loaded plugin
  107797. */
  107798. 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>;
  107799. /**
  107800. * Import meshes into a scene
  107801. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  107802. * @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)
  107803. * @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)
  107804. * @param scene the instance of BABYLON.Scene to append to
  107805. * @param onProgress a callback with a progress event for each file being loaded
  107806. * @param pluginExtension the extension used to determine the plugin
  107807. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  107808. */
  107809. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  107810. meshes: AbstractMesh[];
  107811. particleSystems: IParticleSystem[];
  107812. skeletons: Skeleton[];
  107813. animationGroups: AnimationGroup[];
  107814. }>;
  107815. /**
  107816. * Load a scene
  107817. * @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)
  107818. * @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)
  107819. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107820. * @param onSuccess a callback with the scene when import succeeds
  107821. * @param onProgress a callback with a progress event for each file being loaded
  107822. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107823. * @param pluginExtension the extension used to determine the plugin
  107824. * @returns The loaded plugin
  107825. */
  107826. 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>;
  107827. /**
  107828. * Load a scene
  107829. * @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)
  107830. * @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)
  107831. * @param engine is the instance of BABYLON.Engine to use to create the scene
  107832. * @param onProgress a callback with a progress event for each file being loaded
  107833. * @param pluginExtension the extension used to determine the plugin
  107834. * @returns The loaded scene
  107835. */
  107836. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107837. /**
  107838. * Append a scene
  107839. * @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)
  107840. * @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)
  107841. * @param scene is the instance of BABYLON.Scene to append to
  107842. * @param onSuccess a callback with the scene when import succeeds
  107843. * @param onProgress a callback with a progress event for each file being loaded
  107844. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107845. * @param pluginExtension the extension used to determine the plugin
  107846. * @returns The loaded plugin
  107847. */
  107848. 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>;
  107849. /**
  107850. * Append a scene
  107851. * @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)
  107852. * @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)
  107853. * @param scene is the instance of BABYLON.Scene to append to
  107854. * @param onProgress a callback with a progress event for each file being loaded
  107855. * @param pluginExtension the extension used to determine the plugin
  107856. * @returns The given scene
  107857. */
  107858. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  107859. /**
  107860. * Load a scene into an asset container
  107861. * @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)
  107862. * @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)
  107863. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  107864. * @param onSuccess a callback with the scene when import succeeds
  107865. * @param onProgress a callback with a progress event for each file being loaded
  107866. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  107867. * @param pluginExtension the extension used to determine the plugin
  107868. * @returns The loaded plugin
  107869. */
  107870. 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>;
  107871. /**
  107872. * Load a scene into an asset container
  107873. * @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)
  107874. * @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)
  107875. * @param scene is the instance of Scene to append to
  107876. * @param onProgress a callback with a progress event for each file being loaded
  107877. * @param pluginExtension the extension used to determine the plugin
  107878. * @returns The loaded asset container
  107879. */
  107880. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  107881. }
  107882. }
  107883. declare module BABYLON {
  107884. /**
  107885. * Generic Controller
  107886. */
  107887. export class GenericController extends WebVRController {
  107888. /**
  107889. * Base Url for the controller model.
  107890. */
  107891. static readonly MODEL_BASE_URL: string;
  107892. /**
  107893. * File name for the controller model.
  107894. */
  107895. static readonly MODEL_FILENAME: string;
  107896. /**
  107897. * Creates a new GenericController from a gamepad
  107898. * @param vrGamepad the gamepad that the controller should be created from
  107899. */
  107900. constructor(vrGamepad: any);
  107901. /**
  107902. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107903. * @param scene scene in which to add meshes
  107904. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107905. */
  107906. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107907. /**
  107908. * Called once for each button that changed state since the last frame
  107909. * @param buttonIdx Which button index changed
  107910. * @param state New state of the button
  107911. * @param changes Which properties on the state changed since last frame
  107912. */
  107913. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107914. }
  107915. }
  107916. declare module BABYLON {
  107917. /**
  107918. * Defines the WindowsMotionController object that the state of the windows motion controller
  107919. */
  107920. export class WindowsMotionController extends WebVRController {
  107921. /**
  107922. * The base url used to load the left and right controller models
  107923. */
  107924. static MODEL_BASE_URL: string;
  107925. /**
  107926. * The name of the left controller model file
  107927. */
  107928. static MODEL_LEFT_FILENAME: string;
  107929. /**
  107930. * The name of the right controller model file
  107931. */
  107932. static MODEL_RIGHT_FILENAME: string;
  107933. /**
  107934. * The controller name prefix for this controller type
  107935. */
  107936. static readonly GAMEPAD_ID_PREFIX: string;
  107937. /**
  107938. * The controller id pattern for this controller type
  107939. */
  107940. private static readonly GAMEPAD_ID_PATTERN;
  107941. private _loadedMeshInfo;
  107942. private readonly _mapping;
  107943. /**
  107944. * Fired when the trackpad on this controller is clicked
  107945. */
  107946. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  107947. /**
  107948. * Fired when the trackpad on this controller is modified
  107949. */
  107950. onTrackpadValuesChangedObservable: Observable<StickValues>;
  107951. /**
  107952. * The current x and y values of this controller's trackpad
  107953. */
  107954. trackpad: StickValues;
  107955. /**
  107956. * Creates a new WindowsMotionController from a gamepad
  107957. * @param vrGamepad the gamepad that the controller should be created from
  107958. */
  107959. constructor(vrGamepad: any);
  107960. /**
  107961. * Fired when the trigger on this controller is modified
  107962. */
  107963. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107964. /**
  107965. * Fired when the menu button on this controller is modified
  107966. */
  107967. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107968. /**
  107969. * Fired when the grip button on this controller is modified
  107970. */
  107971. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107972. /**
  107973. * Fired when the thumbstick button on this controller is modified
  107974. */
  107975. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107976. /**
  107977. * Fired when the touchpad button on this controller is modified
  107978. */
  107979. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  107980. /**
  107981. * Fired when the touchpad values on this controller are modified
  107982. */
  107983. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  107984. private _updateTrackpad;
  107985. /**
  107986. * Called once per frame by the engine.
  107987. */
  107988. update(): void;
  107989. /**
  107990. * Called once for each button that changed state since the last frame
  107991. * @param buttonIdx Which button index changed
  107992. * @param state New state of the button
  107993. * @param changes Which properties on the state changed since last frame
  107994. */
  107995. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107996. /**
  107997. * Moves the buttons on the controller mesh based on their current state
  107998. * @param buttonName the name of the button to move
  107999. * @param buttonValue the value of the button which determines the buttons new position
  108000. */
  108001. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  108002. /**
  108003. * Moves the axis on the controller mesh based on its current state
  108004. * @param axis the index of the axis
  108005. * @param axisValue the value of the axis which determines the meshes new position
  108006. * @hidden
  108007. */
  108008. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  108009. /**
  108010. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108011. * @param scene scene in which to add meshes
  108012. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108013. */
  108014. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  108015. /**
  108016. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  108017. * can be transformed by button presses and axes values, based on this._mapping.
  108018. *
  108019. * @param scene scene in which the meshes exist
  108020. * @param meshes list of meshes that make up the controller model to process
  108021. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  108022. */
  108023. private processModel;
  108024. private createMeshInfo;
  108025. /**
  108026. * Gets the ray of the controller in the direction the controller is pointing
  108027. * @param length the length the resulting ray should be
  108028. * @returns a ray in the direction the controller is pointing
  108029. */
  108030. getForwardRay(length?: number): Ray;
  108031. /**
  108032. * Disposes of the controller
  108033. */
  108034. dispose(): void;
  108035. }
  108036. }
  108037. declare module BABYLON {
  108038. /**
  108039. * Oculus Touch Controller
  108040. */
  108041. export class OculusTouchController extends WebVRController {
  108042. /**
  108043. * Base Url for the controller model.
  108044. */
  108045. static MODEL_BASE_URL: string;
  108046. /**
  108047. * File name for the left controller model.
  108048. */
  108049. static MODEL_LEFT_FILENAME: string;
  108050. /**
  108051. * File name for the right controller model.
  108052. */
  108053. static MODEL_RIGHT_FILENAME: string;
  108054. /**
  108055. * Base Url for the Quest controller model.
  108056. */
  108057. static QUEST_MODEL_BASE_URL: string;
  108058. /**
  108059. * @hidden
  108060. * If the controllers are running on a device that needs the updated Quest controller models
  108061. */
  108062. static _IsQuest: boolean;
  108063. /**
  108064. * Fired when the secondary trigger on this controller is modified
  108065. */
  108066. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  108067. /**
  108068. * Fired when the thumb rest on this controller is modified
  108069. */
  108070. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  108071. /**
  108072. * Creates a new OculusTouchController from a gamepad
  108073. * @param vrGamepad the gamepad that the controller should be created from
  108074. */
  108075. constructor(vrGamepad: any);
  108076. /**
  108077. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108078. * @param scene scene in which to add meshes
  108079. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108080. */
  108081. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108082. /**
  108083. * Fired when the A button on this controller is modified
  108084. */
  108085. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108086. /**
  108087. * Fired when the B button on this controller is modified
  108088. */
  108089. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108090. /**
  108091. * Fired when the X button on this controller is modified
  108092. */
  108093. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108094. /**
  108095. * Fired when the Y button on this controller is modified
  108096. */
  108097. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108098. /**
  108099. * Called once for each button that changed state since the last frame
  108100. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  108101. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  108102. * 2) secondary trigger (same)
  108103. * 3) A (right) X (left), touch, pressed = value
  108104. * 4) B / Y
  108105. * 5) thumb rest
  108106. * @param buttonIdx Which button index changed
  108107. * @param state New state of the button
  108108. * @param changes Which properties on the state changed since last frame
  108109. */
  108110. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108111. }
  108112. }
  108113. declare module BABYLON {
  108114. /**
  108115. * Vive Controller
  108116. */
  108117. export class ViveController extends WebVRController {
  108118. /**
  108119. * Base Url for the controller model.
  108120. */
  108121. static MODEL_BASE_URL: string;
  108122. /**
  108123. * File name for the controller model.
  108124. */
  108125. static MODEL_FILENAME: string;
  108126. /**
  108127. * Creates a new ViveController from a gamepad
  108128. * @param vrGamepad the gamepad that the controller should be created from
  108129. */
  108130. constructor(vrGamepad: any);
  108131. /**
  108132. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108133. * @param scene scene in which to add meshes
  108134. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108135. */
  108136. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108137. /**
  108138. * Fired when the left button on this controller is modified
  108139. */
  108140. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108141. /**
  108142. * Fired when the right button on this controller is modified
  108143. */
  108144. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108145. /**
  108146. * Fired when the menu button on this controller is modified
  108147. */
  108148. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108149. /**
  108150. * Called once for each button that changed state since the last frame
  108151. * Vive mapping:
  108152. * 0: touchpad
  108153. * 1: trigger
  108154. * 2: left AND right buttons
  108155. * 3: menu button
  108156. * @param buttonIdx Which button index changed
  108157. * @param state New state of the button
  108158. * @param changes Which properties on the state changed since last frame
  108159. */
  108160. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108161. }
  108162. }
  108163. declare module BABYLON {
  108164. /**
  108165. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  108166. */
  108167. export class WebXRControllerModelLoader {
  108168. /**
  108169. * Creates the WebXRControllerModelLoader
  108170. * @param input xr input that creates the controllers
  108171. */
  108172. constructor(input: WebXRInput);
  108173. }
  108174. }
  108175. declare module BABYLON {
  108176. /**
  108177. * Contains an array of blocks representing the octree
  108178. */
  108179. export interface IOctreeContainer<T> {
  108180. /**
  108181. * Blocks within the octree
  108182. */
  108183. blocks: Array<OctreeBlock<T>>;
  108184. }
  108185. /**
  108186. * Class used to store a cell in an octree
  108187. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108188. */
  108189. export class OctreeBlock<T> {
  108190. /**
  108191. * Gets the content of the current block
  108192. */
  108193. entries: T[];
  108194. /**
  108195. * Gets the list of block children
  108196. */
  108197. blocks: Array<OctreeBlock<T>>;
  108198. private _depth;
  108199. private _maxDepth;
  108200. private _capacity;
  108201. private _minPoint;
  108202. private _maxPoint;
  108203. private _boundingVectors;
  108204. private _creationFunc;
  108205. /**
  108206. * Creates a new block
  108207. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  108208. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  108209. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108210. * @param depth defines the current depth of this block in the octree
  108211. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  108212. * @param creationFunc defines a callback to call when an element is added to the block
  108213. */
  108214. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  108215. /**
  108216. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  108217. */
  108218. readonly capacity: number;
  108219. /**
  108220. * Gets the minimum vector (in world space) of the block's bounding box
  108221. */
  108222. readonly minPoint: Vector3;
  108223. /**
  108224. * Gets the maximum vector (in world space) of the block's bounding box
  108225. */
  108226. readonly maxPoint: Vector3;
  108227. /**
  108228. * Add a new element to this block
  108229. * @param entry defines the element to add
  108230. */
  108231. addEntry(entry: T): void;
  108232. /**
  108233. * Remove an element from this block
  108234. * @param entry defines the element to remove
  108235. */
  108236. removeEntry(entry: T): void;
  108237. /**
  108238. * Add an array of elements to this block
  108239. * @param entries defines the array of elements to add
  108240. */
  108241. addEntries(entries: T[]): void;
  108242. /**
  108243. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  108244. * @param frustumPlanes defines the frustum planes to test
  108245. * @param selection defines the array to store current content if selection is positive
  108246. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108247. */
  108248. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108249. /**
  108250. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  108251. * @param sphereCenter defines the bounding sphere center
  108252. * @param sphereRadius defines the bounding sphere radius
  108253. * @param selection defines the array to store current content if selection is positive
  108254. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108255. */
  108256. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  108257. /**
  108258. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  108259. * @param ray defines the ray to test with
  108260. * @param selection defines the array to store current content if selection is positive
  108261. */
  108262. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  108263. /**
  108264. * Subdivide the content into child blocks (this block will then be empty)
  108265. */
  108266. createInnerBlocks(): void;
  108267. /**
  108268. * @hidden
  108269. */
  108270. 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;
  108271. }
  108272. }
  108273. declare module BABYLON {
  108274. /**
  108275. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  108276. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108277. */
  108278. export class Octree<T> {
  108279. /** 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.) */
  108280. maxDepth: number;
  108281. /**
  108282. * Blocks within the octree containing objects
  108283. */
  108284. blocks: Array<OctreeBlock<T>>;
  108285. /**
  108286. * Content stored in the octree
  108287. */
  108288. dynamicContent: T[];
  108289. private _maxBlockCapacity;
  108290. private _selectionContent;
  108291. private _creationFunc;
  108292. /**
  108293. * Creates a octree
  108294. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108295. * @param creationFunc function to be used to instatiate the octree
  108296. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  108297. * @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.)
  108298. */
  108299. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  108300. /** 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.) */
  108301. maxDepth?: number);
  108302. /**
  108303. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  108304. * @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);
  108305. * @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);
  108306. * @param entries meshes to be added to the octree blocks
  108307. */
  108308. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  108309. /**
  108310. * Adds a mesh to the octree
  108311. * @param entry Mesh to add to the octree
  108312. */
  108313. addMesh(entry: T): void;
  108314. /**
  108315. * Remove an element from the octree
  108316. * @param entry defines the element to remove
  108317. */
  108318. removeMesh(entry: T): void;
  108319. /**
  108320. * Selects an array of meshes within the frustum
  108321. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  108322. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  108323. * @returns array of meshes within the frustum
  108324. */
  108325. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  108326. /**
  108327. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  108328. * @param sphereCenter defines the bounding sphere center
  108329. * @param sphereRadius defines the bounding sphere radius
  108330. * @param allowDuplicate defines if the selection array can contains duplicated entries
  108331. * @returns an array of objects that intersect the sphere
  108332. */
  108333. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  108334. /**
  108335. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  108336. * @param ray defines the ray to test with
  108337. * @returns array of intersected objects
  108338. */
  108339. intersectsRay(ray: Ray): SmartArray<T>;
  108340. /**
  108341. * Adds a mesh into the octree block if it intersects the block
  108342. */
  108343. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  108344. /**
  108345. * Adds a submesh into the octree block if it intersects the block
  108346. */
  108347. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  108348. }
  108349. }
  108350. declare module BABYLON {
  108351. interface Scene {
  108352. /**
  108353. * @hidden
  108354. * Backing Filed
  108355. */
  108356. _selectionOctree: Octree<AbstractMesh>;
  108357. /**
  108358. * Gets the octree used to boost mesh selection (picking)
  108359. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108360. */
  108361. selectionOctree: Octree<AbstractMesh>;
  108362. /**
  108363. * Creates or updates the octree used to boost selection (picking)
  108364. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108365. * @param maxCapacity defines the maximum capacity per leaf
  108366. * @param maxDepth defines the maximum depth of the octree
  108367. * @returns an octree of AbstractMesh
  108368. */
  108369. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  108370. }
  108371. interface AbstractMesh {
  108372. /**
  108373. * @hidden
  108374. * Backing Field
  108375. */
  108376. _submeshesOctree: Octree<SubMesh>;
  108377. /**
  108378. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  108379. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  108380. * @param maxCapacity defines the maximum size of each block (64 by default)
  108381. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  108382. * @returns the new octree
  108383. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  108384. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  108385. */
  108386. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  108387. }
  108388. /**
  108389. * Defines the octree scene component responsible to manage any octrees
  108390. * in a given scene.
  108391. */
  108392. export class OctreeSceneComponent {
  108393. /**
  108394. * The component name help to identify the component in the list of scene components.
  108395. */
  108396. readonly name: string;
  108397. /**
  108398. * The scene the component belongs to.
  108399. */
  108400. scene: Scene;
  108401. /**
  108402. * Indicates if the meshes have been checked to make sure they are isEnabled()
  108403. */
  108404. readonly checksIsEnabled: boolean;
  108405. /**
  108406. * Creates a new instance of the component for the given scene
  108407. * @param scene Defines the scene to register the component in
  108408. */
  108409. constructor(scene: Scene);
  108410. /**
  108411. * Registers the component in a given scene
  108412. */
  108413. register(): void;
  108414. /**
  108415. * Return the list of active meshes
  108416. * @returns the list of active meshes
  108417. */
  108418. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  108419. /**
  108420. * Return the list of active sub meshes
  108421. * @param mesh The mesh to get the candidates sub meshes from
  108422. * @returns the list of active sub meshes
  108423. */
  108424. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  108425. private _tempRay;
  108426. /**
  108427. * Return the list of sub meshes intersecting with a given local ray
  108428. * @param mesh defines the mesh to find the submesh for
  108429. * @param localRay defines the ray in local space
  108430. * @returns the list of intersecting sub meshes
  108431. */
  108432. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  108433. /**
  108434. * Return the list of sub meshes colliding with a collider
  108435. * @param mesh defines the mesh to find the submesh for
  108436. * @param collider defines the collider to evaluate the collision against
  108437. * @returns the list of colliding sub meshes
  108438. */
  108439. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  108440. /**
  108441. * Rebuilds the elements related to this component in case of
  108442. * context lost for instance.
  108443. */
  108444. rebuild(): void;
  108445. /**
  108446. * Disposes the component and the associated ressources.
  108447. */
  108448. dispose(): void;
  108449. }
  108450. }
  108451. declare module BABYLON {
  108452. /**
  108453. * Renders a layer on top of an existing scene
  108454. */
  108455. export class UtilityLayerRenderer implements IDisposable {
  108456. /** the original scene that will be rendered on top of */
  108457. originalScene: Scene;
  108458. private _pointerCaptures;
  108459. private _lastPointerEvents;
  108460. private static _DefaultUtilityLayer;
  108461. private static _DefaultKeepDepthUtilityLayer;
  108462. private _sharedGizmoLight;
  108463. private _renderCamera;
  108464. /**
  108465. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  108466. * @returns the camera that is used when rendering the utility layer
  108467. */
  108468. getRenderCamera(): Nullable<Camera>;
  108469. /**
  108470. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  108471. * @param cam the camera that should be used when rendering the utility layer
  108472. */
  108473. setRenderCamera(cam: Nullable<Camera>): void;
  108474. /**
  108475. * @hidden
  108476. * Light which used by gizmos to get light shading
  108477. */
  108478. _getSharedGizmoLight(): HemisphericLight;
  108479. /**
  108480. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  108481. */
  108482. pickUtilitySceneFirst: boolean;
  108483. /**
  108484. * 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)
  108485. */
  108486. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  108487. /**
  108488. * 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)
  108489. */
  108490. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  108491. /**
  108492. * The scene that is rendered on top of the original scene
  108493. */
  108494. utilityLayerScene: Scene;
  108495. /**
  108496. * If the utility layer should automatically be rendered on top of existing scene
  108497. */
  108498. shouldRender: boolean;
  108499. /**
  108500. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  108501. */
  108502. onlyCheckPointerDownEvents: boolean;
  108503. /**
  108504. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  108505. */
  108506. processAllEvents: boolean;
  108507. /**
  108508. * Observable raised when the pointer move from the utility layer scene to the main scene
  108509. */
  108510. onPointerOutObservable: Observable<number>;
  108511. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  108512. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  108513. private _afterRenderObserver;
  108514. private _sceneDisposeObserver;
  108515. private _originalPointerObserver;
  108516. /**
  108517. * Instantiates a UtilityLayerRenderer
  108518. * @param originalScene the original scene that will be rendered on top of
  108519. * @param handleEvents boolean indicating if the utility layer should handle events
  108520. */
  108521. constructor(
  108522. /** the original scene that will be rendered on top of */
  108523. originalScene: Scene, handleEvents?: boolean);
  108524. private _notifyObservers;
  108525. /**
  108526. * Renders the utility layers scene on top of the original scene
  108527. */
  108528. render(): void;
  108529. /**
  108530. * Disposes of the renderer
  108531. */
  108532. dispose(): void;
  108533. private _updateCamera;
  108534. }
  108535. }
  108536. declare module BABYLON {
  108537. /**
  108538. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  108539. */
  108540. export class Gizmo implements IDisposable {
  108541. /** The utility layer the gizmo will be added to */
  108542. gizmoLayer: UtilityLayerRenderer;
  108543. /**
  108544. * The root mesh of the gizmo
  108545. */
  108546. _rootMesh: Mesh;
  108547. private _attachedMesh;
  108548. /**
  108549. * Ratio for the scale of the gizmo (Default: 1)
  108550. */
  108551. scaleRatio: number;
  108552. /**
  108553. * If a custom mesh has been set (Default: false)
  108554. */
  108555. protected _customMeshSet: boolean;
  108556. /**
  108557. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  108558. * * When set, interactions will be enabled
  108559. */
  108560. attachedMesh: Nullable<AbstractMesh>;
  108561. /**
  108562. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  108563. * @param mesh The mesh to replace the default mesh of the gizmo
  108564. */
  108565. setCustomMesh(mesh: Mesh): void;
  108566. /**
  108567. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  108568. */
  108569. updateGizmoRotationToMatchAttachedMesh: boolean;
  108570. /**
  108571. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  108572. */
  108573. updateGizmoPositionToMatchAttachedMesh: boolean;
  108574. /**
  108575. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  108576. */
  108577. updateScale: boolean;
  108578. protected _interactionsEnabled: boolean;
  108579. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108580. private _beforeRenderObserver;
  108581. private _tempVector;
  108582. /**
  108583. * Creates a gizmo
  108584. * @param gizmoLayer The utility layer the gizmo will be added to
  108585. */
  108586. constructor(
  108587. /** The utility layer the gizmo will be added to */
  108588. gizmoLayer?: UtilityLayerRenderer);
  108589. /**
  108590. * Updates the gizmo to match the attached mesh's position/rotation
  108591. */
  108592. protected _update(): void;
  108593. /**
  108594. * Disposes of the gizmo
  108595. */
  108596. dispose(): void;
  108597. }
  108598. }
  108599. declare module BABYLON {
  108600. /**
  108601. * Single plane drag gizmo
  108602. */
  108603. export class PlaneDragGizmo extends Gizmo {
  108604. /**
  108605. * Drag behavior responsible for the gizmos dragging interactions
  108606. */
  108607. dragBehavior: PointerDragBehavior;
  108608. private _pointerObserver;
  108609. /**
  108610. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108611. */
  108612. snapDistance: number;
  108613. /**
  108614. * Event that fires each time the gizmo snaps to a new location.
  108615. * * snapDistance is the the change in distance
  108616. */
  108617. onSnapObservable: Observable<{
  108618. snapDistance: number;
  108619. }>;
  108620. private _plane;
  108621. private _coloredMaterial;
  108622. private _hoverMaterial;
  108623. private _isEnabled;
  108624. private _parent;
  108625. /** @hidden */
  108626. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  108627. /** @hidden */
  108628. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108629. /**
  108630. * Creates a PlaneDragGizmo
  108631. * @param gizmoLayer The utility layer the gizmo will be added to
  108632. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  108633. * @param color The color of the gizmo
  108634. */
  108635. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108636. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108637. /**
  108638. * If the gizmo is enabled
  108639. */
  108640. isEnabled: boolean;
  108641. /**
  108642. * Disposes of the gizmo
  108643. */
  108644. dispose(): void;
  108645. }
  108646. }
  108647. declare module BABYLON {
  108648. /**
  108649. * Gizmo that enables dragging a mesh along 3 axis
  108650. */
  108651. export class PositionGizmo extends Gizmo {
  108652. /**
  108653. * Internal gizmo used for interactions on the x axis
  108654. */
  108655. xGizmo: AxisDragGizmo;
  108656. /**
  108657. * Internal gizmo used for interactions on the y axis
  108658. */
  108659. yGizmo: AxisDragGizmo;
  108660. /**
  108661. * Internal gizmo used for interactions on the z axis
  108662. */
  108663. zGizmo: AxisDragGizmo;
  108664. /**
  108665. * Internal gizmo used for interactions on the yz plane
  108666. */
  108667. xPlaneGizmo: PlaneDragGizmo;
  108668. /**
  108669. * Internal gizmo used for interactions on the xz plane
  108670. */
  108671. yPlaneGizmo: PlaneDragGizmo;
  108672. /**
  108673. * Internal gizmo used for interactions on the xy plane
  108674. */
  108675. zPlaneGizmo: PlaneDragGizmo;
  108676. /**
  108677. * private variables
  108678. */
  108679. private _meshAttached;
  108680. private _updateGizmoRotationToMatchAttachedMesh;
  108681. private _snapDistance;
  108682. private _scaleRatio;
  108683. /** Fires an event when any of it's sub gizmos are dragged */
  108684. onDragStartObservable: Observable<unknown>;
  108685. /** Fires an event when any of it's sub gizmos are released from dragging */
  108686. onDragEndObservable: Observable<unknown>;
  108687. /**
  108688. * If set to true, planar drag is enabled
  108689. */
  108690. private _planarGizmoEnabled;
  108691. attachedMesh: Nullable<AbstractMesh>;
  108692. /**
  108693. * Creates a PositionGizmo
  108694. * @param gizmoLayer The utility layer the gizmo will be added to
  108695. */
  108696. constructor(gizmoLayer?: UtilityLayerRenderer);
  108697. /**
  108698. * If the planar drag gizmo is enabled
  108699. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  108700. */
  108701. planarGizmoEnabled: boolean;
  108702. updateGizmoRotationToMatchAttachedMesh: boolean;
  108703. /**
  108704. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108705. */
  108706. snapDistance: number;
  108707. /**
  108708. * Ratio for the scale of the gizmo (Default: 1)
  108709. */
  108710. scaleRatio: number;
  108711. /**
  108712. * Disposes of the gizmo
  108713. */
  108714. dispose(): void;
  108715. /**
  108716. * CustomMeshes are not supported by this gizmo
  108717. * @param mesh The mesh to replace the default mesh of the gizmo
  108718. */
  108719. setCustomMesh(mesh: Mesh): void;
  108720. }
  108721. }
  108722. declare module BABYLON {
  108723. /**
  108724. * Single axis drag gizmo
  108725. */
  108726. export class AxisDragGizmo extends Gizmo {
  108727. /**
  108728. * Drag behavior responsible for the gizmos dragging interactions
  108729. */
  108730. dragBehavior: PointerDragBehavior;
  108731. private _pointerObserver;
  108732. /**
  108733. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  108734. */
  108735. snapDistance: number;
  108736. /**
  108737. * Event that fires each time the gizmo snaps to a new location.
  108738. * * snapDistance is the the change in distance
  108739. */
  108740. onSnapObservable: Observable<{
  108741. snapDistance: number;
  108742. }>;
  108743. private _isEnabled;
  108744. private _parent;
  108745. private _arrow;
  108746. private _coloredMaterial;
  108747. private _hoverMaterial;
  108748. /** @hidden */
  108749. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  108750. /** @hidden */
  108751. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  108752. /**
  108753. * Creates an AxisDragGizmo
  108754. * @param gizmoLayer The utility layer the gizmo will be added to
  108755. * @param dragAxis The axis which the gizmo will be able to drag on
  108756. * @param color The color of the gizmo
  108757. */
  108758. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  108759. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  108760. /**
  108761. * If the gizmo is enabled
  108762. */
  108763. isEnabled: boolean;
  108764. /**
  108765. * Disposes of the gizmo
  108766. */
  108767. dispose(): void;
  108768. }
  108769. }
  108770. declare module BABYLON.Debug {
  108771. /**
  108772. * The Axes viewer will show 3 axes in a specific point in space
  108773. */
  108774. export class AxesViewer {
  108775. private _xAxis;
  108776. private _yAxis;
  108777. private _zAxis;
  108778. private _scaleLinesFactor;
  108779. private _instanced;
  108780. /**
  108781. * Gets the hosting scene
  108782. */
  108783. scene: Scene;
  108784. /**
  108785. * Gets or sets a number used to scale line length
  108786. */
  108787. scaleLines: number;
  108788. /** Gets the node hierarchy used to render x-axis */
  108789. readonly xAxis: TransformNode;
  108790. /** Gets the node hierarchy used to render y-axis */
  108791. readonly yAxis: TransformNode;
  108792. /** Gets the node hierarchy used to render z-axis */
  108793. readonly zAxis: TransformNode;
  108794. /**
  108795. * Creates a new AxesViewer
  108796. * @param scene defines the hosting scene
  108797. * @param scaleLines defines a number used to scale line length (1 by default)
  108798. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  108799. * @param xAxis defines the node hierarchy used to render the x-axis
  108800. * @param yAxis defines the node hierarchy used to render the y-axis
  108801. * @param zAxis defines the node hierarchy used to render the z-axis
  108802. */
  108803. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  108804. /**
  108805. * Force the viewer to update
  108806. * @param position defines the position of the viewer
  108807. * @param xaxis defines the x axis of the viewer
  108808. * @param yaxis defines the y axis of the viewer
  108809. * @param zaxis defines the z axis of the viewer
  108810. */
  108811. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  108812. /**
  108813. * Creates an instance of this axes viewer.
  108814. * @returns a new axes viewer with instanced meshes
  108815. */
  108816. createInstance(): AxesViewer;
  108817. /** Releases resources */
  108818. dispose(): void;
  108819. private static _SetRenderingGroupId;
  108820. }
  108821. }
  108822. declare module BABYLON.Debug {
  108823. /**
  108824. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  108825. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  108826. */
  108827. export class BoneAxesViewer extends AxesViewer {
  108828. /**
  108829. * Gets or sets the target mesh where to display the axes viewer
  108830. */
  108831. mesh: Nullable<Mesh>;
  108832. /**
  108833. * Gets or sets the target bone where to display the axes viewer
  108834. */
  108835. bone: Nullable<Bone>;
  108836. /** Gets current position */
  108837. pos: Vector3;
  108838. /** Gets direction of X axis */
  108839. xaxis: Vector3;
  108840. /** Gets direction of Y axis */
  108841. yaxis: Vector3;
  108842. /** Gets direction of Z axis */
  108843. zaxis: Vector3;
  108844. /**
  108845. * Creates a new BoneAxesViewer
  108846. * @param scene defines the hosting scene
  108847. * @param bone defines the target bone
  108848. * @param mesh defines the target mesh
  108849. * @param scaleLines defines a scaling factor for line length (1 by default)
  108850. */
  108851. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  108852. /**
  108853. * Force the viewer to update
  108854. */
  108855. update(): void;
  108856. /** Releases resources */
  108857. dispose(): void;
  108858. }
  108859. }
  108860. declare module BABYLON {
  108861. /**
  108862. * Interface used to define scene explorer extensibility option
  108863. */
  108864. export interface IExplorerExtensibilityOption {
  108865. /**
  108866. * Define the option label
  108867. */
  108868. label: string;
  108869. /**
  108870. * Defines the action to execute on click
  108871. */
  108872. action: (entity: any) => void;
  108873. }
  108874. /**
  108875. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  108876. */
  108877. export interface IExplorerExtensibilityGroup {
  108878. /**
  108879. * Defines a predicate to test if a given type mut be extended
  108880. */
  108881. predicate: (entity: any) => boolean;
  108882. /**
  108883. * Gets the list of options added to a type
  108884. */
  108885. entries: IExplorerExtensibilityOption[];
  108886. }
  108887. /**
  108888. * Interface used to define the options to use to create the Inspector
  108889. */
  108890. export interface IInspectorOptions {
  108891. /**
  108892. * Display in overlay mode (default: false)
  108893. */
  108894. overlay?: boolean;
  108895. /**
  108896. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  108897. */
  108898. globalRoot?: HTMLElement;
  108899. /**
  108900. * Display the Scene explorer
  108901. */
  108902. showExplorer?: boolean;
  108903. /**
  108904. * Display the property inspector
  108905. */
  108906. showInspector?: boolean;
  108907. /**
  108908. * Display in embed mode (both panes on the right)
  108909. */
  108910. embedMode?: boolean;
  108911. /**
  108912. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  108913. */
  108914. handleResize?: boolean;
  108915. /**
  108916. * Allow the panes to popup (default: true)
  108917. */
  108918. enablePopup?: boolean;
  108919. /**
  108920. * Allow the panes to be closed by users (default: true)
  108921. */
  108922. enableClose?: boolean;
  108923. /**
  108924. * Optional list of extensibility entries
  108925. */
  108926. explorerExtensibility?: IExplorerExtensibilityGroup[];
  108927. /**
  108928. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  108929. */
  108930. inspectorURL?: string;
  108931. }
  108932. interface Scene {
  108933. /**
  108934. * @hidden
  108935. * Backing field
  108936. */
  108937. _debugLayer: DebugLayer;
  108938. /**
  108939. * Gets the debug layer (aka Inspector) associated with the scene
  108940. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108941. */
  108942. debugLayer: DebugLayer;
  108943. }
  108944. /**
  108945. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108946. * what is happening in your scene
  108947. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108948. */
  108949. export class DebugLayer {
  108950. /**
  108951. * Define the url to get the inspector script from.
  108952. * By default it uses the babylonjs CDN.
  108953. * @ignoreNaming
  108954. */
  108955. static InspectorURL: string;
  108956. private _scene;
  108957. private BJSINSPECTOR;
  108958. private _onPropertyChangedObservable?;
  108959. /**
  108960. * Observable triggered when a property is changed through the inspector.
  108961. */
  108962. readonly onPropertyChangedObservable: any;
  108963. /**
  108964. * Instantiates a new debug layer.
  108965. * The debug layer (aka Inspector) is the go to tool in order to better understand
  108966. * what is happening in your scene
  108967. * @see http://doc.babylonjs.com/features/playground_debuglayer
  108968. * @param scene Defines the scene to inspect
  108969. */
  108970. constructor(scene: Scene);
  108971. /** Creates the inspector window. */
  108972. private _createInspector;
  108973. /**
  108974. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  108975. * @param entity defines the entity to select
  108976. * @param lineContainerTitle defines the specific block to highlight
  108977. */
  108978. select(entity: any, lineContainerTitle?: string): void;
  108979. /** Get the inspector from bundle or global */
  108980. private _getGlobalInspector;
  108981. /**
  108982. * Get if the inspector is visible or not.
  108983. * @returns true if visible otherwise, false
  108984. */
  108985. isVisible(): boolean;
  108986. /**
  108987. * Hide the inspector and close its window.
  108988. */
  108989. hide(): void;
  108990. /**
  108991. * Launch the debugLayer.
  108992. * @param config Define the configuration of the inspector
  108993. * @return a promise fulfilled when the debug layer is visible
  108994. */
  108995. show(config?: IInspectorOptions): Promise<DebugLayer>;
  108996. }
  108997. }
  108998. declare module BABYLON {
  108999. /**
  109000. * Class containing static functions to help procedurally build meshes
  109001. */
  109002. export class BoxBuilder {
  109003. /**
  109004. * Creates a box mesh
  109005. * * The parameter `size` sets the size (float) of each box side (default 1)
  109006. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  109007. * * 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)
  109008. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109010. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109012. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  109013. * @param name defines the name of the mesh
  109014. * @param options defines the options used to create the mesh
  109015. * @param scene defines the hosting scene
  109016. * @returns the box mesh
  109017. */
  109018. static CreateBox(name: string, options: {
  109019. size?: number;
  109020. width?: number;
  109021. height?: number;
  109022. depth?: number;
  109023. faceUV?: Vector4[];
  109024. faceColors?: Color4[];
  109025. sideOrientation?: number;
  109026. frontUVs?: Vector4;
  109027. backUVs?: Vector4;
  109028. wrap?: boolean;
  109029. topBaseAt?: number;
  109030. bottomBaseAt?: number;
  109031. updatable?: boolean;
  109032. }, scene?: Nullable<Scene>): Mesh;
  109033. }
  109034. }
  109035. declare module BABYLON {
  109036. /**
  109037. * Class containing static functions to help procedurally build meshes
  109038. */
  109039. export class SphereBuilder {
  109040. /**
  109041. * Creates a sphere mesh
  109042. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  109043. * * 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`)
  109044. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  109045. * * 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
  109046. * * 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)
  109047. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109048. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109050. * @param name defines the name of the mesh
  109051. * @param options defines the options used to create the mesh
  109052. * @param scene defines the hosting scene
  109053. * @returns the sphere mesh
  109054. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  109055. */
  109056. static CreateSphere(name: string, options: {
  109057. segments?: number;
  109058. diameter?: number;
  109059. diameterX?: number;
  109060. diameterY?: number;
  109061. diameterZ?: number;
  109062. arc?: number;
  109063. slice?: number;
  109064. sideOrientation?: number;
  109065. frontUVs?: Vector4;
  109066. backUVs?: Vector4;
  109067. updatable?: boolean;
  109068. }, scene?: Nullable<Scene>): Mesh;
  109069. }
  109070. }
  109071. declare module BABYLON.Debug {
  109072. /**
  109073. * Used to show the physics impostor around the specific mesh
  109074. */
  109075. export class PhysicsViewer {
  109076. /** @hidden */
  109077. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  109078. /** @hidden */
  109079. protected _meshes: Array<Nullable<AbstractMesh>>;
  109080. /** @hidden */
  109081. protected _scene: Nullable<Scene>;
  109082. /** @hidden */
  109083. protected _numMeshes: number;
  109084. /** @hidden */
  109085. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  109086. private _renderFunction;
  109087. private _utilityLayer;
  109088. private _debugBoxMesh;
  109089. private _debugSphereMesh;
  109090. private _debugCylinderMesh;
  109091. private _debugMaterial;
  109092. private _debugMeshMeshes;
  109093. /**
  109094. * Creates a new PhysicsViewer
  109095. * @param scene defines the hosting scene
  109096. */
  109097. constructor(scene: Scene);
  109098. /** @hidden */
  109099. protected _updateDebugMeshes(): void;
  109100. /**
  109101. * Renders a specified physic impostor
  109102. * @param impostor defines the impostor to render
  109103. * @param targetMesh defines the mesh represented by the impostor
  109104. * @returns the new debug mesh used to render the impostor
  109105. */
  109106. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  109107. /**
  109108. * Hides a specified physic impostor
  109109. * @param impostor defines the impostor to hide
  109110. */
  109111. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  109112. private _getDebugMaterial;
  109113. private _getDebugBoxMesh;
  109114. private _getDebugSphereMesh;
  109115. private _getDebugCylinderMesh;
  109116. private _getDebugMeshMesh;
  109117. private _getDebugMesh;
  109118. /** Releases all resources */
  109119. dispose(): void;
  109120. }
  109121. }
  109122. declare module BABYLON {
  109123. /**
  109124. * Class containing static functions to help procedurally build meshes
  109125. */
  109126. export class LinesBuilder {
  109127. /**
  109128. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  109129. * * 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
  109130. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  109131. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  109132. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  109133. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  109134. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  109135. * * 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
  109136. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  109137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109138. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  109139. * @param name defines the name of the new line system
  109140. * @param options defines the options used to create the line system
  109141. * @param scene defines the hosting scene
  109142. * @returns a new line system mesh
  109143. */
  109144. static CreateLineSystem(name: string, options: {
  109145. lines: Vector3[][];
  109146. updatable?: boolean;
  109147. instance?: Nullable<LinesMesh>;
  109148. colors?: Nullable<Color4[][]>;
  109149. useVertexAlpha?: boolean;
  109150. }, scene: Nullable<Scene>): LinesMesh;
  109151. /**
  109152. * Creates a line mesh
  109153. * 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
  109154. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109155. * * The parameter `points` is an array successive Vector3
  109156. * * 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
  109157. * * The optional parameter `colors` is an array of successive Color4, one per line point
  109158. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  109159. * * When updating an instance, remember that only point positions can change, not the number of points
  109160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109161. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  109162. * @param name defines the name of the new line system
  109163. * @param options defines the options used to create the line system
  109164. * @param scene defines the hosting scene
  109165. * @returns a new line mesh
  109166. */
  109167. static CreateLines(name: string, options: {
  109168. points: Vector3[];
  109169. updatable?: boolean;
  109170. instance?: Nullable<LinesMesh>;
  109171. colors?: Color4[];
  109172. useVertexAlpha?: boolean;
  109173. }, scene?: Nullable<Scene>): LinesMesh;
  109174. /**
  109175. * Creates a dashed line mesh
  109176. * * 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
  109177. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109178. * * The parameter `points` is an array successive Vector3
  109179. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  109180. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  109181. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109182. * * 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
  109183. * * When updating an instance, remember that only point positions can change, not the number of points
  109184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109185. * @param name defines the name of the mesh
  109186. * @param options defines the options used to create the mesh
  109187. * @param scene defines the hosting scene
  109188. * @returns the dashed line mesh
  109189. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  109190. */
  109191. static CreateDashedLines(name: string, options: {
  109192. points: Vector3[];
  109193. dashSize?: number;
  109194. gapSize?: number;
  109195. dashNb?: number;
  109196. updatable?: boolean;
  109197. instance?: LinesMesh;
  109198. }, scene?: Nullable<Scene>): LinesMesh;
  109199. }
  109200. }
  109201. declare module BABYLON {
  109202. /**
  109203. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109204. * in order to better appreciate the issue one might have.
  109205. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109206. */
  109207. export class RayHelper {
  109208. /**
  109209. * Defines the ray we are currently tryin to visualize.
  109210. */
  109211. ray: Nullable<Ray>;
  109212. private _renderPoints;
  109213. private _renderLine;
  109214. private _renderFunction;
  109215. private _scene;
  109216. private _updateToMeshFunction;
  109217. private _attachedToMesh;
  109218. private _meshSpaceDirection;
  109219. private _meshSpaceOrigin;
  109220. /**
  109221. * Helper function to create a colored helper in a scene in one line.
  109222. * @param ray Defines the ray we are currently tryin to visualize
  109223. * @param scene Defines the scene the ray is used in
  109224. * @param color Defines the color we want to see the ray in
  109225. * @returns The newly created ray helper.
  109226. */
  109227. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  109228. /**
  109229. * Instantiate a new ray helper.
  109230. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  109231. * in order to better appreciate the issue one might have.
  109232. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  109233. * @param ray Defines the ray we are currently tryin to visualize
  109234. */
  109235. constructor(ray: Ray);
  109236. /**
  109237. * Shows the ray we are willing to debug.
  109238. * @param scene Defines the scene the ray needs to be rendered in
  109239. * @param color Defines the color the ray needs to be rendered in
  109240. */
  109241. show(scene: Scene, color?: Color3): void;
  109242. /**
  109243. * Hides the ray we are debugging.
  109244. */
  109245. hide(): void;
  109246. private _render;
  109247. /**
  109248. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  109249. * @param mesh Defines the mesh we want the helper attached to
  109250. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  109251. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  109252. * @param length Defines the length of the ray
  109253. */
  109254. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  109255. /**
  109256. * Detach the ray helper from the mesh it has previously been attached to.
  109257. */
  109258. detachFromMesh(): void;
  109259. private _updateToMesh;
  109260. /**
  109261. * Dispose the helper and release its associated resources.
  109262. */
  109263. dispose(): void;
  109264. }
  109265. }
  109266. declare module BABYLON.Debug {
  109267. /**
  109268. * Class used to render a debug view of a given skeleton
  109269. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  109270. */
  109271. export class SkeletonViewer {
  109272. /** defines the skeleton to render */
  109273. skeleton: Skeleton;
  109274. /** defines the mesh attached to the skeleton */
  109275. mesh: AbstractMesh;
  109276. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109277. autoUpdateBonesMatrices: boolean;
  109278. /** defines the rendering group id to use with the viewer */
  109279. renderingGroupId: number;
  109280. /** Gets or sets the color used to render the skeleton */
  109281. color: Color3;
  109282. private _scene;
  109283. private _debugLines;
  109284. private _debugMesh;
  109285. private _isEnabled;
  109286. private _renderFunction;
  109287. private _utilityLayer;
  109288. /**
  109289. * Returns the mesh used to render the bones
  109290. */
  109291. readonly debugMesh: Nullable<LinesMesh>;
  109292. /**
  109293. * Creates a new SkeletonViewer
  109294. * @param skeleton defines the skeleton to render
  109295. * @param mesh defines the mesh attached to the skeleton
  109296. * @param scene defines the hosting scene
  109297. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  109298. * @param renderingGroupId defines the rendering group id to use with the viewer
  109299. */
  109300. constructor(
  109301. /** defines the skeleton to render */
  109302. skeleton: Skeleton,
  109303. /** defines the mesh attached to the skeleton */
  109304. mesh: AbstractMesh, scene: Scene,
  109305. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  109306. autoUpdateBonesMatrices?: boolean,
  109307. /** defines the rendering group id to use with the viewer */
  109308. renderingGroupId?: number);
  109309. /** Gets or sets a boolean indicating if the viewer is enabled */
  109310. isEnabled: boolean;
  109311. private _getBonePosition;
  109312. private _getLinesForBonesWithLength;
  109313. private _getLinesForBonesNoLength;
  109314. /** Update the viewer to sync with current skeleton state */
  109315. update(): void;
  109316. /** Release associated resources */
  109317. dispose(): void;
  109318. }
  109319. }
  109320. declare module BABYLON {
  109321. /**
  109322. * Options to create the null engine
  109323. */
  109324. export class NullEngineOptions {
  109325. /**
  109326. * Render width (Default: 512)
  109327. */
  109328. renderWidth: number;
  109329. /**
  109330. * Render height (Default: 256)
  109331. */
  109332. renderHeight: number;
  109333. /**
  109334. * Texture size (Default: 512)
  109335. */
  109336. textureSize: number;
  109337. /**
  109338. * If delta time between frames should be constant
  109339. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109340. */
  109341. deterministicLockstep: boolean;
  109342. /**
  109343. * Maximum about of steps between frames (Default: 4)
  109344. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109345. */
  109346. lockstepMaxSteps: number;
  109347. }
  109348. /**
  109349. * The null engine class provides support for headless version of babylon.js.
  109350. * This can be used in server side scenario or for testing purposes
  109351. */
  109352. export class NullEngine extends Engine {
  109353. private _options;
  109354. /**
  109355. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109356. */
  109357. isDeterministicLockStep(): boolean;
  109358. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  109359. getLockstepMaxSteps(): number;
  109360. /**
  109361. * Sets hardware scaling, used to save performance if needed
  109362. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109363. */
  109364. getHardwareScalingLevel(): number;
  109365. constructor(options?: NullEngineOptions);
  109366. createVertexBuffer(vertices: FloatArray): DataBuffer;
  109367. createIndexBuffer(indices: IndicesArray): DataBuffer;
  109368. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  109369. getRenderWidth(useScreen?: boolean): number;
  109370. getRenderHeight(useScreen?: boolean): number;
  109371. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  109372. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  109373. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  109374. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  109375. bindSamplers(effect: Effect): void;
  109376. enableEffect(effect: Effect): void;
  109377. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  109378. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  109379. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  109380. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  109381. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  109382. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  109383. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  109384. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  109385. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  109386. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  109387. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  109388. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  109389. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  109390. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  109391. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109392. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  109393. setFloat(uniform: WebGLUniformLocation, value: number): void;
  109394. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  109395. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  109396. setBool(uniform: WebGLUniformLocation, bool: number): void;
  109397. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  109398. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  109399. bindBuffers(vertexBuffers: {
  109400. [key: string]: VertexBuffer;
  109401. }, indexBuffer: DataBuffer, effect: Effect): void;
  109402. wipeCaches(bruteForce?: boolean): void;
  109403. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  109404. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  109405. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  109406. /** @hidden */
  109407. _createTexture(): WebGLTexture;
  109408. /** @hidden */
  109409. _releaseTexture(texture: InternalTexture): void;
  109410. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  109411. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  109412. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  109413. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  109414. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  109415. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  109416. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  109417. areAllEffectsReady(): boolean;
  109418. /**
  109419. * @hidden
  109420. * Get the current error code of the webGL context
  109421. * @returns the error code
  109422. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  109423. */
  109424. getError(): number;
  109425. /** @hidden */
  109426. _getUnpackAlignement(): number;
  109427. /** @hidden */
  109428. _unpackFlipY(value: boolean): void;
  109429. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  109430. /**
  109431. * Updates a dynamic vertex buffer.
  109432. * @param vertexBuffer the vertex buffer to update
  109433. * @param data the data used to update the vertex buffer
  109434. * @param byteOffset the byte offset of the data (optional)
  109435. * @param byteLength the byte length of the data (optional)
  109436. */
  109437. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  109438. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  109439. /** @hidden */
  109440. _bindTexture(channel: number, texture: InternalTexture): void;
  109441. protected _deleteBuffer(buffer: WebGLBuffer): void;
  109442. releaseEffects(): void;
  109443. displayLoadingUI(): void;
  109444. hideLoadingUI(): void;
  109445. /** @hidden */
  109446. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109447. /** @hidden */
  109448. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109449. /** @hidden */
  109450. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  109451. /** @hidden */
  109452. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  109453. }
  109454. }
  109455. declare module BABYLON {
  109456. /** @hidden */
  109457. export class _OcclusionDataStorage {
  109458. /** @hidden */
  109459. occlusionInternalRetryCounter: number;
  109460. /** @hidden */
  109461. isOcclusionQueryInProgress: boolean;
  109462. /** @hidden */
  109463. isOccluded: boolean;
  109464. /** @hidden */
  109465. occlusionRetryCount: number;
  109466. /** @hidden */
  109467. occlusionType: number;
  109468. /** @hidden */
  109469. occlusionQueryAlgorithmType: number;
  109470. }
  109471. interface Engine {
  109472. /**
  109473. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  109474. * @return the new query
  109475. */
  109476. createQuery(): WebGLQuery;
  109477. /**
  109478. * Delete and release a webGL query
  109479. * @param query defines the query to delete
  109480. * @return the current engine
  109481. */
  109482. deleteQuery(query: WebGLQuery): Engine;
  109483. /**
  109484. * Check if a given query has resolved and got its value
  109485. * @param query defines the query to check
  109486. * @returns true if the query got its value
  109487. */
  109488. isQueryResultAvailable(query: WebGLQuery): boolean;
  109489. /**
  109490. * Gets the value of a given query
  109491. * @param query defines the query to check
  109492. * @returns the value of the query
  109493. */
  109494. getQueryResult(query: WebGLQuery): number;
  109495. /**
  109496. * Initiates an occlusion query
  109497. * @param algorithmType defines the algorithm to use
  109498. * @param query defines the query to use
  109499. * @returns the current engine
  109500. * @see http://doc.babylonjs.com/features/occlusionquery
  109501. */
  109502. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  109503. /**
  109504. * Ends an occlusion query
  109505. * @see http://doc.babylonjs.com/features/occlusionquery
  109506. * @param algorithmType defines the algorithm to use
  109507. * @returns the current engine
  109508. */
  109509. endOcclusionQuery(algorithmType: number): Engine;
  109510. /**
  109511. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  109512. * Please note that only one query can be issued at a time
  109513. * @returns a time token used to track the time span
  109514. */
  109515. startTimeQuery(): Nullable<_TimeToken>;
  109516. /**
  109517. * Ends a time query
  109518. * @param token defines the token used to measure the time span
  109519. * @returns the time spent (in ns)
  109520. */
  109521. endTimeQuery(token: _TimeToken): int;
  109522. /** @hidden */
  109523. _currentNonTimestampToken: Nullable<_TimeToken>;
  109524. /** @hidden */
  109525. _createTimeQuery(): WebGLQuery;
  109526. /** @hidden */
  109527. _deleteTimeQuery(query: WebGLQuery): void;
  109528. /** @hidden */
  109529. _getGlAlgorithmType(algorithmType: number): number;
  109530. /** @hidden */
  109531. _getTimeQueryResult(query: WebGLQuery): any;
  109532. /** @hidden */
  109533. _getTimeQueryAvailability(query: WebGLQuery): any;
  109534. }
  109535. interface AbstractMesh {
  109536. /**
  109537. * Backing filed
  109538. * @hidden
  109539. */
  109540. __occlusionDataStorage: _OcclusionDataStorage;
  109541. /**
  109542. * Access property
  109543. * @hidden
  109544. */
  109545. _occlusionDataStorage: _OcclusionDataStorage;
  109546. /**
  109547. * 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.
  109548. * The default value is -1 which means don't break the query and wait till the result
  109549. * @see http://doc.babylonjs.com/features/occlusionquery
  109550. */
  109551. occlusionRetryCount: number;
  109552. /**
  109553. * 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:
  109554. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  109555. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  109556. * * 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.
  109557. * @see http://doc.babylonjs.com/features/occlusionquery
  109558. */
  109559. occlusionType: number;
  109560. /**
  109561. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  109562. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  109563. * * 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.
  109564. * @see http://doc.babylonjs.com/features/occlusionquery
  109565. */
  109566. occlusionQueryAlgorithmType: number;
  109567. /**
  109568. * 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
  109569. * @see http://doc.babylonjs.com/features/occlusionquery
  109570. */
  109571. isOccluded: boolean;
  109572. /**
  109573. * Flag to check the progress status of the query
  109574. * @see http://doc.babylonjs.com/features/occlusionquery
  109575. */
  109576. isOcclusionQueryInProgress: boolean;
  109577. }
  109578. }
  109579. declare module BABYLON {
  109580. /** @hidden */
  109581. export var _forceTransformFeedbackToBundle: boolean;
  109582. interface Engine {
  109583. /**
  109584. * Creates a webGL transform feedback object
  109585. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  109586. * @returns the webGL transform feedback object
  109587. */
  109588. createTransformFeedback(): WebGLTransformFeedback;
  109589. /**
  109590. * Delete a webGL transform feedback object
  109591. * @param value defines the webGL transform feedback object to delete
  109592. */
  109593. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  109594. /**
  109595. * Bind a webGL transform feedback object to the webgl context
  109596. * @param value defines the webGL transform feedback object to bind
  109597. */
  109598. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  109599. /**
  109600. * Begins a transform feedback operation
  109601. * @param usePoints defines if points or triangles must be used
  109602. */
  109603. beginTransformFeedback(usePoints: boolean): void;
  109604. /**
  109605. * Ends a transform feedback operation
  109606. */
  109607. endTransformFeedback(): void;
  109608. /**
  109609. * Specify the varyings to use with transform feedback
  109610. * @param program defines the associated webGL program
  109611. * @param value defines the list of strings representing the varying names
  109612. */
  109613. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  109614. /**
  109615. * Bind a webGL buffer for a transform feedback operation
  109616. * @param value defines the webGL buffer to bind
  109617. */
  109618. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  109619. }
  109620. }
  109621. declare module BABYLON {
  109622. /**
  109623. * Creation options of the multi render target texture.
  109624. */
  109625. export interface IMultiRenderTargetOptions {
  109626. /**
  109627. * Define if the texture needs to create mip maps after render.
  109628. */
  109629. generateMipMaps?: boolean;
  109630. /**
  109631. * Define the types of all the draw buffers we want to create
  109632. */
  109633. types?: number[];
  109634. /**
  109635. * Define the sampling modes of all the draw buffers we want to create
  109636. */
  109637. samplingModes?: number[];
  109638. /**
  109639. * Define if a depth buffer is required
  109640. */
  109641. generateDepthBuffer?: boolean;
  109642. /**
  109643. * Define if a stencil buffer is required
  109644. */
  109645. generateStencilBuffer?: boolean;
  109646. /**
  109647. * Define if a depth texture is required instead of a depth buffer
  109648. */
  109649. generateDepthTexture?: boolean;
  109650. /**
  109651. * Define the number of desired draw buffers
  109652. */
  109653. textureCount?: number;
  109654. /**
  109655. * Define if aspect ratio should be adapted to the texture or stay the scene one
  109656. */
  109657. doNotChangeAspectRatio?: boolean;
  109658. /**
  109659. * Define the default type of the buffers we are creating
  109660. */
  109661. defaultType?: number;
  109662. }
  109663. /**
  109664. * A multi render target, like a render target provides the ability to render to a texture.
  109665. * Unlike the render target, it can render to several draw buffers in one draw.
  109666. * This is specially interesting in deferred rendering or for any effects requiring more than
  109667. * just one color from a single pass.
  109668. */
  109669. export class MultiRenderTarget extends RenderTargetTexture {
  109670. private _internalTextures;
  109671. private _textures;
  109672. private _multiRenderTargetOptions;
  109673. /**
  109674. * Get if draw buffers are currently supported by the used hardware and browser.
  109675. */
  109676. readonly isSupported: boolean;
  109677. /**
  109678. * Get the list of textures generated by the multi render target.
  109679. */
  109680. readonly textures: Texture[];
  109681. /**
  109682. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  109683. */
  109684. readonly depthTexture: Texture;
  109685. /**
  109686. * Set the wrapping mode on U of all the textures we are rendering to.
  109687. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109688. */
  109689. wrapU: number;
  109690. /**
  109691. * Set the wrapping mode on V of all the textures we are rendering to.
  109692. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  109693. */
  109694. wrapV: number;
  109695. /**
  109696. * Instantiate a new multi render target texture.
  109697. * A multi render target, like a render target provides the ability to render to a texture.
  109698. * Unlike the render target, it can render to several draw buffers in one draw.
  109699. * This is specially interesting in deferred rendering or for any effects requiring more than
  109700. * just one color from a single pass.
  109701. * @param name Define the name of the texture
  109702. * @param size Define the size of the buffers to render to
  109703. * @param count Define the number of target we are rendering into
  109704. * @param scene Define the scene the texture belongs to
  109705. * @param options Define the options used to create the multi render target
  109706. */
  109707. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  109708. /** @hidden */
  109709. _rebuild(): void;
  109710. private _createInternalTextures;
  109711. private _createTextures;
  109712. /**
  109713. * Define the number of samples used if MSAA is enabled.
  109714. */
  109715. samples: number;
  109716. /**
  109717. * Resize all the textures in the multi render target.
  109718. * Be carrefull as it will recreate all the data in the new texture.
  109719. * @param size Define the new size
  109720. */
  109721. resize(size: any): void;
  109722. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  109723. /**
  109724. * Dispose the render targets and their associated resources
  109725. */
  109726. dispose(): void;
  109727. /**
  109728. * Release all the underlying texture used as draw buffers.
  109729. */
  109730. releaseInternalTextures(): void;
  109731. }
  109732. }
  109733. declare module BABYLON {
  109734. interface Engine {
  109735. /**
  109736. * Unbind a list of render target textures from the webGL context
  109737. * This is used only when drawBuffer extension or webGL2 are active
  109738. * @param textures defines the render target textures to unbind
  109739. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  109740. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  109741. */
  109742. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  109743. /**
  109744. * Create a multi render target texture
  109745. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  109746. * @param size defines the size of the texture
  109747. * @param options defines the creation options
  109748. * @returns the cube texture as an InternalTexture
  109749. */
  109750. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  109751. /**
  109752. * Update the sample count for a given multiple render target texture
  109753. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  109754. * @param textures defines the textures to update
  109755. * @param samples defines the sample count to set
  109756. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  109757. */
  109758. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  109759. }
  109760. }
  109761. declare module BABYLON {
  109762. /** @hidden */
  109763. export var rgbdEncodePixelShader: {
  109764. name: string;
  109765. shader: string;
  109766. };
  109767. }
  109768. declare module BABYLON {
  109769. /** @hidden */
  109770. export var rgbdDecodePixelShader: {
  109771. name: string;
  109772. shader: string;
  109773. };
  109774. }
  109775. declare module BABYLON {
  109776. /**
  109777. * Raw texture data and descriptor sufficient for WebGL texture upload
  109778. */
  109779. export interface EnvironmentTextureInfo {
  109780. /**
  109781. * Version of the environment map
  109782. */
  109783. version: number;
  109784. /**
  109785. * Width of image
  109786. */
  109787. width: number;
  109788. /**
  109789. * Irradiance information stored in the file.
  109790. */
  109791. irradiance: any;
  109792. /**
  109793. * Specular information stored in the file.
  109794. */
  109795. specular: any;
  109796. }
  109797. /**
  109798. * Defines One Image in the file. It requires only the position in the file
  109799. * as well as the length.
  109800. */
  109801. interface BufferImageData {
  109802. /**
  109803. * Length of the image data.
  109804. */
  109805. length: number;
  109806. /**
  109807. * Position of the data from the null terminator delimiting the end of the JSON.
  109808. */
  109809. position: number;
  109810. }
  109811. /**
  109812. * Defines the specular data enclosed in the file.
  109813. * This corresponds to the version 1 of the data.
  109814. */
  109815. export interface EnvironmentTextureSpecularInfoV1 {
  109816. /**
  109817. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  109818. */
  109819. specularDataPosition?: number;
  109820. /**
  109821. * This contains all the images data needed to reconstruct the cubemap.
  109822. */
  109823. mipmaps: Array<BufferImageData>;
  109824. /**
  109825. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  109826. */
  109827. lodGenerationScale: number;
  109828. }
  109829. /**
  109830. * Sets of helpers addressing the serialization and deserialization of environment texture
  109831. * stored in a BabylonJS env file.
  109832. * Those files are usually stored as .env files.
  109833. */
  109834. export class EnvironmentTextureTools {
  109835. /**
  109836. * Magic number identifying the env file.
  109837. */
  109838. private static _MagicBytes;
  109839. /**
  109840. * Gets the environment info from an env file.
  109841. * @param data The array buffer containing the .env bytes.
  109842. * @returns the environment file info (the json header) if successfully parsed.
  109843. */
  109844. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109845. /**
  109846. * Creates an environment texture from a loaded cube texture.
  109847. * @param texture defines the cube texture to convert in env file
  109848. * @return a promise containing the environment data if succesfull.
  109849. */
  109850. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109851. /**
  109852. * Creates a JSON representation of the spherical data.
  109853. * @param texture defines the texture containing the polynomials
  109854. * @return the JSON representation of the spherical info
  109855. */
  109856. private static _CreateEnvTextureIrradiance;
  109857. /**
  109858. * Creates the ArrayBufferViews used for initializing environment texture image data.
  109859. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  109860. * @param info parameters that determine what views will be created for accessing the underlying buffer
  109861. * @return the views described by info providing access to the underlying buffer
  109862. */
  109863. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  109864. /**
  109865. * Uploads the texture info contained in the env file to the GPU.
  109866. * @param texture defines the internal texture to upload to
  109867. * @param arrayBuffer defines the buffer cotaining the data to load
  109868. * @param info defines the texture info retrieved through the GetEnvInfo method
  109869. * @returns a promise
  109870. */
  109871. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109872. /**
  109873. * Uploads the levels of image data to the GPU.
  109874. * @param texture defines the internal texture to upload to
  109875. * @param imageData defines the array buffer views of image data [mipmap][face]
  109876. * @returns a promise
  109877. */
  109878. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109879. /**
  109880. * Uploads spherical polynomials information to the texture.
  109881. * @param texture defines the texture we are trying to upload the information to
  109882. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109883. */
  109884. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109885. /** @hidden */
  109886. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109887. }
  109888. }
  109889. declare module BABYLON {
  109890. /**
  109891. * Contains position and normal vectors for a vertex
  109892. */
  109893. export class PositionNormalVertex {
  109894. /** the position of the vertex (defaut: 0,0,0) */
  109895. position: Vector3;
  109896. /** the normal of the vertex (defaut: 0,1,0) */
  109897. normal: Vector3;
  109898. /**
  109899. * Creates a PositionNormalVertex
  109900. * @param position the position of the vertex (defaut: 0,0,0)
  109901. * @param normal the normal of the vertex (defaut: 0,1,0)
  109902. */
  109903. constructor(
  109904. /** the position of the vertex (defaut: 0,0,0) */
  109905. position?: Vector3,
  109906. /** the normal of the vertex (defaut: 0,1,0) */
  109907. normal?: Vector3);
  109908. /**
  109909. * Clones the PositionNormalVertex
  109910. * @returns the cloned PositionNormalVertex
  109911. */
  109912. clone(): PositionNormalVertex;
  109913. }
  109914. /**
  109915. * Contains position, normal and uv vectors for a vertex
  109916. */
  109917. export class PositionNormalTextureVertex {
  109918. /** the position of the vertex (defaut: 0,0,0) */
  109919. position: Vector3;
  109920. /** the normal of the vertex (defaut: 0,1,0) */
  109921. normal: Vector3;
  109922. /** the uv of the vertex (default: 0,0) */
  109923. uv: Vector2;
  109924. /**
  109925. * Creates a PositionNormalTextureVertex
  109926. * @param position the position of the vertex (defaut: 0,0,0)
  109927. * @param normal the normal of the vertex (defaut: 0,1,0)
  109928. * @param uv the uv of the vertex (default: 0,0)
  109929. */
  109930. constructor(
  109931. /** the position of the vertex (defaut: 0,0,0) */
  109932. position?: Vector3,
  109933. /** the normal of the vertex (defaut: 0,1,0) */
  109934. normal?: Vector3,
  109935. /** the uv of the vertex (default: 0,0) */
  109936. uv?: Vector2);
  109937. /**
  109938. * Clones the PositionNormalTextureVertex
  109939. * @returns the cloned PositionNormalTextureVertex
  109940. */
  109941. clone(): PositionNormalTextureVertex;
  109942. }
  109943. }
  109944. declare module BABYLON {
  109945. /** @hidden */
  109946. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  109947. private _genericAttributeLocation;
  109948. private _varyingLocationCount;
  109949. private _varyingLocationMap;
  109950. private _replacements;
  109951. private _textureCount;
  109952. private _uniforms;
  109953. lineProcessor(line: string): string;
  109954. attributeProcessor(attribute: string): string;
  109955. varyingProcessor(varying: string, isFragment: boolean): string;
  109956. uniformProcessor(uniform: string): string;
  109957. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  109958. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  109959. }
  109960. }
  109961. declare module BABYLON {
  109962. /**
  109963. * Container for accessors for natively-stored mesh data buffers.
  109964. */
  109965. class NativeDataBuffer extends DataBuffer {
  109966. /**
  109967. * Accessor value used to identify/retrieve a natively-stored index buffer.
  109968. */
  109969. nativeIndexBuffer?: any;
  109970. /**
  109971. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  109972. */
  109973. nativeVertexBuffer?: any;
  109974. }
  109975. /** @hidden */
  109976. export class NativeEngine extends Engine {
  109977. private readonly _native;
  109978. getHardwareScalingLevel(): number;
  109979. constructor();
  109980. /**
  109981. * Can be used to override the current requestAnimationFrame requester.
  109982. * @hidden
  109983. */
  109984. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  109985. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  109986. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  109987. createVertexBuffer(data: DataArray): NativeDataBuffer;
  109988. recordVertexArrayObject(vertexBuffers: {
  109989. [key: string]: VertexBuffer;
  109990. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  109991. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  109992. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  109993. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  109994. /**
  109995. * Draw a list of indexed primitives
  109996. * @param fillMode defines the primitive to use
  109997. * @param indexStart defines the starting index
  109998. * @param indexCount defines the number of index to draw
  109999. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110000. */
  110001. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  110002. /**
  110003. * Draw a list of unindexed primitives
  110004. * @param fillMode defines the primitive to use
  110005. * @param verticesStart defines the index of first vertex to draw
  110006. * @param verticesCount defines the count of vertices to draw
  110007. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110008. */
  110009. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  110010. createPipelineContext(): IPipelineContext;
  110011. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  110012. /** @hidden */
  110013. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  110014. /** @hidden */
  110015. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  110016. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  110017. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  110018. protected _setProgram(program: WebGLProgram): void;
  110019. _releaseEffect(effect: Effect): void;
  110020. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  110021. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  110022. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  110023. bindSamplers(effect: Effect): void;
  110024. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  110025. getRenderWidth(useScreen?: boolean): number;
  110026. getRenderHeight(useScreen?: boolean): number;
  110027. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  110028. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110029. /**
  110030. * Set the z offset to apply to current rendering
  110031. * @param value defines the offset to apply
  110032. */
  110033. setZOffset(value: number): void;
  110034. /**
  110035. * Gets the current value of the zOffset
  110036. * @returns the current zOffset state
  110037. */
  110038. getZOffset(): number;
  110039. /**
  110040. * Enable or disable depth buffering
  110041. * @param enable defines the state to set
  110042. */
  110043. setDepthBuffer(enable: boolean): void;
  110044. /**
  110045. * Gets a boolean indicating if depth writing is enabled
  110046. * @returns the current depth writing state
  110047. */
  110048. getDepthWrite(): boolean;
  110049. /**
  110050. * Enable or disable depth writing
  110051. * @param enable defines the state to set
  110052. */
  110053. setDepthWrite(enable: boolean): void;
  110054. /**
  110055. * Enable or disable color writing
  110056. * @param enable defines the state to set
  110057. */
  110058. setColorWrite(enable: boolean): void;
  110059. /**
  110060. * Gets a boolean indicating if color writing is enabled
  110061. * @returns the current color writing state
  110062. */
  110063. getColorWrite(): boolean;
  110064. /**
  110065. * Sets alpha constants used by some alpha blending modes
  110066. * @param r defines the red component
  110067. * @param g defines the green component
  110068. * @param b defines the blue component
  110069. * @param a defines the alpha component
  110070. */
  110071. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  110072. /**
  110073. * Sets the current alpha mode
  110074. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  110075. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  110076. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110077. */
  110078. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  110079. /**
  110080. * Gets the current alpha mode
  110081. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110082. * @returns the current alpha mode
  110083. */
  110084. getAlphaMode(): number;
  110085. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  110086. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  110087. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  110088. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  110089. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  110090. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  110091. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  110092. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  110093. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  110094. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  110095. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  110096. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  110097. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  110098. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110099. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110100. setFloat(uniform: WebGLUniformLocation, value: number): void;
  110101. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  110102. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  110103. setBool(uniform: WebGLUniformLocation, bool: number): void;
  110104. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  110105. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  110106. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  110107. wipeCaches(bruteForce?: boolean): void;
  110108. _createTexture(): WebGLTexture;
  110109. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  110110. /**
  110111. * Usually called from BABYLON.Texture.ts.
  110112. * Passed information to create a WebGLTexture
  110113. * @param urlArg defines a value which contains one of the following:
  110114. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  110115. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  110116. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  110117. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  110118. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  110119. * @param scene needed for loading to the correct scene
  110120. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  110121. * @param onLoad optional callback to be called upon successful completion
  110122. * @param onError optional callback to be called upon failure
  110123. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  110124. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110125. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110126. * @param forcedExtension defines the extension to use to pick the right loader
  110127. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110128. */
  110129. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  110130. /**
  110131. * Creates a cube texture
  110132. * @param rootUrl defines the url where the files to load is located
  110133. * @param scene defines the current scene
  110134. * @param files defines the list of files to load (1 per face)
  110135. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  110136. * @param onLoad defines an optional callback raised when the texture is loaded
  110137. * @param onError defines an optional callback raised if there is an issue to load the texture
  110138. * @param format defines the format of the data
  110139. * @param forcedExtension defines the extension to use to pick the right loader
  110140. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  110141. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  110142. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  110143. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  110144. * @returns the cube texture as an InternalTexture
  110145. */
  110146. 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;
  110147. private _getSamplingFilter;
  110148. private static _GetNativeTextureFormat;
  110149. createRenderTargetTexture(size: number | {
  110150. width: number;
  110151. height: number;
  110152. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110153. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110154. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110155. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110156. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  110157. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  110158. /**
  110159. * Updates a dynamic vertex buffer.
  110160. * @param vertexBuffer the vertex buffer to update
  110161. * @param data the data used to update the vertex buffer
  110162. * @param byteOffset the byte offset of the data (optional)
  110163. * @param byteLength the byte length of the data (optional)
  110164. */
  110165. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  110166. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  110167. private _updateAnisotropicLevel;
  110168. private _getAddressMode;
  110169. /** @hidden */
  110170. _bindTexture(channel: number, texture: InternalTexture): void;
  110171. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  110172. releaseEffects(): void;
  110173. /** @hidden */
  110174. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110175. /** @hidden */
  110176. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110177. /** @hidden */
  110178. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110179. /** @hidden */
  110180. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110181. }
  110182. }
  110183. declare module BABYLON {
  110184. /**
  110185. * Gather the list of clipboard event types as constants.
  110186. */
  110187. export class ClipboardEventTypes {
  110188. /**
  110189. * The clipboard event is fired when a copy command is active (pressed).
  110190. */
  110191. static readonly COPY: number;
  110192. /**
  110193. * The clipboard event is fired when a cut command is active (pressed).
  110194. */
  110195. static readonly CUT: number;
  110196. /**
  110197. * The clipboard event is fired when a paste command is active (pressed).
  110198. */
  110199. static readonly PASTE: number;
  110200. }
  110201. /**
  110202. * This class is used to store clipboard related info for the onClipboardObservable event.
  110203. */
  110204. export class ClipboardInfo {
  110205. /**
  110206. * Defines the type of event (BABYLON.ClipboardEventTypes)
  110207. */
  110208. type: number;
  110209. /**
  110210. * Defines the related dom event
  110211. */
  110212. event: ClipboardEvent;
  110213. /**
  110214. *Creates an instance of ClipboardInfo.
  110215. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  110216. * @param event Defines the related dom event
  110217. */
  110218. constructor(
  110219. /**
  110220. * Defines the type of event (BABYLON.ClipboardEventTypes)
  110221. */
  110222. type: number,
  110223. /**
  110224. * Defines the related dom event
  110225. */
  110226. event: ClipboardEvent);
  110227. /**
  110228. * Get the clipboard event's type from the keycode.
  110229. * @param keyCode Defines the keyCode for the current keyboard event.
  110230. * @return {number}
  110231. */
  110232. static GetTypeFromCharacter(keyCode: number): number;
  110233. }
  110234. }
  110235. declare module BABYLON {
  110236. /**
  110237. * Google Daydream controller
  110238. */
  110239. export class DaydreamController extends WebVRController {
  110240. /**
  110241. * Base Url for the controller model.
  110242. */
  110243. static MODEL_BASE_URL: string;
  110244. /**
  110245. * File name for the controller model.
  110246. */
  110247. static MODEL_FILENAME: string;
  110248. /**
  110249. * Gamepad Id prefix used to identify Daydream Controller.
  110250. */
  110251. static readonly GAMEPAD_ID_PREFIX: string;
  110252. /**
  110253. * Creates a new DaydreamController from a gamepad
  110254. * @param vrGamepad the gamepad that the controller should be created from
  110255. */
  110256. constructor(vrGamepad: any);
  110257. /**
  110258. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110259. * @param scene scene in which to add meshes
  110260. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110261. */
  110262. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110263. /**
  110264. * Called once for each button that changed state since the last frame
  110265. * @param buttonIdx Which button index changed
  110266. * @param state New state of the button
  110267. * @param changes Which properties on the state changed since last frame
  110268. */
  110269. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110270. }
  110271. }
  110272. declare module BABYLON {
  110273. /**
  110274. * Gear VR Controller
  110275. */
  110276. export class GearVRController extends WebVRController {
  110277. /**
  110278. * Base Url for the controller model.
  110279. */
  110280. static MODEL_BASE_URL: string;
  110281. /**
  110282. * File name for the controller model.
  110283. */
  110284. static MODEL_FILENAME: string;
  110285. /**
  110286. * Gamepad Id prefix used to identify this controller.
  110287. */
  110288. static readonly GAMEPAD_ID_PREFIX: string;
  110289. private readonly _buttonIndexToObservableNameMap;
  110290. /**
  110291. * Creates a new GearVRController from a gamepad
  110292. * @param vrGamepad the gamepad that the controller should be created from
  110293. */
  110294. constructor(vrGamepad: any);
  110295. /**
  110296. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  110297. * @param scene scene in which to add meshes
  110298. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  110299. */
  110300. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  110301. /**
  110302. * Called once for each button that changed state since the last frame
  110303. * @param buttonIdx Which button index changed
  110304. * @param state New state of the button
  110305. * @param changes Which properties on the state changed since last frame
  110306. */
  110307. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  110308. }
  110309. }
  110310. declare module BABYLON {
  110311. /**
  110312. * Class containing static functions to help procedurally build meshes
  110313. */
  110314. export class PolyhedronBuilder {
  110315. /**
  110316. * Creates a polyhedron mesh
  110317. * * 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
  110318. * * The parameter `size` (positive float, default 1) sets the polygon size
  110319. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110320. * * 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`
  110321. * * 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
  110322. * * 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)`)
  110323. * * 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
  110324. * * 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
  110325. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110326. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110328. * @param name defines the name of the mesh
  110329. * @param options defines the options used to create the mesh
  110330. * @param scene defines the hosting scene
  110331. * @returns the polyhedron mesh
  110332. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110333. */
  110334. static CreatePolyhedron(name: string, options: {
  110335. type?: number;
  110336. size?: number;
  110337. sizeX?: number;
  110338. sizeY?: number;
  110339. sizeZ?: number;
  110340. custom?: any;
  110341. faceUV?: Vector4[];
  110342. faceColors?: Color4[];
  110343. flat?: boolean;
  110344. updatable?: boolean;
  110345. sideOrientation?: number;
  110346. frontUVs?: Vector4;
  110347. backUVs?: Vector4;
  110348. }, scene?: Nullable<Scene>): Mesh;
  110349. }
  110350. }
  110351. declare module BABYLON {
  110352. /**
  110353. * Gizmo that enables scaling a mesh along 3 axis
  110354. */
  110355. export class ScaleGizmo extends Gizmo {
  110356. /**
  110357. * Internal gizmo used for interactions on the x axis
  110358. */
  110359. xGizmo: AxisScaleGizmo;
  110360. /**
  110361. * Internal gizmo used for interactions on the y axis
  110362. */
  110363. yGizmo: AxisScaleGizmo;
  110364. /**
  110365. * Internal gizmo used for interactions on the z axis
  110366. */
  110367. zGizmo: AxisScaleGizmo;
  110368. /**
  110369. * Internal gizmo used to scale all axis equally
  110370. */
  110371. uniformScaleGizmo: AxisScaleGizmo;
  110372. private _meshAttached;
  110373. private _updateGizmoRotationToMatchAttachedMesh;
  110374. private _snapDistance;
  110375. private _scaleRatio;
  110376. private _uniformScalingMesh;
  110377. private _octahedron;
  110378. /** Fires an event when any of it's sub gizmos are dragged */
  110379. onDragStartObservable: Observable<unknown>;
  110380. /** Fires an event when any of it's sub gizmos are released from dragging */
  110381. onDragEndObservable: Observable<unknown>;
  110382. attachedMesh: Nullable<AbstractMesh>;
  110383. /**
  110384. * Creates a ScaleGizmo
  110385. * @param gizmoLayer The utility layer the gizmo will be added to
  110386. */
  110387. constructor(gizmoLayer?: UtilityLayerRenderer);
  110388. updateGizmoRotationToMatchAttachedMesh: boolean;
  110389. /**
  110390. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110391. */
  110392. snapDistance: number;
  110393. /**
  110394. * Ratio for the scale of the gizmo (Default: 1)
  110395. */
  110396. scaleRatio: number;
  110397. /**
  110398. * Disposes of the gizmo
  110399. */
  110400. dispose(): void;
  110401. }
  110402. }
  110403. declare module BABYLON {
  110404. /**
  110405. * Single axis scale gizmo
  110406. */
  110407. export class AxisScaleGizmo extends Gizmo {
  110408. /**
  110409. * Drag behavior responsible for the gizmos dragging interactions
  110410. */
  110411. dragBehavior: PointerDragBehavior;
  110412. private _pointerObserver;
  110413. /**
  110414. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110415. */
  110416. snapDistance: number;
  110417. /**
  110418. * Event that fires each time the gizmo snaps to a new location.
  110419. * * snapDistance is the the change in distance
  110420. */
  110421. onSnapObservable: Observable<{
  110422. snapDistance: number;
  110423. }>;
  110424. /**
  110425. * If the scaling operation should be done on all axis (default: false)
  110426. */
  110427. uniformScaling: boolean;
  110428. private _isEnabled;
  110429. private _parent;
  110430. private _arrow;
  110431. private _coloredMaterial;
  110432. private _hoverMaterial;
  110433. /**
  110434. * Creates an AxisScaleGizmo
  110435. * @param gizmoLayer The utility layer the gizmo will be added to
  110436. * @param dragAxis The axis which the gizmo will be able to scale on
  110437. * @param color The color of the gizmo
  110438. */
  110439. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  110440. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110441. /**
  110442. * If the gizmo is enabled
  110443. */
  110444. isEnabled: boolean;
  110445. /**
  110446. * Disposes of the gizmo
  110447. */
  110448. dispose(): void;
  110449. /**
  110450. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  110451. * @param mesh The mesh to replace the default mesh of the gizmo
  110452. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  110453. */
  110454. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  110455. }
  110456. }
  110457. declare module BABYLON {
  110458. /**
  110459. * Bounding box gizmo
  110460. */
  110461. export class BoundingBoxGizmo extends Gizmo {
  110462. private _lineBoundingBox;
  110463. private _rotateSpheresParent;
  110464. private _scaleBoxesParent;
  110465. private _boundingDimensions;
  110466. private _renderObserver;
  110467. private _pointerObserver;
  110468. private _scaleDragSpeed;
  110469. private _tmpQuaternion;
  110470. private _tmpVector;
  110471. private _tmpRotationMatrix;
  110472. /**
  110473. * 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)
  110474. */
  110475. ignoreChildren: boolean;
  110476. /**
  110477. * 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)
  110478. */
  110479. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  110480. /**
  110481. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  110482. */
  110483. rotationSphereSize: number;
  110484. /**
  110485. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  110486. */
  110487. scaleBoxSize: number;
  110488. /**
  110489. * 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)
  110490. */
  110491. fixedDragMeshScreenSize: boolean;
  110492. /**
  110493. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  110494. */
  110495. fixedDragMeshScreenSizeDistanceFactor: number;
  110496. /**
  110497. * Fired when a rotation sphere or scale box is dragged
  110498. */
  110499. onDragStartObservable: Observable<{}>;
  110500. /**
  110501. * Fired when a scale box is dragged
  110502. */
  110503. onScaleBoxDragObservable: Observable<{}>;
  110504. /**
  110505. * Fired when a scale box drag is ended
  110506. */
  110507. onScaleBoxDragEndObservable: Observable<{}>;
  110508. /**
  110509. * Fired when a rotation sphere is dragged
  110510. */
  110511. onRotationSphereDragObservable: Observable<{}>;
  110512. /**
  110513. * Fired when a rotation sphere drag is ended
  110514. */
  110515. onRotationSphereDragEndObservable: Observable<{}>;
  110516. /**
  110517. * 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)
  110518. */
  110519. scalePivot: Nullable<Vector3>;
  110520. /**
  110521. * Mesh used as a pivot to rotate the attached mesh
  110522. */
  110523. private _anchorMesh;
  110524. private _existingMeshScale;
  110525. private _dragMesh;
  110526. private pointerDragBehavior;
  110527. private coloredMaterial;
  110528. private hoverColoredMaterial;
  110529. /**
  110530. * Sets the color of the bounding box gizmo
  110531. * @param color the color to set
  110532. */
  110533. setColor(color: Color3): void;
  110534. /**
  110535. * Creates an BoundingBoxGizmo
  110536. * @param gizmoLayer The utility layer the gizmo will be added to
  110537. * @param color The color of the gizmo
  110538. */
  110539. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  110540. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110541. private _selectNode;
  110542. /**
  110543. * Updates the bounding box information for the Gizmo
  110544. */
  110545. updateBoundingBox(): void;
  110546. private _updateRotationSpheres;
  110547. private _updateScaleBoxes;
  110548. /**
  110549. * Enables rotation on the specified axis and disables rotation on the others
  110550. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  110551. */
  110552. setEnabledRotationAxis(axis: string): void;
  110553. /**
  110554. * Enables/disables scaling
  110555. * @param enable if scaling should be enabled
  110556. */
  110557. setEnabledScaling(enable: boolean): void;
  110558. private _updateDummy;
  110559. /**
  110560. * Enables a pointer drag behavior on the bounding box of the gizmo
  110561. */
  110562. enableDragBehavior(): void;
  110563. /**
  110564. * Disposes of the gizmo
  110565. */
  110566. dispose(): void;
  110567. /**
  110568. * 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)
  110569. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  110570. * @returns the bounding box mesh with the passed in mesh as a child
  110571. */
  110572. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  110573. /**
  110574. * CustomMeshes are not supported by this gizmo
  110575. * @param mesh The mesh to replace the default mesh of the gizmo
  110576. */
  110577. setCustomMesh(mesh: Mesh): void;
  110578. }
  110579. }
  110580. declare module BABYLON {
  110581. /**
  110582. * Single plane rotation gizmo
  110583. */
  110584. export class PlaneRotationGizmo extends Gizmo {
  110585. /**
  110586. * Drag behavior responsible for the gizmos dragging interactions
  110587. */
  110588. dragBehavior: PointerDragBehavior;
  110589. private _pointerObserver;
  110590. /**
  110591. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  110592. */
  110593. snapDistance: number;
  110594. /**
  110595. * Event that fires each time the gizmo snaps to a new location.
  110596. * * snapDistance is the the change in distance
  110597. */
  110598. onSnapObservable: Observable<{
  110599. snapDistance: number;
  110600. }>;
  110601. private _isEnabled;
  110602. private _parent;
  110603. /**
  110604. * Creates a PlaneRotationGizmo
  110605. * @param gizmoLayer The utility layer the gizmo will be added to
  110606. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  110607. * @param color The color of the gizmo
  110608. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110609. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110610. */
  110611. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  110612. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  110613. /**
  110614. * If the gizmo is enabled
  110615. */
  110616. isEnabled: boolean;
  110617. /**
  110618. * Disposes of the gizmo
  110619. */
  110620. dispose(): void;
  110621. }
  110622. }
  110623. declare module BABYLON {
  110624. /**
  110625. * Gizmo that enables rotating a mesh along 3 axis
  110626. */
  110627. export class RotationGizmo extends Gizmo {
  110628. /**
  110629. * Internal gizmo used for interactions on the x axis
  110630. */
  110631. xGizmo: PlaneRotationGizmo;
  110632. /**
  110633. * Internal gizmo used for interactions on the y axis
  110634. */
  110635. yGizmo: PlaneRotationGizmo;
  110636. /**
  110637. * Internal gizmo used for interactions on the z axis
  110638. */
  110639. zGizmo: PlaneRotationGizmo;
  110640. /** Fires an event when any of it's sub gizmos are dragged */
  110641. onDragStartObservable: Observable<unknown>;
  110642. /** Fires an event when any of it's sub gizmos are released from dragging */
  110643. onDragEndObservable: Observable<unknown>;
  110644. private _meshAttached;
  110645. attachedMesh: Nullable<AbstractMesh>;
  110646. /**
  110647. * Creates a RotationGizmo
  110648. * @param gizmoLayer The utility layer the gizmo will be added to
  110649. * @param tessellation Amount of tessellation to be used when creating rotation circles
  110650. * @param useEulerRotation Use and update Euler angle instead of quaternion
  110651. */
  110652. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  110653. updateGizmoRotationToMatchAttachedMesh: boolean;
  110654. /**
  110655. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  110656. */
  110657. snapDistance: number;
  110658. /**
  110659. * Ratio for the scale of the gizmo (Default: 1)
  110660. */
  110661. scaleRatio: number;
  110662. /**
  110663. * Disposes of the gizmo
  110664. */
  110665. dispose(): void;
  110666. /**
  110667. * CustomMeshes are not supported by this gizmo
  110668. * @param mesh The mesh to replace the default mesh of the gizmo
  110669. */
  110670. setCustomMesh(mesh: Mesh): void;
  110671. }
  110672. }
  110673. declare module BABYLON {
  110674. /**
  110675. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  110676. */
  110677. export class GizmoManager implements IDisposable {
  110678. private scene;
  110679. /**
  110680. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  110681. */
  110682. gizmos: {
  110683. positionGizmo: Nullable<PositionGizmo>;
  110684. rotationGizmo: Nullable<RotationGizmo>;
  110685. scaleGizmo: Nullable<ScaleGizmo>;
  110686. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  110687. };
  110688. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  110689. clearGizmoOnEmptyPointerEvent: boolean;
  110690. /** Fires an event when the manager is attached to a mesh */
  110691. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  110692. private _gizmosEnabled;
  110693. private _pointerObserver;
  110694. private _attachedMesh;
  110695. private _boundingBoxColor;
  110696. private _defaultUtilityLayer;
  110697. private _defaultKeepDepthUtilityLayer;
  110698. /**
  110699. * When bounding box gizmo is enabled, this can be used to track drag/end events
  110700. */
  110701. boundingBoxDragBehavior: SixDofDragBehavior;
  110702. /**
  110703. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  110704. */
  110705. attachableMeshes: Nullable<Array<AbstractMesh>>;
  110706. /**
  110707. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  110708. */
  110709. usePointerToAttachGizmos: boolean;
  110710. /**
  110711. * Utility layer that the bounding box gizmo belongs to
  110712. */
  110713. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  110714. /**
  110715. * Utility layer that all gizmos besides bounding box belong to
  110716. */
  110717. readonly utilityLayer: UtilityLayerRenderer;
  110718. /**
  110719. * Instatiates a gizmo manager
  110720. * @param scene the scene to overlay the gizmos on top of
  110721. */
  110722. constructor(scene: Scene);
  110723. /**
  110724. * Attaches a set of gizmos to the specified mesh
  110725. * @param mesh The mesh the gizmo's should be attached to
  110726. */
  110727. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  110728. /**
  110729. * If the position gizmo is enabled
  110730. */
  110731. positionGizmoEnabled: boolean;
  110732. /**
  110733. * If the rotation gizmo is enabled
  110734. */
  110735. rotationGizmoEnabled: boolean;
  110736. /**
  110737. * If the scale gizmo is enabled
  110738. */
  110739. scaleGizmoEnabled: boolean;
  110740. /**
  110741. * If the boundingBox gizmo is enabled
  110742. */
  110743. boundingBoxGizmoEnabled: boolean;
  110744. /**
  110745. * Disposes of the gizmo manager
  110746. */
  110747. dispose(): void;
  110748. }
  110749. }
  110750. declare module BABYLON {
  110751. /**
  110752. * A directional light is defined by a direction (what a surprise!).
  110753. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  110754. * 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.
  110755. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110756. */
  110757. export class DirectionalLight extends ShadowLight {
  110758. private _shadowFrustumSize;
  110759. /**
  110760. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  110761. */
  110762. /**
  110763. * Specifies a fix frustum size for the shadow generation.
  110764. */
  110765. shadowFrustumSize: number;
  110766. private _shadowOrthoScale;
  110767. /**
  110768. * Gets the shadow projection scale against the optimal computed one.
  110769. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110770. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110771. */
  110772. /**
  110773. * Sets the shadow projection scale against the optimal computed one.
  110774. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  110775. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  110776. */
  110777. shadowOrthoScale: number;
  110778. /**
  110779. * Automatically compute the projection matrix to best fit (including all the casters)
  110780. * on each frame.
  110781. */
  110782. autoUpdateExtends: boolean;
  110783. private _orthoLeft;
  110784. private _orthoRight;
  110785. private _orthoTop;
  110786. private _orthoBottom;
  110787. /**
  110788. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  110789. * The directional light is emitted from everywhere in the given direction.
  110790. * It can cast shadows.
  110791. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110792. * @param name The friendly name of the light
  110793. * @param direction The direction of the light
  110794. * @param scene The scene the light belongs to
  110795. */
  110796. constructor(name: string, direction: Vector3, scene: Scene);
  110797. /**
  110798. * Returns the string "DirectionalLight".
  110799. * @return The class name
  110800. */
  110801. getClassName(): string;
  110802. /**
  110803. * Returns the integer 1.
  110804. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110805. */
  110806. getTypeID(): number;
  110807. /**
  110808. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  110809. * Returns the DirectionalLight Shadow projection matrix.
  110810. */
  110811. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110812. /**
  110813. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  110814. * Returns the DirectionalLight Shadow projection matrix.
  110815. */
  110816. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  110817. /**
  110818. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  110819. * Returns the DirectionalLight Shadow projection matrix.
  110820. */
  110821. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110822. protected _buildUniformLayout(): void;
  110823. /**
  110824. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  110825. * @param effect The effect to update
  110826. * @param lightIndex The index of the light in the effect to update
  110827. * @returns The directional light
  110828. */
  110829. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  110830. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  110831. /**
  110832. * Gets the minZ used for shadow according to both the scene and the light.
  110833. *
  110834. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110835. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110836. * @param activeCamera The camera we are returning the min for
  110837. * @returns the depth min z
  110838. */
  110839. getDepthMinZ(activeCamera: Camera): number;
  110840. /**
  110841. * Gets the maxZ used for shadow according to both the scene and the light.
  110842. *
  110843. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  110844. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  110845. * @param activeCamera The camera we are returning the max for
  110846. * @returns the depth max z
  110847. */
  110848. getDepthMaxZ(activeCamera: Camera): number;
  110849. /**
  110850. * Prepares the list of defines specific to the light type.
  110851. * @param defines the list of defines
  110852. * @param lightIndex defines the index of the light for the effect
  110853. */
  110854. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110855. }
  110856. }
  110857. declare module BABYLON {
  110858. /**
  110859. * Class containing static functions to help procedurally build meshes
  110860. */
  110861. export class HemisphereBuilder {
  110862. /**
  110863. * Creates a hemisphere mesh
  110864. * @param name defines the name of the mesh
  110865. * @param options defines the options used to create the mesh
  110866. * @param scene defines the hosting scene
  110867. * @returns the hemisphere mesh
  110868. */
  110869. static CreateHemisphere(name: string, options: {
  110870. segments?: number;
  110871. diameter?: number;
  110872. sideOrientation?: number;
  110873. }, scene: any): Mesh;
  110874. }
  110875. }
  110876. declare module BABYLON {
  110877. /**
  110878. * A spot light is defined by a position, a direction, an angle, and an exponent.
  110879. * These values define a cone of light starting from the position, emitting toward the direction.
  110880. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  110881. * and the exponent defines the speed of the decay of the light with distance (reach).
  110882. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110883. */
  110884. export class SpotLight extends ShadowLight {
  110885. private _angle;
  110886. private _innerAngle;
  110887. private _cosHalfAngle;
  110888. private _lightAngleScale;
  110889. private _lightAngleOffset;
  110890. /**
  110891. * Gets the cone angle of the spot light in Radians.
  110892. */
  110893. /**
  110894. * Sets the cone angle of the spot light in Radians.
  110895. */
  110896. angle: number;
  110897. /**
  110898. * Only used in gltf falloff mode, this defines the angle where
  110899. * the directional falloff will start before cutting at angle which could be seen
  110900. * as outer angle.
  110901. */
  110902. /**
  110903. * Only used in gltf falloff mode, this defines the angle where
  110904. * the directional falloff will start before cutting at angle which could be seen
  110905. * as outer angle.
  110906. */
  110907. innerAngle: number;
  110908. private _shadowAngleScale;
  110909. /**
  110910. * Allows scaling the angle of the light for shadow generation only.
  110911. */
  110912. /**
  110913. * Allows scaling the angle of the light for shadow generation only.
  110914. */
  110915. shadowAngleScale: number;
  110916. /**
  110917. * The light decay speed with the distance from the emission spot.
  110918. */
  110919. exponent: number;
  110920. private _projectionTextureMatrix;
  110921. /**
  110922. * Allows reading the projecton texture
  110923. */
  110924. readonly projectionTextureMatrix: Matrix;
  110925. protected _projectionTextureLightNear: number;
  110926. /**
  110927. * Gets the near clip of the Spotlight for texture projection.
  110928. */
  110929. /**
  110930. * Sets the near clip of the Spotlight for texture projection.
  110931. */
  110932. projectionTextureLightNear: number;
  110933. protected _projectionTextureLightFar: number;
  110934. /**
  110935. * Gets the far clip of the Spotlight for texture projection.
  110936. */
  110937. /**
  110938. * Sets the far clip of the Spotlight for texture projection.
  110939. */
  110940. projectionTextureLightFar: number;
  110941. protected _projectionTextureUpDirection: Vector3;
  110942. /**
  110943. * Gets the Up vector of the Spotlight for texture projection.
  110944. */
  110945. /**
  110946. * Sets the Up vector of the Spotlight for texture projection.
  110947. */
  110948. projectionTextureUpDirection: Vector3;
  110949. private _projectionTexture;
  110950. /**
  110951. * Gets the projection texture of the light.
  110952. */
  110953. /**
  110954. * Sets the projection texture of the light.
  110955. */
  110956. projectionTexture: Nullable<BaseTexture>;
  110957. private _projectionTextureViewLightDirty;
  110958. private _projectionTextureProjectionLightDirty;
  110959. private _projectionTextureDirty;
  110960. private _projectionTextureViewTargetVector;
  110961. private _projectionTextureViewLightMatrix;
  110962. private _projectionTextureProjectionLightMatrix;
  110963. private _projectionTextureScalingMatrix;
  110964. /**
  110965. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  110966. * It can cast shadows.
  110967. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110968. * @param name The light friendly name
  110969. * @param position The position of the spot light in the scene
  110970. * @param direction The direction of the light in the scene
  110971. * @param angle The cone angle of the light in Radians
  110972. * @param exponent The light decay speed with the distance from the emission spot
  110973. * @param scene The scene the lights belongs to
  110974. */
  110975. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  110976. /**
  110977. * Returns the string "SpotLight".
  110978. * @returns the class name
  110979. */
  110980. getClassName(): string;
  110981. /**
  110982. * Returns the integer 2.
  110983. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110984. */
  110985. getTypeID(): number;
  110986. /**
  110987. * Overrides the direction setter to recompute the projection texture view light Matrix.
  110988. */
  110989. protected _setDirection(value: Vector3): void;
  110990. /**
  110991. * Overrides the position setter to recompute the projection texture view light Matrix.
  110992. */
  110993. protected _setPosition(value: Vector3): void;
  110994. /**
  110995. * 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.
  110996. * Returns the SpotLight.
  110997. */
  110998. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110999. protected _computeProjectionTextureViewLightMatrix(): void;
  111000. protected _computeProjectionTextureProjectionLightMatrix(): void;
  111001. /**
  111002. * Main function for light texture projection matrix computing.
  111003. */
  111004. protected _computeProjectionTextureMatrix(): void;
  111005. protected _buildUniformLayout(): void;
  111006. private _computeAngleValues;
  111007. /**
  111008. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  111009. * @param effect The effect to update
  111010. * @param lightIndex The index of the light in the effect to update
  111011. * @returns The spot light
  111012. */
  111013. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  111014. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  111015. /**
  111016. * Disposes the light and the associated resources.
  111017. */
  111018. dispose(): void;
  111019. /**
  111020. * Prepares the list of defines specific to the light type.
  111021. * @param defines the list of defines
  111022. * @param lightIndex defines the index of the light for the effect
  111023. */
  111024. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111025. }
  111026. }
  111027. declare module BABYLON {
  111028. /**
  111029. * Gizmo that enables viewing a light
  111030. */
  111031. export class LightGizmo extends Gizmo {
  111032. private _lightMesh;
  111033. private _material;
  111034. private cachedPosition;
  111035. private cachedForward;
  111036. /**
  111037. * Creates a LightGizmo
  111038. * @param gizmoLayer The utility layer the gizmo will be added to
  111039. */
  111040. constructor(gizmoLayer?: UtilityLayerRenderer);
  111041. private _light;
  111042. /**
  111043. * The light that the gizmo is attached to
  111044. */
  111045. light: Nullable<Light>;
  111046. /**
  111047. * Gets the material used to render the light gizmo
  111048. */
  111049. readonly material: StandardMaterial;
  111050. /**
  111051. * @hidden
  111052. * Updates the gizmo to match the attached mesh's position/rotation
  111053. */
  111054. protected _update(): void;
  111055. private static _Scale;
  111056. /**
  111057. * Creates the lines for a light mesh
  111058. */
  111059. private static _createLightLines;
  111060. /**
  111061. * Disposes of the light gizmo
  111062. */
  111063. dispose(): void;
  111064. private static _CreateHemisphericLightMesh;
  111065. private static _CreatePointLightMesh;
  111066. private static _CreateSpotLightMesh;
  111067. private static _CreateDirectionalLightMesh;
  111068. }
  111069. }
  111070. declare module BABYLON {
  111071. /** @hidden */
  111072. export var backgroundFragmentDeclaration: {
  111073. name: string;
  111074. shader: string;
  111075. };
  111076. }
  111077. declare module BABYLON {
  111078. /** @hidden */
  111079. export var backgroundUboDeclaration: {
  111080. name: string;
  111081. shader: string;
  111082. };
  111083. }
  111084. declare module BABYLON {
  111085. /** @hidden */
  111086. export var backgroundPixelShader: {
  111087. name: string;
  111088. shader: string;
  111089. };
  111090. }
  111091. declare module BABYLON {
  111092. /** @hidden */
  111093. export var backgroundVertexDeclaration: {
  111094. name: string;
  111095. shader: string;
  111096. };
  111097. }
  111098. declare module BABYLON {
  111099. /** @hidden */
  111100. export var backgroundVertexShader: {
  111101. name: string;
  111102. shader: string;
  111103. };
  111104. }
  111105. declare module BABYLON {
  111106. /**
  111107. * Background material used to create an efficient environement around your scene.
  111108. */
  111109. export class BackgroundMaterial extends PushMaterial {
  111110. /**
  111111. * Standard reflectance value at parallel view angle.
  111112. */
  111113. static StandardReflectance0: number;
  111114. /**
  111115. * Standard reflectance value at grazing angle.
  111116. */
  111117. static StandardReflectance90: number;
  111118. protected _primaryColor: Color3;
  111119. /**
  111120. * Key light Color (multiply against the environement texture)
  111121. */
  111122. primaryColor: Color3;
  111123. protected __perceptualColor: Nullable<Color3>;
  111124. /**
  111125. * Experimental Internal Use Only.
  111126. *
  111127. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  111128. * This acts as a helper to set the primary color to a more "human friendly" value.
  111129. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  111130. * output color as close as possible from the chosen value.
  111131. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  111132. * part of lighting setup.)
  111133. */
  111134. _perceptualColor: Nullable<Color3>;
  111135. protected _primaryColorShadowLevel: float;
  111136. /**
  111137. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  111138. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  111139. */
  111140. primaryColorShadowLevel: float;
  111141. protected _primaryColorHighlightLevel: float;
  111142. /**
  111143. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  111144. * The primary color is used at the level chosen to define what the white area would look.
  111145. */
  111146. primaryColorHighlightLevel: float;
  111147. protected _reflectionTexture: Nullable<BaseTexture>;
  111148. /**
  111149. * Reflection Texture used in the material.
  111150. * Should be author in a specific way for the best result (refer to the documentation).
  111151. */
  111152. reflectionTexture: Nullable<BaseTexture>;
  111153. protected _reflectionBlur: float;
  111154. /**
  111155. * Reflection Texture level of blur.
  111156. *
  111157. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  111158. * texture twice.
  111159. */
  111160. reflectionBlur: float;
  111161. protected _diffuseTexture: Nullable<BaseTexture>;
  111162. /**
  111163. * Diffuse Texture used in the material.
  111164. * Should be author in a specific way for the best result (refer to the documentation).
  111165. */
  111166. diffuseTexture: Nullable<BaseTexture>;
  111167. protected _shadowLights: Nullable<IShadowLight[]>;
  111168. /**
  111169. * Specify the list of lights casting shadow on the material.
  111170. * All scene shadow lights will be included if null.
  111171. */
  111172. shadowLights: Nullable<IShadowLight[]>;
  111173. protected _shadowLevel: float;
  111174. /**
  111175. * Helps adjusting the shadow to a softer level if required.
  111176. * 0 means black shadows and 1 means no shadows.
  111177. */
  111178. shadowLevel: float;
  111179. protected _sceneCenter: Vector3;
  111180. /**
  111181. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  111182. * It is usually zero but might be interesting to modify according to your setup.
  111183. */
  111184. sceneCenter: Vector3;
  111185. protected _opacityFresnel: boolean;
  111186. /**
  111187. * This helps specifying that the material is falling off to the sky box at grazing angle.
  111188. * This helps ensuring a nice transition when the camera goes under the ground.
  111189. */
  111190. opacityFresnel: boolean;
  111191. protected _reflectionFresnel: boolean;
  111192. /**
  111193. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  111194. * This helps adding a mirror texture on the ground.
  111195. */
  111196. reflectionFresnel: boolean;
  111197. protected _reflectionFalloffDistance: number;
  111198. /**
  111199. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  111200. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  111201. */
  111202. reflectionFalloffDistance: number;
  111203. protected _reflectionAmount: number;
  111204. /**
  111205. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  111206. */
  111207. reflectionAmount: number;
  111208. protected _reflectionReflectance0: number;
  111209. /**
  111210. * This specifies the weight of the reflection at grazing angle.
  111211. */
  111212. reflectionReflectance0: number;
  111213. protected _reflectionReflectance90: number;
  111214. /**
  111215. * This specifies the weight of the reflection at a perpendicular point of view.
  111216. */
  111217. reflectionReflectance90: number;
  111218. /**
  111219. * Sets the reflection reflectance fresnel values according to the default standard
  111220. * empirically know to work well :-)
  111221. */
  111222. reflectionStandardFresnelWeight: number;
  111223. protected _useRGBColor: boolean;
  111224. /**
  111225. * Helps to directly use the maps channels instead of their level.
  111226. */
  111227. useRGBColor: boolean;
  111228. protected _enableNoise: boolean;
  111229. /**
  111230. * This helps reducing the banding effect that could occur on the background.
  111231. */
  111232. enableNoise: boolean;
  111233. /**
  111234. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111235. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  111236. * Recommended to be keep at 1.0 except for special cases.
  111237. */
  111238. fovMultiplier: number;
  111239. private _fovMultiplier;
  111240. /**
  111241. * Enable the FOV adjustment feature controlled by fovMultiplier.
  111242. */
  111243. useEquirectangularFOV: boolean;
  111244. private _maxSimultaneousLights;
  111245. /**
  111246. * Number of Simultaneous lights allowed on the material.
  111247. */
  111248. maxSimultaneousLights: int;
  111249. /**
  111250. * Default configuration related to image processing available in the Background Material.
  111251. */
  111252. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111253. /**
  111254. * Keep track of the image processing observer to allow dispose and replace.
  111255. */
  111256. private _imageProcessingObserver;
  111257. /**
  111258. * Attaches a new image processing configuration to the PBR Material.
  111259. * @param configuration (if null the scene configuration will be use)
  111260. */
  111261. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111262. /**
  111263. * Gets the image processing configuration used either in this material.
  111264. */
  111265. /**
  111266. * Sets the Default image processing configuration used either in the this material.
  111267. *
  111268. * If sets to null, the scene one is in use.
  111269. */
  111270. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  111271. /**
  111272. * Gets wether the color curves effect is enabled.
  111273. */
  111274. /**
  111275. * Sets wether the color curves effect is enabled.
  111276. */
  111277. cameraColorCurvesEnabled: boolean;
  111278. /**
  111279. * Gets wether the color grading effect is enabled.
  111280. */
  111281. /**
  111282. * Gets wether the color grading effect is enabled.
  111283. */
  111284. cameraColorGradingEnabled: boolean;
  111285. /**
  111286. * Gets wether tonemapping is enabled or not.
  111287. */
  111288. /**
  111289. * Sets wether tonemapping is enabled or not
  111290. */
  111291. cameraToneMappingEnabled: boolean;
  111292. /**
  111293. * The camera exposure used on this material.
  111294. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111295. * This corresponds to a photographic exposure.
  111296. */
  111297. /**
  111298. * The camera exposure used on this material.
  111299. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111300. * This corresponds to a photographic exposure.
  111301. */
  111302. cameraExposure: float;
  111303. /**
  111304. * Gets The camera contrast used on this material.
  111305. */
  111306. /**
  111307. * Sets The camera contrast used on this material.
  111308. */
  111309. cameraContrast: float;
  111310. /**
  111311. * Gets the Color Grading 2D Lookup Texture.
  111312. */
  111313. /**
  111314. * Sets the Color Grading 2D Lookup Texture.
  111315. */
  111316. cameraColorGradingTexture: Nullable<BaseTexture>;
  111317. /**
  111318. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111319. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111320. * 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;
  111321. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111322. */
  111323. /**
  111324. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111325. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111326. * 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;
  111327. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111328. */
  111329. cameraColorCurves: Nullable<ColorCurves>;
  111330. /**
  111331. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  111332. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  111333. */
  111334. switchToBGR: boolean;
  111335. private _renderTargets;
  111336. private _reflectionControls;
  111337. private _white;
  111338. private _primaryShadowColor;
  111339. private _primaryHighlightColor;
  111340. /**
  111341. * Instantiates a Background Material in the given scene
  111342. * @param name The friendly name of the material
  111343. * @param scene The scene to add the material to
  111344. */
  111345. constructor(name: string, scene: Scene);
  111346. /**
  111347. * Gets a boolean indicating that current material needs to register RTT
  111348. */
  111349. readonly hasRenderTargetTextures: boolean;
  111350. /**
  111351. * The entire material has been created in order to prevent overdraw.
  111352. * @returns false
  111353. */
  111354. needAlphaTesting(): boolean;
  111355. /**
  111356. * The entire material has been created in order to prevent overdraw.
  111357. * @returns true if blending is enable
  111358. */
  111359. needAlphaBlending(): boolean;
  111360. /**
  111361. * Checks wether the material is ready to be rendered for a given mesh.
  111362. * @param mesh The mesh to render
  111363. * @param subMesh The submesh to check against
  111364. * @param useInstances Specify wether or not the material is used with instances
  111365. * @returns true if all the dependencies are ready (Textures, Effects...)
  111366. */
  111367. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111368. /**
  111369. * Compute the primary color according to the chosen perceptual color.
  111370. */
  111371. private _computePrimaryColorFromPerceptualColor;
  111372. /**
  111373. * Compute the highlights and shadow colors according to their chosen levels.
  111374. */
  111375. private _computePrimaryColors;
  111376. /**
  111377. * Build the uniform buffer used in the material.
  111378. */
  111379. buildUniformLayout(): void;
  111380. /**
  111381. * Unbind the material.
  111382. */
  111383. unbind(): void;
  111384. /**
  111385. * Bind only the world matrix to the material.
  111386. * @param world The world matrix to bind.
  111387. */
  111388. bindOnlyWorldMatrix(world: Matrix): void;
  111389. /**
  111390. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  111391. * @param world The world matrix to bind.
  111392. * @param subMesh The submesh to bind for.
  111393. */
  111394. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111395. /**
  111396. * Checks to see if a texture is used in the material.
  111397. * @param texture - Base texture to use.
  111398. * @returns - Boolean specifying if a texture is used in the material.
  111399. */
  111400. hasTexture(texture: BaseTexture): boolean;
  111401. /**
  111402. * Dispose the material.
  111403. * @param forceDisposeEffect Force disposal of the associated effect.
  111404. * @param forceDisposeTextures Force disposal of the associated textures.
  111405. */
  111406. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111407. /**
  111408. * Clones the material.
  111409. * @param name The cloned name.
  111410. * @returns The cloned material.
  111411. */
  111412. clone(name: string): BackgroundMaterial;
  111413. /**
  111414. * Serializes the current material to its JSON representation.
  111415. * @returns The JSON representation.
  111416. */
  111417. serialize(): any;
  111418. /**
  111419. * Gets the class name of the material
  111420. * @returns "BackgroundMaterial"
  111421. */
  111422. getClassName(): string;
  111423. /**
  111424. * Parse a JSON input to create back a background material.
  111425. * @param source The JSON data to parse
  111426. * @param scene The scene to create the parsed material in
  111427. * @param rootUrl The root url of the assets the material depends upon
  111428. * @returns the instantiated BackgroundMaterial.
  111429. */
  111430. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  111431. }
  111432. }
  111433. declare module BABYLON {
  111434. /**
  111435. * Represents the different options available during the creation of
  111436. * a Environment helper.
  111437. *
  111438. * This can control the default ground, skybox and image processing setup of your scene.
  111439. */
  111440. export interface IEnvironmentHelperOptions {
  111441. /**
  111442. * Specifies wether or not to create a ground.
  111443. * True by default.
  111444. */
  111445. createGround: boolean;
  111446. /**
  111447. * Specifies the ground size.
  111448. * 15 by default.
  111449. */
  111450. groundSize: number;
  111451. /**
  111452. * The texture used on the ground for the main color.
  111453. * Comes from the BabylonJS CDN by default.
  111454. *
  111455. * Remarks: Can be either a texture or a url.
  111456. */
  111457. groundTexture: string | BaseTexture;
  111458. /**
  111459. * The color mixed in the ground texture by default.
  111460. * BabylonJS clearColor by default.
  111461. */
  111462. groundColor: Color3;
  111463. /**
  111464. * Specifies the ground opacity.
  111465. * 1 by default.
  111466. */
  111467. groundOpacity: number;
  111468. /**
  111469. * Enables the ground to receive shadows.
  111470. * True by default.
  111471. */
  111472. enableGroundShadow: boolean;
  111473. /**
  111474. * Helps preventing the shadow to be fully black on the ground.
  111475. * 0.5 by default.
  111476. */
  111477. groundShadowLevel: number;
  111478. /**
  111479. * Creates a mirror texture attach to the ground.
  111480. * false by default.
  111481. */
  111482. enableGroundMirror: boolean;
  111483. /**
  111484. * Specifies the ground mirror size ratio.
  111485. * 0.3 by default as the default kernel is 64.
  111486. */
  111487. groundMirrorSizeRatio: number;
  111488. /**
  111489. * Specifies the ground mirror blur kernel size.
  111490. * 64 by default.
  111491. */
  111492. groundMirrorBlurKernel: number;
  111493. /**
  111494. * Specifies the ground mirror visibility amount.
  111495. * 1 by default
  111496. */
  111497. groundMirrorAmount: number;
  111498. /**
  111499. * Specifies the ground mirror reflectance weight.
  111500. * This uses the standard weight of the background material to setup the fresnel effect
  111501. * of the mirror.
  111502. * 1 by default.
  111503. */
  111504. groundMirrorFresnelWeight: number;
  111505. /**
  111506. * Specifies the ground mirror Falloff distance.
  111507. * This can helps reducing the size of the reflection.
  111508. * 0 by Default.
  111509. */
  111510. groundMirrorFallOffDistance: number;
  111511. /**
  111512. * Specifies the ground mirror texture type.
  111513. * Unsigned Int by Default.
  111514. */
  111515. groundMirrorTextureType: number;
  111516. /**
  111517. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  111518. * the shown objects.
  111519. */
  111520. groundYBias: number;
  111521. /**
  111522. * Specifies wether or not to create a skybox.
  111523. * True by default.
  111524. */
  111525. createSkybox: boolean;
  111526. /**
  111527. * Specifies the skybox size.
  111528. * 20 by default.
  111529. */
  111530. skyboxSize: number;
  111531. /**
  111532. * The texture used on the skybox for the main color.
  111533. * Comes from the BabylonJS CDN by default.
  111534. *
  111535. * Remarks: Can be either a texture or a url.
  111536. */
  111537. skyboxTexture: string | BaseTexture;
  111538. /**
  111539. * The color mixed in the skybox texture by default.
  111540. * BabylonJS clearColor by default.
  111541. */
  111542. skyboxColor: Color3;
  111543. /**
  111544. * The background rotation around the Y axis of the scene.
  111545. * This helps aligning the key lights of your scene with the background.
  111546. * 0 by default.
  111547. */
  111548. backgroundYRotation: number;
  111549. /**
  111550. * Compute automatically the size of the elements to best fit with the scene.
  111551. */
  111552. sizeAuto: boolean;
  111553. /**
  111554. * Default position of the rootMesh if autoSize is not true.
  111555. */
  111556. rootPosition: Vector3;
  111557. /**
  111558. * Sets up the image processing in the scene.
  111559. * true by default.
  111560. */
  111561. setupImageProcessing: boolean;
  111562. /**
  111563. * The texture used as your environment texture in the scene.
  111564. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  111565. *
  111566. * Remarks: Can be either a texture or a url.
  111567. */
  111568. environmentTexture: string | BaseTexture;
  111569. /**
  111570. * The value of the exposure to apply to the scene.
  111571. * 0.6 by default if setupImageProcessing is true.
  111572. */
  111573. cameraExposure: number;
  111574. /**
  111575. * The value of the contrast to apply to the scene.
  111576. * 1.6 by default if setupImageProcessing is true.
  111577. */
  111578. cameraContrast: number;
  111579. /**
  111580. * Specifies wether or not tonemapping should be enabled in the scene.
  111581. * true by default if setupImageProcessing is true.
  111582. */
  111583. toneMappingEnabled: boolean;
  111584. }
  111585. /**
  111586. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  111587. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  111588. * It also helps with the default setup of your imageProcessing configuration.
  111589. */
  111590. export class EnvironmentHelper {
  111591. /**
  111592. * Default ground texture URL.
  111593. */
  111594. private static _groundTextureCDNUrl;
  111595. /**
  111596. * Default skybox texture URL.
  111597. */
  111598. private static _skyboxTextureCDNUrl;
  111599. /**
  111600. * Default environment texture URL.
  111601. */
  111602. private static _environmentTextureCDNUrl;
  111603. /**
  111604. * Creates the default options for the helper.
  111605. */
  111606. private static _getDefaultOptions;
  111607. private _rootMesh;
  111608. /**
  111609. * Gets the root mesh created by the helper.
  111610. */
  111611. readonly rootMesh: Mesh;
  111612. private _skybox;
  111613. /**
  111614. * Gets the skybox created by the helper.
  111615. */
  111616. readonly skybox: Nullable<Mesh>;
  111617. private _skyboxTexture;
  111618. /**
  111619. * Gets the skybox texture created by the helper.
  111620. */
  111621. readonly skyboxTexture: Nullable<BaseTexture>;
  111622. private _skyboxMaterial;
  111623. /**
  111624. * Gets the skybox material created by the helper.
  111625. */
  111626. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  111627. private _ground;
  111628. /**
  111629. * Gets the ground mesh created by the helper.
  111630. */
  111631. readonly ground: Nullable<Mesh>;
  111632. private _groundTexture;
  111633. /**
  111634. * Gets the ground texture created by the helper.
  111635. */
  111636. readonly groundTexture: Nullable<BaseTexture>;
  111637. private _groundMirror;
  111638. /**
  111639. * Gets the ground mirror created by the helper.
  111640. */
  111641. readonly groundMirror: Nullable<MirrorTexture>;
  111642. /**
  111643. * Gets the ground mirror render list to helps pushing the meshes
  111644. * you wish in the ground reflection.
  111645. */
  111646. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  111647. private _groundMaterial;
  111648. /**
  111649. * Gets the ground material created by the helper.
  111650. */
  111651. readonly groundMaterial: Nullable<BackgroundMaterial>;
  111652. /**
  111653. * Stores the creation options.
  111654. */
  111655. private readonly _scene;
  111656. private _options;
  111657. /**
  111658. * This observable will be notified with any error during the creation of the environment,
  111659. * mainly texture creation errors.
  111660. */
  111661. onErrorObservable: Observable<{
  111662. message?: string;
  111663. exception?: any;
  111664. }>;
  111665. /**
  111666. * constructor
  111667. * @param options Defines the options we want to customize the helper
  111668. * @param scene The scene to add the material to
  111669. */
  111670. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  111671. /**
  111672. * Updates the background according to the new options
  111673. * @param options
  111674. */
  111675. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  111676. /**
  111677. * Sets the primary color of all the available elements.
  111678. * @param color the main color to affect to the ground and the background
  111679. */
  111680. setMainColor(color: Color3): void;
  111681. /**
  111682. * Setup the image processing according to the specified options.
  111683. */
  111684. private _setupImageProcessing;
  111685. /**
  111686. * Setup the environment texture according to the specified options.
  111687. */
  111688. private _setupEnvironmentTexture;
  111689. /**
  111690. * Setup the background according to the specified options.
  111691. */
  111692. private _setupBackground;
  111693. /**
  111694. * Get the scene sizes according to the setup.
  111695. */
  111696. private _getSceneSize;
  111697. /**
  111698. * Setup the ground according to the specified options.
  111699. */
  111700. private _setupGround;
  111701. /**
  111702. * Setup the ground material according to the specified options.
  111703. */
  111704. private _setupGroundMaterial;
  111705. /**
  111706. * Setup the ground diffuse texture according to the specified options.
  111707. */
  111708. private _setupGroundDiffuseTexture;
  111709. /**
  111710. * Setup the ground mirror texture according to the specified options.
  111711. */
  111712. private _setupGroundMirrorTexture;
  111713. /**
  111714. * Setup the ground to receive the mirror texture.
  111715. */
  111716. private _setupMirrorInGroundMaterial;
  111717. /**
  111718. * Setup the skybox according to the specified options.
  111719. */
  111720. private _setupSkybox;
  111721. /**
  111722. * Setup the skybox material according to the specified options.
  111723. */
  111724. private _setupSkyboxMaterial;
  111725. /**
  111726. * Setup the skybox reflection texture according to the specified options.
  111727. */
  111728. private _setupSkyboxReflectionTexture;
  111729. private _errorHandler;
  111730. /**
  111731. * Dispose all the elements created by the Helper.
  111732. */
  111733. dispose(): void;
  111734. }
  111735. }
  111736. declare module BABYLON {
  111737. /**
  111738. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  111739. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  111740. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  111741. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  111742. */
  111743. export class PhotoDome extends TransformNode {
  111744. /**
  111745. * Define the image as a Monoscopic panoramic 360 image.
  111746. */
  111747. static readonly MODE_MONOSCOPIC: number;
  111748. /**
  111749. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111750. */
  111751. static readonly MODE_TOPBOTTOM: number;
  111752. /**
  111753. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111754. */
  111755. static readonly MODE_SIDEBYSIDE: number;
  111756. private _useDirectMapping;
  111757. /**
  111758. * The texture being displayed on the sphere
  111759. */
  111760. protected _photoTexture: Texture;
  111761. /**
  111762. * Gets or sets the texture being displayed on the sphere
  111763. */
  111764. photoTexture: Texture;
  111765. /**
  111766. * Observable raised when an error occured while loading the 360 image
  111767. */
  111768. onLoadErrorObservable: Observable<string>;
  111769. /**
  111770. * The skybox material
  111771. */
  111772. protected _material: BackgroundMaterial;
  111773. /**
  111774. * The surface used for the skybox
  111775. */
  111776. protected _mesh: Mesh;
  111777. /**
  111778. * Gets the mesh used for the skybox.
  111779. */
  111780. readonly mesh: Mesh;
  111781. /**
  111782. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111783. * Also see the options.resolution property.
  111784. */
  111785. fovMultiplier: number;
  111786. private _imageMode;
  111787. /**
  111788. * Gets or set the current video mode for the video. It can be:
  111789. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  111790. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  111791. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  111792. */
  111793. imageMode: number;
  111794. /**
  111795. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  111796. * @param name Element's name, child elements will append suffixes for their own names.
  111797. * @param urlsOfPhoto defines the url of the photo to display
  111798. * @param options defines an object containing optional or exposed sub element properties
  111799. * @param onError defines a callback called when an error occured while loading the texture
  111800. */
  111801. constructor(name: string, urlOfPhoto: string, options: {
  111802. resolution?: number;
  111803. size?: number;
  111804. useDirectMapping?: boolean;
  111805. faceForward?: boolean;
  111806. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  111807. private _onBeforeCameraRenderObserver;
  111808. private _changeImageMode;
  111809. /**
  111810. * Releases resources associated with this node.
  111811. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111812. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111813. */
  111814. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111815. }
  111816. }
  111817. declare module BABYLON {
  111818. /**
  111819. * Class used to host RGBD texture specific utilities
  111820. */
  111821. export class RGBDTextureTools {
  111822. /**
  111823. * Expand the RGBD Texture from RGBD to Half Float if possible.
  111824. * @param texture the texture to expand.
  111825. */
  111826. static ExpandRGBDTexture(texture: Texture): void;
  111827. }
  111828. }
  111829. declare module BABYLON {
  111830. /**
  111831. * Class used to host texture specific utilities
  111832. */
  111833. export class BRDFTextureTools {
  111834. /**
  111835. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  111836. * @param scene defines the hosting scene
  111837. * @returns the environment BRDF texture
  111838. */
  111839. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  111840. private static _environmentBRDFBase64Texture;
  111841. }
  111842. }
  111843. declare module BABYLON {
  111844. /**
  111845. * @hidden
  111846. */
  111847. export interface IMaterialClearCoatDefines {
  111848. CLEARCOAT: boolean;
  111849. CLEARCOAT_DEFAULTIOR: boolean;
  111850. CLEARCOAT_TEXTURE: boolean;
  111851. CLEARCOAT_TEXTUREDIRECTUV: number;
  111852. CLEARCOAT_BUMP: boolean;
  111853. CLEARCOAT_BUMPDIRECTUV: number;
  111854. CLEARCOAT_TINT: boolean;
  111855. CLEARCOAT_TINT_TEXTURE: boolean;
  111856. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  111857. /** @hidden */
  111858. _areTexturesDirty: boolean;
  111859. }
  111860. /**
  111861. * Define the code related to the clear coat parameters of the pbr material.
  111862. */
  111863. export class PBRClearCoatConfiguration {
  111864. /**
  111865. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111866. * The default fits with a polyurethane material.
  111867. */
  111868. private static readonly _DefaultIndexOfRefraction;
  111869. private _isEnabled;
  111870. /**
  111871. * Defines if the clear coat is enabled in the material.
  111872. */
  111873. isEnabled: boolean;
  111874. /**
  111875. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  111876. */
  111877. intensity: number;
  111878. /**
  111879. * Defines the clear coat layer roughness.
  111880. */
  111881. roughness: number;
  111882. private _indexOfRefraction;
  111883. /**
  111884. * Defines the index of refraction of the clear coat.
  111885. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  111886. * The default fits with a polyurethane material.
  111887. * Changing the default value is more performance intensive.
  111888. */
  111889. indexOfRefraction: number;
  111890. private _texture;
  111891. /**
  111892. * Stores the clear coat values in a texture.
  111893. */
  111894. texture: Nullable<BaseTexture>;
  111895. private _bumpTexture;
  111896. /**
  111897. * Define the clear coat specific bump texture.
  111898. */
  111899. bumpTexture: Nullable<BaseTexture>;
  111900. private _isTintEnabled;
  111901. /**
  111902. * Defines if the clear coat tint is enabled in the material.
  111903. */
  111904. isTintEnabled: boolean;
  111905. /**
  111906. * Defines the clear coat tint of the material.
  111907. * This is only use if tint is enabled
  111908. */
  111909. tintColor: Color3;
  111910. /**
  111911. * Defines the distance at which the tint color should be found in the
  111912. * clear coat media.
  111913. * This is only use if tint is enabled
  111914. */
  111915. tintColorAtDistance: number;
  111916. /**
  111917. * Defines the clear coat layer thickness.
  111918. * This is only use if tint is enabled
  111919. */
  111920. tintThickness: number;
  111921. private _tintTexture;
  111922. /**
  111923. * Stores the clear tint values in a texture.
  111924. * rgb is tint
  111925. * a is a thickness factor
  111926. */
  111927. tintTexture: Nullable<BaseTexture>;
  111928. /** @hidden */
  111929. private _internalMarkAllSubMeshesAsTexturesDirty;
  111930. /** @hidden */
  111931. _markAllSubMeshesAsTexturesDirty(): void;
  111932. /**
  111933. * Instantiate a new istance of clear coat configuration.
  111934. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  111935. */
  111936. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  111937. /**
  111938. * Gets wehter the submesh is ready to be used or not.
  111939. * @param defines the list of "defines" to update.
  111940. * @param scene defines the scene the material belongs to.
  111941. * @param engine defines the engine the material belongs to.
  111942. * @param disableBumpMap defines wether the material disables bump or not.
  111943. * @returns - boolean indicating that the submesh is ready or not.
  111944. */
  111945. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  111946. /**
  111947. * Checks to see if a texture is used in the material.
  111948. * @param defines the list of "defines" to update.
  111949. * @param scene defines the scene to the material belongs to.
  111950. */
  111951. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  111952. /**
  111953. * Binds the material data.
  111954. * @param uniformBuffer defines the Uniform buffer to fill in.
  111955. * @param scene defines the scene the material belongs to.
  111956. * @param engine defines the engine the material belongs to.
  111957. * @param disableBumpMap defines wether the material disables bump or not.
  111958. * @param isFrozen defines wether the material is frozen or not.
  111959. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  111960. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  111961. */
  111962. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  111963. /**
  111964. * Checks to see if a texture is used in the material.
  111965. * @param texture - Base texture to use.
  111966. * @returns - Boolean specifying if a texture is used in the material.
  111967. */
  111968. hasTexture(texture: BaseTexture): boolean;
  111969. /**
  111970. * Returns an array of the actively used textures.
  111971. * @param activeTextures Array of BaseTextures
  111972. */
  111973. getActiveTextures(activeTextures: BaseTexture[]): void;
  111974. /**
  111975. * Returns the animatable textures.
  111976. * @param animatables Array of animatable textures.
  111977. */
  111978. getAnimatables(animatables: IAnimatable[]): void;
  111979. /**
  111980. * Disposes the resources of the material.
  111981. * @param forceDisposeTextures - Forces the disposal of all textures.
  111982. */
  111983. dispose(forceDisposeTextures?: boolean): void;
  111984. /**
  111985. * Get the current class name of the texture useful for serialization or dynamic coding.
  111986. * @returns "PBRClearCoatConfiguration"
  111987. */
  111988. getClassName(): string;
  111989. /**
  111990. * Add fallbacks to the effect fallbacks list.
  111991. * @param defines defines the Base texture to use.
  111992. * @param fallbacks defines the current fallback list.
  111993. * @param currentRank defines the current fallback rank.
  111994. * @returns the new fallback rank.
  111995. */
  111996. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  111997. /**
  111998. * Add the required uniforms to the current list.
  111999. * @param uniforms defines the current uniform list.
  112000. */
  112001. static AddUniforms(uniforms: string[]): void;
  112002. /**
  112003. * Add the required samplers to the current list.
  112004. * @param samplers defines the current sampler list.
  112005. */
  112006. static AddSamplers(samplers: string[]): void;
  112007. /**
  112008. * Add the required uniforms to the current buffer.
  112009. * @param uniformBuffer defines the current uniform buffer.
  112010. */
  112011. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112012. /**
  112013. * Makes a duplicate of the current configuration into another one.
  112014. * @param clearCoatConfiguration define the config where to copy the info
  112015. */
  112016. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  112017. /**
  112018. * Serializes this clear coat configuration.
  112019. * @returns - An object with the serialized config.
  112020. */
  112021. serialize(): any;
  112022. /**
  112023. * Parses a anisotropy Configuration from a serialized object.
  112024. * @param source - Serialized object.
  112025. * @param scene Defines the scene we are parsing for
  112026. * @param rootUrl Defines the rootUrl to load from
  112027. */
  112028. parse(source: any, scene: Scene, rootUrl: string): void;
  112029. }
  112030. }
  112031. declare module BABYLON {
  112032. /**
  112033. * @hidden
  112034. */
  112035. export interface IMaterialAnisotropicDefines {
  112036. ANISOTROPIC: boolean;
  112037. ANISOTROPIC_TEXTURE: boolean;
  112038. ANISOTROPIC_TEXTUREDIRECTUV: number;
  112039. MAINUV1: boolean;
  112040. _areTexturesDirty: boolean;
  112041. _needUVs: boolean;
  112042. }
  112043. /**
  112044. * Define the code related to the anisotropic parameters of the pbr material.
  112045. */
  112046. export class PBRAnisotropicConfiguration {
  112047. private _isEnabled;
  112048. /**
  112049. * Defines if the anisotropy is enabled in the material.
  112050. */
  112051. isEnabled: boolean;
  112052. /**
  112053. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  112054. */
  112055. intensity: number;
  112056. /**
  112057. * Defines if the effect is along the tangents, bitangents or in between.
  112058. * By default, the effect is "strectching" the highlights along the tangents.
  112059. */
  112060. direction: Vector2;
  112061. private _texture;
  112062. /**
  112063. * Stores the anisotropy values in a texture.
  112064. * rg is direction (like normal from -1 to 1)
  112065. * b is a intensity
  112066. */
  112067. texture: Nullable<BaseTexture>;
  112068. /** @hidden */
  112069. private _internalMarkAllSubMeshesAsTexturesDirty;
  112070. /** @hidden */
  112071. _markAllSubMeshesAsTexturesDirty(): void;
  112072. /**
  112073. * Instantiate a new istance of anisotropy configuration.
  112074. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112075. */
  112076. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112077. /**
  112078. * Specifies that the submesh is ready to be used.
  112079. * @param defines the list of "defines" to update.
  112080. * @param scene defines the scene the material belongs to.
  112081. * @returns - boolean indicating that the submesh is ready or not.
  112082. */
  112083. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  112084. /**
  112085. * Checks to see if a texture is used in the material.
  112086. * @param defines the list of "defines" to update.
  112087. * @param mesh the mesh we are preparing the defines for.
  112088. * @param scene defines the scene the material belongs to.
  112089. */
  112090. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  112091. /**
  112092. * Binds the material data.
  112093. * @param uniformBuffer defines the Uniform buffer to fill in.
  112094. * @param scene defines the scene the material belongs to.
  112095. * @param isFrozen defines wether the material is frozen or not.
  112096. */
  112097. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  112098. /**
  112099. * Checks to see if a texture is used in the material.
  112100. * @param texture - Base texture to use.
  112101. * @returns - Boolean specifying if a texture is used in the material.
  112102. */
  112103. hasTexture(texture: BaseTexture): boolean;
  112104. /**
  112105. * Returns an array of the actively used textures.
  112106. * @param activeTextures Array of BaseTextures
  112107. */
  112108. getActiveTextures(activeTextures: BaseTexture[]): void;
  112109. /**
  112110. * Returns the animatable textures.
  112111. * @param animatables Array of animatable textures.
  112112. */
  112113. getAnimatables(animatables: IAnimatable[]): void;
  112114. /**
  112115. * Disposes the resources of the material.
  112116. * @param forceDisposeTextures - Forces the disposal of all textures.
  112117. */
  112118. dispose(forceDisposeTextures?: boolean): void;
  112119. /**
  112120. * Get the current class name of the texture useful for serialization or dynamic coding.
  112121. * @returns "PBRAnisotropicConfiguration"
  112122. */
  112123. getClassName(): string;
  112124. /**
  112125. * Add fallbacks to the effect fallbacks list.
  112126. * @param defines defines the Base texture to use.
  112127. * @param fallbacks defines the current fallback list.
  112128. * @param currentRank defines the current fallback rank.
  112129. * @returns the new fallback rank.
  112130. */
  112131. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112132. /**
  112133. * Add the required uniforms to the current list.
  112134. * @param uniforms defines the current uniform list.
  112135. */
  112136. static AddUniforms(uniforms: string[]): void;
  112137. /**
  112138. * Add the required uniforms to the current buffer.
  112139. * @param uniformBuffer defines the current uniform buffer.
  112140. */
  112141. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112142. /**
  112143. * Add the required samplers to the current list.
  112144. * @param samplers defines the current sampler list.
  112145. */
  112146. static AddSamplers(samplers: string[]): void;
  112147. /**
  112148. * Makes a duplicate of the current configuration into another one.
  112149. * @param anisotropicConfiguration define the config where to copy the info
  112150. */
  112151. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  112152. /**
  112153. * Serializes this anisotropy configuration.
  112154. * @returns - An object with the serialized config.
  112155. */
  112156. serialize(): any;
  112157. /**
  112158. * Parses a anisotropy Configuration from a serialized object.
  112159. * @param source - Serialized object.
  112160. * @param scene Defines the scene we are parsing for
  112161. * @param rootUrl Defines the rootUrl to load from
  112162. */
  112163. parse(source: any, scene: Scene, rootUrl: string): void;
  112164. }
  112165. }
  112166. declare module BABYLON {
  112167. /**
  112168. * @hidden
  112169. */
  112170. export interface IMaterialBRDFDefines {
  112171. BRDF_V_HEIGHT_CORRELATED: boolean;
  112172. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112173. SPHERICAL_HARMONICS: boolean;
  112174. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  112175. /** @hidden */
  112176. _areMiscDirty: boolean;
  112177. }
  112178. /**
  112179. * Define the code related to the BRDF parameters of the pbr material.
  112180. */
  112181. export class PBRBRDFConfiguration {
  112182. /**
  112183. * Default value used for the energy conservation.
  112184. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  112185. */
  112186. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  112187. /**
  112188. * Default value used for the Smith Visibility Height Correlated mode.
  112189. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  112190. */
  112191. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  112192. /**
  112193. * Default value used for the IBL diffuse part.
  112194. * This can help switching back to the polynomials mode globally which is a tiny bit
  112195. * less GPU intensive at the drawback of a lower quality.
  112196. */
  112197. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  112198. /**
  112199. * Default value used for activating energy conservation for the specular workflow.
  112200. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  112201. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  112202. */
  112203. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  112204. private _useEnergyConservation;
  112205. /**
  112206. * Defines if the material uses energy conservation.
  112207. */
  112208. useEnergyConservation: boolean;
  112209. private _useSmithVisibilityHeightCorrelated;
  112210. /**
  112211. * LEGACY Mode set to false
  112212. * Defines if the material uses height smith correlated visibility term.
  112213. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  112214. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  112215. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  112216. * Not relying on height correlated will also disable energy conservation.
  112217. */
  112218. useSmithVisibilityHeightCorrelated: boolean;
  112219. private _useSphericalHarmonics;
  112220. /**
  112221. * LEGACY Mode set to false
  112222. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  112223. * diffuse part of the IBL.
  112224. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  112225. * to the ground truth.
  112226. */
  112227. useSphericalHarmonics: boolean;
  112228. private _useSpecularGlossinessInputEnergyConservation;
  112229. /**
  112230. * Defines if the material uses energy conservation, when the specular workflow is active.
  112231. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  112232. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  112233. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  112234. */
  112235. useSpecularGlossinessInputEnergyConservation: boolean;
  112236. /** @hidden */
  112237. private _internalMarkAllSubMeshesAsMiscDirty;
  112238. /** @hidden */
  112239. _markAllSubMeshesAsMiscDirty(): void;
  112240. /**
  112241. * Instantiate a new istance of clear coat configuration.
  112242. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  112243. */
  112244. constructor(markAllSubMeshesAsMiscDirty: () => void);
  112245. /**
  112246. * Checks to see if a texture is used in the material.
  112247. * @param defines the list of "defines" to update.
  112248. */
  112249. prepareDefines(defines: IMaterialBRDFDefines): void;
  112250. /**
  112251. * Get the current class name of the texture useful for serialization or dynamic coding.
  112252. * @returns "PBRClearCoatConfiguration"
  112253. */
  112254. getClassName(): string;
  112255. /**
  112256. * Makes a duplicate of the current configuration into another one.
  112257. * @param brdfConfiguration define the config where to copy the info
  112258. */
  112259. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  112260. /**
  112261. * Serializes this BRDF configuration.
  112262. * @returns - An object with the serialized config.
  112263. */
  112264. serialize(): any;
  112265. /**
  112266. * Parses a anisotropy Configuration from a serialized object.
  112267. * @param source - Serialized object.
  112268. * @param scene Defines the scene we are parsing for
  112269. * @param rootUrl Defines the rootUrl to load from
  112270. */
  112271. parse(source: any, scene: Scene, rootUrl: string): void;
  112272. }
  112273. }
  112274. declare module BABYLON {
  112275. /**
  112276. * @hidden
  112277. */
  112278. export interface IMaterialSheenDefines {
  112279. SHEEN: boolean;
  112280. SHEEN_TEXTURE: boolean;
  112281. SHEEN_TEXTUREDIRECTUV: number;
  112282. SHEEN_LINKWITHALBEDO: boolean;
  112283. /** @hidden */
  112284. _areTexturesDirty: boolean;
  112285. }
  112286. /**
  112287. * Define the code related to the Sheen parameters of the pbr material.
  112288. */
  112289. export class PBRSheenConfiguration {
  112290. private _isEnabled;
  112291. /**
  112292. * Defines if the material uses sheen.
  112293. */
  112294. isEnabled: boolean;
  112295. private _linkSheenWithAlbedo;
  112296. /**
  112297. * Defines if the sheen is linked to the sheen color.
  112298. */
  112299. linkSheenWithAlbedo: boolean;
  112300. /**
  112301. * Defines the sheen intensity.
  112302. */
  112303. intensity: number;
  112304. /**
  112305. * Defines the sheen color.
  112306. */
  112307. color: Color3;
  112308. private _texture;
  112309. /**
  112310. * Stores the sheen tint values in a texture.
  112311. * rgb is tint
  112312. * a is a intensity
  112313. */
  112314. texture: Nullable<BaseTexture>;
  112315. /** @hidden */
  112316. private _internalMarkAllSubMeshesAsTexturesDirty;
  112317. /** @hidden */
  112318. _markAllSubMeshesAsTexturesDirty(): void;
  112319. /**
  112320. * Instantiate a new istance of clear coat configuration.
  112321. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112322. */
  112323. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112324. /**
  112325. * Specifies that the submesh is ready to be used.
  112326. * @param defines the list of "defines" to update.
  112327. * @param scene defines the scene the material belongs to.
  112328. * @returns - boolean indicating that the submesh is ready or not.
  112329. */
  112330. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  112331. /**
  112332. * Checks to see if a texture is used in the material.
  112333. * @param defines the list of "defines" to update.
  112334. * @param scene defines the scene the material belongs to.
  112335. */
  112336. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  112337. /**
  112338. * Binds the material data.
  112339. * @param uniformBuffer defines the Uniform buffer to fill in.
  112340. * @param scene defines the scene the material belongs to.
  112341. * @param isFrozen defines wether the material is frozen or not.
  112342. */
  112343. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  112344. /**
  112345. * Checks to see if a texture is used in the material.
  112346. * @param texture - Base texture to use.
  112347. * @returns - Boolean specifying if a texture is used in the material.
  112348. */
  112349. hasTexture(texture: BaseTexture): boolean;
  112350. /**
  112351. * Returns an array of the actively used textures.
  112352. * @param activeTextures Array of BaseTextures
  112353. */
  112354. getActiveTextures(activeTextures: BaseTexture[]): void;
  112355. /**
  112356. * Returns the animatable textures.
  112357. * @param animatables Array of animatable textures.
  112358. */
  112359. getAnimatables(animatables: IAnimatable[]): void;
  112360. /**
  112361. * Disposes the resources of the material.
  112362. * @param forceDisposeTextures - Forces the disposal of all textures.
  112363. */
  112364. dispose(forceDisposeTextures?: boolean): void;
  112365. /**
  112366. * Get the current class name of the texture useful for serialization or dynamic coding.
  112367. * @returns "PBRSheenConfiguration"
  112368. */
  112369. getClassName(): string;
  112370. /**
  112371. * Add fallbacks to the effect fallbacks list.
  112372. * @param defines defines the Base texture to use.
  112373. * @param fallbacks defines the current fallback list.
  112374. * @param currentRank defines the current fallback rank.
  112375. * @returns the new fallback rank.
  112376. */
  112377. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112378. /**
  112379. * Add the required uniforms to the current list.
  112380. * @param uniforms defines the current uniform list.
  112381. */
  112382. static AddUniforms(uniforms: string[]): void;
  112383. /**
  112384. * Add the required uniforms to the current buffer.
  112385. * @param uniformBuffer defines the current uniform buffer.
  112386. */
  112387. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112388. /**
  112389. * Add the required samplers to the current list.
  112390. * @param samplers defines the current sampler list.
  112391. */
  112392. static AddSamplers(samplers: string[]): void;
  112393. /**
  112394. * Makes a duplicate of the current configuration into another one.
  112395. * @param sheenConfiguration define the config where to copy the info
  112396. */
  112397. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  112398. /**
  112399. * Serializes this BRDF configuration.
  112400. * @returns - An object with the serialized config.
  112401. */
  112402. serialize(): any;
  112403. /**
  112404. * Parses a anisotropy Configuration from a serialized object.
  112405. * @param source - Serialized object.
  112406. * @param scene Defines the scene we are parsing for
  112407. * @param rootUrl Defines the rootUrl to load from
  112408. */
  112409. parse(source: any, scene: Scene, rootUrl: string): void;
  112410. }
  112411. }
  112412. declare module BABYLON {
  112413. /**
  112414. * @hidden
  112415. */
  112416. export interface IMaterialSubSurfaceDefines {
  112417. SUBSURFACE: boolean;
  112418. SS_REFRACTION: boolean;
  112419. SS_TRANSLUCENCY: boolean;
  112420. SS_SCATERRING: boolean;
  112421. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112422. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112423. SS_REFRACTIONMAP_3D: boolean;
  112424. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112425. SS_LODINREFRACTIONALPHA: boolean;
  112426. SS_GAMMAREFRACTION: boolean;
  112427. SS_RGBDREFRACTION: boolean;
  112428. SS_LINEARSPECULARREFRACTION: boolean;
  112429. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112430. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112431. /** @hidden */
  112432. _areTexturesDirty: boolean;
  112433. }
  112434. /**
  112435. * Define the code related to the sub surface parameters of the pbr material.
  112436. */
  112437. export class PBRSubSurfaceConfiguration {
  112438. private _isRefractionEnabled;
  112439. /**
  112440. * Defines if the refraction is enabled in the material.
  112441. */
  112442. isRefractionEnabled: boolean;
  112443. private _isTranslucencyEnabled;
  112444. /**
  112445. * Defines if the translucency is enabled in the material.
  112446. */
  112447. isTranslucencyEnabled: boolean;
  112448. private _isScatteringEnabled;
  112449. /**
  112450. * Defines the refraction intensity of the material.
  112451. * The refraction when enabled replaces the Diffuse part of the material.
  112452. * The intensity helps transitionning between diffuse and refraction.
  112453. */
  112454. refractionIntensity: number;
  112455. /**
  112456. * Defines the translucency intensity of the material.
  112457. * When translucency has been enabled, this defines how much of the "translucency"
  112458. * is addded to the diffuse part of the material.
  112459. */
  112460. translucencyIntensity: number;
  112461. /**
  112462. * Defines the scattering intensity of the material.
  112463. * When scattering has been enabled, this defines how much of the "scattered light"
  112464. * is addded to the diffuse part of the material.
  112465. */
  112466. scatteringIntensity: number;
  112467. private _thicknessTexture;
  112468. /**
  112469. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  112470. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  112471. * 0 would mean minimumThickness
  112472. * 1 would mean maximumThickness
  112473. * The other channels might be use as a mask to vary the different effects intensity.
  112474. */
  112475. thicknessTexture: Nullable<BaseTexture>;
  112476. private _refractionTexture;
  112477. /**
  112478. * Defines the texture to use for refraction.
  112479. */
  112480. refractionTexture: Nullable<BaseTexture>;
  112481. private _indexOfRefraction;
  112482. /**
  112483. * Defines the index of refraction used in the material.
  112484. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  112485. */
  112486. indexOfRefraction: number;
  112487. private _invertRefractionY;
  112488. /**
  112489. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  112490. */
  112491. invertRefractionY: boolean;
  112492. private _linkRefractionWithTransparency;
  112493. /**
  112494. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  112495. * Materials half opaque for instance using refraction could benefit from this control.
  112496. */
  112497. linkRefractionWithTransparency: boolean;
  112498. /**
  112499. * Defines the minimum thickness stored in the thickness map.
  112500. * If no thickness map is defined, this value will be used to simulate thickness.
  112501. */
  112502. minimumThickness: number;
  112503. /**
  112504. * Defines the maximum thickness stored in the thickness map.
  112505. */
  112506. maximumThickness: number;
  112507. /**
  112508. * Defines the volume tint of the material.
  112509. * This is used for both translucency and scattering.
  112510. */
  112511. tintColor: Color3;
  112512. /**
  112513. * Defines the distance at which the tint color should be found in the media.
  112514. * This is used for refraction only.
  112515. */
  112516. tintColorAtDistance: number;
  112517. /**
  112518. * Defines how far each channel transmit through the media.
  112519. * It is defined as a color to simplify it selection.
  112520. */
  112521. diffusionDistance: Color3;
  112522. private _useMaskFromThicknessTexture;
  112523. /**
  112524. * Stores the intensity of the different subsurface effects in the thickness texture.
  112525. * * the green channel is the translucency intensity.
  112526. * * the blue channel is the scattering intensity.
  112527. * * the alpha channel is the refraction intensity.
  112528. */
  112529. useMaskFromThicknessTexture: boolean;
  112530. /** @hidden */
  112531. private _internalMarkAllSubMeshesAsTexturesDirty;
  112532. /** @hidden */
  112533. _markAllSubMeshesAsTexturesDirty(): void;
  112534. /**
  112535. * Instantiate a new istance of sub surface configuration.
  112536. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  112537. */
  112538. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  112539. /**
  112540. * Gets wehter the submesh is ready to be used or not.
  112541. * @param defines the list of "defines" to update.
  112542. * @param scene defines the scene the material belongs to.
  112543. * @returns - boolean indicating that the submesh is ready or not.
  112544. */
  112545. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  112546. /**
  112547. * Checks to see if a texture is used in the material.
  112548. * @param defines the list of "defines" to update.
  112549. * @param scene defines the scene to the material belongs to.
  112550. */
  112551. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  112552. /**
  112553. * Binds the material data.
  112554. * @param uniformBuffer defines the Uniform buffer to fill in.
  112555. * @param scene defines the scene the material belongs to.
  112556. * @param engine defines the engine the material belongs to.
  112557. * @param isFrozen defines wether the material is frozen or not.
  112558. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  112559. */
  112560. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  112561. /**
  112562. * Unbinds the material from the mesh.
  112563. * @param activeEffect defines the effect that should be unbound from.
  112564. * @returns true if unbound, otherwise false
  112565. */
  112566. unbind(activeEffect: Effect): boolean;
  112567. /**
  112568. * Returns the texture used for refraction or null if none is used.
  112569. * @param scene defines the scene the material belongs to.
  112570. * @returns - Refraction texture if present. If no refraction texture and refraction
  112571. * is linked with transparency, returns environment texture. Otherwise, returns null.
  112572. */
  112573. private _getRefractionTexture;
  112574. /**
  112575. * Returns true if alpha blending should be disabled.
  112576. */
  112577. readonly disableAlphaBlending: boolean;
  112578. /**
  112579. * Fills the list of render target textures.
  112580. * @param renderTargets the list of render targets to update
  112581. */
  112582. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  112583. /**
  112584. * Checks to see if a texture is used in the material.
  112585. * @param texture - Base texture to use.
  112586. * @returns - Boolean specifying if a texture is used in the material.
  112587. */
  112588. hasTexture(texture: BaseTexture): boolean;
  112589. /**
  112590. * Gets a boolean indicating that current material needs to register RTT
  112591. * @returns true if this uses a render target otherwise false.
  112592. */
  112593. hasRenderTargetTextures(): boolean;
  112594. /**
  112595. * Returns an array of the actively used textures.
  112596. * @param activeTextures Array of BaseTextures
  112597. */
  112598. getActiveTextures(activeTextures: BaseTexture[]): void;
  112599. /**
  112600. * Returns the animatable textures.
  112601. * @param animatables Array of animatable textures.
  112602. */
  112603. getAnimatables(animatables: IAnimatable[]): void;
  112604. /**
  112605. * Disposes the resources of the material.
  112606. * @param forceDisposeTextures - Forces the disposal of all textures.
  112607. */
  112608. dispose(forceDisposeTextures?: boolean): void;
  112609. /**
  112610. * Get the current class name of the texture useful for serialization or dynamic coding.
  112611. * @returns "PBRSubSurfaceConfiguration"
  112612. */
  112613. getClassName(): string;
  112614. /**
  112615. * Add fallbacks to the effect fallbacks list.
  112616. * @param defines defines the Base texture to use.
  112617. * @param fallbacks defines the current fallback list.
  112618. * @param currentRank defines the current fallback rank.
  112619. * @returns the new fallback rank.
  112620. */
  112621. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  112622. /**
  112623. * Add the required uniforms to the current list.
  112624. * @param uniforms defines the current uniform list.
  112625. */
  112626. static AddUniforms(uniforms: string[]): void;
  112627. /**
  112628. * Add the required samplers to the current list.
  112629. * @param samplers defines the current sampler list.
  112630. */
  112631. static AddSamplers(samplers: string[]): void;
  112632. /**
  112633. * Add the required uniforms to the current buffer.
  112634. * @param uniformBuffer defines the current uniform buffer.
  112635. */
  112636. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  112637. /**
  112638. * Makes a duplicate of the current configuration into another one.
  112639. * @param configuration define the config where to copy the info
  112640. */
  112641. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  112642. /**
  112643. * Serializes this Sub Surface configuration.
  112644. * @returns - An object with the serialized config.
  112645. */
  112646. serialize(): any;
  112647. /**
  112648. * Parses a anisotropy Configuration from a serialized object.
  112649. * @param source - Serialized object.
  112650. * @param scene Defines the scene we are parsing for
  112651. * @param rootUrl Defines the rootUrl to load from
  112652. */
  112653. parse(source: any, scene: Scene, rootUrl: string): void;
  112654. }
  112655. }
  112656. declare module BABYLON {
  112657. /** @hidden */
  112658. export var pbrFragmentDeclaration: {
  112659. name: string;
  112660. shader: string;
  112661. };
  112662. }
  112663. declare module BABYLON {
  112664. /** @hidden */
  112665. export var pbrUboDeclaration: {
  112666. name: string;
  112667. shader: string;
  112668. };
  112669. }
  112670. declare module BABYLON {
  112671. /** @hidden */
  112672. export var pbrFragmentExtraDeclaration: {
  112673. name: string;
  112674. shader: string;
  112675. };
  112676. }
  112677. declare module BABYLON {
  112678. /** @hidden */
  112679. export var pbrFragmentSamplersDeclaration: {
  112680. name: string;
  112681. shader: string;
  112682. };
  112683. }
  112684. declare module BABYLON {
  112685. /** @hidden */
  112686. export var pbrHelperFunctions: {
  112687. name: string;
  112688. shader: string;
  112689. };
  112690. }
  112691. declare module BABYLON {
  112692. /** @hidden */
  112693. export var harmonicsFunctions: {
  112694. name: string;
  112695. shader: string;
  112696. };
  112697. }
  112698. declare module BABYLON {
  112699. /** @hidden */
  112700. export var pbrDirectLightingSetupFunctions: {
  112701. name: string;
  112702. shader: string;
  112703. };
  112704. }
  112705. declare module BABYLON {
  112706. /** @hidden */
  112707. export var pbrDirectLightingFalloffFunctions: {
  112708. name: string;
  112709. shader: string;
  112710. };
  112711. }
  112712. declare module BABYLON {
  112713. /** @hidden */
  112714. export var pbrBRDFFunctions: {
  112715. name: string;
  112716. shader: string;
  112717. };
  112718. }
  112719. declare module BABYLON {
  112720. /** @hidden */
  112721. export var pbrDirectLightingFunctions: {
  112722. name: string;
  112723. shader: string;
  112724. };
  112725. }
  112726. declare module BABYLON {
  112727. /** @hidden */
  112728. export var pbrIBLFunctions: {
  112729. name: string;
  112730. shader: string;
  112731. };
  112732. }
  112733. declare module BABYLON {
  112734. /** @hidden */
  112735. export var pbrDebug: {
  112736. name: string;
  112737. shader: string;
  112738. };
  112739. }
  112740. declare module BABYLON {
  112741. /** @hidden */
  112742. export var pbrPixelShader: {
  112743. name: string;
  112744. shader: string;
  112745. };
  112746. }
  112747. declare module BABYLON {
  112748. /** @hidden */
  112749. export var pbrVertexDeclaration: {
  112750. name: string;
  112751. shader: string;
  112752. };
  112753. }
  112754. declare module BABYLON {
  112755. /** @hidden */
  112756. export var pbrVertexShader: {
  112757. name: string;
  112758. shader: string;
  112759. };
  112760. }
  112761. declare module BABYLON {
  112762. /**
  112763. * Manages the defines for the PBR Material.
  112764. * @hidden
  112765. */
  112766. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  112767. PBR: boolean;
  112768. MAINUV1: boolean;
  112769. MAINUV2: boolean;
  112770. UV1: boolean;
  112771. UV2: boolean;
  112772. ALBEDO: boolean;
  112773. ALBEDODIRECTUV: number;
  112774. VERTEXCOLOR: boolean;
  112775. AMBIENT: boolean;
  112776. AMBIENTDIRECTUV: number;
  112777. AMBIENTINGRAYSCALE: boolean;
  112778. OPACITY: boolean;
  112779. VERTEXALPHA: boolean;
  112780. OPACITYDIRECTUV: number;
  112781. OPACITYRGB: boolean;
  112782. ALPHATEST: boolean;
  112783. DEPTHPREPASS: boolean;
  112784. ALPHABLEND: boolean;
  112785. ALPHAFROMALBEDO: boolean;
  112786. ALPHATESTVALUE: string;
  112787. SPECULAROVERALPHA: boolean;
  112788. RADIANCEOVERALPHA: boolean;
  112789. ALPHAFRESNEL: boolean;
  112790. LINEARALPHAFRESNEL: boolean;
  112791. PREMULTIPLYALPHA: boolean;
  112792. EMISSIVE: boolean;
  112793. EMISSIVEDIRECTUV: number;
  112794. REFLECTIVITY: boolean;
  112795. REFLECTIVITYDIRECTUV: number;
  112796. SPECULARTERM: boolean;
  112797. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  112798. MICROSURFACEAUTOMATIC: boolean;
  112799. LODBASEDMICROSFURACE: boolean;
  112800. MICROSURFACEMAP: boolean;
  112801. MICROSURFACEMAPDIRECTUV: number;
  112802. METALLICWORKFLOW: boolean;
  112803. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  112804. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  112805. METALLNESSSTOREINMETALMAPBLUE: boolean;
  112806. AOSTOREINMETALMAPRED: boolean;
  112807. ENVIRONMENTBRDF: boolean;
  112808. ENVIRONMENTBRDF_RGBD: boolean;
  112809. NORMAL: boolean;
  112810. TANGENT: boolean;
  112811. BUMP: boolean;
  112812. BUMPDIRECTUV: number;
  112813. OBJECTSPACE_NORMALMAP: boolean;
  112814. PARALLAX: boolean;
  112815. PARALLAXOCCLUSION: boolean;
  112816. NORMALXYSCALE: boolean;
  112817. LIGHTMAP: boolean;
  112818. LIGHTMAPDIRECTUV: number;
  112819. USELIGHTMAPASSHADOWMAP: boolean;
  112820. GAMMALIGHTMAP: boolean;
  112821. RGBDLIGHTMAP: boolean;
  112822. REFLECTION: boolean;
  112823. REFLECTIONMAP_3D: boolean;
  112824. REFLECTIONMAP_SPHERICAL: boolean;
  112825. REFLECTIONMAP_PLANAR: boolean;
  112826. REFLECTIONMAP_CUBIC: boolean;
  112827. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  112828. REFLECTIONMAP_PROJECTION: boolean;
  112829. REFLECTIONMAP_SKYBOX: boolean;
  112830. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  112831. REFLECTIONMAP_EXPLICIT: boolean;
  112832. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  112833. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  112834. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  112835. INVERTCUBICMAP: boolean;
  112836. USESPHERICALFROMREFLECTIONMAP: boolean;
  112837. USEIRRADIANCEMAP: boolean;
  112838. SPHERICAL_HARMONICS: boolean;
  112839. USESPHERICALINVERTEX: boolean;
  112840. REFLECTIONMAP_OPPOSITEZ: boolean;
  112841. LODINREFLECTIONALPHA: boolean;
  112842. GAMMAREFLECTION: boolean;
  112843. RGBDREFLECTION: boolean;
  112844. LINEARSPECULARREFLECTION: boolean;
  112845. RADIANCEOCCLUSION: boolean;
  112846. HORIZONOCCLUSION: boolean;
  112847. INSTANCES: boolean;
  112848. NUM_BONE_INFLUENCERS: number;
  112849. BonesPerMesh: number;
  112850. BONETEXTURE: boolean;
  112851. NONUNIFORMSCALING: boolean;
  112852. MORPHTARGETS: boolean;
  112853. MORPHTARGETS_NORMAL: boolean;
  112854. MORPHTARGETS_TANGENT: boolean;
  112855. MORPHTARGETS_UV: boolean;
  112856. NUM_MORPH_INFLUENCERS: number;
  112857. IMAGEPROCESSING: boolean;
  112858. VIGNETTE: boolean;
  112859. VIGNETTEBLENDMODEMULTIPLY: boolean;
  112860. VIGNETTEBLENDMODEOPAQUE: boolean;
  112861. TONEMAPPING: boolean;
  112862. TONEMAPPING_ACES: boolean;
  112863. CONTRAST: boolean;
  112864. COLORCURVES: boolean;
  112865. COLORGRADING: boolean;
  112866. COLORGRADING3D: boolean;
  112867. SAMPLER3DGREENDEPTH: boolean;
  112868. SAMPLER3DBGRMAP: boolean;
  112869. IMAGEPROCESSINGPOSTPROCESS: boolean;
  112870. EXPOSURE: boolean;
  112871. MULTIVIEW: boolean;
  112872. USEPHYSICALLIGHTFALLOFF: boolean;
  112873. USEGLTFLIGHTFALLOFF: boolean;
  112874. TWOSIDEDLIGHTING: boolean;
  112875. SHADOWFLOAT: boolean;
  112876. CLIPPLANE: boolean;
  112877. CLIPPLANE2: boolean;
  112878. CLIPPLANE3: boolean;
  112879. CLIPPLANE4: boolean;
  112880. POINTSIZE: boolean;
  112881. FOG: boolean;
  112882. LOGARITHMICDEPTH: boolean;
  112883. FORCENORMALFORWARD: boolean;
  112884. SPECULARAA: boolean;
  112885. CLEARCOAT: boolean;
  112886. CLEARCOAT_DEFAULTIOR: boolean;
  112887. CLEARCOAT_TEXTURE: boolean;
  112888. CLEARCOAT_TEXTUREDIRECTUV: number;
  112889. CLEARCOAT_BUMP: boolean;
  112890. CLEARCOAT_BUMPDIRECTUV: number;
  112891. CLEARCOAT_TINT: boolean;
  112892. CLEARCOAT_TINT_TEXTURE: boolean;
  112893. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  112894. ANISOTROPIC: boolean;
  112895. ANISOTROPIC_TEXTURE: boolean;
  112896. ANISOTROPIC_TEXTUREDIRECTUV: number;
  112897. BRDF_V_HEIGHT_CORRELATED: boolean;
  112898. MS_BRDF_ENERGY_CONSERVATION: boolean;
  112899. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  112900. SHEEN: boolean;
  112901. SHEEN_TEXTURE: boolean;
  112902. SHEEN_TEXTUREDIRECTUV: number;
  112903. SHEEN_LINKWITHALBEDO: boolean;
  112904. SUBSURFACE: boolean;
  112905. SS_REFRACTION: boolean;
  112906. SS_TRANSLUCENCY: boolean;
  112907. SS_SCATERRING: boolean;
  112908. SS_THICKNESSANDMASK_TEXTURE: boolean;
  112909. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  112910. SS_REFRACTIONMAP_3D: boolean;
  112911. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  112912. SS_LODINREFRACTIONALPHA: boolean;
  112913. SS_GAMMAREFRACTION: boolean;
  112914. SS_RGBDREFRACTION: boolean;
  112915. SS_LINEARSPECULARREFRACTION: boolean;
  112916. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  112917. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  112918. UNLIT: boolean;
  112919. DEBUGMODE: number;
  112920. /**
  112921. * Initializes the PBR Material defines.
  112922. */
  112923. constructor();
  112924. /**
  112925. * Resets the PBR Material defines.
  112926. */
  112927. reset(): void;
  112928. }
  112929. /**
  112930. * The Physically based material base class of BJS.
  112931. *
  112932. * This offers the main features of a standard PBR material.
  112933. * For more information, please refer to the documentation :
  112934. * https://doc.babylonjs.com/how_to/physically_based_rendering
  112935. */
  112936. export abstract class PBRBaseMaterial extends PushMaterial {
  112937. /**
  112938. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  112939. */
  112940. static readonly PBRMATERIAL_OPAQUE: number;
  112941. /**
  112942. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  112943. */
  112944. static readonly PBRMATERIAL_ALPHATEST: number;
  112945. /**
  112946. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112947. */
  112948. static readonly PBRMATERIAL_ALPHABLEND: number;
  112949. /**
  112950. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  112951. * They are also discarded below the alpha cutoff threshold to improve performances.
  112952. */
  112953. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  112954. /**
  112955. * Defines the default value of how much AO map is occluding the analytical lights
  112956. * (point spot...).
  112957. */
  112958. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  112959. /**
  112960. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  112961. */
  112962. static readonly LIGHTFALLOFF_PHYSICAL: number;
  112963. /**
  112964. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  112965. * to enhance interoperability with other engines.
  112966. */
  112967. static readonly LIGHTFALLOFF_GLTF: number;
  112968. /**
  112969. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  112970. * to enhance interoperability with other materials.
  112971. */
  112972. static readonly LIGHTFALLOFF_STANDARD: number;
  112973. /**
  112974. * Intensity of the direct lights e.g. the four lights available in your scene.
  112975. * This impacts both the direct diffuse and specular highlights.
  112976. */
  112977. protected _directIntensity: number;
  112978. /**
  112979. * Intensity of the emissive part of the material.
  112980. * This helps controlling the emissive effect without modifying the emissive color.
  112981. */
  112982. protected _emissiveIntensity: number;
  112983. /**
  112984. * Intensity of the environment e.g. how much the environment will light the object
  112985. * either through harmonics for rough material or through the refelction for shiny ones.
  112986. */
  112987. protected _environmentIntensity: number;
  112988. /**
  112989. * This is a special control allowing the reduction of the specular highlights coming from the
  112990. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  112991. */
  112992. protected _specularIntensity: number;
  112993. /**
  112994. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  112995. */
  112996. private _lightingInfos;
  112997. /**
  112998. * Debug Control allowing disabling the bump map on this material.
  112999. */
  113000. protected _disableBumpMap: boolean;
  113001. /**
  113002. * AKA Diffuse Texture in standard nomenclature.
  113003. */
  113004. protected _albedoTexture: Nullable<BaseTexture>;
  113005. /**
  113006. * AKA Occlusion Texture in other nomenclature.
  113007. */
  113008. protected _ambientTexture: Nullable<BaseTexture>;
  113009. /**
  113010. * AKA Occlusion Texture Intensity in other nomenclature.
  113011. */
  113012. protected _ambientTextureStrength: number;
  113013. /**
  113014. * Defines how much the AO map is occluding the analytical lights (point spot...).
  113015. * 1 means it completely occludes it
  113016. * 0 mean it has no impact
  113017. */
  113018. protected _ambientTextureImpactOnAnalyticalLights: number;
  113019. /**
  113020. * Stores the alpha values in a texture.
  113021. */
  113022. protected _opacityTexture: Nullable<BaseTexture>;
  113023. /**
  113024. * Stores the reflection values in a texture.
  113025. */
  113026. protected _reflectionTexture: Nullable<BaseTexture>;
  113027. /**
  113028. * Stores the emissive values in a texture.
  113029. */
  113030. protected _emissiveTexture: Nullable<BaseTexture>;
  113031. /**
  113032. * AKA Specular texture in other nomenclature.
  113033. */
  113034. protected _reflectivityTexture: Nullable<BaseTexture>;
  113035. /**
  113036. * Used to switch from specular/glossiness to metallic/roughness workflow.
  113037. */
  113038. protected _metallicTexture: Nullable<BaseTexture>;
  113039. /**
  113040. * Specifies the metallic scalar of the metallic/roughness workflow.
  113041. * Can also be used to scale the metalness values of the metallic texture.
  113042. */
  113043. protected _metallic: Nullable<number>;
  113044. /**
  113045. * Specifies the roughness scalar of the metallic/roughness workflow.
  113046. * Can also be used to scale the roughness values of the metallic texture.
  113047. */
  113048. protected _roughness: Nullable<number>;
  113049. /**
  113050. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  113051. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  113052. */
  113053. protected _microSurfaceTexture: Nullable<BaseTexture>;
  113054. /**
  113055. * Stores surface normal data used to displace a mesh in a texture.
  113056. */
  113057. protected _bumpTexture: Nullable<BaseTexture>;
  113058. /**
  113059. * Stores the pre-calculated light information of a mesh in a texture.
  113060. */
  113061. protected _lightmapTexture: Nullable<BaseTexture>;
  113062. /**
  113063. * The color of a material in ambient lighting.
  113064. */
  113065. protected _ambientColor: Color3;
  113066. /**
  113067. * AKA Diffuse Color in other nomenclature.
  113068. */
  113069. protected _albedoColor: Color3;
  113070. /**
  113071. * AKA Specular Color in other nomenclature.
  113072. */
  113073. protected _reflectivityColor: Color3;
  113074. /**
  113075. * The color applied when light is reflected from a material.
  113076. */
  113077. protected _reflectionColor: Color3;
  113078. /**
  113079. * The color applied when light is emitted from a material.
  113080. */
  113081. protected _emissiveColor: Color3;
  113082. /**
  113083. * AKA Glossiness in other nomenclature.
  113084. */
  113085. protected _microSurface: number;
  113086. /**
  113087. * Specifies that the material will use the light map as a show map.
  113088. */
  113089. protected _useLightmapAsShadowmap: boolean;
  113090. /**
  113091. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  113092. * makes the reflect vector face the model (under horizon).
  113093. */
  113094. protected _useHorizonOcclusion: boolean;
  113095. /**
  113096. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  113097. * too much the area relying on ambient texture to define their ambient occlusion.
  113098. */
  113099. protected _useRadianceOcclusion: boolean;
  113100. /**
  113101. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  113102. */
  113103. protected _useAlphaFromAlbedoTexture: boolean;
  113104. /**
  113105. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  113106. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  113107. */
  113108. protected _useSpecularOverAlpha: boolean;
  113109. /**
  113110. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  113111. */
  113112. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  113113. /**
  113114. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  113115. */
  113116. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  113117. /**
  113118. * Specifies if the metallic texture contains the roughness information in its green channel.
  113119. */
  113120. protected _useRoughnessFromMetallicTextureGreen: boolean;
  113121. /**
  113122. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113123. */
  113124. protected _useMetallnessFromMetallicTextureBlue: boolean;
  113125. /**
  113126. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113127. */
  113128. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  113129. /**
  113130. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113131. */
  113132. protected _useAmbientInGrayScale: boolean;
  113133. /**
  113134. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113135. * The material will try to infer what glossiness each pixel should be.
  113136. */
  113137. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  113138. /**
  113139. * Defines the falloff type used in this material.
  113140. * It by default is Physical.
  113141. */
  113142. protected _lightFalloff: number;
  113143. /**
  113144. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113145. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113146. */
  113147. protected _useRadianceOverAlpha: boolean;
  113148. /**
  113149. * Allows using an object space normal map (instead of tangent space).
  113150. */
  113151. protected _useObjectSpaceNormalMap: boolean;
  113152. /**
  113153. * Allows using the bump map in parallax mode.
  113154. */
  113155. protected _useParallax: boolean;
  113156. /**
  113157. * Allows using the bump map in parallax occlusion mode.
  113158. */
  113159. protected _useParallaxOcclusion: boolean;
  113160. /**
  113161. * Controls the scale bias of the parallax mode.
  113162. */
  113163. protected _parallaxScaleBias: number;
  113164. /**
  113165. * If sets to true, disables all the lights affecting the material.
  113166. */
  113167. protected _disableLighting: boolean;
  113168. /**
  113169. * Number of Simultaneous lights allowed on the material.
  113170. */
  113171. protected _maxSimultaneousLights: number;
  113172. /**
  113173. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113174. */
  113175. protected _invertNormalMapX: boolean;
  113176. /**
  113177. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113178. */
  113179. protected _invertNormalMapY: boolean;
  113180. /**
  113181. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113182. */
  113183. protected _twoSidedLighting: boolean;
  113184. /**
  113185. * Defines the alpha limits in alpha test mode.
  113186. */
  113187. protected _alphaCutOff: number;
  113188. /**
  113189. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113190. */
  113191. protected _forceAlphaTest: boolean;
  113192. /**
  113193. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113194. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113195. */
  113196. protected _useAlphaFresnel: boolean;
  113197. /**
  113198. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113199. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113200. */
  113201. protected _useLinearAlphaFresnel: boolean;
  113202. /**
  113203. * The transparency mode of the material.
  113204. */
  113205. protected _transparencyMode: Nullable<number>;
  113206. /**
  113207. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  113208. * from cos thetav and roughness:
  113209. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  113210. */
  113211. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  113212. /**
  113213. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113214. */
  113215. protected _forceIrradianceInFragment: boolean;
  113216. /**
  113217. * Force normal to face away from face.
  113218. */
  113219. protected _forceNormalForward: boolean;
  113220. /**
  113221. * Enables specular anti aliasing in the PBR shader.
  113222. * It will both interacts on the Geometry for analytical and IBL lighting.
  113223. * It also prefilter the roughness map based on the bump values.
  113224. */
  113225. protected _enableSpecularAntiAliasing: boolean;
  113226. /**
  113227. * Default configuration related to image processing available in the PBR Material.
  113228. */
  113229. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113230. /**
  113231. * Keep track of the image processing observer to allow dispose and replace.
  113232. */
  113233. private _imageProcessingObserver;
  113234. /**
  113235. * Attaches a new image processing configuration to the PBR Material.
  113236. * @param configuration
  113237. */
  113238. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113239. /**
  113240. * Stores the available render targets.
  113241. */
  113242. private _renderTargets;
  113243. /**
  113244. * Sets the global ambient color for the material used in lighting calculations.
  113245. */
  113246. private _globalAmbientColor;
  113247. /**
  113248. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  113249. */
  113250. private _useLogarithmicDepth;
  113251. /**
  113252. * If set to true, no lighting calculations will be applied.
  113253. */
  113254. private _unlit;
  113255. private _debugMode;
  113256. /**
  113257. * @hidden
  113258. * This is reserved for the inspector.
  113259. * Defines the material debug mode.
  113260. * It helps seeing only some components of the material while troubleshooting.
  113261. */
  113262. debugMode: number;
  113263. /**
  113264. * @hidden
  113265. * This is reserved for the inspector.
  113266. * Specify from where on screen the debug mode should start.
  113267. * The value goes from -1 (full screen) to 1 (not visible)
  113268. * It helps with side by side comparison against the final render
  113269. * This defaults to -1
  113270. */
  113271. private debugLimit;
  113272. /**
  113273. * @hidden
  113274. * This is reserved for the inspector.
  113275. * As the default viewing range might not be enough (if the ambient is really small for instance)
  113276. * You can use the factor to better multiply the final value.
  113277. */
  113278. private debugFactor;
  113279. /**
  113280. * Defines the clear coat layer parameters for the material.
  113281. */
  113282. readonly clearCoat: PBRClearCoatConfiguration;
  113283. /**
  113284. * Defines the anisotropic parameters for the material.
  113285. */
  113286. readonly anisotropy: PBRAnisotropicConfiguration;
  113287. /**
  113288. * Defines the BRDF parameters for the material.
  113289. */
  113290. readonly brdf: PBRBRDFConfiguration;
  113291. /**
  113292. * Defines the Sheen parameters for the material.
  113293. */
  113294. readonly sheen: PBRSheenConfiguration;
  113295. /**
  113296. * Defines the SubSurface parameters for the material.
  113297. */
  113298. readonly subSurface: PBRSubSurfaceConfiguration;
  113299. /**
  113300. * Custom callback helping to override the default shader used in the material.
  113301. */
  113302. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  113303. protected _rebuildInParallel: boolean;
  113304. /**
  113305. * Instantiates a new PBRMaterial instance.
  113306. *
  113307. * @param name The material name
  113308. * @param scene The scene the material will be use in.
  113309. */
  113310. constructor(name: string, scene: Scene);
  113311. /**
  113312. * Gets a boolean indicating that current material needs to register RTT
  113313. */
  113314. readonly hasRenderTargetTextures: boolean;
  113315. /**
  113316. * Gets the name of the material class.
  113317. */
  113318. getClassName(): string;
  113319. /**
  113320. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  113321. */
  113322. /**
  113323. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  113324. */
  113325. useLogarithmicDepth: boolean;
  113326. /**
  113327. * Gets the current transparency mode.
  113328. */
  113329. /**
  113330. * Sets the transparency mode of the material.
  113331. *
  113332. * | Value | Type | Description |
  113333. * | ----- | ----------------------------------- | ----------- |
  113334. * | 0 | OPAQUE | |
  113335. * | 1 | ALPHATEST | |
  113336. * | 2 | ALPHABLEND | |
  113337. * | 3 | ALPHATESTANDBLEND | |
  113338. *
  113339. */
  113340. transparencyMode: Nullable<number>;
  113341. /**
  113342. * Returns true if alpha blending should be disabled.
  113343. */
  113344. private readonly _disableAlphaBlending;
  113345. /**
  113346. * Specifies whether or not this material should be rendered in alpha blend mode.
  113347. */
  113348. needAlphaBlending(): boolean;
  113349. /**
  113350. * Specifies if the mesh will require alpha blending.
  113351. * @param mesh - BJS mesh.
  113352. */
  113353. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  113354. /**
  113355. * Specifies whether or not this material should be rendered in alpha test mode.
  113356. */
  113357. needAlphaTesting(): boolean;
  113358. /**
  113359. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  113360. */
  113361. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  113362. /**
  113363. * Gets the texture used for the alpha test.
  113364. */
  113365. getAlphaTestTexture(): Nullable<BaseTexture>;
  113366. /**
  113367. * Specifies that the submesh is ready to be used.
  113368. * @param mesh - BJS mesh.
  113369. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  113370. * @param useInstances - Specifies that instances should be used.
  113371. * @returns - boolean indicating that the submesh is ready or not.
  113372. */
  113373. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113374. /**
  113375. * Specifies if the material uses metallic roughness workflow.
  113376. * @returns boolean specifiying if the material uses metallic roughness workflow.
  113377. */
  113378. isMetallicWorkflow(): boolean;
  113379. private _prepareEffect;
  113380. private _prepareDefines;
  113381. /**
  113382. * Force shader compilation
  113383. */
  113384. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  113385. clipPlane: boolean;
  113386. }>): void;
  113387. /**
  113388. * Initializes the uniform buffer layout for the shader.
  113389. */
  113390. buildUniformLayout(): void;
  113391. /**
  113392. * Unbinds the material from the mesh
  113393. */
  113394. unbind(): void;
  113395. /**
  113396. * Binds the submesh data.
  113397. * @param world - The world matrix.
  113398. * @param mesh - The BJS mesh.
  113399. * @param subMesh - A submesh of the BJS mesh.
  113400. */
  113401. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113402. /**
  113403. * Returns the animatable textures.
  113404. * @returns - Array of animatable textures.
  113405. */
  113406. getAnimatables(): IAnimatable[];
  113407. /**
  113408. * Returns the texture used for reflections.
  113409. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  113410. */
  113411. private _getReflectionTexture;
  113412. /**
  113413. * Returns an array of the actively used textures.
  113414. * @returns - Array of BaseTextures
  113415. */
  113416. getActiveTextures(): BaseTexture[];
  113417. /**
  113418. * Checks to see if a texture is used in the material.
  113419. * @param texture - Base texture to use.
  113420. * @returns - Boolean specifying if a texture is used in the material.
  113421. */
  113422. hasTexture(texture: BaseTexture): boolean;
  113423. /**
  113424. * Disposes the resources of the material.
  113425. * @param forceDisposeEffect - Forces the disposal of effects.
  113426. * @param forceDisposeTextures - Forces the disposal of all textures.
  113427. */
  113428. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  113429. }
  113430. }
  113431. declare module BABYLON {
  113432. /**
  113433. * The Physically based material of BJS.
  113434. *
  113435. * This offers the main features of a standard PBR material.
  113436. * For more information, please refer to the documentation :
  113437. * https://doc.babylonjs.com/how_to/physically_based_rendering
  113438. */
  113439. export class PBRMaterial extends PBRBaseMaterial {
  113440. /**
  113441. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  113442. */
  113443. static readonly PBRMATERIAL_OPAQUE: number;
  113444. /**
  113445. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  113446. */
  113447. static readonly PBRMATERIAL_ALPHATEST: number;
  113448. /**
  113449. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113450. */
  113451. static readonly PBRMATERIAL_ALPHABLEND: number;
  113452. /**
  113453. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  113454. * They are also discarded below the alpha cutoff threshold to improve performances.
  113455. */
  113456. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  113457. /**
  113458. * Defines the default value of how much AO map is occluding the analytical lights
  113459. * (point spot...).
  113460. */
  113461. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  113462. /**
  113463. * Intensity of the direct lights e.g. the four lights available in your scene.
  113464. * This impacts both the direct diffuse and specular highlights.
  113465. */
  113466. directIntensity: number;
  113467. /**
  113468. * Intensity of the emissive part of the material.
  113469. * This helps controlling the emissive effect without modifying the emissive color.
  113470. */
  113471. emissiveIntensity: number;
  113472. /**
  113473. * Intensity of the environment e.g. how much the environment will light the object
  113474. * either through harmonics for rough material or through the refelction for shiny ones.
  113475. */
  113476. environmentIntensity: number;
  113477. /**
  113478. * This is a special control allowing the reduction of the specular highlights coming from the
  113479. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  113480. */
  113481. specularIntensity: number;
  113482. /**
  113483. * Debug Control allowing disabling the bump map on this material.
  113484. */
  113485. disableBumpMap: boolean;
  113486. /**
  113487. * AKA Diffuse Texture in standard nomenclature.
  113488. */
  113489. albedoTexture: BaseTexture;
  113490. /**
  113491. * AKA Occlusion Texture in other nomenclature.
  113492. */
  113493. ambientTexture: BaseTexture;
  113494. /**
  113495. * AKA Occlusion Texture Intensity in other nomenclature.
  113496. */
  113497. ambientTextureStrength: number;
  113498. /**
  113499. * Defines how much the AO map is occluding the analytical lights (point spot...).
  113500. * 1 means it completely occludes it
  113501. * 0 mean it has no impact
  113502. */
  113503. ambientTextureImpactOnAnalyticalLights: number;
  113504. /**
  113505. * Stores the alpha values in a texture.
  113506. */
  113507. opacityTexture: BaseTexture;
  113508. /**
  113509. * Stores the reflection values in a texture.
  113510. */
  113511. reflectionTexture: Nullable<BaseTexture>;
  113512. /**
  113513. * Stores the emissive values in a texture.
  113514. */
  113515. emissiveTexture: BaseTexture;
  113516. /**
  113517. * AKA Specular texture in other nomenclature.
  113518. */
  113519. reflectivityTexture: BaseTexture;
  113520. /**
  113521. * Used to switch from specular/glossiness to metallic/roughness workflow.
  113522. */
  113523. metallicTexture: BaseTexture;
  113524. /**
  113525. * Specifies the metallic scalar of the metallic/roughness workflow.
  113526. * Can also be used to scale the metalness values of the metallic texture.
  113527. */
  113528. metallic: Nullable<number>;
  113529. /**
  113530. * Specifies the roughness scalar of the metallic/roughness workflow.
  113531. * Can also be used to scale the roughness values of the metallic texture.
  113532. */
  113533. roughness: Nullable<number>;
  113534. /**
  113535. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  113536. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  113537. */
  113538. microSurfaceTexture: BaseTexture;
  113539. /**
  113540. * Stores surface normal data used to displace a mesh in a texture.
  113541. */
  113542. bumpTexture: BaseTexture;
  113543. /**
  113544. * Stores the pre-calculated light information of a mesh in a texture.
  113545. */
  113546. lightmapTexture: BaseTexture;
  113547. /**
  113548. * Stores the refracted light information in a texture.
  113549. */
  113550. refractionTexture: Nullable<BaseTexture>;
  113551. /**
  113552. * The color of a material in ambient lighting.
  113553. */
  113554. ambientColor: Color3;
  113555. /**
  113556. * AKA Diffuse Color in other nomenclature.
  113557. */
  113558. albedoColor: Color3;
  113559. /**
  113560. * AKA Specular Color in other nomenclature.
  113561. */
  113562. reflectivityColor: Color3;
  113563. /**
  113564. * The color reflected from the material.
  113565. */
  113566. reflectionColor: Color3;
  113567. /**
  113568. * The color emitted from the material.
  113569. */
  113570. emissiveColor: Color3;
  113571. /**
  113572. * AKA Glossiness in other nomenclature.
  113573. */
  113574. microSurface: number;
  113575. /**
  113576. * source material index of refraction (IOR)' / 'destination material IOR.
  113577. */
  113578. indexOfRefraction: number;
  113579. /**
  113580. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113581. */
  113582. invertRefractionY: boolean;
  113583. /**
  113584. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113585. * Materials half opaque for instance using refraction could benefit from this control.
  113586. */
  113587. linkRefractionWithTransparency: boolean;
  113588. /**
  113589. * If true, the light map contains occlusion information instead of lighting info.
  113590. */
  113591. useLightmapAsShadowmap: boolean;
  113592. /**
  113593. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  113594. */
  113595. useAlphaFromAlbedoTexture: boolean;
  113596. /**
  113597. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  113598. */
  113599. forceAlphaTest: boolean;
  113600. /**
  113601. * Defines the alpha limits in alpha test mode.
  113602. */
  113603. alphaCutOff: number;
  113604. /**
  113605. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  113606. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  113607. */
  113608. useSpecularOverAlpha: boolean;
  113609. /**
  113610. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  113611. */
  113612. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  113613. /**
  113614. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  113615. */
  113616. useRoughnessFromMetallicTextureAlpha: boolean;
  113617. /**
  113618. * Specifies if the metallic texture contains the roughness information in its green channel.
  113619. */
  113620. useRoughnessFromMetallicTextureGreen: boolean;
  113621. /**
  113622. * Specifies if the metallic texture contains the metallness information in its blue channel.
  113623. */
  113624. useMetallnessFromMetallicTextureBlue: boolean;
  113625. /**
  113626. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  113627. */
  113628. useAmbientOcclusionFromMetallicTextureRed: boolean;
  113629. /**
  113630. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  113631. */
  113632. useAmbientInGrayScale: boolean;
  113633. /**
  113634. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  113635. * The material will try to infer what glossiness each pixel should be.
  113636. */
  113637. useAutoMicroSurfaceFromReflectivityMap: boolean;
  113638. /**
  113639. * BJS is using an harcoded light falloff based on a manually sets up range.
  113640. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113641. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113642. */
  113643. /**
  113644. * BJS is using an harcoded light falloff based on a manually sets up range.
  113645. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  113646. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  113647. */
  113648. usePhysicalLightFalloff: boolean;
  113649. /**
  113650. * In order to support the falloff compatibility with gltf, a special mode has been added
  113651. * to reproduce the gltf light falloff.
  113652. */
  113653. /**
  113654. * In order to support the falloff compatibility with gltf, a special mode has been added
  113655. * to reproduce the gltf light falloff.
  113656. */
  113657. useGLTFLightFalloff: boolean;
  113658. /**
  113659. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  113660. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  113661. */
  113662. useRadianceOverAlpha: boolean;
  113663. /**
  113664. * Allows using an object space normal map (instead of tangent space).
  113665. */
  113666. useObjectSpaceNormalMap: boolean;
  113667. /**
  113668. * Allows using the bump map in parallax mode.
  113669. */
  113670. useParallax: boolean;
  113671. /**
  113672. * Allows using the bump map in parallax occlusion mode.
  113673. */
  113674. useParallaxOcclusion: boolean;
  113675. /**
  113676. * Controls the scale bias of the parallax mode.
  113677. */
  113678. parallaxScaleBias: number;
  113679. /**
  113680. * If sets to true, disables all the lights affecting the material.
  113681. */
  113682. disableLighting: boolean;
  113683. /**
  113684. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  113685. */
  113686. forceIrradianceInFragment: boolean;
  113687. /**
  113688. * Number of Simultaneous lights allowed on the material.
  113689. */
  113690. maxSimultaneousLights: number;
  113691. /**
  113692. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  113693. */
  113694. invertNormalMapX: boolean;
  113695. /**
  113696. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  113697. */
  113698. invertNormalMapY: boolean;
  113699. /**
  113700. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  113701. */
  113702. twoSidedLighting: boolean;
  113703. /**
  113704. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113705. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  113706. */
  113707. useAlphaFresnel: boolean;
  113708. /**
  113709. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  113710. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  113711. */
  113712. useLinearAlphaFresnel: boolean;
  113713. /**
  113714. * Let user defines the brdf lookup texture used for IBL.
  113715. * A default 8bit version is embedded but you could point at :
  113716. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  113717. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  113718. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  113719. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  113720. */
  113721. environmentBRDFTexture: Nullable<BaseTexture>;
  113722. /**
  113723. * Force normal to face away from face.
  113724. */
  113725. forceNormalForward: boolean;
  113726. /**
  113727. * Enables specular anti aliasing in the PBR shader.
  113728. * It will both interacts on the Geometry for analytical and IBL lighting.
  113729. * It also prefilter the roughness map based on the bump values.
  113730. */
  113731. enableSpecularAntiAliasing: boolean;
  113732. /**
  113733. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  113734. * makes the reflect vector face the model (under horizon).
  113735. */
  113736. useHorizonOcclusion: boolean;
  113737. /**
  113738. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  113739. * too much the area relying on ambient texture to define their ambient occlusion.
  113740. */
  113741. useRadianceOcclusion: boolean;
  113742. /**
  113743. * If set to true, no lighting calculations will be applied.
  113744. */
  113745. unlit: boolean;
  113746. /**
  113747. * Gets the image processing configuration used either in this material.
  113748. */
  113749. /**
  113750. * Sets the Default image processing configuration used either in the this material.
  113751. *
  113752. * If sets to null, the scene one is in use.
  113753. */
  113754. imageProcessingConfiguration: ImageProcessingConfiguration;
  113755. /**
  113756. * Gets wether the color curves effect is enabled.
  113757. */
  113758. /**
  113759. * Sets wether the color curves effect is enabled.
  113760. */
  113761. cameraColorCurvesEnabled: boolean;
  113762. /**
  113763. * Gets wether the color grading effect is enabled.
  113764. */
  113765. /**
  113766. * Gets wether the color grading effect is enabled.
  113767. */
  113768. cameraColorGradingEnabled: boolean;
  113769. /**
  113770. * Gets wether tonemapping is enabled or not.
  113771. */
  113772. /**
  113773. * Sets wether tonemapping is enabled or not
  113774. */
  113775. cameraToneMappingEnabled: boolean;
  113776. /**
  113777. * The camera exposure used on this material.
  113778. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113779. * This corresponds to a photographic exposure.
  113780. */
  113781. /**
  113782. * The camera exposure used on this material.
  113783. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  113784. * This corresponds to a photographic exposure.
  113785. */
  113786. cameraExposure: number;
  113787. /**
  113788. * Gets The camera contrast used on this material.
  113789. */
  113790. /**
  113791. * Sets The camera contrast used on this material.
  113792. */
  113793. cameraContrast: number;
  113794. /**
  113795. * Gets the Color Grading 2D Lookup Texture.
  113796. */
  113797. /**
  113798. * Sets the Color Grading 2D Lookup Texture.
  113799. */
  113800. cameraColorGradingTexture: Nullable<BaseTexture>;
  113801. /**
  113802. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113803. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113804. * 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;
  113805. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113806. */
  113807. /**
  113808. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  113809. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  113810. * 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;
  113811. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  113812. */
  113813. cameraColorCurves: Nullable<ColorCurves>;
  113814. /**
  113815. * Instantiates a new PBRMaterial instance.
  113816. *
  113817. * @param name The material name
  113818. * @param scene The scene the material will be use in.
  113819. */
  113820. constructor(name: string, scene: Scene);
  113821. /**
  113822. * Returns the name of this material class.
  113823. */
  113824. getClassName(): string;
  113825. /**
  113826. * Makes a duplicate of the current material.
  113827. * @param name - name to use for the new material.
  113828. */
  113829. clone(name: string): PBRMaterial;
  113830. /**
  113831. * Serializes this PBR Material.
  113832. * @returns - An object with the serialized material.
  113833. */
  113834. serialize(): any;
  113835. /**
  113836. * Parses a PBR Material from a serialized object.
  113837. * @param source - Serialized object.
  113838. * @param scene - BJS scene instance.
  113839. * @param rootUrl - url for the scene object
  113840. * @returns - PBRMaterial
  113841. */
  113842. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  113843. }
  113844. }
  113845. declare module BABYLON {
  113846. /**
  113847. * Direct draw surface info
  113848. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  113849. */
  113850. export interface DDSInfo {
  113851. /**
  113852. * Width of the texture
  113853. */
  113854. width: number;
  113855. /**
  113856. * Width of the texture
  113857. */
  113858. height: number;
  113859. /**
  113860. * Number of Mipmaps for the texture
  113861. * @see https://en.wikipedia.org/wiki/Mipmap
  113862. */
  113863. mipmapCount: number;
  113864. /**
  113865. * If the textures format is a known fourCC format
  113866. * @see https://www.fourcc.org/
  113867. */
  113868. isFourCC: boolean;
  113869. /**
  113870. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  113871. */
  113872. isRGB: boolean;
  113873. /**
  113874. * If the texture is a lumincance format
  113875. */
  113876. isLuminance: boolean;
  113877. /**
  113878. * If this is a cube texture
  113879. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  113880. */
  113881. isCube: boolean;
  113882. /**
  113883. * If the texture is a compressed format eg. FOURCC_DXT1
  113884. */
  113885. isCompressed: boolean;
  113886. /**
  113887. * The dxgiFormat of the texture
  113888. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  113889. */
  113890. dxgiFormat: number;
  113891. /**
  113892. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  113893. */
  113894. textureType: number;
  113895. /**
  113896. * Sphericle polynomial created for the dds texture
  113897. */
  113898. sphericalPolynomial?: SphericalPolynomial;
  113899. }
  113900. /**
  113901. * Class used to provide DDS decompression tools
  113902. */
  113903. export class DDSTools {
  113904. /**
  113905. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  113906. */
  113907. static StoreLODInAlphaChannel: boolean;
  113908. /**
  113909. * Gets DDS information from an array buffer
  113910. * @param arrayBuffer defines the array buffer to read data from
  113911. * @returns the DDS information
  113912. */
  113913. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  113914. private static _FloatView;
  113915. private static _Int32View;
  113916. private static _ToHalfFloat;
  113917. private static _FromHalfFloat;
  113918. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  113919. private static _GetHalfFloatRGBAArrayBuffer;
  113920. private static _GetFloatRGBAArrayBuffer;
  113921. private static _GetFloatAsUIntRGBAArrayBuffer;
  113922. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  113923. private static _GetRGBAArrayBuffer;
  113924. private static _ExtractLongWordOrder;
  113925. private static _GetRGBArrayBuffer;
  113926. private static _GetLuminanceArrayBuffer;
  113927. /**
  113928. * Uploads DDS Levels to a Babylon Texture
  113929. * @hidden
  113930. */
  113931. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  113932. }
  113933. interface Engine {
  113934. /**
  113935. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  113936. * @param rootUrl defines the url where the file to load is located
  113937. * @param scene defines the current scene
  113938. * @param lodScale defines scale to apply to the mip map selection
  113939. * @param lodOffset defines offset to apply to the mip map selection
  113940. * @param onLoad defines an optional callback raised when the texture is loaded
  113941. * @param onError defines an optional callback raised if there is an issue to load the texture
  113942. * @param format defines the format of the data
  113943. * @param forcedExtension defines the extension to use to pick the right loader
  113944. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  113945. * @returns the cube texture as an InternalTexture
  113946. */
  113947. 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;
  113948. }
  113949. }
  113950. declare module BABYLON {
  113951. /**
  113952. * Implementation of the DDS Texture Loader.
  113953. * @hidden
  113954. */
  113955. export class _DDSTextureLoader implements IInternalTextureLoader {
  113956. /**
  113957. * Defines wether the loader supports cascade loading the different faces.
  113958. */
  113959. readonly supportCascades: boolean;
  113960. /**
  113961. * This returns if the loader support the current file information.
  113962. * @param extension defines the file extension of the file being loaded
  113963. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113964. * @param fallback defines the fallback internal texture if any
  113965. * @param isBase64 defines whether the texture is encoded as a base64
  113966. * @param isBuffer defines whether the texture data are stored as a buffer
  113967. * @returns true if the loader can load the specified file
  113968. */
  113969. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  113970. /**
  113971. * Transform the url before loading if required.
  113972. * @param rootUrl the url of the texture
  113973. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113974. * @returns the transformed texture
  113975. */
  113976. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  113977. /**
  113978. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  113979. * @param rootUrl the url of the texture
  113980. * @param textureFormatInUse defines the current compressed format in use iun the engine
  113981. * @returns the fallback texture
  113982. */
  113983. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  113984. /**
  113985. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  113986. * @param data contains the texture data
  113987. * @param texture defines the BabylonJS internal texture
  113988. * @param createPolynomials will be true if polynomials have been requested
  113989. * @param onLoad defines the callback to trigger once the texture is ready
  113990. * @param onError defines the callback to trigger in case of error
  113991. */
  113992. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  113993. /**
  113994. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  113995. * @param data contains the texture data
  113996. * @param texture defines the BabylonJS internal texture
  113997. * @param callback defines the method to call once ready to upload
  113998. */
  113999. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114000. }
  114001. }
  114002. declare module BABYLON {
  114003. /**
  114004. * Implementation of the ENV Texture Loader.
  114005. * @hidden
  114006. */
  114007. export class _ENVTextureLoader implements IInternalTextureLoader {
  114008. /**
  114009. * Defines wether the loader supports cascade loading the different faces.
  114010. */
  114011. readonly supportCascades: boolean;
  114012. /**
  114013. * This returns if the loader support the current file information.
  114014. * @param extension defines the file extension of the file being loaded
  114015. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114016. * @param fallback defines the fallback internal texture if any
  114017. * @param isBase64 defines whether the texture is encoded as a base64
  114018. * @param isBuffer defines whether the texture data are stored as a buffer
  114019. * @returns true if the loader can load the specified file
  114020. */
  114021. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114022. /**
  114023. * Transform the url before loading if required.
  114024. * @param rootUrl the url of the texture
  114025. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114026. * @returns the transformed texture
  114027. */
  114028. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114029. /**
  114030. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114031. * @param rootUrl the url of the texture
  114032. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114033. * @returns the fallback texture
  114034. */
  114035. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114036. /**
  114037. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114038. * @param data contains the texture data
  114039. * @param texture defines the BabylonJS internal texture
  114040. * @param createPolynomials will be true if polynomials have been requested
  114041. * @param onLoad defines the callback to trigger once the texture is ready
  114042. * @param onError defines the callback to trigger in case of error
  114043. */
  114044. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114045. /**
  114046. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114047. * @param data contains the texture data
  114048. * @param texture defines the BabylonJS internal texture
  114049. * @param callback defines the method to call once ready to upload
  114050. */
  114051. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114052. }
  114053. }
  114054. declare module BABYLON {
  114055. /**
  114056. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  114057. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  114058. */
  114059. export class KhronosTextureContainer {
  114060. /** contents of the KTX container file */
  114061. arrayBuffer: any;
  114062. private static HEADER_LEN;
  114063. private static COMPRESSED_2D;
  114064. private static COMPRESSED_3D;
  114065. private static TEX_2D;
  114066. private static TEX_3D;
  114067. /**
  114068. * Gets the openGL type
  114069. */
  114070. glType: number;
  114071. /**
  114072. * Gets the openGL type size
  114073. */
  114074. glTypeSize: number;
  114075. /**
  114076. * Gets the openGL format
  114077. */
  114078. glFormat: number;
  114079. /**
  114080. * Gets the openGL internal format
  114081. */
  114082. glInternalFormat: number;
  114083. /**
  114084. * Gets the base internal format
  114085. */
  114086. glBaseInternalFormat: number;
  114087. /**
  114088. * Gets image width in pixel
  114089. */
  114090. pixelWidth: number;
  114091. /**
  114092. * Gets image height in pixel
  114093. */
  114094. pixelHeight: number;
  114095. /**
  114096. * Gets image depth in pixels
  114097. */
  114098. pixelDepth: number;
  114099. /**
  114100. * Gets the number of array elements
  114101. */
  114102. numberOfArrayElements: number;
  114103. /**
  114104. * Gets the number of faces
  114105. */
  114106. numberOfFaces: number;
  114107. /**
  114108. * Gets the number of mipmap levels
  114109. */
  114110. numberOfMipmapLevels: number;
  114111. /**
  114112. * Gets the bytes of key value data
  114113. */
  114114. bytesOfKeyValueData: number;
  114115. /**
  114116. * Gets the load type
  114117. */
  114118. loadType: number;
  114119. /**
  114120. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  114121. */
  114122. isInvalid: boolean;
  114123. /**
  114124. * Creates a new KhronosTextureContainer
  114125. * @param arrayBuffer contents of the KTX container file
  114126. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  114127. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  114128. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  114129. */
  114130. constructor(
  114131. /** contents of the KTX container file */
  114132. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  114133. /**
  114134. * Uploads KTX content to a Babylon Texture.
  114135. * It is assumed that the texture has already been created & is currently bound
  114136. * @hidden
  114137. */
  114138. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  114139. private _upload2DCompressedLevels;
  114140. }
  114141. }
  114142. declare module BABYLON {
  114143. /**
  114144. * Implementation of the KTX Texture Loader.
  114145. * @hidden
  114146. */
  114147. export class _KTXTextureLoader implements IInternalTextureLoader {
  114148. /**
  114149. * Defines wether the loader supports cascade loading the different faces.
  114150. */
  114151. readonly supportCascades: boolean;
  114152. /**
  114153. * This returns if the loader support the current file information.
  114154. * @param extension defines the file extension of the file being loaded
  114155. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114156. * @param fallback defines the fallback internal texture if any
  114157. * @param isBase64 defines whether the texture is encoded as a base64
  114158. * @param isBuffer defines whether the texture data are stored as a buffer
  114159. * @returns true if the loader can load the specified file
  114160. */
  114161. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114162. /**
  114163. * Transform the url before loading if required.
  114164. * @param rootUrl the url of the texture
  114165. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114166. * @returns the transformed texture
  114167. */
  114168. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114169. /**
  114170. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114171. * @param rootUrl the url of the texture
  114172. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114173. * @returns the fallback texture
  114174. */
  114175. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114176. /**
  114177. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114178. * @param data contains the texture data
  114179. * @param texture defines the BabylonJS internal texture
  114180. * @param createPolynomials will be true if polynomials have been requested
  114181. * @param onLoad defines the callback to trigger once the texture is ready
  114182. * @param onError defines the callback to trigger in case of error
  114183. */
  114184. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114185. /**
  114186. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114187. * @param data contains the texture data
  114188. * @param texture defines the BabylonJS internal texture
  114189. * @param callback defines the method to call once ready to upload
  114190. */
  114191. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  114192. }
  114193. }
  114194. declare module BABYLON {
  114195. /**
  114196. * Options for the default xr helper
  114197. */
  114198. export class WebXRDefaultExperienceOptions {
  114199. /**
  114200. * Floor meshes that should be used for teleporting
  114201. */
  114202. floorMeshes: Array<AbstractMesh>;
  114203. }
  114204. /**
  114205. * Default experience which provides a similar setup to the previous webVRExperience
  114206. */
  114207. export class WebXRDefaultExperience {
  114208. /**
  114209. * Base experience
  114210. */
  114211. baseExperience: WebXRExperienceHelper;
  114212. /**
  114213. * Input experience extension
  114214. */
  114215. input: WebXRInput;
  114216. /**
  114217. * Loads the controller models
  114218. */
  114219. controllerModelLoader: WebXRControllerModelLoader;
  114220. /**
  114221. * Enables laser pointer and selection
  114222. */
  114223. pointerSelection: WebXRControllerPointerSelection;
  114224. /**
  114225. * Enables teleportation
  114226. */
  114227. teleportation: WebXRControllerTeleportation;
  114228. /**
  114229. * Enables ui for enetering/exiting xr
  114230. */
  114231. enterExitUI: WebXREnterExitUI;
  114232. /**
  114233. * Default output canvas xr should render to
  114234. */
  114235. outputCanvas: WebXRManagedOutputCanvas;
  114236. /**
  114237. * Creates the default xr experience
  114238. * @param scene scene
  114239. * @param options options for basic configuration
  114240. * @returns resulting WebXRDefaultExperience
  114241. */
  114242. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114243. private constructor();
  114244. /**
  114245. * DIsposes of the experience helper
  114246. */
  114247. dispose(): void;
  114248. }
  114249. }
  114250. declare module BABYLON {
  114251. /** @hidden */
  114252. export var _forceSceneHelpersToBundle: boolean;
  114253. interface Scene {
  114254. /**
  114255. * Creates a default light for the scene.
  114256. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  114257. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  114258. */
  114259. createDefaultLight(replace?: boolean): void;
  114260. /**
  114261. * Creates a default camera for the scene.
  114262. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  114263. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  114264. * @param replace has default false, when true replaces the active camera in the scene
  114265. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  114266. */
  114267. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  114268. /**
  114269. * Creates a default camera and a default light.
  114270. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  114271. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  114272. * @param replace has the default false, when true replaces the active camera/light in the scene
  114273. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  114274. */
  114275. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  114276. /**
  114277. * Creates a new sky box
  114278. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  114279. * @param environmentTexture defines the texture to use as environment texture
  114280. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  114281. * @param scale defines the overall scale of the skybox
  114282. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  114283. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  114284. * @returns a new mesh holding the sky box
  114285. */
  114286. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  114287. /**
  114288. * Creates a new environment
  114289. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  114290. * @param options defines the options you can use to configure the environment
  114291. * @returns the new EnvironmentHelper
  114292. */
  114293. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  114294. /**
  114295. * Creates a new VREXperienceHelper
  114296. * @see http://doc.babylonjs.com/how_to/webvr_helper
  114297. * @param webVROptions defines the options used to create the new VREXperienceHelper
  114298. * @returns a new VREXperienceHelper
  114299. */
  114300. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  114301. /**
  114302. * Creates a new WebXRDefaultExperience
  114303. * @see http://doc.babylonjs.com/how_to/webxr
  114304. * @param options experience options
  114305. * @returns a promise for a new WebXRDefaultExperience
  114306. */
  114307. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  114308. }
  114309. }
  114310. declare module BABYLON {
  114311. /**
  114312. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  114313. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  114314. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  114315. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  114316. */
  114317. export class VideoDome extends TransformNode {
  114318. /**
  114319. * Define the video source as a Monoscopic panoramic 360 video.
  114320. */
  114321. static readonly MODE_MONOSCOPIC: number;
  114322. /**
  114323. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  114324. */
  114325. static readonly MODE_TOPBOTTOM: number;
  114326. /**
  114327. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  114328. */
  114329. static readonly MODE_SIDEBYSIDE: number;
  114330. private _halfDome;
  114331. private _useDirectMapping;
  114332. /**
  114333. * The video texture being displayed on the sphere
  114334. */
  114335. protected _videoTexture: VideoTexture;
  114336. /**
  114337. * Gets the video texture being displayed on the sphere
  114338. */
  114339. readonly videoTexture: VideoTexture;
  114340. /**
  114341. * The skybox material
  114342. */
  114343. protected _material: BackgroundMaterial;
  114344. /**
  114345. * The surface used for the skybox
  114346. */
  114347. protected _mesh: Mesh;
  114348. /**
  114349. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  114350. */
  114351. private _halfDomeMask;
  114352. /**
  114353. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  114354. * Also see the options.resolution property.
  114355. */
  114356. fovMultiplier: number;
  114357. private _videoMode;
  114358. /**
  114359. * Gets or set the current video mode for the video. It can be:
  114360. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  114361. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  114362. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  114363. */
  114364. videoMode: number;
  114365. /**
  114366. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  114367. *
  114368. */
  114369. /**
  114370. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  114371. */
  114372. halfDome: boolean;
  114373. /**
  114374. * Oberserver used in Stereoscopic VR Mode.
  114375. */
  114376. private _onBeforeCameraRenderObserver;
  114377. /**
  114378. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  114379. * @param name Element's name, child elements will append suffixes for their own names.
  114380. * @param urlsOrVideo defines the url(s) or the video element to use
  114381. * @param options An object containing optional or exposed sub element properties
  114382. */
  114383. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  114384. resolution?: number;
  114385. clickToPlay?: boolean;
  114386. autoPlay?: boolean;
  114387. loop?: boolean;
  114388. size?: number;
  114389. poster?: string;
  114390. faceForward?: boolean;
  114391. useDirectMapping?: boolean;
  114392. halfDomeMode?: boolean;
  114393. }, scene: Scene);
  114394. private _changeVideoMode;
  114395. /**
  114396. * Releases resources associated with this node.
  114397. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114398. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114399. */
  114400. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114401. }
  114402. }
  114403. declare module BABYLON {
  114404. /**
  114405. * This class can be used to get instrumentation data from a Babylon engine
  114406. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114407. */
  114408. export class EngineInstrumentation implements IDisposable {
  114409. /**
  114410. * Define the instrumented engine.
  114411. */
  114412. engine: Engine;
  114413. private _captureGPUFrameTime;
  114414. private _gpuFrameTimeToken;
  114415. private _gpuFrameTime;
  114416. private _captureShaderCompilationTime;
  114417. private _shaderCompilationTime;
  114418. private _onBeginFrameObserver;
  114419. private _onEndFrameObserver;
  114420. private _onBeforeShaderCompilationObserver;
  114421. private _onAfterShaderCompilationObserver;
  114422. /**
  114423. * Gets the perf counter used for GPU frame time
  114424. */
  114425. readonly gpuFrameTimeCounter: PerfCounter;
  114426. /**
  114427. * Gets the GPU frame time capture status
  114428. */
  114429. /**
  114430. * Enable or disable the GPU frame time capture
  114431. */
  114432. captureGPUFrameTime: boolean;
  114433. /**
  114434. * Gets the perf counter used for shader compilation time
  114435. */
  114436. readonly shaderCompilationTimeCounter: PerfCounter;
  114437. /**
  114438. * Gets the shader compilation time capture status
  114439. */
  114440. /**
  114441. * Enable or disable the shader compilation time capture
  114442. */
  114443. captureShaderCompilationTime: boolean;
  114444. /**
  114445. * Instantiates a new engine instrumentation.
  114446. * This class can be used to get instrumentation data from a Babylon engine
  114447. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  114448. * @param engine Defines the engine to instrument
  114449. */
  114450. constructor(
  114451. /**
  114452. * Define the instrumented engine.
  114453. */
  114454. engine: Engine);
  114455. /**
  114456. * Dispose and release associated resources.
  114457. */
  114458. dispose(): void;
  114459. }
  114460. }
  114461. declare module BABYLON {
  114462. /**
  114463. * This class can be used to get instrumentation data from a Babylon engine
  114464. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114465. */
  114466. export class SceneInstrumentation implements IDisposable {
  114467. /**
  114468. * Defines the scene to instrument
  114469. */
  114470. scene: Scene;
  114471. private _captureActiveMeshesEvaluationTime;
  114472. private _activeMeshesEvaluationTime;
  114473. private _captureRenderTargetsRenderTime;
  114474. private _renderTargetsRenderTime;
  114475. private _captureFrameTime;
  114476. private _frameTime;
  114477. private _captureRenderTime;
  114478. private _renderTime;
  114479. private _captureInterFrameTime;
  114480. private _interFrameTime;
  114481. private _captureParticlesRenderTime;
  114482. private _particlesRenderTime;
  114483. private _captureSpritesRenderTime;
  114484. private _spritesRenderTime;
  114485. private _capturePhysicsTime;
  114486. private _physicsTime;
  114487. private _captureAnimationsTime;
  114488. private _animationsTime;
  114489. private _captureCameraRenderTime;
  114490. private _cameraRenderTime;
  114491. private _onBeforeActiveMeshesEvaluationObserver;
  114492. private _onAfterActiveMeshesEvaluationObserver;
  114493. private _onBeforeRenderTargetsRenderObserver;
  114494. private _onAfterRenderTargetsRenderObserver;
  114495. private _onAfterRenderObserver;
  114496. private _onBeforeDrawPhaseObserver;
  114497. private _onAfterDrawPhaseObserver;
  114498. private _onBeforeAnimationsObserver;
  114499. private _onBeforeParticlesRenderingObserver;
  114500. private _onAfterParticlesRenderingObserver;
  114501. private _onBeforeSpritesRenderingObserver;
  114502. private _onAfterSpritesRenderingObserver;
  114503. private _onBeforePhysicsObserver;
  114504. private _onAfterPhysicsObserver;
  114505. private _onAfterAnimationsObserver;
  114506. private _onBeforeCameraRenderObserver;
  114507. private _onAfterCameraRenderObserver;
  114508. /**
  114509. * Gets the perf counter used for active meshes evaluation time
  114510. */
  114511. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  114512. /**
  114513. * Gets the active meshes evaluation time capture status
  114514. */
  114515. /**
  114516. * Enable or disable the active meshes evaluation time capture
  114517. */
  114518. captureActiveMeshesEvaluationTime: boolean;
  114519. /**
  114520. * Gets the perf counter used for render targets render time
  114521. */
  114522. readonly renderTargetsRenderTimeCounter: PerfCounter;
  114523. /**
  114524. * Gets the render targets render time capture status
  114525. */
  114526. /**
  114527. * Enable or disable the render targets render time capture
  114528. */
  114529. captureRenderTargetsRenderTime: boolean;
  114530. /**
  114531. * Gets the perf counter used for particles render time
  114532. */
  114533. readonly particlesRenderTimeCounter: PerfCounter;
  114534. /**
  114535. * Gets the particles render time capture status
  114536. */
  114537. /**
  114538. * Enable or disable the particles render time capture
  114539. */
  114540. captureParticlesRenderTime: boolean;
  114541. /**
  114542. * Gets the perf counter used for sprites render time
  114543. */
  114544. readonly spritesRenderTimeCounter: PerfCounter;
  114545. /**
  114546. * Gets the sprites render time capture status
  114547. */
  114548. /**
  114549. * Enable or disable the sprites render time capture
  114550. */
  114551. captureSpritesRenderTime: boolean;
  114552. /**
  114553. * Gets the perf counter used for physics time
  114554. */
  114555. readonly physicsTimeCounter: PerfCounter;
  114556. /**
  114557. * Gets the physics time capture status
  114558. */
  114559. /**
  114560. * Enable or disable the physics time capture
  114561. */
  114562. capturePhysicsTime: boolean;
  114563. /**
  114564. * Gets the perf counter used for animations time
  114565. */
  114566. readonly animationsTimeCounter: PerfCounter;
  114567. /**
  114568. * Gets the animations time capture status
  114569. */
  114570. /**
  114571. * Enable or disable the animations time capture
  114572. */
  114573. captureAnimationsTime: boolean;
  114574. /**
  114575. * Gets the perf counter used for frame time capture
  114576. */
  114577. readonly frameTimeCounter: PerfCounter;
  114578. /**
  114579. * Gets the frame time capture status
  114580. */
  114581. /**
  114582. * Enable or disable the frame time capture
  114583. */
  114584. captureFrameTime: boolean;
  114585. /**
  114586. * Gets the perf counter used for inter-frames time capture
  114587. */
  114588. readonly interFrameTimeCounter: PerfCounter;
  114589. /**
  114590. * Gets the inter-frames time capture status
  114591. */
  114592. /**
  114593. * Enable or disable the inter-frames time capture
  114594. */
  114595. captureInterFrameTime: boolean;
  114596. /**
  114597. * Gets the perf counter used for render time capture
  114598. */
  114599. readonly renderTimeCounter: PerfCounter;
  114600. /**
  114601. * Gets the render time capture status
  114602. */
  114603. /**
  114604. * Enable or disable the render time capture
  114605. */
  114606. captureRenderTime: boolean;
  114607. /**
  114608. * Gets the perf counter used for camera render time capture
  114609. */
  114610. readonly cameraRenderTimeCounter: PerfCounter;
  114611. /**
  114612. * Gets the camera render time capture status
  114613. */
  114614. /**
  114615. * Enable or disable the camera render time capture
  114616. */
  114617. captureCameraRenderTime: boolean;
  114618. /**
  114619. * Gets the perf counter used for draw calls
  114620. */
  114621. readonly drawCallsCounter: PerfCounter;
  114622. /**
  114623. * Instantiates a new scene instrumentation.
  114624. * This class can be used to get instrumentation data from a Babylon engine
  114625. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  114626. * @param scene Defines the scene to instrument
  114627. */
  114628. constructor(
  114629. /**
  114630. * Defines the scene to instrument
  114631. */
  114632. scene: Scene);
  114633. /**
  114634. * Dispose and release associated resources.
  114635. */
  114636. dispose(): void;
  114637. }
  114638. }
  114639. declare module BABYLON {
  114640. /** @hidden */
  114641. export var glowMapGenerationPixelShader: {
  114642. name: string;
  114643. shader: string;
  114644. };
  114645. }
  114646. declare module BABYLON {
  114647. /** @hidden */
  114648. export var glowMapGenerationVertexShader: {
  114649. name: string;
  114650. shader: string;
  114651. };
  114652. }
  114653. declare module BABYLON {
  114654. /**
  114655. * Effect layer options. This helps customizing the behaviour
  114656. * of the effect layer.
  114657. */
  114658. export interface IEffectLayerOptions {
  114659. /**
  114660. * Multiplication factor apply to the canvas size to compute the render target size
  114661. * used to generated the objects (the smaller the faster).
  114662. */
  114663. mainTextureRatio: number;
  114664. /**
  114665. * Enforces a fixed size texture to ensure effect stability across devices.
  114666. */
  114667. mainTextureFixedSize?: number;
  114668. /**
  114669. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  114670. */
  114671. alphaBlendingMode: number;
  114672. /**
  114673. * The camera attached to the layer.
  114674. */
  114675. camera: Nullable<Camera>;
  114676. /**
  114677. * The rendering group to draw the layer in.
  114678. */
  114679. renderingGroupId: number;
  114680. }
  114681. /**
  114682. * The effect layer Helps adding post process effect blended with the main pass.
  114683. *
  114684. * This can be for instance use to generate glow or higlight effects on the scene.
  114685. *
  114686. * The effect layer class can not be used directly and is intented to inherited from to be
  114687. * customized per effects.
  114688. */
  114689. export abstract class EffectLayer {
  114690. private _vertexBuffers;
  114691. private _indexBuffer;
  114692. private _cachedDefines;
  114693. private _effectLayerMapGenerationEffect;
  114694. private _effectLayerOptions;
  114695. private _mergeEffect;
  114696. protected _scene: Scene;
  114697. protected _engine: Engine;
  114698. protected _maxSize: number;
  114699. protected _mainTextureDesiredSize: ISize;
  114700. protected _mainTexture: RenderTargetTexture;
  114701. protected _shouldRender: boolean;
  114702. protected _postProcesses: PostProcess[];
  114703. protected _textures: BaseTexture[];
  114704. protected _emissiveTextureAndColor: {
  114705. texture: Nullable<BaseTexture>;
  114706. color: Color4;
  114707. };
  114708. /**
  114709. * The name of the layer
  114710. */
  114711. name: string;
  114712. /**
  114713. * The clear color of the texture used to generate the glow map.
  114714. */
  114715. neutralColor: Color4;
  114716. /**
  114717. * Specifies wether the highlight layer is enabled or not.
  114718. */
  114719. isEnabled: boolean;
  114720. /**
  114721. * Gets the camera attached to the layer.
  114722. */
  114723. readonly camera: Nullable<Camera>;
  114724. /**
  114725. * Gets the rendering group id the layer should render in.
  114726. */
  114727. renderingGroupId: number;
  114728. /**
  114729. * An event triggered when the effect layer has been disposed.
  114730. */
  114731. onDisposeObservable: Observable<EffectLayer>;
  114732. /**
  114733. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  114734. */
  114735. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  114736. /**
  114737. * An event triggered when the generated texture is being merged in the scene.
  114738. */
  114739. onBeforeComposeObservable: Observable<EffectLayer>;
  114740. /**
  114741. * An event triggered when the generated texture has been merged in the scene.
  114742. */
  114743. onAfterComposeObservable: Observable<EffectLayer>;
  114744. /**
  114745. * An event triggered when the efffect layer changes its size.
  114746. */
  114747. onSizeChangedObservable: Observable<EffectLayer>;
  114748. /** @hidden */
  114749. static _SceneComponentInitialization: (scene: Scene) => void;
  114750. /**
  114751. * Instantiates a new effect Layer and references it in the scene.
  114752. * @param name The name of the layer
  114753. * @param scene The scene to use the layer in
  114754. */
  114755. constructor(
  114756. /** The Friendly of the effect in the scene */
  114757. name: string, scene: Scene);
  114758. /**
  114759. * Get the effect name of the layer.
  114760. * @return The effect name
  114761. */
  114762. abstract getEffectName(): string;
  114763. /**
  114764. * Checks for the readiness of the element composing the layer.
  114765. * @param subMesh the mesh to check for
  114766. * @param useInstances specify wether or not to use instances to render the mesh
  114767. * @return true if ready otherwise, false
  114768. */
  114769. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114770. /**
  114771. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  114772. * @returns true if the effect requires stencil during the main canvas render pass.
  114773. */
  114774. abstract needStencil(): boolean;
  114775. /**
  114776. * Create the merge effect. This is the shader use to blit the information back
  114777. * to the main canvas at the end of the scene rendering.
  114778. * @returns The effect containing the shader used to merge the effect on the main canvas
  114779. */
  114780. protected abstract _createMergeEffect(): Effect;
  114781. /**
  114782. * Creates the render target textures and post processes used in the effect layer.
  114783. */
  114784. protected abstract _createTextureAndPostProcesses(): void;
  114785. /**
  114786. * Implementation specific of rendering the generating effect on the main canvas.
  114787. * @param effect The effect used to render through
  114788. */
  114789. protected abstract _internalRender(effect: Effect): void;
  114790. /**
  114791. * Sets the required values for both the emissive texture and and the main color.
  114792. */
  114793. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  114794. /**
  114795. * Free any resources and references associated to a mesh.
  114796. * Internal use
  114797. * @param mesh The mesh to free.
  114798. */
  114799. abstract _disposeMesh(mesh: Mesh): void;
  114800. /**
  114801. * Serializes this layer (Glow or Highlight for example)
  114802. * @returns a serialized layer object
  114803. */
  114804. abstract serialize?(): any;
  114805. /**
  114806. * Initializes the effect layer with the required options.
  114807. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  114808. */
  114809. protected _init(options: Partial<IEffectLayerOptions>): void;
  114810. /**
  114811. * Generates the index buffer of the full screen quad blending to the main canvas.
  114812. */
  114813. private _generateIndexBuffer;
  114814. /**
  114815. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  114816. */
  114817. private _generateVertexBuffer;
  114818. /**
  114819. * Sets the main texture desired size which is the closest power of two
  114820. * of the engine canvas size.
  114821. */
  114822. private _setMainTextureSize;
  114823. /**
  114824. * Creates the main texture for the effect layer.
  114825. */
  114826. protected _createMainTexture(): void;
  114827. /**
  114828. * Adds specific effects defines.
  114829. * @param defines The defines to add specifics to.
  114830. */
  114831. protected _addCustomEffectDefines(defines: string[]): void;
  114832. /**
  114833. * Checks for the readiness of the element composing the layer.
  114834. * @param subMesh the mesh to check for
  114835. * @param useInstances specify wether or not to use instances to render the mesh
  114836. * @param emissiveTexture the associated emissive texture used to generate the glow
  114837. * @return true if ready otherwise, false
  114838. */
  114839. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  114840. /**
  114841. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  114842. */
  114843. render(): void;
  114844. /**
  114845. * Determine if a given mesh will be used in the current effect.
  114846. * @param mesh mesh to test
  114847. * @returns true if the mesh will be used
  114848. */
  114849. hasMesh(mesh: AbstractMesh): boolean;
  114850. /**
  114851. * Returns true if the layer contains information to display, otherwise false.
  114852. * @returns true if the glow layer should be rendered
  114853. */
  114854. shouldRender(): boolean;
  114855. /**
  114856. * Returns true if the mesh should render, otherwise false.
  114857. * @param mesh The mesh to render
  114858. * @returns true if it should render otherwise false
  114859. */
  114860. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  114861. /**
  114862. * Returns true if the mesh can be rendered, otherwise false.
  114863. * @param mesh The mesh to render
  114864. * @param material The material used on the mesh
  114865. * @returns true if it can be rendered otherwise false
  114866. */
  114867. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  114868. /**
  114869. * Returns true if the mesh should render, otherwise false.
  114870. * @param mesh The mesh to render
  114871. * @returns true if it should render otherwise false
  114872. */
  114873. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  114874. /**
  114875. * Renders the submesh passed in parameter to the generation map.
  114876. */
  114877. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  114878. /**
  114879. * Rebuild the required buffers.
  114880. * @hidden Internal use only.
  114881. */
  114882. _rebuild(): void;
  114883. /**
  114884. * Dispose only the render target textures and post process.
  114885. */
  114886. private _disposeTextureAndPostProcesses;
  114887. /**
  114888. * Dispose the highlight layer and free resources.
  114889. */
  114890. dispose(): void;
  114891. /**
  114892. * Gets the class name of the effect layer
  114893. * @returns the string with the class name of the effect layer
  114894. */
  114895. getClassName(): string;
  114896. /**
  114897. * Creates an effect layer from parsed effect layer data
  114898. * @param parsedEffectLayer defines effect layer data
  114899. * @param scene defines the current scene
  114900. * @param rootUrl defines the root URL containing the effect layer information
  114901. * @returns a parsed effect Layer
  114902. */
  114903. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  114904. }
  114905. }
  114906. declare module BABYLON {
  114907. interface AbstractScene {
  114908. /**
  114909. * The list of effect layers (highlights/glow) added to the scene
  114910. * @see http://doc.babylonjs.com/how_to/highlight_layer
  114911. * @see http://doc.babylonjs.com/how_to/glow_layer
  114912. */
  114913. effectLayers: Array<EffectLayer>;
  114914. /**
  114915. * Removes the given effect layer from this scene.
  114916. * @param toRemove defines the effect layer to remove
  114917. * @returns the index of the removed effect layer
  114918. */
  114919. removeEffectLayer(toRemove: EffectLayer): number;
  114920. /**
  114921. * Adds the given effect layer to this scene
  114922. * @param newEffectLayer defines the effect layer to add
  114923. */
  114924. addEffectLayer(newEffectLayer: EffectLayer): void;
  114925. }
  114926. /**
  114927. * Defines the layer scene component responsible to manage any effect layers
  114928. * in a given scene.
  114929. */
  114930. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  114931. /**
  114932. * The component name helpfull to identify the component in the list of scene components.
  114933. */
  114934. readonly name: string;
  114935. /**
  114936. * The scene the component belongs to.
  114937. */
  114938. scene: Scene;
  114939. private _engine;
  114940. private _renderEffects;
  114941. private _needStencil;
  114942. private _previousStencilState;
  114943. /**
  114944. * Creates a new instance of the component for the given scene
  114945. * @param scene Defines the scene to register the component in
  114946. */
  114947. constructor(scene: Scene);
  114948. /**
  114949. * Registers the component in a given scene
  114950. */
  114951. register(): void;
  114952. /**
  114953. * Rebuilds the elements related to this component in case of
  114954. * context lost for instance.
  114955. */
  114956. rebuild(): void;
  114957. /**
  114958. * Serializes the component data to the specified json object
  114959. * @param serializationObject The object to serialize to
  114960. */
  114961. serialize(serializationObject: any): void;
  114962. /**
  114963. * Adds all the elements from the container to the scene
  114964. * @param container the container holding the elements
  114965. */
  114966. addFromContainer(container: AbstractScene): void;
  114967. /**
  114968. * Removes all the elements in the container from the scene
  114969. * @param container contains the elements to remove
  114970. * @param dispose if the removed element should be disposed (default: false)
  114971. */
  114972. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  114973. /**
  114974. * Disposes the component and the associated ressources.
  114975. */
  114976. dispose(): void;
  114977. private _isReadyForMesh;
  114978. private _renderMainTexture;
  114979. private _setStencil;
  114980. private _setStencilBack;
  114981. private _draw;
  114982. private _drawCamera;
  114983. private _drawRenderingGroup;
  114984. }
  114985. }
  114986. declare module BABYLON {
  114987. /** @hidden */
  114988. export var glowMapMergePixelShader: {
  114989. name: string;
  114990. shader: string;
  114991. };
  114992. }
  114993. declare module BABYLON {
  114994. /** @hidden */
  114995. export var glowMapMergeVertexShader: {
  114996. name: string;
  114997. shader: string;
  114998. };
  114999. }
  115000. declare module BABYLON {
  115001. interface AbstractScene {
  115002. /**
  115003. * Return a the first highlight layer of the scene with a given name.
  115004. * @param name The name of the highlight layer to look for.
  115005. * @return The highlight layer if found otherwise null.
  115006. */
  115007. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  115008. }
  115009. /**
  115010. * Glow layer options. This helps customizing the behaviour
  115011. * of the glow layer.
  115012. */
  115013. export interface IGlowLayerOptions {
  115014. /**
  115015. * Multiplication factor apply to the canvas size to compute the render target size
  115016. * used to generated the glowing objects (the smaller the faster).
  115017. */
  115018. mainTextureRatio: number;
  115019. /**
  115020. * Enforces a fixed size texture to ensure resize independant blur.
  115021. */
  115022. mainTextureFixedSize?: number;
  115023. /**
  115024. * How big is the kernel of the blur texture.
  115025. */
  115026. blurKernelSize: number;
  115027. /**
  115028. * The camera attached to the layer.
  115029. */
  115030. camera: Nullable<Camera>;
  115031. /**
  115032. * Enable MSAA by chosing the number of samples.
  115033. */
  115034. mainTextureSamples?: number;
  115035. /**
  115036. * The rendering group to draw the layer in.
  115037. */
  115038. renderingGroupId: number;
  115039. }
  115040. /**
  115041. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  115042. *
  115043. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  115044. * glowy meshes to your scene.
  115045. *
  115046. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  115047. */
  115048. export class GlowLayer extends EffectLayer {
  115049. /**
  115050. * Effect Name of the layer.
  115051. */
  115052. static readonly EffectName: string;
  115053. /**
  115054. * The default blur kernel size used for the glow.
  115055. */
  115056. static DefaultBlurKernelSize: number;
  115057. /**
  115058. * The default texture size ratio used for the glow.
  115059. */
  115060. static DefaultTextureRatio: number;
  115061. /**
  115062. * Sets the kernel size of the blur.
  115063. */
  115064. /**
  115065. * Gets the kernel size of the blur.
  115066. */
  115067. blurKernelSize: number;
  115068. /**
  115069. * Sets the glow intensity.
  115070. */
  115071. /**
  115072. * Gets the glow intensity.
  115073. */
  115074. intensity: number;
  115075. private _options;
  115076. private _intensity;
  115077. private _horizontalBlurPostprocess1;
  115078. private _verticalBlurPostprocess1;
  115079. private _horizontalBlurPostprocess2;
  115080. private _verticalBlurPostprocess2;
  115081. private _blurTexture1;
  115082. private _blurTexture2;
  115083. private _postProcesses1;
  115084. private _postProcesses2;
  115085. private _includedOnlyMeshes;
  115086. private _excludedMeshes;
  115087. /**
  115088. * Callback used to let the user override the color selection on a per mesh basis
  115089. */
  115090. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  115091. /**
  115092. * Callback used to let the user override the texture selection on a per mesh basis
  115093. */
  115094. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  115095. /**
  115096. * Instantiates a new glow Layer and references it to the scene.
  115097. * @param name The name of the layer
  115098. * @param scene The scene to use the layer in
  115099. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  115100. */
  115101. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  115102. /**
  115103. * Get the effect name of the layer.
  115104. * @return The effect name
  115105. */
  115106. getEffectName(): string;
  115107. /**
  115108. * Create the merge effect. This is the shader use to blit the information back
  115109. * to the main canvas at the end of the scene rendering.
  115110. */
  115111. protected _createMergeEffect(): Effect;
  115112. /**
  115113. * Creates the render target textures and post processes used in the glow layer.
  115114. */
  115115. protected _createTextureAndPostProcesses(): void;
  115116. /**
  115117. * Checks for the readiness of the element composing the layer.
  115118. * @param subMesh the mesh to check for
  115119. * @param useInstances specify wether or not to use instances to render the mesh
  115120. * @param emissiveTexture the associated emissive texture used to generate the glow
  115121. * @return true if ready otherwise, false
  115122. */
  115123. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115124. /**
  115125. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115126. */
  115127. needStencil(): boolean;
  115128. /**
  115129. * Returns true if the mesh can be rendered, otherwise false.
  115130. * @param mesh The mesh to render
  115131. * @param material The material used on the mesh
  115132. * @returns true if it can be rendered otherwise false
  115133. */
  115134. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  115135. /**
  115136. * Implementation specific of rendering the generating effect on the main canvas.
  115137. * @param effect The effect used to render through
  115138. */
  115139. protected _internalRender(effect: Effect): void;
  115140. /**
  115141. * Sets the required values for both the emissive texture and and the main color.
  115142. */
  115143. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115144. /**
  115145. * Returns true if the mesh should render, otherwise false.
  115146. * @param mesh The mesh to render
  115147. * @returns true if it should render otherwise false
  115148. */
  115149. protected _shouldRenderMesh(mesh: Mesh): boolean;
  115150. /**
  115151. * Adds specific effects defines.
  115152. * @param defines The defines to add specifics to.
  115153. */
  115154. protected _addCustomEffectDefines(defines: string[]): void;
  115155. /**
  115156. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  115157. * @param mesh The mesh to exclude from the glow layer
  115158. */
  115159. addExcludedMesh(mesh: Mesh): void;
  115160. /**
  115161. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  115162. * @param mesh The mesh to remove
  115163. */
  115164. removeExcludedMesh(mesh: Mesh): void;
  115165. /**
  115166. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  115167. * @param mesh The mesh to include in the glow layer
  115168. */
  115169. addIncludedOnlyMesh(mesh: Mesh): void;
  115170. /**
  115171. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  115172. * @param mesh The mesh to remove
  115173. */
  115174. removeIncludedOnlyMesh(mesh: Mesh): void;
  115175. /**
  115176. * Determine if a given mesh will be used in the glow layer
  115177. * @param mesh The mesh to test
  115178. * @returns true if the mesh will be highlighted by the current glow layer
  115179. */
  115180. hasMesh(mesh: AbstractMesh): boolean;
  115181. /**
  115182. * Free any resources and references associated to a mesh.
  115183. * Internal use
  115184. * @param mesh The mesh to free.
  115185. * @hidden
  115186. */
  115187. _disposeMesh(mesh: Mesh): void;
  115188. /**
  115189. * Gets the class name of the effect layer
  115190. * @returns the string with the class name of the effect layer
  115191. */
  115192. getClassName(): string;
  115193. /**
  115194. * Serializes this glow layer
  115195. * @returns a serialized glow layer object
  115196. */
  115197. serialize(): any;
  115198. /**
  115199. * Creates a Glow Layer from parsed glow layer data
  115200. * @param parsedGlowLayer defines glow layer data
  115201. * @param scene defines the current scene
  115202. * @param rootUrl defines the root URL containing the glow layer information
  115203. * @returns a parsed Glow Layer
  115204. */
  115205. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  115206. }
  115207. }
  115208. declare module BABYLON {
  115209. /** @hidden */
  115210. export var glowBlurPostProcessPixelShader: {
  115211. name: string;
  115212. shader: string;
  115213. };
  115214. }
  115215. declare module BABYLON {
  115216. interface AbstractScene {
  115217. /**
  115218. * Return a the first highlight layer of the scene with a given name.
  115219. * @param name The name of the highlight layer to look for.
  115220. * @return The highlight layer if found otherwise null.
  115221. */
  115222. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  115223. }
  115224. /**
  115225. * Highlight layer options. This helps customizing the behaviour
  115226. * of the highlight layer.
  115227. */
  115228. export interface IHighlightLayerOptions {
  115229. /**
  115230. * Multiplication factor apply to the canvas size to compute the render target size
  115231. * used to generated the glowing objects (the smaller the faster).
  115232. */
  115233. mainTextureRatio: number;
  115234. /**
  115235. * Enforces a fixed size texture to ensure resize independant blur.
  115236. */
  115237. mainTextureFixedSize?: number;
  115238. /**
  115239. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  115240. * of the picture to blur (the smaller the faster).
  115241. */
  115242. blurTextureSizeRatio: number;
  115243. /**
  115244. * How big in texel of the blur texture is the vertical blur.
  115245. */
  115246. blurVerticalSize: number;
  115247. /**
  115248. * How big in texel of the blur texture is the horizontal blur.
  115249. */
  115250. blurHorizontalSize: number;
  115251. /**
  115252. * Alpha blending mode used to apply the blur. Default is combine.
  115253. */
  115254. alphaBlendingMode: number;
  115255. /**
  115256. * The camera attached to the layer.
  115257. */
  115258. camera: Nullable<Camera>;
  115259. /**
  115260. * Should we display highlight as a solid stroke?
  115261. */
  115262. isStroke?: boolean;
  115263. /**
  115264. * The rendering group to draw the layer in.
  115265. */
  115266. renderingGroupId: number;
  115267. }
  115268. /**
  115269. * The highlight layer Helps adding a glow effect around a mesh.
  115270. *
  115271. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  115272. * glowy meshes to your scene.
  115273. *
  115274. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  115275. */
  115276. export class HighlightLayer extends EffectLayer {
  115277. name: string;
  115278. /**
  115279. * Effect Name of the highlight layer.
  115280. */
  115281. static readonly EffectName: string;
  115282. /**
  115283. * The neutral color used during the preparation of the glow effect.
  115284. * This is black by default as the blend operation is a blend operation.
  115285. */
  115286. static NeutralColor: Color4;
  115287. /**
  115288. * Stencil value used for glowing meshes.
  115289. */
  115290. static GlowingMeshStencilReference: number;
  115291. /**
  115292. * Stencil value used for the other meshes in the scene.
  115293. */
  115294. static NormalMeshStencilReference: number;
  115295. /**
  115296. * Specifies whether or not the inner glow is ACTIVE in the layer.
  115297. */
  115298. innerGlow: boolean;
  115299. /**
  115300. * Specifies whether or not the outer glow is ACTIVE in the layer.
  115301. */
  115302. outerGlow: boolean;
  115303. /**
  115304. * Specifies the horizontal size of the blur.
  115305. */
  115306. /**
  115307. * Gets the horizontal size of the blur.
  115308. */
  115309. blurHorizontalSize: number;
  115310. /**
  115311. * Specifies the vertical size of the blur.
  115312. */
  115313. /**
  115314. * Gets the vertical size of the blur.
  115315. */
  115316. blurVerticalSize: number;
  115317. /**
  115318. * An event triggered when the highlight layer is being blurred.
  115319. */
  115320. onBeforeBlurObservable: Observable<HighlightLayer>;
  115321. /**
  115322. * An event triggered when the highlight layer has been blurred.
  115323. */
  115324. onAfterBlurObservable: Observable<HighlightLayer>;
  115325. private _instanceGlowingMeshStencilReference;
  115326. private _options;
  115327. private _downSamplePostprocess;
  115328. private _horizontalBlurPostprocess;
  115329. private _verticalBlurPostprocess;
  115330. private _blurTexture;
  115331. private _meshes;
  115332. private _excludedMeshes;
  115333. /**
  115334. * Instantiates a new highlight Layer and references it to the scene..
  115335. * @param name The name of the layer
  115336. * @param scene The scene to use the layer in
  115337. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  115338. */
  115339. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  115340. /**
  115341. * Get the effect name of the layer.
  115342. * @return The effect name
  115343. */
  115344. getEffectName(): string;
  115345. /**
  115346. * Create the merge effect. This is the shader use to blit the information back
  115347. * to the main canvas at the end of the scene rendering.
  115348. */
  115349. protected _createMergeEffect(): Effect;
  115350. /**
  115351. * Creates the render target textures and post processes used in the highlight layer.
  115352. */
  115353. protected _createTextureAndPostProcesses(): void;
  115354. /**
  115355. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  115356. */
  115357. needStencil(): boolean;
  115358. /**
  115359. * Checks for the readiness of the element composing the layer.
  115360. * @param subMesh the mesh to check for
  115361. * @param useInstances specify wether or not to use instances to render the mesh
  115362. * @param emissiveTexture the associated emissive texture used to generate the glow
  115363. * @return true if ready otherwise, false
  115364. */
  115365. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  115366. /**
  115367. * Implementation specific of rendering the generating effect on the main canvas.
  115368. * @param effect The effect used to render through
  115369. */
  115370. protected _internalRender(effect: Effect): void;
  115371. /**
  115372. * Returns true if the layer contains information to display, otherwise false.
  115373. */
  115374. shouldRender(): boolean;
  115375. /**
  115376. * Returns true if the mesh should render, otherwise false.
  115377. * @param mesh The mesh to render
  115378. * @returns true if it should render otherwise false
  115379. */
  115380. protected _shouldRenderMesh(mesh: Mesh): boolean;
  115381. /**
  115382. * Sets the required values for both the emissive texture and and the main color.
  115383. */
  115384. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  115385. /**
  115386. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  115387. * @param mesh The mesh to exclude from the highlight layer
  115388. */
  115389. addExcludedMesh(mesh: Mesh): void;
  115390. /**
  115391. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  115392. * @param mesh The mesh to highlight
  115393. */
  115394. removeExcludedMesh(mesh: Mesh): void;
  115395. /**
  115396. * Determine if a given mesh will be highlighted by the current HighlightLayer
  115397. * @param mesh mesh to test
  115398. * @returns true if the mesh will be highlighted by the current HighlightLayer
  115399. */
  115400. hasMesh(mesh: AbstractMesh): boolean;
  115401. /**
  115402. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  115403. * @param mesh The mesh to highlight
  115404. * @param color The color of the highlight
  115405. * @param glowEmissiveOnly Extract the glow from the emissive texture
  115406. */
  115407. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  115408. /**
  115409. * Remove a mesh from the highlight layer in order to make it stop glowing.
  115410. * @param mesh The mesh to highlight
  115411. */
  115412. removeMesh(mesh: Mesh): void;
  115413. /**
  115414. * Force the stencil to the normal expected value for none glowing parts
  115415. */
  115416. private _defaultStencilReference;
  115417. /**
  115418. * Free any resources and references associated to a mesh.
  115419. * Internal use
  115420. * @param mesh The mesh to free.
  115421. * @hidden
  115422. */
  115423. _disposeMesh(mesh: Mesh): void;
  115424. /**
  115425. * Dispose the highlight layer and free resources.
  115426. */
  115427. dispose(): void;
  115428. /**
  115429. * Gets the class name of the effect layer
  115430. * @returns the string with the class name of the effect layer
  115431. */
  115432. getClassName(): string;
  115433. /**
  115434. * Serializes this Highlight layer
  115435. * @returns a serialized Highlight layer object
  115436. */
  115437. serialize(): any;
  115438. /**
  115439. * Creates a Highlight layer from parsed Highlight layer data
  115440. * @param parsedHightlightLayer defines the Highlight layer data
  115441. * @param scene defines the current scene
  115442. * @param rootUrl defines the root URL containing the Highlight layer information
  115443. * @returns a parsed Highlight layer
  115444. */
  115445. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  115446. }
  115447. }
  115448. declare module BABYLON {
  115449. interface AbstractScene {
  115450. /**
  115451. * The list of layers (background and foreground) of the scene
  115452. */
  115453. layers: Array<Layer>;
  115454. }
  115455. /**
  115456. * Defines the layer scene component responsible to manage any layers
  115457. * in a given scene.
  115458. */
  115459. export class LayerSceneComponent implements ISceneComponent {
  115460. /**
  115461. * The component name helpfull to identify the component in the list of scene components.
  115462. */
  115463. readonly name: string;
  115464. /**
  115465. * The scene the component belongs to.
  115466. */
  115467. scene: Scene;
  115468. private _engine;
  115469. /**
  115470. * Creates a new instance of the component for the given scene
  115471. * @param scene Defines the scene to register the component in
  115472. */
  115473. constructor(scene: Scene);
  115474. /**
  115475. * Registers the component in a given scene
  115476. */
  115477. register(): void;
  115478. /**
  115479. * Rebuilds the elements related to this component in case of
  115480. * context lost for instance.
  115481. */
  115482. rebuild(): void;
  115483. /**
  115484. * Disposes the component and the associated ressources.
  115485. */
  115486. dispose(): void;
  115487. private _draw;
  115488. private _drawCameraPredicate;
  115489. private _drawCameraBackground;
  115490. private _drawCameraForeground;
  115491. private _drawRenderTargetPredicate;
  115492. private _drawRenderTargetBackground;
  115493. private _drawRenderTargetForeground;
  115494. /**
  115495. * Adds all the elements from the container to the scene
  115496. * @param container the container holding the elements
  115497. */
  115498. addFromContainer(container: AbstractScene): void;
  115499. /**
  115500. * Removes all the elements in the container from the scene
  115501. * @param container contains the elements to remove
  115502. * @param dispose if the removed element should be disposed (default: false)
  115503. */
  115504. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115505. }
  115506. }
  115507. declare module BABYLON {
  115508. /** @hidden */
  115509. export var layerPixelShader: {
  115510. name: string;
  115511. shader: string;
  115512. };
  115513. }
  115514. declare module BABYLON {
  115515. /** @hidden */
  115516. export var layerVertexShader: {
  115517. name: string;
  115518. shader: string;
  115519. };
  115520. }
  115521. declare module BABYLON {
  115522. /**
  115523. * This represents a full screen 2d layer.
  115524. * This can be useful to display a picture in the background of your scene for instance.
  115525. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115526. */
  115527. export class Layer {
  115528. /**
  115529. * Define the name of the layer.
  115530. */
  115531. name: string;
  115532. /**
  115533. * Define the texture the layer should display.
  115534. */
  115535. texture: Nullable<Texture>;
  115536. /**
  115537. * Is the layer in background or foreground.
  115538. */
  115539. isBackground: boolean;
  115540. /**
  115541. * Define the color of the layer (instead of texture).
  115542. */
  115543. color: Color4;
  115544. /**
  115545. * Define the scale of the layer in order to zoom in out of the texture.
  115546. */
  115547. scale: Vector2;
  115548. /**
  115549. * Define an offset for the layer in order to shift the texture.
  115550. */
  115551. offset: Vector2;
  115552. /**
  115553. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  115554. */
  115555. alphaBlendingMode: number;
  115556. /**
  115557. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  115558. * Alpha test will not mix with the background color in case of transparency.
  115559. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  115560. */
  115561. alphaTest: boolean;
  115562. /**
  115563. * Define a mask to restrict the layer to only some of the scene cameras.
  115564. */
  115565. layerMask: number;
  115566. /**
  115567. * Define the list of render target the layer is visible into.
  115568. */
  115569. renderTargetTextures: RenderTargetTexture[];
  115570. /**
  115571. * Define if the layer is only used in renderTarget or if it also
  115572. * renders in the main frame buffer of the canvas.
  115573. */
  115574. renderOnlyInRenderTargetTextures: boolean;
  115575. private _scene;
  115576. private _vertexBuffers;
  115577. private _indexBuffer;
  115578. private _effect;
  115579. private _alphaTestEffect;
  115580. /**
  115581. * An event triggered when the layer is disposed.
  115582. */
  115583. onDisposeObservable: Observable<Layer>;
  115584. private _onDisposeObserver;
  115585. /**
  115586. * Back compatibility with callback before the onDisposeObservable existed.
  115587. * The set callback will be triggered when the layer has been disposed.
  115588. */
  115589. onDispose: () => void;
  115590. /**
  115591. * An event triggered before rendering the scene
  115592. */
  115593. onBeforeRenderObservable: Observable<Layer>;
  115594. private _onBeforeRenderObserver;
  115595. /**
  115596. * Back compatibility with callback before the onBeforeRenderObservable existed.
  115597. * The set callback will be triggered just before rendering the layer.
  115598. */
  115599. onBeforeRender: () => void;
  115600. /**
  115601. * An event triggered after rendering the scene
  115602. */
  115603. onAfterRenderObservable: Observable<Layer>;
  115604. private _onAfterRenderObserver;
  115605. /**
  115606. * Back compatibility with callback before the onAfterRenderObservable existed.
  115607. * The set callback will be triggered just after rendering the layer.
  115608. */
  115609. onAfterRender: () => void;
  115610. /**
  115611. * Instantiates a new layer.
  115612. * This represents a full screen 2d layer.
  115613. * This can be useful to display a picture in the background of your scene for instance.
  115614. * @see https://www.babylonjs-playground.com/#08A2BS#1
  115615. * @param name Define the name of the layer in the scene
  115616. * @param imgUrl Define the url of the texture to display in the layer
  115617. * @param scene Define the scene the layer belongs to
  115618. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  115619. * @param color Defines a color for the layer
  115620. */
  115621. constructor(
  115622. /**
  115623. * Define the name of the layer.
  115624. */
  115625. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  115626. private _createIndexBuffer;
  115627. /** @hidden */
  115628. _rebuild(): void;
  115629. /**
  115630. * Renders the layer in the scene.
  115631. */
  115632. render(): void;
  115633. /**
  115634. * Disposes and releases the associated ressources.
  115635. */
  115636. dispose(): void;
  115637. }
  115638. }
  115639. declare module BABYLON {
  115640. /** @hidden */
  115641. export var lensFlarePixelShader: {
  115642. name: string;
  115643. shader: string;
  115644. };
  115645. }
  115646. declare module BABYLON {
  115647. /** @hidden */
  115648. export var lensFlareVertexShader: {
  115649. name: string;
  115650. shader: string;
  115651. };
  115652. }
  115653. declare module BABYLON {
  115654. /**
  115655. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115656. * It is usually composed of several `lensFlare`.
  115657. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115658. */
  115659. export class LensFlareSystem {
  115660. /**
  115661. * Define the name of the lens flare system
  115662. */
  115663. name: string;
  115664. /**
  115665. * List of lens flares used in this system.
  115666. */
  115667. lensFlares: LensFlare[];
  115668. /**
  115669. * Define a limit from the border the lens flare can be visible.
  115670. */
  115671. borderLimit: number;
  115672. /**
  115673. * Define a viewport border we do not want to see the lens flare in.
  115674. */
  115675. viewportBorder: number;
  115676. /**
  115677. * Define a predicate which could limit the list of meshes able to occlude the effect.
  115678. */
  115679. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  115680. /**
  115681. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  115682. */
  115683. layerMask: number;
  115684. /**
  115685. * Define the id of the lens flare system in the scene.
  115686. * (equal to name by default)
  115687. */
  115688. id: string;
  115689. private _scene;
  115690. private _emitter;
  115691. private _vertexBuffers;
  115692. private _indexBuffer;
  115693. private _effect;
  115694. private _positionX;
  115695. private _positionY;
  115696. private _isEnabled;
  115697. /** @hidden */
  115698. static _SceneComponentInitialization: (scene: Scene) => void;
  115699. /**
  115700. * Instantiates a lens flare system.
  115701. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  115702. * It is usually composed of several `lensFlare`.
  115703. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115704. * @param name Define the name of the lens flare system in the scene
  115705. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  115706. * @param scene Define the scene the lens flare system belongs to
  115707. */
  115708. constructor(
  115709. /**
  115710. * Define the name of the lens flare system
  115711. */
  115712. name: string, emitter: any, scene: Scene);
  115713. /**
  115714. * Define if the lens flare system is enabled.
  115715. */
  115716. isEnabled: boolean;
  115717. /**
  115718. * Get the scene the effects belongs to.
  115719. * @returns the scene holding the lens flare system
  115720. */
  115721. getScene(): Scene;
  115722. /**
  115723. * Get the emitter of the lens flare system.
  115724. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115725. * @returns the emitter of the lens flare system
  115726. */
  115727. getEmitter(): any;
  115728. /**
  115729. * Set the emitter of the lens flare system.
  115730. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  115731. * @param newEmitter Define the new emitter of the system
  115732. */
  115733. setEmitter(newEmitter: any): void;
  115734. /**
  115735. * Get the lens flare system emitter position.
  115736. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  115737. * @returns the position
  115738. */
  115739. getEmitterPosition(): Vector3;
  115740. /**
  115741. * @hidden
  115742. */
  115743. computeEffectivePosition(globalViewport: Viewport): boolean;
  115744. /** @hidden */
  115745. _isVisible(): boolean;
  115746. /**
  115747. * @hidden
  115748. */
  115749. render(): boolean;
  115750. /**
  115751. * Dispose and release the lens flare with its associated resources.
  115752. */
  115753. dispose(): void;
  115754. /**
  115755. * Parse a lens flare system from a JSON repressentation
  115756. * @param parsedLensFlareSystem Define the JSON to parse
  115757. * @param scene Define the scene the parsed system should be instantiated in
  115758. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  115759. * @returns the parsed system
  115760. */
  115761. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  115762. /**
  115763. * Serialize the current Lens Flare System into a JSON representation.
  115764. * @returns the serialized JSON
  115765. */
  115766. serialize(): any;
  115767. }
  115768. }
  115769. declare module BABYLON {
  115770. /**
  115771. * This represents one of the lens effect in a `lensFlareSystem`.
  115772. * It controls one of the indiviual texture used in the effect.
  115773. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115774. */
  115775. export class LensFlare {
  115776. /**
  115777. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115778. */
  115779. size: number;
  115780. /**
  115781. * 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.
  115782. */
  115783. position: number;
  115784. /**
  115785. * Define the lens color.
  115786. */
  115787. color: Color3;
  115788. /**
  115789. * Define the lens texture.
  115790. */
  115791. texture: Nullable<Texture>;
  115792. /**
  115793. * Define the alpha mode to render this particular lens.
  115794. */
  115795. alphaMode: number;
  115796. private _system;
  115797. /**
  115798. * Creates a new Lens Flare.
  115799. * This represents one of the lens effect in a `lensFlareSystem`.
  115800. * It controls one of the indiviual texture used in the effect.
  115801. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115802. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  115803. * @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.
  115804. * @param color Define the lens color
  115805. * @param imgUrl Define the lens texture url
  115806. * @param system Define the `lensFlareSystem` this flare is part of
  115807. * @returns The newly created Lens Flare
  115808. */
  115809. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  115810. /**
  115811. * Instantiates a new Lens Flare.
  115812. * This represents one of the lens effect in a `lensFlareSystem`.
  115813. * It controls one of the indiviual texture used in the effect.
  115814. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115815. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  115816. * @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.
  115817. * @param color Define the lens color
  115818. * @param imgUrl Define the lens texture url
  115819. * @param system Define the `lensFlareSystem` this flare is part of
  115820. */
  115821. constructor(
  115822. /**
  115823. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  115824. */
  115825. size: number,
  115826. /**
  115827. * 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.
  115828. */
  115829. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  115830. /**
  115831. * Dispose and release the lens flare with its associated resources.
  115832. */
  115833. dispose(): void;
  115834. }
  115835. }
  115836. declare module BABYLON {
  115837. interface AbstractScene {
  115838. /**
  115839. * The list of lens flare system added to the scene
  115840. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  115841. */
  115842. lensFlareSystems: Array<LensFlareSystem>;
  115843. /**
  115844. * Removes the given lens flare system from this scene.
  115845. * @param toRemove The lens flare system to remove
  115846. * @returns The index of the removed lens flare system
  115847. */
  115848. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  115849. /**
  115850. * Adds the given lens flare system to this scene
  115851. * @param newLensFlareSystem The lens flare system to add
  115852. */
  115853. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  115854. /**
  115855. * Gets a lens flare system using its name
  115856. * @param name defines the name to look for
  115857. * @returns the lens flare system or null if not found
  115858. */
  115859. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  115860. /**
  115861. * Gets a lens flare system using its id
  115862. * @param id defines the id to look for
  115863. * @returns the lens flare system or null if not found
  115864. */
  115865. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  115866. }
  115867. /**
  115868. * Defines the lens flare scene component responsible to manage any lens flares
  115869. * in a given scene.
  115870. */
  115871. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  115872. /**
  115873. * The component name helpfull to identify the component in the list of scene components.
  115874. */
  115875. readonly name: string;
  115876. /**
  115877. * The scene the component belongs to.
  115878. */
  115879. scene: Scene;
  115880. /**
  115881. * Creates a new instance of the component for the given scene
  115882. * @param scene Defines the scene to register the component in
  115883. */
  115884. constructor(scene: Scene);
  115885. /**
  115886. * Registers the component in a given scene
  115887. */
  115888. register(): void;
  115889. /**
  115890. * Rebuilds the elements related to this component in case of
  115891. * context lost for instance.
  115892. */
  115893. rebuild(): void;
  115894. /**
  115895. * Adds all the elements from the container to the scene
  115896. * @param container the container holding the elements
  115897. */
  115898. addFromContainer(container: AbstractScene): void;
  115899. /**
  115900. * Removes all the elements in the container from the scene
  115901. * @param container contains the elements to remove
  115902. * @param dispose if the removed element should be disposed (default: false)
  115903. */
  115904. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115905. /**
  115906. * Serializes the component data to the specified json object
  115907. * @param serializationObject The object to serialize to
  115908. */
  115909. serialize(serializationObject: any): void;
  115910. /**
  115911. * Disposes the component and the associated ressources.
  115912. */
  115913. dispose(): void;
  115914. private _draw;
  115915. }
  115916. }
  115917. declare module BABYLON {
  115918. /**
  115919. * Defines the shadow generator component responsible to manage any shadow generators
  115920. * in a given scene.
  115921. */
  115922. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  115923. /**
  115924. * The component name helpfull to identify the component in the list of scene components.
  115925. */
  115926. readonly name: string;
  115927. /**
  115928. * The scene the component belongs to.
  115929. */
  115930. scene: Scene;
  115931. /**
  115932. * Creates a new instance of the component for the given scene
  115933. * @param scene Defines the scene to register the component in
  115934. */
  115935. constructor(scene: Scene);
  115936. /**
  115937. * Registers the component in a given scene
  115938. */
  115939. register(): void;
  115940. /**
  115941. * Rebuilds the elements related to this component in case of
  115942. * context lost for instance.
  115943. */
  115944. rebuild(): void;
  115945. /**
  115946. * Serializes the component data to the specified json object
  115947. * @param serializationObject The object to serialize to
  115948. */
  115949. serialize(serializationObject: any): void;
  115950. /**
  115951. * Adds all the elements from the container to the scene
  115952. * @param container the container holding the elements
  115953. */
  115954. addFromContainer(container: AbstractScene): void;
  115955. /**
  115956. * Removes all the elements in the container from the scene
  115957. * @param container contains the elements to remove
  115958. * @param dispose if the removed element should be disposed (default: false)
  115959. */
  115960. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  115961. /**
  115962. * Rebuilds the elements related to this component in case of
  115963. * context lost for instance.
  115964. */
  115965. dispose(): void;
  115966. private _gatherRenderTargets;
  115967. }
  115968. }
  115969. declare module BABYLON {
  115970. /**
  115971. * A point light is a light defined by an unique point in world space.
  115972. * The light is emitted in every direction from this point.
  115973. * A good example of a point light is a standard light bulb.
  115974. * Documentation: https://doc.babylonjs.com/babylon101/lights
  115975. */
  115976. export class PointLight extends ShadowLight {
  115977. private _shadowAngle;
  115978. /**
  115979. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115980. * This specifies what angle the shadow will use to be created.
  115981. *
  115982. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  115983. */
  115984. /**
  115985. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115986. * This specifies what angle the shadow will use to be created.
  115987. *
  115988. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  115989. */
  115990. shadowAngle: number;
  115991. /**
  115992. * Gets the direction if it has been set.
  115993. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115994. */
  115995. /**
  115996. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  115997. */
  115998. direction: Vector3;
  115999. /**
  116000. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  116001. * A PointLight emits the light in every direction.
  116002. * It can cast shadows.
  116003. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  116004. * ```javascript
  116005. * var pointLight = new PointLight("pl", camera.position, scene);
  116006. * ```
  116007. * Documentation : https://doc.babylonjs.com/babylon101/lights
  116008. * @param name The light friendly name
  116009. * @param position The position of the point light in the scene
  116010. * @param scene The scene the lights belongs to
  116011. */
  116012. constructor(name: string, position: Vector3, scene: Scene);
  116013. /**
  116014. * Returns the string "PointLight"
  116015. * @returns the class name
  116016. */
  116017. getClassName(): string;
  116018. /**
  116019. * Returns the integer 0.
  116020. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  116021. */
  116022. getTypeID(): number;
  116023. /**
  116024. * Specifies wether or not the shadowmap should be a cube texture.
  116025. * @returns true if the shadowmap needs to be a cube texture.
  116026. */
  116027. needCube(): boolean;
  116028. /**
  116029. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  116030. * @param faceIndex The index of the face we are computed the direction to generate shadow
  116031. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  116032. */
  116033. getShadowDirection(faceIndex?: number): Vector3;
  116034. /**
  116035. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  116036. * - fov = PI / 2
  116037. * - aspect ratio : 1.0
  116038. * - z-near and far equal to the active camera minZ and maxZ.
  116039. * Returns the PointLight.
  116040. */
  116041. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  116042. protected _buildUniformLayout(): void;
  116043. /**
  116044. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  116045. * @param effect The effect to update
  116046. * @param lightIndex The index of the light in the effect to update
  116047. * @returns The point light
  116048. */
  116049. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  116050. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  116051. /**
  116052. * Prepares the list of defines specific to the light type.
  116053. * @param defines the list of defines
  116054. * @param lightIndex defines the index of the light for the effect
  116055. */
  116056. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  116057. }
  116058. }
  116059. declare module BABYLON {
  116060. /**
  116061. * Header information of HDR texture files.
  116062. */
  116063. export interface HDRInfo {
  116064. /**
  116065. * The height of the texture in pixels.
  116066. */
  116067. height: number;
  116068. /**
  116069. * The width of the texture in pixels.
  116070. */
  116071. width: number;
  116072. /**
  116073. * The index of the beginning of the data in the binary file.
  116074. */
  116075. dataPosition: number;
  116076. }
  116077. /**
  116078. * This groups tools to convert HDR texture to native colors array.
  116079. */
  116080. export class HDRTools {
  116081. private static Ldexp;
  116082. private static Rgbe2float;
  116083. private static readStringLine;
  116084. /**
  116085. * Reads header information from an RGBE texture stored in a native array.
  116086. * More information on this format are available here:
  116087. * https://en.wikipedia.org/wiki/RGBE_image_format
  116088. *
  116089. * @param uint8array The binary file stored in native array.
  116090. * @return The header information.
  116091. */
  116092. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  116093. /**
  116094. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  116095. * This RGBE texture needs to store the information as a panorama.
  116096. *
  116097. * More information on this format are available here:
  116098. * https://en.wikipedia.org/wiki/RGBE_image_format
  116099. *
  116100. * @param buffer The binary file stored in an array buffer.
  116101. * @param size The expected size of the extracted cubemap.
  116102. * @return The Cube Map information.
  116103. */
  116104. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  116105. /**
  116106. * Returns the pixels data extracted from an RGBE texture.
  116107. * This pixels will be stored left to right up to down in the R G B order in one array.
  116108. *
  116109. * More information on this format are available here:
  116110. * https://en.wikipedia.org/wiki/RGBE_image_format
  116111. *
  116112. * @param uint8array The binary file stored in an array buffer.
  116113. * @param hdrInfo The header information of the file.
  116114. * @return The pixels data in RGB right to left up to down order.
  116115. */
  116116. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  116117. private static RGBE_ReadPixels_RLE;
  116118. }
  116119. }
  116120. declare module BABYLON {
  116121. /**
  116122. * This represents a texture coming from an HDR input.
  116123. *
  116124. * The only supported format is currently panorama picture stored in RGBE format.
  116125. * Example of such files can be found on HDRLib: http://hdrlib.com/
  116126. */
  116127. export class HDRCubeTexture extends BaseTexture {
  116128. private static _facesMapping;
  116129. private _generateHarmonics;
  116130. private _noMipmap;
  116131. private _textureMatrix;
  116132. private _size;
  116133. private _onLoad;
  116134. private _onError;
  116135. /**
  116136. * The texture URL.
  116137. */
  116138. url: string;
  116139. /**
  116140. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  116141. */
  116142. coordinatesMode: number;
  116143. protected _isBlocking: boolean;
  116144. /**
  116145. * Sets wether or not the texture is blocking during loading.
  116146. */
  116147. /**
  116148. * Gets wether or not the texture is blocking during loading.
  116149. */
  116150. isBlocking: boolean;
  116151. protected _rotationY: number;
  116152. /**
  116153. * Sets texture matrix rotation angle around Y axis in radians.
  116154. */
  116155. /**
  116156. * Gets texture matrix rotation angle around Y axis radians.
  116157. */
  116158. rotationY: number;
  116159. /**
  116160. * Gets or sets the center of the bounding box associated with the cube texture
  116161. * It must define where the camera used to render the texture was set
  116162. */
  116163. boundingBoxPosition: Vector3;
  116164. private _boundingBoxSize;
  116165. /**
  116166. * Gets or sets the size of the bounding box associated with the cube texture
  116167. * When defined, the cubemap will switch to local mode
  116168. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  116169. * @example https://www.babylonjs-playground.com/#RNASML
  116170. */
  116171. boundingBoxSize: Vector3;
  116172. /**
  116173. * Instantiates an HDRTexture from the following parameters.
  116174. *
  116175. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  116176. * @param scene The scene the texture will be used in
  116177. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  116178. * @param noMipmap Forces to not generate the mipmap if true
  116179. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  116180. * @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)
  116181. * @param reserved Reserved flag for internal use.
  116182. */
  116183. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  116184. /**
  116185. * Get the current class name of the texture useful for serialization or dynamic coding.
  116186. * @returns "HDRCubeTexture"
  116187. */
  116188. getClassName(): string;
  116189. /**
  116190. * Occurs when the file is raw .hdr file.
  116191. */
  116192. private loadTexture;
  116193. clone(): HDRCubeTexture;
  116194. delayLoad(): void;
  116195. /**
  116196. * Get the texture reflection matrix used to rotate/transform the reflection.
  116197. * @returns the reflection matrix
  116198. */
  116199. getReflectionTextureMatrix(): Matrix;
  116200. /**
  116201. * Set the texture reflection matrix used to rotate/transform the reflection.
  116202. * @param value Define the reflection matrix to set
  116203. */
  116204. setReflectionTextureMatrix(value: Matrix): void;
  116205. /**
  116206. * Parses a JSON representation of an HDR Texture in order to create the texture
  116207. * @param parsedTexture Define the JSON representation
  116208. * @param scene Define the scene the texture should be created in
  116209. * @param rootUrl Define the root url in case we need to load relative dependencies
  116210. * @returns the newly created texture after parsing
  116211. */
  116212. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  116213. serialize(): any;
  116214. }
  116215. }
  116216. declare module BABYLON {
  116217. /**
  116218. * Class used to control physics engine
  116219. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  116220. */
  116221. export class PhysicsEngine implements IPhysicsEngine {
  116222. private _physicsPlugin;
  116223. /**
  116224. * Global value used to control the smallest number supported by the simulation
  116225. */
  116226. static Epsilon: number;
  116227. private _impostors;
  116228. private _joints;
  116229. /**
  116230. * Gets the gravity vector used by the simulation
  116231. */
  116232. gravity: Vector3;
  116233. /**
  116234. * Factory used to create the default physics plugin.
  116235. * @returns The default physics plugin
  116236. */
  116237. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  116238. /**
  116239. * Creates a new Physics Engine
  116240. * @param gravity defines the gravity vector used by the simulation
  116241. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  116242. */
  116243. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  116244. /**
  116245. * Sets the gravity vector used by the simulation
  116246. * @param gravity defines the gravity vector to use
  116247. */
  116248. setGravity(gravity: Vector3): void;
  116249. /**
  116250. * Set the time step of the physics engine.
  116251. * Default is 1/60.
  116252. * To slow it down, enter 1/600 for example.
  116253. * To speed it up, 1/30
  116254. * @param newTimeStep defines the new timestep to apply to this world.
  116255. */
  116256. setTimeStep(newTimeStep?: number): void;
  116257. /**
  116258. * Get the time step of the physics engine.
  116259. * @returns the current time step
  116260. */
  116261. getTimeStep(): number;
  116262. /**
  116263. * Release all resources
  116264. */
  116265. dispose(): void;
  116266. /**
  116267. * Gets the name of the current physics plugin
  116268. * @returns the name of the plugin
  116269. */
  116270. getPhysicsPluginName(): string;
  116271. /**
  116272. * Adding a new impostor for the impostor tracking.
  116273. * This will be done by the impostor itself.
  116274. * @param impostor the impostor to add
  116275. */
  116276. addImpostor(impostor: PhysicsImpostor): void;
  116277. /**
  116278. * Remove an impostor from the engine.
  116279. * This impostor and its mesh will not longer be updated by the physics engine.
  116280. * @param impostor the impostor to remove
  116281. */
  116282. removeImpostor(impostor: PhysicsImpostor): void;
  116283. /**
  116284. * Add a joint to the physics engine
  116285. * @param mainImpostor defines the main impostor to which the joint is added.
  116286. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  116287. * @param joint defines the joint that will connect both impostors.
  116288. */
  116289. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116290. /**
  116291. * Removes a joint from the simulation
  116292. * @param mainImpostor defines the impostor used with the joint
  116293. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  116294. * @param joint defines the joint to remove
  116295. */
  116296. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  116297. /**
  116298. * Called by the scene. No need to call it.
  116299. * @param delta defines the timespam between frames
  116300. */
  116301. _step(delta: number): void;
  116302. /**
  116303. * Gets the current plugin used to run the simulation
  116304. * @returns current plugin
  116305. */
  116306. getPhysicsPlugin(): IPhysicsEnginePlugin;
  116307. /**
  116308. * Gets the list of physic impostors
  116309. * @returns an array of PhysicsImpostor
  116310. */
  116311. getImpostors(): Array<PhysicsImpostor>;
  116312. /**
  116313. * Gets the impostor for a physics enabled object
  116314. * @param object defines the object impersonated by the impostor
  116315. * @returns the PhysicsImpostor or null if not found
  116316. */
  116317. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  116318. /**
  116319. * Gets the impostor for a physics body object
  116320. * @param body defines physics body used by the impostor
  116321. * @returns the PhysicsImpostor or null if not found
  116322. */
  116323. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  116324. /**
  116325. * Does a raycast in the physics world
  116326. * @param from when should the ray start?
  116327. * @param to when should the ray end?
  116328. * @returns PhysicsRaycastResult
  116329. */
  116330. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116331. }
  116332. }
  116333. declare module BABYLON {
  116334. /** @hidden */
  116335. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  116336. private _useDeltaForWorldStep;
  116337. world: any;
  116338. name: string;
  116339. private _physicsMaterials;
  116340. private _fixedTimeStep;
  116341. private _cannonRaycastResult;
  116342. private _raycastResult;
  116343. private _physicsBodysToRemoveAfterStep;
  116344. BJSCANNON: any;
  116345. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  116346. setGravity(gravity: Vector3): void;
  116347. setTimeStep(timeStep: number): void;
  116348. getTimeStep(): number;
  116349. executeStep(delta: number): void;
  116350. private _removeMarkedPhysicsBodiesFromWorld;
  116351. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116352. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116353. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116354. private _processChildMeshes;
  116355. removePhysicsBody(impostor: PhysicsImpostor): void;
  116356. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116357. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116358. private _addMaterial;
  116359. private _checkWithEpsilon;
  116360. private _createShape;
  116361. private _createHeightmap;
  116362. private _minus90X;
  116363. private _plus90X;
  116364. private _tmpPosition;
  116365. private _tmpDeltaPosition;
  116366. private _tmpUnityRotation;
  116367. private _updatePhysicsBodyTransformation;
  116368. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116369. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116370. isSupported(): boolean;
  116371. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116372. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116373. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116374. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116375. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116376. getBodyMass(impostor: PhysicsImpostor): number;
  116377. getBodyFriction(impostor: PhysicsImpostor): number;
  116378. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116379. getBodyRestitution(impostor: PhysicsImpostor): number;
  116380. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116381. sleepBody(impostor: PhysicsImpostor): void;
  116382. wakeUpBody(impostor: PhysicsImpostor): void;
  116383. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  116384. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116385. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116386. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116387. getRadius(impostor: PhysicsImpostor): number;
  116388. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116389. dispose(): void;
  116390. private _extendNamespace;
  116391. /**
  116392. * Does a raycast in the physics world
  116393. * @param from when should the ray start?
  116394. * @param to when should the ray end?
  116395. * @returns PhysicsRaycastResult
  116396. */
  116397. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116398. }
  116399. }
  116400. declare module BABYLON {
  116401. /** @hidden */
  116402. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  116403. world: any;
  116404. name: string;
  116405. BJSOIMO: any;
  116406. private _raycastResult;
  116407. constructor(iterations?: number, oimoInjection?: any);
  116408. setGravity(gravity: Vector3): void;
  116409. setTimeStep(timeStep: number): void;
  116410. getTimeStep(): number;
  116411. private _tmpImpostorsArray;
  116412. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116413. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116414. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116415. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116416. private _tmpPositionVector;
  116417. removePhysicsBody(impostor: PhysicsImpostor): void;
  116418. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116419. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116420. isSupported(): boolean;
  116421. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116422. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116423. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116424. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116425. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116426. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116427. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116428. getBodyMass(impostor: PhysicsImpostor): number;
  116429. getBodyFriction(impostor: PhysicsImpostor): number;
  116430. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116431. getBodyRestitution(impostor: PhysicsImpostor): number;
  116432. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116433. sleepBody(impostor: PhysicsImpostor): void;
  116434. wakeUpBody(impostor: PhysicsImpostor): void;
  116435. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116436. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  116437. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  116438. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116439. getRadius(impostor: PhysicsImpostor): number;
  116440. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116441. dispose(): void;
  116442. /**
  116443. * Does a raycast in the physics world
  116444. * @param from when should the ray start?
  116445. * @param to when should the ray end?
  116446. * @returns PhysicsRaycastResult
  116447. */
  116448. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116449. }
  116450. }
  116451. declare module BABYLON {
  116452. /**
  116453. * Class containing static functions to help procedurally build meshes
  116454. */
  116455. export class RibbonBuilder {
  116456. /**
  116457. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116458. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  116459. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  116460. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  116461. * * 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
  116462. * * 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
  116463. * * 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
  116464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116465. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116466. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116467. * * 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
  116468. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  116469. * * 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
  116470. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  116471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116472. * @param name defines the name of the mesh
  116473. * @param options defines the options used to create the mesh
  116474. * @param scene defines the hosting scene
  116475. * @returns the ribbon mesh
  116476. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  116477. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116478. */
  116479. static CreateRibbon(name: string, options: {
  116480. pathArray: Vector3[][];
  116481. closeArray?: boolean;
  116482. closePath?: boolean;
  116483. offset?: number;
  116484. updatable?: boolean;
  116485. sideOrientation?: number;
  116486. frontUVs?: Vector4;
  116487. backUVs?: Vector4;
  116488. instance?: Mesh;
  116489. invertUV?: boolean;
  116490. uvs?: Vector2[];
  116491. colors?: Color4[];
  116492. }, scene?: Nullable<Scene>): Mesh;
  116493. }
  116494. }
  116495. declare module BABYLON {
  116496. /**
  116497. * Class containing static functions to help procedurally build meshes
  116498. */
  116499. export class ShapeBuilder {
  116500. /**
  116501. * 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.
  116502. * * 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.
  116503. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116504. * * 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.
  116505. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  116506. * * 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
  116507. * * 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
  116508. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  116509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116510. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116511. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  116512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116513. * @param name defines the name of the mesh
  116514. * @param options defines the options used to create the mesh
  116515. * @param scene defines the hosting scene
  116516. * @returns the extruded shape mesh
  116517. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116518. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116519. */
  116520. static ExtrudeShape(name: string, options: {
  116521. shape: Vector3[];
  116522. path: Vector3[];
  116523. scale?: number;
  116524. rotation?: number;
  116525. cap?: number;
  116526. updatable?: boolean;
  116527. sideOrientation?: number;
  116528. frontUVs?: Vector4;
  116529. backUVs?: Vector4;
  116530. instance?: Mesh;
  116531. invertUV?: boolean;
  116532. }, scene?: Nullable<Scene>): Mesh;
  116533. /**
  116534. * Creates an custom extruded shape mesh.
  116535. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  116536. * * 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.
  116537. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  116538. * * 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
  116539. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  116540. * * 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
  116541. * * It must returns a float value that will be the scale value applied to the shape on each path point
  116542. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  116543. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  116544. * * 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
  116545. * * 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
  116546. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  116547. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116548. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116549. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116550. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116551. * @param name defines the name of the mesh
  116552. * @param options defines the options used to create the mesh
  116553. * @param scene defines the hosting scene
  116554. * @returns the custom extruded shape mesh
  116555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  116556. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116557. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  116558. */
  116559. static ExtrudeShapeCustom(name: string, options: {
  116560. shape: Vector3[];
  116561. path: Vector3[];
  116562. scaleFunction?: any;
  116563. rotationFunction?: any;
  116564. ribbonCloseArray?: boolean;
  116565. ribbonClosePath?: boolean;
  116566. cap?: number;
  116567. updatable?: boolean;
  116568. sideOrientation?: number;
  116569. frontUVs?: Vector4;
  116570. backUVs?: Vector4;
  116571. instance?: Mesh;
  116572. invertUV?: boolean;
  116573. }, scene?: Nullable<Scene>): Mesh;
  116574. private static _ExtrudeShapeGeneric;
  116575. }
  116576. }
  116577. declare module BABYLON {
  116578. /**
  116579. * AmmoJS Physics plugin
  116580. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  116581. * @see https://github.com/kripken/ammo.js/
  116582. */
  116583. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  116584. private _useDeltaForWorldStep;
  116585. /**
  116586. * Reference to the Ammo library
  116587. */
  116588. bjsAMMO: any;
  116589. /**
  116590. * Created ammoJS world which physics bodies are added to
  116591. */
  116592. world: any;
  116593. /**
  116594. * Name of the plugin
  116595. */
  116596. name: string;
  116597. private _timeStep;
  116598. private _fixedTimeStep;
  116599. private _maxSteps;
  116600. private _tmpQuaternion;
  116601. private _tmpAmmoTransform;
  116602. private _tmpAmmoQuaternion;
  116603. private _tmpAmmoConcreteContactResultCallback;
  116604. private _collisionConfiguration;
  116605. private _dispatcher;
  116606. private _overlappingPairCache;
  116607. private _solver;
  116608. private _softBodySolver;
  116609. private _tmpAmmoVectorA;
  116610. private _tmpAmmoVectorB;
  116611. private _tmpAmmoVectorC;
  116612. private _tmpAmmoVectorD;
  116613. private _tmpContactCallbackResult;
  116614. private _tmpAmmoVectorRCA;
  116615. private _tmpAmmoVectorRCB;
  116616. private _raycastResult;
  116617. private static readonly DISABLE_COLLISION_FLAG;
  116618. private static readonly KINEMATIC_FLAG;
  116619. private static readonly DISABLE_DEACTIVATION_FLAG;
  116620. /**
  116621. * Initializes the ammoJS plugin
  116622. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  116623. * @param ammoInjection can be used to inject your own ammo reference
  116624. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  116625. */
  116626. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  116627. /**
  116628. * Sets the gravity of the physics world (m/(s^2))
  116629. * @param gravity Gravity to set
  116630. */
  116631. setGravity(gravity: Vector3): void;
  116632. /**
  116633. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  116634. * @param timeStep timestep to use in seconds
  116635. */
  116636. setTimeStep(timeStep: number): void;
  116637. /**
  116638. * 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)
  116639. * @param fixedTimeStep fixedTimeStep to use in seconds
  116640. */
  116641. setFixedTimeStep(fixedTimeStep: number): void;
  116642. /**
  116643. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  116644. * @param maxSteps the maximum number of steps by the physics engine per frame
  116645. */
  116646. setMaxSteps(maxSteps: number): void;
  116647. /**
  116648. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  116649. * @returns the current timestep in seconds
  116650. */
  116651. getTimeStep(): number;
  116652. private _isImpostorInContact;
  116653. private _isImpostorPairInContact;
  116654. private _stepSimulation;
  116655. /**
  116656. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  116657. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  116658. * After the step the babylon meshes are set to the position of the physics imposters
  116659. * @param delta amount of time to step forward
  116660. * @param impostors array of imposters to update before/after the step
  116661. */
  116662. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  116663. /**
  116664. * Update babylon mesh to match physics world object
  116665. * @param impostor imposter to match
  116666. */
  116667. private _afterSoftStep;
  116668. /**
  116669. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116670. * @param impostor imposter to match
  116671. */
  116672. private _ropeStep;
  116673. /**
  116674. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  116675. * @param impostor imposter to match
  116676. */
  116677. private _softbodyOrClothStep;
  116678. private _tmpVector;
  116679. private _tmpMatrix;
  116680. /**
  116681. * Applies an impulse on the imposter
  116682. * @param impostor imposter to apply impulse to
  116683. * @param force amount of force to be applied to the imposter
  116684. * @param contactPoint the location to apply the impulse on the imposter
  116685. */
  116686. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116687. /**
  116688. * Applies a force on the imposter
  116689. * @param impostor imposter to apply force
  116690. * @param force amount of force to be applied to the imposter
  116691. * @param contactPoint the location to apply the force on the imposter
  116692. */
  116693. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  116694. /**
  116695. * Creates a physics body using the plugin
  116696. * @param impostor the imposter to create the physics body on
  116697. */
  116698. generatePhysicsBody(impostor: PhysicsImpostor): void;
  116699. /**
  116700. * Removes the physics body from the imposter and disposes of the body's memory
  116701. * @param impostor imposter to remove the physics body from
  116702. */
  116703. removePhysicsBody(impostor: PhysicsImpostor): void;
  116704. /**
  116705. * Generates a joint
  116706. * @param impostorJoint the imposter joint to create the joint with
  116707. */
  116708. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  116709. /**
  116710. * Removes a joint
  116711. * @param impostorJoint the imposter joint to remove the joint from
  116712. */
  116713. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  116714. private _addMeshVerts;
  116715. /**
  116716. * Initialise the soft body vertices to match its object's (mesh) vertices
  116717. * Softbody vertices (nodes) are in world space and to match this
  116718. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  116719. * @param impostor to create the softbody for
  116720. */
  116721. private _softVertexData;
  116722. /**
  116723. * Create an impostor's soft body
  116724. * @param impostor to create the softbody for
  116725. */
  116726. private _createSoftbody;
  116727. /**
  116728. * Create cloth for an impostor
  116729. * @param impostor to create the softbody for
  116730. */
  116731. private _createCloth;
  116732. /**
  116733. * Create rope for an impostor
  116734. * @param impostor to create the softbody for
  116735. */
  116736. private _createRope;
  116737. private _addHullVerts;
  116738. private _createShape;
  116739. /**
  116740. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  116741. * @param impostor imposter containing the physics body and babylon object
  116742. */
  116743. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  116744. /**
  116745. * Sets the babylon object's position/rotation from the physics body's position/rotation
  116746. * @param impostor imposter containing the physics body and babylon object
  116747. * @param newPosition new position
  116748. * @param newRotation new rotation
  116749. */
  116750. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  116751. /**
  116752. * If this plugin is supported
  116753. * @returns true if its supported
  116754. */
  116755. isSupported(): boolean;
  116756. /**
  116757. * Sets the linear velocity of the physics body
  116758. * @param impostor imposter to set the velocity on
  116759. * @param velocity velocity to set
  116760. */
  116761. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116762. /**
  116763. * Sets the angular velocity of the physics body
  116764. * @param impostor imposter to set the velocity on
  116765. * @param velocity velocity to set
  116766. */
  116767. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  116768. /**
  116769. * gets the linear velocity
  116770. * @param impostor imposter to get linear velocity from
  116771. * @returns linear velocity
  116772. */
  116773. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116774. /**
  116775. * gets the angular velocity
  116776. * @param impostor imposter to get angular velocity from
  116777. * @returns angular velocity
  116778. */
  116779. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  116780. /**
  116781. * Sets the mass of physics body
  116782. * @param impostor imposter to set the mass on
  116783. * @param mass mass to set
  116784. */
  116785. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  116786. /**
  116787. * Gets the mass of the physics body
  116788. * @param impostor imposter to get the mass from
  116789. * @returns mass
  116790. */
  116791. getBodyMass(impostor: PhysicsImpostor): number;
  116792. /**
  116793. * Gets friction of the impostor
  116794. * @param impostor impostor to get friction from
  116795. * @returns friction value
  116796. */
  116797. getBodyFriction(impostor: PhysicsImpostor): number;
  116798. /**
  116799. * Sets friction of the impostor
  116800. * @param impostor impostor to set friction on
  116801. * @param friction friction value
  116802. */
  116803. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  116804. /**
  116805. * Gets restitution of the impostor
  116806. * @param impostor impostor to get restitution from
  116807. * @returns restitution value
  116808. */
  116809. getBodyRestitution(impostor: PhysicsImpostor): number;
  116810. /**
  116811. * Sets resitution of the impostor
  116812. * @param impostor impostor to set resitution on
  116813. * @param restitution resitution value
  116814. */
  116815. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  116816. /**
  116817. * Gets pressure inside the impostor
  116818. * @param impostor impostor to get pressure from
  116819. * @returns pressure value
  116820. */
  116821. getBodyPressure(impostor: PhysicsImpostor): number;
  116822. /**
  116823. * Sets pressure inside a soft body impostor
  116824. * Cloth and rope must remain 0 pressure
  116825. * @param impostor impostor to set pressure on
  116826. * @param pressure pressure value
  116827. */
  116828. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  116829. /**
  116830. * Gets stiffness of the impostor
  116831. * @param impostor impostor to get stiffness from
  116832. * @returns pressure value
  116833. */
  116834. getBodyStiffness(impostor: PhysicsImpostor): number;
  116835. /**
  116836. * Sets stiffness of the impostor
  116837. * @param impostor impostor to set stiffness on
  116838. * @param stiffness stiffness value from 0 to 1
  116839. */
  116840. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  116841. /**
  116842. * Gets velocityIterations of the impostor
  116843. * @param impostor impostor to get velocity iterations from
  116844. * @returns velocityIterations value
  116845. */
  116846. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  116847. /**
  116848. * Sets velocityIterations of the impostor
  116849. * @param impostor impostor to set velocity iterations on
  116850. * @param velocityIterations velocityIterations value
  116851. */
  116852. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  116853. /**
  116854. * Gets positionIterations of the impostor
  116855. * @param impostor impostor to get position iterations from
  116856. * @returns positionIterations value
  116857. */
  116858. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  116859. /**
  116860. * Sets positionIterations of the impostor
  116861. * @param impostor impostor to set position on
  116862. * @param positionIterations positionIterations value
  116863. */
  116864. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  116865. /**
  116866. * Append an anchor to a cloth object
  116867. * @param impostor is the cloth impostor to add anchor to
  116868. * @param otherImpostor is the rigid impostor to anchor to
  116869. * @param width ratio across width from 0 to 1
  116870. * @param height ratio up height from 0 to 1
  116871. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  116872. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116873. */
  116874. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116875. /**
  116876. * Append an hook to a rope object
  116877. * @param impostor is the rope impostor to add hook to
  116878. * @param otherImpostor is the rigid impostor to hook to
  116879. * @param length ratio along the rope from 0 to 1
  116880. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  116881. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  116882. */
  116883. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  116884. /**
  116885. * Sleeps the physics body and stops it from being active
  116886. * @param impostor impostor to sleep
  116887. */
  116888. sleepBody(impostor: PhysicsImpostor): void;
  116889. /**
  116890. * Activates the physics body
  116891. * @param impostor impostor to activate
  116892. */
  116893. wakeUpBody(impostor: PhysicsImpostor): void;
  116894. /**
  116895. * Updates the distance parameters of the joint
  116896. * @param joint joint to update
  116897. * @param maxDistance maximum distance of the joint
  116898. * @param minDistance minimum distance of the joint
  116899. */
  116900. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  116901. /**
  116902. * Sets a motor on the joint
  116903. * @param joint joint to set motor on
  116904. * @param speed speed of the motor
  116905. * @param maxForce maximum force of the motor
  116906. * @param motorIndex index of the motor
  116907. */
  116908. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  116909. /**
  116910. * Sets the motors limit
  116911. * @param joint joint to set limit on
  116912. * @param upperLimit upper limit
  116913. * @param lowerLimit lower limit
  116914. */
  116915. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  116916. /**
  116917. * Syncs the position and rotation of a mesh with the impostor
  116918. * @param mesh mesh to sync
  116919. * @param impostor impostor to update the mesh with
  116920. */
  116921. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  116922. /**
  116923. * Gets the radius of the impostor
  116924. * @param impostor impostor to get radius from
  116925. * @returns the radius
  116926. */
  116927. getRadius(impostor: PhysicsImpostor): number;
  116928. /**
  116929. * Gets the box size of the impostor
  116930. * @param impostor impostor to get box size from
  116931. * @param result the resulting box size
  116932. */
  116933. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  116934. /**
  116935. * Disposes of the impostor
  116936. */
  116937. dispose(): void;
  116938. /**
  116939. * Does a raycast in the physics world
  116940. * @param from when should the ray start?
  116941. * @param to when should the ray end?
  116942. * @returns PhysicsRaycastResult
  116943. */
  116944. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  116945. }
  116946. }
  116947. declare module BABYLON {
  116948. interface AbstractScene {
  116949. /**
  116950. * The list of reflection probes added to the scene
  116951. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116952. */
  116953. reflectionProbes: Array<ReflectionProbe>;
  116954. /**
  116955. * Removes the given reflection probe from this scene.
  116956. * @param toRemove The reflection probe to remove
  116957. * @returns The index of the removed reflection probe
  116958. */
  116959. removeReflectionProbe(toRemove: ReflectionProbe): number;
  116960. /**
  116961. * Adds the given reflection probe to this scene.
  116962. * @param newReflectionProbe The reflection probe to add
  116963. */
  116964. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  116965. }
  116966. /**
  116967. * Class used to generate realtime reflection / refraction cube textures
  116968. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  116969. */
  116970. export class ReflectionProbe {
  116971. /** defines the name of the probe */
  116972. name: string;
  116973. private _scene;
  116974. private _renderTargetTexture;
  116975. private _projectionMatrix;
  116976. private _viewMatrix;
  116977. private _target;
  116978. private _add;
  116979. private _attachedMesh;
  116980. private _invertYAxis;
  116981. /** Gets or sets probe position (center of the cube map) */
  116982. position: Vector3;
  116983. /**
  116984. * Creates a new reflection probe
  116985. * @param name defines the name of the probe
  116986. * @param size defines the texture resolution (for each face)
  116987. * @param scene defines the hosting scene
  116988. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  116989. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  116990. */
  116991. constructor(
  116992. /** defines the name of the probe */
  116993. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  116994. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  116995. samples: number;
  116996. /** Gets or sets the refresh rate to use (on every frame by default) */
  116997. refreshRate: number;
  116998. /**
  116999. * Gets the hosting scene
  117000. * @returns a Scene
  117001. */
  117002. getScene(): Scene;
  117003. /** Gets the internal CubeTexture used to render to */
  117004. readonly cubeTexture: RenderTargetTexture;
  117005. /** Gets the list of meshes to render */
  117006. readonly renderList: Nullable<AbstractMesh[]>;
  117007. /**
  117008. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  117009. * @param mesh defines the mesh to attach to
  117010. */
  117011. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  117012. /**
  117013. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  117014. * @param renderingGroupId The rendering group id corresponding to its index
  117015. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  117016. */
  117017. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  117018. /**
  117019. * Clean all associated resources
  117020. */
  117021. dispose(): void;
  117022. /**
  117023. * Converts the reflection probe information to a readable string for debug purpose.
  117024. * @param fullDetails Supports for multiple levels of logging within scene loading
  117025. * @returns the human readable reflection probe info
  117026. */
  117027. toString(fullDetails?: boolean): string;
  117028. /**
  117029. * Get the class name of the relfection probe.
  117030. * @returns "ReflectionProbe"
  117031. */
  117032. getClassName(): string;
  117033. /**
  117034. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  117035. * @returns The JSON representation of the texture
  117036. */
  117037. serialize(): any;
  117038. /**
  117039. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  117040. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  117041. * @param scene Define the scene the parsed reflection probe should be instantiated in
  117042. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  117043. * @returns The parsed reflection probe if successful
  117044. */
  117045. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  117046. }
  117047. }
  117048. declare module BABYLON {
  117049. /** @hidden */
  117050. export var _BabylonLoaderRegistered: boolean;
  117051. }
  117052. declare module BABYLON {
  117053. /**
  117054. * The Physically based simple base material of BJS.
  117055. *
  117056. * This enables better naming and convention enforcements on top of the pbrMaterial.
  117057. * It is used as the base class for both the specGloss and metalRough conventions.
  117058. */
  117059. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  117060. /**
  117061. * Number of Simultaneous lights allowed on the material.
  117062. */
  117063. maxSimultaneousLights: number;
  117064. /**
  117065. * If sets to true, disables all the lights affecting the material.
  117066. */
  117067. disableLighting: boolean;
  117068. /**
  117069. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  117070. */
  117071. environmentTexture: BaseTexture;
  117072. /**
  117073. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  117074. */
  117075. invertNormalMapX: boolean;
  117076. /**
  117077. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  117078. */
  117079. invertNormalMapY: boolean;
  117080. /**
  117081. * Normal map used in the model.
  117082. */
  117083. normalTexture: BaseTexture;
  117084. /**
  117085. * Emissivie color used to self-illuminate the model.
  117086. */
  117087. emissiveColor: Color3;
  117088. /**
  117089. * Emissivie texture used to self-illuminate the model.
  117090. */
  117091. emissiveTexture: BaseTexture;
  117092. /**
  117093. * Occlusion Channel Strenght.
  117094. */
  117095. occlusionStrength: number;
  117096. /**
  117097. * Occlusion Texture of the material (adding extra occlusion effects).
  117098. */
  117099. occlusionTexture: BaseTexture;
  117100. /**
  117101. * Defines the alpha limits in alpha test mode.
  117102. */
  117103. alphaCutOff: number;
  117104. /**
  117105. * Gets the current double sided mode.
  117106. */
  117107. /**
  117108. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  117109. */
  117110. doubleSided: boolean;
  117111. /**
  117112. * Stores the pre-calculated light information of a mesh in a texture.
  117113. */
  117114. lightmapTexture: BaseTexture;
  117115. /**
  117116. * If true, the light map contains occlusion information instead of lighting info.
  117117. */
  117118. useLightmapAsShadowmap: boolean;
  117119. /**
  117120. * Instantiates a new PBRMaterial instance.
  117121. *
  117122. * @param name The material name
  117123. * @param scene The scene the material will be use in.
  117124. */
  117125. constructor(name: string, scene: Scene);
  117126. getClassName(): string;
  117127. }
  117128. }
  117129. declare module BABYLON {
  117130. /**
  117131. * The PBR material of BJS following the metal roughness convention.
  117132. *
  117133. * This fits to the PBR convention in the GLTF definition:
  117134. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  117135. */
  117136. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  117137. /**
  117138. * The base color has two different interpretations depending on the value of metalness.
  117139. * When the material is a metal, the base color is the specific measured reflectance value
  117140. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  117141. * of the material.
  117142. */
  117143. baseColor: Color3;
  117144. /**
  117145. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  117146. * well as opacity information in the alpha channel.
  117147. */
  117148. baseTexture: BaseTexture;
  117149. /**
  117150. * Specifies the metallic scalar value of the material.
  117151. * Can also be used to scale the metalness values of the metallic texture.
  117152. */
  117153. metallic: number;
  117154. /**
  117155. * Specifies the roughness scalar value of the material.
  117156. * Can also be used to scale the roughness values of the metallic texture.
  117157. */
  117158. roughness: number;
  117159. /**
  117160. * Texture containing both the metallic value in the B channel and the
  117161. * roughness value in the G channel to keep better precision.
  117162. */
  117163. metallicRoughnessTexture: BaseTexture;
  117164. /**
  117165. * Instantiates a new PBRMetalRoughnessMaterial instance.
  117166. *
  117167. * @param name The material name
  117168. * @param scene The scene the material will be use in.
  117169. */
  117170. constructor(name: string, scene: Scene);
  117171. /**
  117172. * Return the currrent class name of the material.
  117173. */
  117174. getClassName(): string;
  117175. /**
  117176. * Makes a duplicate of the current material.
  117177. * @param name - name to use for the new material.
  117178. */
  117179. clone(name: string): PBRMetallicRoughnessMaterial;
  117180. /**
  117181. * Serialize the material to a parsable JSON object.
  117182. */
  117183. serialize(): any;
  117184. /**
  117185. * Parses a JSON object correponding to the serialize function.
  117186. */
  117187. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  117188. }
  117189. }
  117190. declare module BABYLON {
  117191. /**
  117192. * The PBR material of BJS following the specular glossiness convention.
  117193. *
  117194. * This fits to the PBR convention in the GLTF definition:
  117195. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  117196. */
  117197. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  117198. /**
  117199. * Specifies the diffuse color of the material.
  117200. */
  117201. diffuseColor: Color3;
  117202. /**
  117203. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  117204. * channel.
  117205. */
  117206. diffuseTexture: BaseTexture;
  117207. /**
  117208. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  117209. */
  117210. specularColor: Color3;
  117211. /**
  117212. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  117213. */
  117214. glossiness: number;
  117215. /**
  117216. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  117217. */
  117218. specularGlossinessTexture: BaseTexture;
  117219. /**
  117220. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  117221. *
  117222. * @param name The material name
  117223. * @param scene The scene the material will be use in.
  117224. */
  117225. constructor(name: string, scene: Scene);
  117226. /**
  117227. * Return the currrent class name of the material.
  117228. */
  117229. getClassName(): string;
  117230. /**
  117231. * Makes a duplicate of the current material.
  117232. * @param name - name to use for the new material.
  117233. */
  117234. clone(name: string): PBRSpecularGlossinessMaterial;
  117235. /**
  117236. * Serialize the material to a parsable JSON object.
  117237. */
  117238. serialize(): any;
  117239. /**
  117240. * Parses a JSON object correponding to the serialize function.
  117241. */
  117242. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  117243. }
  117244. }
  117245. declare module BABYLON {
  117246. /**
  117247. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  117248. * It can help converting any input color in a desired output one. This can then be used to create effects
  117249. * from sepia, black and white to sixties or futuristic rendering...
  117250. *
  117251. * The only supported format is currently 3dl.
  117252. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  117253. */
  117254. export class ColorGradingTexture extends BaseTexture {
  117255. /**
  117256. * The current texture matrix. (will always be identity in color grading texture)
  117257. */
  117258. private _textureMatrix;
  117259. /**
  117260. * The texture URL.
  117261. */
  117262. url: string;
  117263. /**
  117264. * Empty line regex stored for GC.
  117265. */
  117266. private static _noneEmptyLineRegex;
  117267. private _engine;
  117268. /**
  117269. * Instantiates a ColorGradingTexture from the following parameters.
  117270. *
  117271. * @param url The location of the color gradind data (currently only supporting 3dl)
  117272. * @param scene The scene the texture will be used in
  117273. */
  117274. constructor(url: string, scene: Scene);
  117275. /**
  117276. * Returns the texture matrix used in most of the material.
  117277. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  117278. */
  117279. getTextureMatrix(): Matrix;
  117280. /**
  117281. * Occurs when the file being loaded is a .3dl LUT file.
  117282. */
  117283. private load3dlTexture;
  117284. /**
  117285. * Starts the loading process of the texture.
  117286. */
  117287. private loadTexture;
  117288. /**
  117289. * Clones the color gradind texture.
  117290. */
  117291. clone(): ColorGradingTexture;
  117292. /**
  117293. * Called during delayed load for textures.
  117294. */
  117295. delayLoad(): void;
  117296. /**
  117297. * Parses a color grading texture serialized by Babylon.
  117298. * @param parsedTexture The texture information being parsedTexture
  117299. * @param scene The scene to load the texture in
  117300. * @param rootUrl The root url of the data assets to load
  117301. * @return A color gradind texture
  117302. */
  117303. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  117304. /**
  117305. * Serializes the LUT texture to json format.
  117306. */
  117307. serialize(): any;
  117308. }
  117309. }
  117310. declare module BABYLON {
  117311. /**
  117312. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  117313. */
  117314. export class EquiRectangularCubeTexture extends BaseTexture {
  117315. /** The six faces of the cube. */
  117316. private static _FacesMapping;
  117317. private _noMipmap;
  117318. private _onLoad;
  117319. private _onError;
  117320. /** The size of the cubemap. */
  117321. private _size;
  117322. /** The buffer of the image. */
  117323. private _buffer;
  117324. /** The width of the input image. */
  117325. private _width;
  117326. /** The height of the input image. */
  117327. private _height;
  117328. /** The URL to the image. */
  117329. url: string;
  117330. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  117331. coordinatesMode: number;
  117332. /**
  117333. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  117334. * @param url The location of the image
  117335. * @param scene The scene the texture will be used in
  117336. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117337. * @param noMipmap Forces to not generate the mipmap if true
  117338. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  117339. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  117340. * @param onLoad — defines a callback called when texture is loaded
  117341. * @param onError — defines a callback called if there is an error
  117342. */
  117343. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  117344. /**
  117345. * Load the image data, by putting the image on a canvas and extracting its buffer.
  117346. */
  117347. private loadImage;
  117348. /**
  117349. * Convert the image buffer into a cubemap and create a CubeTexture.
  117350. */
  117351. private loadTexture;
  117352. /**
  117353. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  117354. * @param buffer The ArrayBuffer that should be converted.
  117355. * @returns The buffer as Float32Array.
  117356. */
  117357. private getFloat32ArrayFromArrayBuffer;
  117358. /**
  117359. * Get the current class name of the texture useful for serialization or dynamic coding.
  117360. * @returns "EquiRectangularCubeTexture"
  117361. */
  117362. getClassName(): string;
  117363. /**
  117364. * Create a clone of the current EquiRectangularCubeTexture and return it.
  117365. * @returns A clone of the current EquiRectangularCubeTexture.
  117366. */
  117367. clone(): EquiRectangularCubeTexture;
  117368. }
  117369. }
  117370. declare module BABYLON {
  117371. /**
  117372. * Based on jsTGALoader - Javascript loader for TGA file
  117373. * By Vincent Thibault
  117374. * @see http://blog.robrowser.com/javascript-tga-loader.html
  117375. */
  117376. export class TGATools {
  117377. private static _TYPE_INDEXED;
  117378. private static _TYPE_RGB;
  117379. private static _TYPE_GREY;
  117380. private static _TYPE_RLE_INDEXED;
  117381. private static _TYPE_RLE_RGB;
  117382. private static _TYPE_RLE_GREY;
  117383. private static _ORIGIN_MASK;
  117384. private static _ORIGIN_SHIFT;
  117385. private static _ORIGIN_BL;
  117386. private static _ORIGIN_BR;
  117387. private static _ORIGIN_UL;
  117388. private static _ORIGIN_UR;
  117389. /**
  117390. * Gets the header of a TGA file
  117391. * @param data defines the TGA data
  117392. * @returns the header
  117393. */
  117394. static GetTGAHeader(data: Uint8Array): any;
  117395. /**
  117396. * Uploads TGA content to a Babylon Texture
  117397. * @hidden
  117398. */
  117399. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  117400. /** @hidden */
  117401. 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;
  117402. /** @hidden */
  117403. 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;
  117404. /** @hidden */
  117405. 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;
  117406. /** @hidden */
  117407. 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;
  117408. /** @hidden */
  117409. 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;
  117410. /** @hidden */
  117411. 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;
  117412. }
  117413. }
  117414. declare module BABYLON {
  117415. /**
  117416. * Implementation of the TGA Texture Loader.
  117417. * @hidden
  117418. */
  117419. export class _TGATextureLoader implements IInternalTextureLoader {
  117420. /**
  117421. * Defines wether the loader supports cascade loading the different faces.
  117422. */
  117423. readonly supportCascades: boolean;
  117424. /**
  117425. * This returns if the loader support the current file information.
  117426. * @param extension defines the file extension of the file being loaded
  117427. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117428. * @param fallback defines the fallback internal texture if any
  117429. * @param isBase64 defines whether the texture is encoded as a base64
  117430. * @param isBuffer defines whether the texture data are stored as a buffer
  117431. * @returns true if the loader can load the specified file
  117432. */
  117433. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117434. /**
  117435. * Transform the url before loading if required.
  117436. * @param rootUrl the url of the texture
  117437. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117438. * @returns the transformed texture
  117439. */
  117440. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117441. /**
  117442. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117443. * @param rootUrl the url of the texture
  117444. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117445. * @returns the fallback texture
  117446. */
  117447. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117448. /**
  117449. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  117450. * @param data contains the texture data
  117451. * @param texture defines the BabylonJS internal texture
  117452. * @param createPolynomials will be true if polynomials have been requested
  117453. * @param onLoad defines the callback to trigger once the texture is ready
  117454. * @param onError defines the callback to trigger in case of error
  117455. */
  117456. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117457. /**
  117458. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117459. * @param data contains the texture data
  117460. * @param texture defines the BabylonJS internal texture
  117461. * @param callback defines the method to call once ready to upload
  117462. */
  117463. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117464. }
  117465. }
  117466. declare module BABYLON {
  117467. /**
  117468. * Info about the .basis files
  117469. */
  117470. class BasisFileInfo {
  117471. /**
  117472. * If the file has alpha
  117473. */
  117474. hasAlpha: boolean;
  117475. /**
  117476. * Info about each image of the basis file
  117477. */
  117478. images: Array<{
  117479. levels: Array<{
  117480. width: number;
  117481. height: number;
  117482. transcodedPixels: ArrayBufferView;
  117483. }>;
  117484. }>;
  117485. }
  117486. /**
  117487. * Result of transcoding a basis file
  117488. */
  117489. class TranscodeResult {
  117490. /**
  117491. * Info about the .basis file
  117492. */
  117493. fileInfo: BasisFileInfo;
  117494. /**
  117495. * Format to use when loading the file
  117496. */
  117497. format: number;
  117498. }
  117499. /**
  117500. * Configuration options for the Basis transcoder
  117501. */
  117502. export class BasisTranscodeConfiguration {
  117503. /**
  117504. * Supported compression formats used to determine the supported output format of the transcoder
  117505. */
  117506. supportedCompressionFormats?: {
  117507. /**
  117508. * etc1 compression format
  117509. */
  117510. etc1?: boolean;
  117511. /**
  117512. * s3tc compression format
  117513. */
  117514. s3tc?: boolean;
  117515. /**
  117516. * pvrtc compression format
  117517. */
  117518. pvrtc?: boolean;
  117519. /**
  117520. * etc2 compression format
  117521. */
  117522. etc2?: boolean;
  117523. };
  117524. /**
  117525. * If mipmap levels should be loaded for transcoded images (Default: true)
  117526. */
  117527. loadMipmapLevels?: boolean;
  117528. /**
  117529. * Index of a single image to load (Default: all images)
  117530. */
  117531. loadSingleImage?: number;
  117532. }
  117533. /**
  117534. * Used to load .Basis files
  117535. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  117536. */
  117537. export class BasisTools {
  117538. private static _IgnoreSupportedFormats;
  117539. /**
  117540. * URL to use when loading the basis transcoder
  117541. */
  117542. static JSModuleURL: string;
  117543. /**
  117544. * URL to use when loading the wasm module for the transcoder
  117545. */
  117546. static WasmModuleURL: string;
  117547. /**
  117548. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  117549. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  117550. * @returns internal format corresponding to the Basis format
  117551. */
  117552. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  117553. private static _WorkerPromise;
  117554. private static _Worker;
  117555. private static _actionId;
  117556. private static _CreateWorkerAsync;
  117557. /**
  117558. * Transcodes a loaded image file to compressed pixel data
  117559. * @param imageData image data to transcode
  117560. * @param config configuration options for the transcoding
  117561. * @returns a promise resulting in the transcoded image
  117562. */
  117563. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  117564. /**
  117565. * Loads a texture from the transcode result
  117566. * @param texture texture load to
  117567. * @param transcodeResult the result of transcoding the basis file to load from
  117568. */
  117569. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  117570. }
  117571. }
  117572. declare module BABYLON {
  117573. /**
  117574. * Loader for .basis file format
  117575. */
  117576. export class _BasisTextureLoader implements IInternalTextureLoader {
  117577. /**
  117578. * Defines whether the loader supports cascade loading the different faces.
  117579. */
  117580. readonly supportCascades: boolean;
  117581. /**
  117582. * This returns if the loader support the current file information.
  117583. * @param extension defines the file extension of the file being loaded
  117584. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117585. * @param fallback defines the fallback internal texture if any
  117586. * @param isBase64 defines whether the texture is encoded as a base64
  117587. * @param isBuffer defines whether the texture data are stored as a buffer
  117588. * @returns true if the loader can load the specified file
  117589. */
  117590. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  117591. /**
  117592. * Transform the url before loading if required.
  117593. * @param rootUrl the url of the texture
  117594. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117595. * @returns the transformed texture
  117596. */
  117597. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  117598. /**
  117599. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  117600. * @param rootUrl the url of the texture
  117601. * @param textureFormatInUse defines the current compressed format in use iun the engine
  117602. * @returns the fallback texture
  117603. */
  117604. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  117605. /**
  117606. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  117607. * @param data contains the texture data
  117608. * @param texture defines the BabylonJS internal texture
  117609. * @param createPolynomials will be true if polynomials have been requested
  117610. * @param onLoad defines the callback to trigger once the texture is ready
  117611. * @param onError defines the callback to trigger in case of error
  117612. */
  117613. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  117614. /**
  117615. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  117616. * @param data contains the texture data
  117617. * @param texture defines the BabylonJS internal texture
  117618. * @param callback defines the method to call once ready to upload
  117619. */
  117620. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  117621. }
  117622. }
  117623. declare module BABYLON {
  117624. /**
  117625. * 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.
  117626. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117627. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117628. */
  117629. export class CustomProceduralTexture extends ProceduralTexture {
  117630. private _animate;
  117631. private _time;
  117632. private _config;
  117633. private _texturePath;
  117634. /**
  117635. * Instantiates a new Custom Procedural Texture.
  117636. * 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.
  117637. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  117638. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  117639. * @param name Define the name of the texture
  117640. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  117641. * @param size Define the size of the texture to create
  117642. * @param scene Define the scene the texture belongs to
  117643. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  117644. * @param generateMipMaps Define if the texture should creates mip maps or not
  117645. */
  117646. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117647. private _loadJson;
  117648. /**
  117649. * Is the texture ready to be used ? (rendered at least once)
  117650. * @returns true if ready, otherwise, false.
  117651. */
  117652. isReady(): boolean;
  117653. /**
  117654. * Render the texture to its associated render target.
  117655. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  117656. */
  117657. render(useCameraPostProcess?: boolean): void;
  117658. /**
  117659. * Update the list of dependant textures samplers in the shader.
  117660. */
  117661. updateTextures(): void;
  117662. /**
  117663. * Update the uniform values of the procedural texture in the shader.
  117664. */
  117665. updateShaderUniforms(): void;
  117666. /**
  117667. * Define if the texture animates or not.
  117668. */
  117669. animate: boolean;
  117670. }
  117671. }
  117672. declare module BABYLON {
  117673. /** @hidden */
  117674. export var noisePixelShader: {
  117675. name: string;
  117676. shader: string;
  117677. };
  117678. }
  117679. declare module BABYLON {
  117680. /**
  117681. * Class used to generate noise procedural textures
  117682. */
  117683. export class NoiseProceduralTexture extends ProceduralTexture {
  117684. private _time;
  117685. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  117686. brightness: number;
  117687. /** Defines the number of octaves to process */
  117688. octaves: number;
  117689. /** Defines the level of persistence (0.8 by default) */
  117690. persistence: number;
  117691. /** Gets or sets animation speed factor (default is 1) */
  117692. animationSpeedFactor: number;
  117693. /**
  117694. * Creates a new NoiseProceduralTexture
  117695. * @param name defines the name fo the texture
  117696. * @param size defines the size of the texture (default is 256)
  117697. * @param scene defines the hosting scene
  117698. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  117699. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  117700. */
  117701. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  117702. private _updateShaderUniforms;
  117703. protected _getDefines(): string;
  117704. /** Generate the current state of the procedural texture */
  117705. render(useCameraPostProcess?: boolean): void;
  117706. /**
  117707. * Serializes this noise procedural texture
  117708. * @returns a serialized noise procedural texture object
  117709. */
  117710. serialize(): any;
  117711. /**
  117712. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  117713. * @param parsedTexture defines parsed texture data
  117714. * @param scene defines the current scene
  117715. * @param rootUrl defines the root URL containing noise procedural texture information
  117716. * @returns a parsed NoiseProceduralTexture
  117717. */
  117718. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  117719. }
  117720. }
  117721. declare module BABYLON {
  117722. /**
  117723. * Raw cube texture where the raw buffers are passed in
  117724. */
  117725. export class RawCubeTexture extends CubeTexture {
  117726. /**
  117727. * Creates a cube texture where the raw buffers are passed in.
  117728. * @param scene defines the scene the texture is attached to
  117729. * @param data defines the array of data to use to create each face
  117730. * @param size defines the size of the textures
  117731. * @param format defines the format of the data
  117732. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  117733. * @param generateMipMaps defines if the engine should generate the mip levels
  117734. * @param invertY defines if data must be stored with Y axis inverted
  117735. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  117736. * @param compression defines the compression used (null by default)
  117737. */
  117738. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  117739. /**
  117740. * Updates the raw cube texture.
  117741. * @param data defines the data to store
  117742. * @param format defines the data format
  117743. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  117744. * @param invertY defines if data must be stored with Y axis inverted
  117745. * @param compression defines the compression used (null by default)
  117746. * @param level defines which level of the texture to update
  117747. */
  117748. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  117749. /**
  117750. * Updates a raw cube texture with RGBD encoded data.
  117751. * @param data defines the array of data [mipmap][face] to use to create each face
  117752. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  117753. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  117754. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  117755. * @returns a promsie that resolves when the operation is complete
  117756. */
  117757. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  117758. /**
  117759. * Clones the raw cube texture.
  117760. * @return a new cube texture
  117761. */
  117762. clone(): CubeTexture;
  117763. /** @hidden */
  117764. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  117765. }
  117766. }
  117767. declare module BABYLON {
  117768. /**
  117769. * Class used to store 3D textures containing user data
  117770. */
  117771. export class RawTexture3D extends Texture {
  117772. /** Gets or sets the texture format to use */
  117773. format: number;
  117774. private _engine;
  117775. /**
  117776. * Create a new RawTexture3D
  117777. * @param data defines the data of the texture
  117778. * @param width defines the width of the texture
  117779. * @param height defines the height of the texture
  117780. * @param depth defines the depth of the texture
  117781. * @param format defines the texture format to use
  117782. * @param scene defines the hosting scene
  117783. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  117784. * @param invertY defines if texture must be stored with Y axis inverted
  117785. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  117786. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  117787. */
  117788. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  117789. /** Gets or sets the texture format to use */
  117790. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  117791. /**
  117792. * Update the texture with new data
  117793. * @param data defines the data to store in the texture
  117794. */
  117795. update(data: ArrayBufferView): void;
  117796. }
  117797. }
  117798. declare module BABYLON {
  117799. /**
  117800. * Creates a refraction texture used by refraction channel of the standard material.
  117801. * It is like a mirror but to see through a material.
  117802. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117803. */
  117804. export class RefractionTexture extends RenderTargetTexture {
  117805. /**
  117806. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  117807. * 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.
  117808. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117809. */
  117810. refractionPlane: Plane;
  117811. /**
  117812. * Define how deep under the surface we should see.
  117813. */
  117814. depth: number;
  117815. /**
  117816. * Creates a refraction texture used by refraction channel of the standard material.
  117817. * It is like a mirror but to see through a material.
  117818. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  117819. * @param name Define the texture name
  117820. * @param size Define the size of the underlying texture
  117821. * @param scene Define the scene the refraction belongs to
  117822. * @param generateMipMaps Define if we need to generate mips level for the refraction
  117823. */
  117824. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  117825. /**
  117826. * Clone the refraction texture.
  117827. * @returns the cloned texture
  117828. */
  117829. clone(): RefractionTexture;
  117830. /**
  117831. * Serialize the texture to a JSON representation you could use in Parse later on
  117832. * @returns the serialized JSON representation
  117833. */
  117834. serialize(): any;
  117835. }
  117836. }
  117837. declare module BABYLON {
  117838. /**
  117839. * Defines the options related to the creation of an HtmlElementTexture
  117840. */
  117841. export interface IHtmlElementTextureOptions {
  117842. /**
  117843. * Defines wether mip maps should be created or not.
  117844. */
  117845. generateMipMaps?: boolean;
  117846. /**
  117847. * Defines the sampling mode of the texture.
  117848. */
  117849. samplingMode?: number;
  117850. /**
  117851. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  117852. */
  117853. engine: Nullable<Engine>;
  117854. /**
  117855. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  117856. */
  117857. scene: Nullable<Scene>;
  117858. }
  117859. /**
  117860. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  117861. * To be as efficient as possible depending on your constraints nothing aside the first upload
  117862. * is automatically managed.
  117863. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  117864. * in your application.
  117865. *
  117866. * As the update is not automatic, you need to call them manually.
  117867. */
  117868. export class HtmlElementTexture extends BaseTexture {
  117869. /**
  117870. * The texture URL.
  117871. */
  117872. element: HTMLVideoElement | HTMLCanvasElement;
  117873. private static readonly DefaultOptions;
  117874. private _textureMatrix;
  117875. private _engine;
  117876. private _isVideo;
  117877. private _generateMipMaps;
  117878. private _samplingMode;
  117879. /**
  117880. * Instantiates a HtmlElementTexture from the following parameters.
  117881. *
  117882. * @param name Defines the name of the texture
  117883. * @param element Defines the video or canvas the texture is filled with
  117884. * @param options Defines the other none mandatory texture creation options
  117885. */
  117886. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  117887. private _createInternalTexture;
  117888. /**
  117889. * Returns the texture matrix used in most of the material.
  117890. */
  117891. getTextureMatrix(): Matrix;
  117892. /**
  117893. * Updates the content of the texture.
  117894. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  117895. */
  117896. update(invertY?: Nullable<boolean>): void;
  117897. }
  117898. }
  117899. declare module BABYLON {
  117900. /**
  117901. * Enum used to define the target of a block
  117902. */
  117903. export enum NodeMaterialBlockTargets {
  117904. /** Vertex shader */
  117905. Vertex = 1,
  117906. /** Fragment shader */
  117907. Fragment = 2,
  117908. /** Neutral */
  117909. Neutral = 4,
  117910. /** Vertex and Fragment */
  117911. VertexAndFragment = 3
  117912. }
  117913. }
  117914. declare module BABYLON {
  117915. /**
  117916. * Defines the kind of connection point for node based material
  117917. */
  117918. export enum NodeMaterialBlockConnectionPointTypes {
  117919. /** Float */
  117920. Float = 1,
  117921. /** Int */
  117922. Int = 2,
  117923. /** Vector2 */
  117924. Vector2 = 4,
  117925. /** Vector3 */
  117926. Vector3 = 8,
  117927. /** Vector4 */
  117928. Vector4 = 16,
  117929. /** Color3 */
  117930. Color3 = 32,
  117931. /** Color4 */
  117932. Color4 = 64,
  117933. /** Matrix */
  117934. Matrix = 128,
  117935. /** Detect type based on connection */
  117936. AutoDetect = 1024,
  117937. /** Output type that will be defined by input type */
  117938. BasedOnInput = 2048
  117939. }
  117940. }
  117941. declare module BABYLON {
  117942. /**
  117943. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  117944. */
  117945. export enum NodeMaterialBlockConnectionPointMode {
  117946. /** Value is an uniform */
  117947. Uniform = 0,
  117948. /** Value is a mesh attribute */
  117949. Attribute = 1,
  117950. /** Value is a varying between vertex and fragment shaders */
  117951. Varying = 2,
  117952. /** Mode is undefined */
  117953. Undefined = 3
  117954. }
  117955. }
  117956. declare module BABYLON {
  117957. /**
  117958. * Enum used to define system values e.g. values automatically provided by the system
  117959. */
  117960. export enum NodeMaterialSystemValues {
  117961. /** World */
  117962. World = 1,
  117963. /** View */
  117964. View = 2,
  117965. /** Projection */
  117966. Projection = 3,
  117967. /** ViewProjection */
  117968. ViewProjection = 4,
  117969. /** WorldView */
  117970. WorldView = 5,
  117971. /** WorldViewProjection */
  117972. WorldViewProjection = 6,
  117973. /** CameraPosition */
  117974. CameraPosition = 7,
  117975. /** Fog Color */
  117976. FogColor = 8
  117977. }
  117978. }
  117979. declare module BABYLON {
  117980. /**
  117981. * Root class for all node material optimizers
  117982. */
  117983. export class NodeMaterialOptimizer {
  117984. /**
  117985. * Function used to optimize a NodeMaterial graph
  117986. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  117987. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  117988. */
  117989. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  117990. }
  117991. }
  117992. declare module BABYLON {
  117993. /**
  117994. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  117995. */
  117996. export class TransformBlock extends NodeMaterialBlock {
  117997. /**
  117998. * Defines the value to use to complement W value to transform it to a Vector4
  117999. */
  118000. complementW: number;
  118001. /**
  118002. * Defines the value to use to complement z value to transform it to a Vector4
  118003. */
  118004. complementZ: number;
  118005. /**
  118006. * Creates a new TransformBlock
  118007. * @param name defines the block name
  118008. */
  118009. constructor(name: string);
  118010. /**
  118011. * Gets the current class name
  118012. * @returns the class name
  118013. */
  118014. getClassName(): string;
  118015. /**
  118016. * Gets the vector input
  118017. */
  118018. readonly vector: NodeMaterialConnectionPoint;
  118019. /**
  118020. * Gets the output component
  118021. */
  118022. readonly output: NodeMaterialConnectionPoint;
  118023. /**
  118024. * Gets the matrix transform input
  118025. */
  118026. readonly transform: NodeMaterialConnectionPoint;
  118027. protected _buildBlock(state: NodeMaterialBuildState): this;
  118028. serialize(): any;
  118029. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118030. protected _dumpPropertiesCode(): string;
  118031. }
  118032. }
  118033. declare module BABYLON {
  118034. /**
  118035. * Block used to output the vertex position
  118036. */
  118037. export class VertexOutputBlock extends NodeMaterialBlock {
  118038. /**
  118039. * Creates a new VertexOutputBlock
  118040. * @param name defines the block name
  118041. */
  118042. constructor(name: string);
  118043. /**
  118044. * Gets the current class name
  118045. * @returns the class name
  118046. */
  118047. getClassName(): string;
  118048. /**
  118049. * Gets the vector input component
  118050. */
  118051. readonly vector: NodeMaterialConnectionPoint;
  118052. protected _buildBlock(state: NodeMaterialBuildState): this;
  118053. }
  118054. }
  118055. declare module BABYLON {
  118056. /**
  118057. * Block used to output the final color
  118058. */
  118059. export class FragmentOutputBlock extends NodeMaterialBlock {
  118060. /**
  118061. * Create a new FragmentOutputBlock
  118062. * @param name defines the block name
  118063. */
  118064. constructor(name: string);
  118065. /**
  118066. * Gets the current class name
  118067. * @returns the class name
  118068. */
  118069. getClassName(): string;
  118070. /**
  118071. * Gets the rgba input component
  118072. */
  118073. readonly rgba: NodeMaterialConnectionPoint;
  118074. /**
  118075. * Gets the rgb input component
  118076. */
  118077. readonly rgb: NodeMaterialConnectionPoint;
  118078. /**
  118079. * Gets the a input component
  118080. */
  118081. readonly a: NodeMaterialConnectionPoint;
  118082. protected _buildBlock(state: NodeMaterialBuildState): this;
  118083. }
  118084. }
  118085. declare module BABYLON {
  118086. /**
  118087. * Block used to read a reflection texture from a sampler
  118088. */
  118089. export class ReflectionTextureBlock extends NodeMaterialBlock {
  118090. private _define3DName;
  118091. private _defineCubicName;
  118092. private _defineExplicitName;
  118093. private _defineProjectionName;
  118094. private _defineLocalCubicName;
  118095. private _defineSphericalName;
  118096. private _definePlanarName;
  118097. private _defineEquirectangularName;
  118098. private _defineMirroredEquirectangularFixedName;
  118099. private _defineEquirectangularFixedName;
  118100. private _defineSkyboxName;
  118101. private _cubeSamplerName;
  118102. private _2DSamplerName;
  118103. private _positionUVWName;
  118104. private _directionWName;
  118105. private _reflectionCoordsName;
  118106. private _reflection2DCoordsName;
  118107. private _reflectionColorName;
  118108. private _reflectionMatrixName;
  118109. /**
  118110. * Gets or sets the texture associated with the node
  118111. */
  118112. texture: Nullable<BaseTexture>;
  118113. /**
  118114. * Create a new TextureBlock
  118115. * @param name defines the block name
  118116. */
  118117. constructor(name: string);
  118118. /**
  118119. * Gets the current class name
  118120. * @returns the class name
  118121. */
  118122. getClassName(): string;
  118123. /**
  118124. * Gets the world position input component
  118125. */
  118126. readonly position: NodeMaterialConnectionPoint;
  118127. /**
  118128. * Gets the world position input component
  118129. */
  118130. readonly worldPosition: NodeMaterialConnectionPoint;
  118131. /**
  118132. * Gets the world normal input component
  118133. */
  118134. readonly worldNormal: NodeMaterialConnectionPoint;
  118135. /**
  118136. * Gets the world input component
  118137. */
  118138. readonly world: NodeMaterialConnectionPoint;
  118139. /**
  118140. * Gets the camera (or eye) position component
  118141. */
  118142. readonly cameraPosition: NodeMaterialConnectionPoint;
  118143. /**
  118144. * Gets the view input component
  118145. */
  118146. readonly view: NodeMaterialConnectionPoint;
  118147. /**
  118148. * Gets the rgb output component
  118149. */
  118150. readonly rgb: NodeMaterialConnectionPoint;
  118151. /**
  118152. * Gets the r output component
  118153. */
  118154. readonly r: NodeMaterialConnectionPoint;
  118155. /**
  118156. * Gets the g output component
  118157. */
  118158. readonly g: NodeMaterialConnectionPoint;
  118159. /**
  118160. * Gets the b output component
  118161. */
  118162. readonly b: NodeMaterialConnectionPoint;
  118163. autoConfigure(material: NodeMaterial): void;
  118164. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118165. isReady(): boolean;
  118166. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118167. private _injectVertexCode;
  118168. private _writeOutput;
  118169. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118170. serialize(): any;
  118171. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118172. }
  118173. }
  118174. declare module BABYLON {
  118175. /**
  118176. * Interface used to configure the node material editor
  118177. */
  118178. export interface INodeMaterialEditorOptions {
  118179. /** Define the URl to load node editor script */
  118180. editorURL?: string;
  118181. }
  118182. /** @hidden */
  118183. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  118184. /** BONES */
  118185. NUM_BONE_INFLUENCERS: number;
  118186. BonesPerMesh: number;
  118187. BONETEXTURE: boolean;
  118188. /** MORPH TARGETS */
  118189. MORPHTARGETS: boolean;
  118190. MORPHTARGETS_NORMAL: boolean;
  118191. MORPHTARGETS_TANGENT: boolean;
  118192. MORPHTARGETS_UV: boolean;
  118193. NUM_MORPH_INFLUENCERS: number;
  118194. /** IMAGE PROCESSING */
  118195. IMAGEPROCESSING: boolean;
  118196. VIGNETTE: boolean;
  118197. VIGNETTEBLENDMODEMULTIPLY: boolean;
  118198. VIGNETTEBLENDMODEOPAQUE: boolean;
  118199. TONEMAPPING: boolean;
  118200. TONEMAPPING_ACES: boolean;
  118201. CONTRAST: boolean;
  118202. EXPOSURE: boolean;
  118203. COLORCURVES: boolean;
  118204. COLORGRADING: boolean;
  118205. COLORGRADING3D: boolean;
  118206. SAMPLER3DGREENDEPTH: boolean;
  118207. SAMPLER3DBGRMAP: boolean;
  118208. IMAGEPROCESSINGPOSTPROCESS: boolean;
  118209. /** MISC. */
  118210. BUMPDIRECTUV: number;
  118211. constructor();
  118212. setValue(name: string, value: boolean): void;
  118213. }
  118214. /**
  118215. * Class used to configure NodeMaterial
  118216. */
  118217. export interface INodeMaterialOptions {
  118218. /**
  118219. * Defines if blocks should emit comments
  118220. */
  118221. emitComments: boolean;
  118222. }
  118223. /**
  118224. * Class used to create a node based material built by assembling shader blocks
  118225. */
  118226. export class NodeMaterial extends PushMaterial {
  118227. private static _BuildIdGenerator;
  118228. private _options;
  118229. private _vertexCompilationState;
  118230. private _fragmentCompilationState;
  118231. private _sharedData;
  118232. private _buildId;
  118233. private _buildWasSuccessful;
  118234. private _cachedWorldViewMatrix;
  118235. private _cachedWorldViewProjectionMatrix;
  118236. private _optimizers;
  118237. private _animationFrame;
  118238. /** Define the URl to load node editor script */
  118239. static EditorURL: string;
  118240. private BJSNODEMATERIALEDITOR;
  118241. /** Get the inspector from bundle or global */
  118242. private _getGlobalNodeMaterialEditor;
  118243. /**
  118244. * 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)
  118245. */
  118246. ignoreAlpha: boolean;
  118247. /**
  118248. * Defines the maximum number of lights that can be used in the material
  118249. */
  118250. maxSimultaneousLights: number;
  118251. /**
  118252. * Observable raised when the material is built
  118253. */
  118254. onBuildObservable: Observable<NodeMaterial>;
  118255. /**
  118256. * Gets or sets the root nodes of the material vertex shader
  118257. */
  118258. _vertexOutputNodes: NodeMaterialBlock[];
  118259. /**
  118260. * Gets or sets the root nodes of the material fragment (pixel) shader
  118261. */
  118262. _fragmentOutputNodes: NodeMaterialBlock[];
  118263. /** Gets or sets options to control the node material overall behavior */
  118264. options: INodeMaterialOptions;
  118265. /**
  118266. * Default configuration related to image processing available in the standard Material.
  118267. */
  118268. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  118269. /**
  118270. * Gets the image processing configuration used either in this material.
  118271. */
  118272. /**
  118273. * Sets the Default image processing configuration used either in the this material.
  118274. *
  118275. * If sets to null, the scene one is in use.
  118276. */
  118277. imageProcessingConfiguration: ImageProcessingConfiguration;
  118278. /**
  118279. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  118280. */
  118281. attachedBlocks: NodeMaterialBlock[];
  118282. /**
  118283. * Create a new node based material
  118284. * @param name defines the material name
  118285. * @param scene defines the hosting scene
  118286. * @param options defines creation option
  118287. */
  118288. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  118289. /**
  118290. * Gets the current class name of the material e.g. "NodeMaterial"
  118291. * @returns the class name
  118292. */
  118293. getClassName(): string;
  118294. /**
  118295. * Keep track of the image processing observer to allow dispose and replace.
  118296. */
  118297. private _imageProcessingObserver;
  118298. /**
  118299. * Attaches a new image processing configuration to the Standard Material.
  118300. * @param configuration
  118301. */
  118302. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  118303. /**
  118304. * Get a block by its name
  118305. * @param name defines the name of the block to retrieve
  118306. * @returns the required block or null if not found
  118307. */
  118308. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  118309. /**
  118310. * Get a block by its name
  118311. * @param predicate defines the predicate used to find the good candidate
  118312. * @returns the required block or null if not found
  118313. */
  118314. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  118315. /**
  118316. * Get an input block by its name
  118317. * @param predicate defines the predicate used to find the good candidate
  118318. * @returns the required input block or null if not found
  118319. */
  118320. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  118321. /**
  118322. * Gets the list of input blocks attached to this material
  118323. * @returns an array of InputBlocks
  118324. */
  118325. getInputBlocks(): InputBlock[];
  118326. /**
  118327. * Adds a new optimizer to the list of optimizers
  118328. * @param optimizer defines the optimizers to add
  118329. * @returns the current material
  118330. */
  118331. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  118332. /**
  118333. * Remove an optimizer from the list of optimizers
  118334. * @param optimizer defines the optimizers to remove
  118335. * @returns the current material
  118336. */
  118337. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  118338. /**
  118339. * Add a new block to the list of output nodes
  118340. * @param node defines the node to add
  118341. * @returns the current material
  118342. */
  118343. addOutputNode(node: NodeMaterialBlock): this;
  118344. /**
  118345. * Remove a block from the list of root nodes
  118346. * @param node defines the node to remove
  118347. * @returns the current material
  118348. */
  118349. removeOutputNode(node: NodeMaterialBlock): this;
  118350. private _addVertexOutputNode;
  118351. private _removeVertexOutputNode;
  118352. private _addFragmentOutputNode;
  118353. private _removeFragmentOutputNode;
  118354. /**
  118355. * Specifies if the material will require alpha blending
  118356. * @returns a boolean specifying if alpha blending is needed
  118357. */
  118358. needAlphaBlending(): boolean;
  118359. /**
  118360. * Specifies if this material should be rendered in alpha test mode
  118361. * @returns a boolean specifying if an alpha test is needed.
  118362. */
  118363. needAlphaTesting(): boolean;
  118364. private _initializeBlock;
  118365. private _resetDualBlocks;
  118366. /**
  118367. * Build the material and generates the inner effect
  118368. * @param verbose defines if the build should log activity
  118369. */
  118370. build(verbose?: boolean): void;
  118371. /**
  118372. * Runs an otpimization phase to try to improve the shader code
  118373. */
  118374. optimize(): void;
  118375. private _prepareDefinesForAttributes;
  118376. /**
  118377. * Get if the submesh is ready to be used and all its information available.
  118378. * Child classes can use it to update shaders
  118379. * @param mesh defines the mesh to check
  118380. * @param subMesh defines which submesh to check
  118381. * @param useInstances specifies that instances should be used
  118382. * @returns a boolean indicating that the submesh is ready or not
  118383. */
  118384. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  118385. /**
  118386. * Get a string representing the shaders built by the current node graph
  118387. */
  118388. readonly compiledShaders: string;
  118389. /**
  118390. * Binds the world matrix to the material
  118391. * @param world defines the world transformation matrix
  118392. */
  118393. bindOnlyWorldMatrix(world: Matrix): void;
  118394. /**
  118395. * Binds the submesh to this material by preparing the effect and shader to draw
  118396. * @param world defines the world transformation matrix
  118397. * @param mesh defines the mesh containing the submesh
  118398. * @param subMesh defines the submesh to bind the material to
  118399. */
  118400. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  118401. /**
  118402. * Gets the active textures from the material
  118403. * @returns an array of textures
  118404. */
  118405. getActiveTextures(): BaseTexture[];
  118406. /**
  118407. * Gets the list of texture blocks
  118408. * @returns an array of texture blocks
  118409. */
  118410. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  118411. /**
  118412. * Specifies if the material uses a texture
  118413. * @param texture defines the texture to check against the material
  118414. * @returns a boolean specifying if the material uses the texture
  118415. */
  118416. hasTexture(texture: BaseTexture): boolean;
  118417. /**
  118418. * Disposes the material
  118419. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  118420. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  118421. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  118422. */
  118423. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  118424. /** Creates the node editor window. */
  118425. private _createNodeEditor;
  118426. /**
  118427. * Launch the node material editor
  118428. * @param config Define the configuration of the editor
  118429. * @return a promise fulfilled when the node editor is visible
  118430. */
  118431. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  118432. /**
  118433. * Clear the current material
  118434. */
  118435. clear(): void;
  118436. /**
  118437. * Clear the current material and set it to a default state
  118438. */
  118439. setToDefault(): void;
  118440. /**
  118441. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  118442. * @param url defines the url to load from
  118443. * @returns a promise that will fullfil when the material is fully loaded
  118444. */
  118445. loadAsync(url: string): Promise<unknown>;
  118446. private _gatherBlocks;
  118447. /**
  118448. * Generate a string containing the code declaration required to create an equivalent of this material
  118449. * @returns a string
  118450. */
  118451. generateCode(): string;
  118452. /**
  118453. * Serializes this material in a JSON representation
  118454. * @returns the serialized material object
  118455. */
  118456. serialize(): any;
  118457. private _restoreConnections;
  118458. /**
  118459. * Clear the current graph and load a new one from a serialization object
  118460. * @param source defines the JSON representation of the material
  118461. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118462. */
  118463. loadFromSerialization(source: any, rootUrl?: string): void;
  118464. /**
  118465. * Creates a node material from parsed material data
  118466. * @param source defines the JSON representation of the material
  118467. * @param scene defines the hosting scene
  118468. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118469. * @returns a new node material
  118470. */
  118471. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  118472. /**
  118473. * Creates a new node material set to default basic configuration
  118474. * @param name defines the name of the material
  118475. * @param scene defines the hosting scene
  118476. * @returns a new NodeMaterial
  118477. */
  118478. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  118479. }
  118480. }
  118481. declare module BABYLON {
  118482. /**
  118483. * Block used to read a texture from a sampler
  118484. */
  118485. export class TextureBlock extends NodeMaterialBlock {
  118486. private _defineName;
  118487. private _samplerName;
  118488. private _transformedUVName;
  118489. private _textureTransformName;
  118490. private _textureInfoName;
  118491. private _mainUVName;
  118492. private _mainUVDefineName;
  118493. /**
  118494. * Gets or sets the texture associated with the node
  118495. */
  118496. texture: Nullable<Texture>;
  118497. /**
  118498. * Create a new TextureBlock
  118499. * @param name defines the block name
  118500. */
  118501. constructor(name: string);
  118502. /**
  118503. * Gets the current class name
  118504. * @returns the class name
  118505. */
  118506. getClassName(): string;
  118507. /**
  118508. * Gets the uv input component
  118509. */
  118510. readonly uv: NodeMaterialConnectionPoint;
  118511. /**
  118512. * Gets the rgba output component
  118513. */
  118514. readonly rgba: NodeMaterialConnectionPoint;
  118515. /**
  118516. * Gets the rgb output component
  118517. */
  118518. readonly rgb: NodeMaterialConnectionPoint;
  118519. /**
  118520. * Gets the r output component
  118521. */
  118522. readonly r: NodeMaterialConnectionPoint;
  118523. /**
  118524. * Gets the g output component
  118525. */
  118526. readonly g: NodeMaterialConnectionPoint;
  118527. /**
  118528. * Gets the b output component
  118529. */
  118530. readonly b: NodeMaterialConnectionPoint;
  118531. /**
  118532. * Gets the a output component
  118533. */
  118534. readonly a: NodeMaterialConnectionPoint;
  118535. readonly target: NodeMaterialBlockTargets;
  118536. autoConfigure(material: NodeMaterial): void;
  118537. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118538. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118539. isReady(): boolean;
  118540. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118541. private readonly _isMixed;
  118542. private _injectVertexCode;
  118543. private _writeOutput;
  118544. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  118545. protected _dumpPropertiesCode(): string;
  118546. serialize(): any;
  118547. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118548. }
  118549. }
  118550. declare module BABYLON {
  118551. /**
  118552. * Class used to store shared data between 2 NodeMaterialBuildState
  118553. */
  118554. export class NodeMaterialBuildStateSharedData {
  118555. /**
  118556. * Gets the list of emitted varyings
  118557. */
  118558. temps: string[];
  118559. /**
  118560. * Gets the list of emitted varyings
  118561. */
  118562. varyings: string[];
  118563. /**
  118564. * Gets the varying declaration string
  118565. */
  118566. varyingDeclaration: string;
  118567. /**
  118568. * Input blocks
  118569. */
  118570. inputBlocks: InputBlock[];
  118571. /**
  118572. * Input blocks
  118573. */
  118574. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  118575. /**
  118576. * Bindable blocks (Blocks that need to set data to the effect)
  118577. */
  118578. bindableBlocks: NodeMaterialBlock[];
  118579. /**
  118580. * List of blocks that can provide a compilation fallback
  118581. */
  118582. blocksWithFallbacks: NodeMaterialBlock[];
  118583. /**
  118584. * List of blocks that can provide a define update
  118585. */
  118586. blocksWithDefines: NodeMaterialBlock[];
  118587. /**
  118588. * List of blocks that can provide a repeatable content
  118589. */
  118590. repeatableContentBlocks: NodeMaterialBlock[];
  118591. /**
  118592. * List of blocks that can provide a dynamic list of uniforms
  118593. */
  118594. dynamicUniformBlocks: NodeMaterialBlock[];
  118595. /**
  118596. * List of blocks that can block the isReady function for the material
  118597. */
  118598. blockingBlocks: NodeMaterialBlock[];
  118599. /**
  118600. * Gets the list of animated inputs
  118601. */
  118602. animatedInputs: InputBlock[];
  118603. /**
  118604. * Build Id used to avoid multiple recompilations
  118605. */
  118606. buildId: number;
  118607. /** List of emitted variables */
  118608. variableNames: {
  118609. [key: string]: number;
  118610. };
  118611. /** List of emitted defines */
  118612. defineNames: {
  118613. [key: string]: number;
  118614. };
  118615. /** Should emit comments? */
  118616. emitComments: boolean;
  118617. /** Emit build activity */
  118618. verbose: boolean;
  118619. /** Gets or sets the hosting scene */
  118620. scene: Scene;
  118621. /**
  118622. * Gets the compilation hints emitted at compilation time
  118623. */
  118624. hints: {
  118625. needWorldViewMatrix: boolean;
  118626. needWorldViewProjectionMatrix: boolean;
  118627. needAlphaBlending: boolean;
  118628. needAlphaTesting: boolean;
  118629. };
  118630. /**
  118631. * List of compilation checks
  118632. */
  118633. checks: {
  118634. emitVertex: boolean;
  118635. emitFragment: boolean;
  118636. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  118637. };
  118638. /** Creates a new shared data */
  118639. constructor();
  118640. /**
  118641. * Emits console errors and exceptions if there is a failing check
  118642. */
  118643. emitErrors(): void;
  118644. }
  118645. }
  118646. declare module BABYLON {
  118647. /**
  118648. * Class used to store node based material build state
  118649. */
  118650. export class NodeMaterialBuildState {
  118651. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  118652. supportUniformBuffers: boolean;
  118653. /**
  118654. * Gets the list of emitted attributes
  118655. */
  118656. attributes: string[];
  118657. /**
  118658. * Gets the list of emitted uniforms
  118659. */
  118660. uniforms: string[];
  118661. /**
  118662. * Gets the list of emitted constants
  118663. */
  118664. constants: string[];
  118665. /**
  118666. * Gets the list of emitted uniform buffers
  118667. */
  118668. uniformBuffers: string[];
  118669. /**
  118670. * Gets the list of emitted samplers
  118671. */
  118672. samplers: string[];
  118673. /**
  118674. * Gets the list of emitted functions
  118675. */
  118676. functions: {
  118677. [key: string]: string;
  118678. };
  118679. /**
  118680. * Gets the list of emitted extensions
  118681. */
  118682. extensions: {
  118683. [key: string]: string;
  118684. };
  118685. /**
  118686. * Gets the target of the compilation state
  118687. */
  118688. target: NodeMaterialBlockTargets;
  118689. /**
  118690. * Gets the list of emitted counters
  118691. */
  118692. counters: {
  118693. [key: string]: number;
  118694. };
  118695. /**
  118696. * Shared data between multiple NodeMaterialBuildState instances
  118697. */
  118698. sharedData: NodeMaterialBuildStateSharedData;
  118699. /** @hidden */
  118700. _vertexState: NodeMaterialBuildState;
  118701. /** @hidden */
  118702. _attributeDeclaration: string;
  118703. /** @hidden */
  118704. _uniformDeclaration: string;
  118705. /** @hidden */
  118706. _constantDeclaration: string;
  118707. /** @hidden */
  118708. _samplerDeclaration: string;
  118709. /** @hidden */
  118710. _varyingTransfer: string;
  118711. private _repeatableContentAnchorIndex;
  118712. /** @hidden */
  118713. _builtCompilationString: string;
  118714. /**
  118715. * Gets the emitted compilation strings
  118716. */
  118717. compilationString: string;
  118718. /**
  118719. * Finalize the compilation strings
  118720. * @param state defines the current compilation state
  118721. */
  118722. finalize(state: NodeMaterialBuildState): void;
  118723. /** @hidden */
  118724. readonly _repeatableContentAnchor: string;
  118725. /** @hidden */
  118726. _getFreeVariableName(prefix: string): string;
  118727. /** @hidden */
  118728. _getFreeDefineName(prefix: string): string;
  118729. /** @hidden */
  118730. _excludeVariableName(name: string): void;
  118731. /** @hidden */
  118732. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  118733. /** @hidden */
  118734. _emitExtension(name: string, extension: string): void;
  118735. /** @hidden */
  118736. _emitFunction(name: string, code: string, comments: string): void;
  118737. /** @hidden */
  118738. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  118739. replaceStrings?: {
  118740. search: RegExp;
  118741. replace: string;
  118742. }[];
  118743. repeatKey?: string;
  118744. }): string;
  118745. /** @hidden */
  118746. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  118747. repeatKey?: string;
  118748. removeAttributes?: boolean;
  118749. removeUniforms?: boolean;
  118750. removeVaryings?: boolean;
  118751. removeIfDef?: boolean;
  118752. replaceStrings?: {
  118753. search: RegExp;
  118754. replace: string;
  118755. }[];
  118756. }, storeKey?: string): void;
  118757. /** @hidden */
  118758. _registerTempVariable(name: string): boolean;
  118759. /** @hidden */
  118760. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  118761. /** @hidden */
  118762. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  118763. }
  118764. }
  118765. declare module BABYLON {
  118766. /**
  118767. * Defines a block that can be used inside a node based material
  118768. */
  118769. export class NodeMaterialBlock {
  118770. private _buildId;
  118771. private _buildTarget;
  118772. private _target;
  118773. private _isFinalMerger;
  118774. private _isInput;
  118775. /** @hidden */
  118776. _codeVariableName: string;
  118777. /** @hidden */
  118778. _inputs: NodeMaterialConnectionPoint[];
  118779. /** @hidden */
  118780. _outputs: NodeMaterialConnectionPoint[];
  118781. /** @hidden */
  118782. _preparationId: number;
  118783. /**
  118784. * Gets or sets the name of the block
  118785. */
  118786. name: string;
  118787. /**
  118788. * Gets or sets the unique id of the node
  118789. */
  118790. uniqueId: number;
  118791. /**
  118792. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  118793. */
  118794. readonly isFinalMerger: boolean;
  118795. /**
  118796. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  118797. */
  118798. readonly isInput: boolean;
  118799. /**
  118800. * Gets or sets the build Id
  118801. */
  118802. buildId: number;
  118803. /**
  118804. * Gets or sets the target of the block
  118805. */
  118806. target: NodeMaterialBlockTargets;
  118807. /**
  118808. * Gets the list of input points
  118809. */
  118810. readonly inputs: NodeMaterialConnectionPoint[];
  118811. /** Gets the list of output points */
  118812. readonly outputs: NodeMaterialConnectionPoint[];
  118813. /**
  118814. * Find an input by its name
  118815. * @param name defines the name of the input to look for
  118816. * @returns the input or null if not found
  118817. */
  118818. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118819. /**
  118820. * Find an output by its name
  118821. * @param name defines the name of the outputto look for
  118822. * @returns the output or null if not found
  118823. */
  118824. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  118825. /**
  118826. * Creates a new NodeMaterialBlock
  118827. * @param name defines the block name
  118828. * @param target defines the target of that block (Vertex by default)
  118829. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  118830. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  118831. */
  118832. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  118833. /**
  118834. * Initialize the block and prepare the context for build
  118835. * @param state defines the state that will be used for the build
  118836. */
  118837. initialize(state: NodeMaterialBuildState): void;
  118838. /**
  118839. * Bind data to effect. Will only be called for blocks with isBindable === true
  118840. * @param effect defines the effect to bind data to
  118841. * @param nodeMaterial defines the hosting NodeMaterial
  118842. * @param mesh defines the mesh that will be rendered
  118843. */
  118844. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  118845. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  118846. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  118847. protected _writeFloat(value: number): string;
  118848. /**
  118849. * Gets the current class name e.g. "NodeMaterialBlock"
  118850. * @returns the class name
  118851. */
  118852. getClassName(): string;
  118853. /**
  118854. * Register a new input. Must be called inside a block constructor
  118855. * @param name defines the connection point name
  118856. * @param type defines the connection point type
  118857. * @param isOptional defines a boolean indicating that this input can be omitted
  118858. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118859. * @returns the current block
  118860. */
  118861. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  118862. /**
  118863. * Register a new output. Must be called inside a block constructor
  118864. * @param name defines the connection point name
  118865. * @param type defines the connection point type
  118866. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  118867. * @returns the current block
  118868. */
  118869. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  118870. /**
  118871. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  118872. * @param forOutput defines an optional connection point to check compatibility with
  118873. * @returns the first available input or null
  118874. */
  118875. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  118876. /**
  118877. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  118878. * @param forBlock defines an optional block to check compatibility with
  118879. * @returns the first available input or null
  118880. */
  118881. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  118882. /**
  118883. * Gets the sibling of the given output
  118884. * @param current defines the current output
  118885. * @returns the next output in the list or null
  118886. */
  118887. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  118888. /**
  118889. * Connect current block with another block
  118890. * @param other defines the block to connect with
  118891. * @param options define the various options to help pick the right connections
  118892. * @returns the current block
  118893. */
  118894. connectTo(other: NodeMaterialBlock, options?: {
  118895. input?: string;
  118896. output?: string;
  118897. outputSwizzle?: string;
  118898. }): this | undefined;
  118899. protected _buildBlock(state: NodeMaterialBuildState): void;
  118900. /**
  118901. * Add uniforms, samplers and uniform buffers at compilation time
  118902. * @param state defines the state to update
  118903. * @param nodeMaterial defines the node material requesting the update
  118904. * @param defines defines the material defines to update
  118905. */
  118906. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  118907. /**
  118908. * Add potential fallbacks if shader compilation fails
  118909. * @param mesh defines the mesh to be rendered
  118910. * @param fallbacks defines the current prioritized list of fallbacks
  118911. */
  118912. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  118913. /**
  118914. * Initialize defines for shader compilation
  118915. * @param mesh defines the mesh to be rendered
  118916. * @param nodeMaterial defines the node material requesting the update
  118917. * @param defines defines the material defines to update
  118918. * @param useInstances specifies that instances should be used
  118919. */
  118920. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118921. /**
  118922. * Update defines for shader compilation
  118923. * @param mesh defines the mesh to be rendered
  118924. * @param nodeMaterial defines the node material requesting the update
  118925. * @param defines defines the material defines to update
  118926. * @param useInstances specifies that instances should be used
  118927. */
  118928. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  118929. /**
  118930. * Lets the block try to connect some inputs automatically
  118931. * @param material defines the hosting NodeMaterial
  118932. */
  118933. autoConfigure(material: NodeMaterial): void;
  118934. /**
  118935. * Function called when a block is declared as repeatable content generator
  118936. * @param vertexShaderState defines the current compilation state for the vertex shader
  118937. * @param fragmentShaderState defines the current compilation state for the fragment shader
  118938. * @param mesh defines the mesh to be rendered
  118939. * @param defines defines the material defines to update
  118940. */
  118941. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  118942. /**
  118943. * Checks if the block is ready
  118944. * @param mesh defines the mesh to be rendered
  118945. * @param nodeMaterial defines the node material requesting the update
  118946. * @param defines defines the material defines to update
  118947. * @param useInstances specifies that instances should be used
  118948. * @returns true if the block is ready
  118949. */
  118950. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  118951. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  118952. private _processBuild;
  118953. /**
  118954. * Compile the current node and generate the shader code
  118955. * @param state defines the current compilation state (uniforms, samplers, current string)
  118956. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  118957. * @returns true if already built
  118958. */
  118959. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  118960. protected _inputRename(name: string): string;
  118961. protected _outputRename(name: string): string;
  118962. protected _dumpPropertiesCode(): string;
  118963. /** @hidden */
  118964. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  118965. /**
  118966. * Clone the current block to a new identical block
  118967. * @param scene defines the hosting scene
  118968. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  118969. * @returns a copy of the current block
  118970. */
  118971. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  118972. /**
  118973. * Serializes this block in a JSON representation
  118974. * @returns the serialized block object
  118975. */
  118976. serialize(): any;
  118977. /** @hidden */
  118978. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  118979. }
  118980. }
  118981. declare module BABYLON {
  118982. /**
  118983. * Enum defining the type of animations supported by InputBlock
  118984. */
  118985. export enum AnimatedInputBlockTypes {
  118986. /** No animation */
  118987. None = 0,
  118988. /** Time based animation. Will only work for floats */
  118989. Time = 1
  118990. }
  118991. }
  118992. declare module BABYLON {
  118993. /**
  118994. * Block used to expose an input value
  118995. */
  118996. export class InputBlock extends NodeMaterialBlock {
  118997. private _mode;
  118998. private _associatedVariableName;
  118999. private _storedValue;
  119000. private _valueCallback;
  119001. private _type;
  119002. private _animationType;
  119003. /** Gets or set a value used to limit the range of float values */
  119004. min: number;
  119005. /** Gets or set a value used to limit the range of float values */
  119006. max: number;
  119007. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  119008. matrixMode: number;
  119009. /** @hidden */
  119010. _systemValue: Nullable<NodeMaterialSystemValues>;
  119011. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  119012. visibleInInspector: boolean;
  119013. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  119014. isConstant: boolean;
  119015. /**
  119016. * Gets or sets the connection point type (default is float)
  119017. */
  119018. readonly type: NodeMaterialBlockConnectionPointTypes;
  119019. /**
  119020. * Creates a new InputBlock
  119021. * @param name defines the block name
  119022. * @param target defines the target of that block (Vertex by default)
  119023. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  119024. */
  119025. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  119026. /**
  119027. * Gets the output component
  119028. */
  119029. readonly output: NodeMaterialConnectionPoint;
  119030. /**
  119031. * Set the source of this connection point to a vertex attribute
  119032. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  119033. * @returns the current connection point
  119034. */
  119035. setAsAttribute(attributeName?: string): InputBlock;
  119036. /**
  119037. * Set the source of this connection point to a system value
  119038. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  119039. * @returns the current connection point
  119040. */
  119041. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  119042. /**
  119043. * Gets or sets the value of that point.
  119044. * Please note that this value will be ignored if valueCallback is defined
  119045. */
  119046. value: any;
  119047. /**
  119048. * Gets or sets a callback used to get the value of that point.
  119049. * Please note that setting this value will force the connection point to ignore the value property
  119050. */
  119051. valueCallback: () => any;
  119052. /**
  119053. * Gets or sets the associated variable name in the shader
  119054. */
  119055. associatedVariableName: string;
  119056. /** Gets or sets the type of animation applied to the input */
  119057. animationType: AnimatedInputBlockTypes;
  119058. /**
  119059. * Gets a boolean indicating that this connection point not defined yet
  119060. */
  119061. readonly isUndefined: boolean;
  119062. /**
  119063. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  119064. * In this case the connection point name must be the name of the uniform to use.
  119065. * Can only be set on inputs
  119066. */
  119067. isUniform: boolean;
  119068. /**
  119069. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  119070. * In this case the connection point name must be the name of the attribute to use
  119071. * Can only be set on inputs
  119072. */
  119073. isAttribute: boolean;
  119074. /**
  119075. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  119076. * Can only be set on exit points
  119077. */
  119078. isVarying: boolean;
  119079. /**
  119080. * Gets a boolean indicating that the current connection point is a system value
  119081. */
  119082. readonly isSystemValue: boolean;
  119083. /**
  119084. * Gets or sets the current well known value or null if not defined as a system value
  119085. */
  119086. systemValue: Nullable<NodeMaterialSystemValues>;
  119087. /**
  119088. * Gets the current class name
  119089. * @returns the class name
  119090. */
  119091. getClassName(): string;
  119092. /**
  119093. * Animate the input if animationType !== None
  119094. * @param scene defines the rendering scene
  119095. */
  119096. animate(scene: Scene): void;
  119097. private _emitDefine;
  119098. initialize(state: NodeMaterialBuildState): void;
  119099. /**
  119100. * Set the input block to its default value (based on its type)
  119101. */
  119102. setDefaultValue(): void;
  119103. private _emitConstant;
  119104. private _emit;
  119105. /** @hidden */
  119106. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  119107. /** @hidden */
  119108. _transmit(effect: Effect, scene: Scene): void;
  119109. protected _buildBlock(state: NodeMaterialBuildState): void;
  119110. protected _dumpPropertiesCode(): string;
  119111. serialize(): any;
  119112. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119113. }
  119114. }
  119115. declare module BABYLON {
  119116. /**
  119117. * Defines a connection point for a block
  119118. */
  119119. export class NodeMaterialConnectionPoint {
  119120. /** @hidden */
  119121. _ownerBlock: NodeMaterialBlock;
  119122. /** @hidden */
  119123. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  119124. private _endpoints;
  119125. private _associatedVariableName;
  119126. /** @hidden */
  119127. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  119128. /** @hidden */
  119129. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  119130. private _type;
  119131. /** @hidden */
  119132. _enforceAssociatedVariableName: boolean;
  119133. /**
  119134. * Gets or sets the additional types supported by this connection point
  119135. */
  119136. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  119137. /**
  119138. * Gets or sets the additional types excluded by this connection point
  119139. */
  119140. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  119141. /**
  119142. * Gets or sets the associated variable name in the shader
  119143. */
  119144. associatedVariableName: string;
  119145. /**
  119146. * Gets or sets the connection point type (default is float)
  119147. */
  119148. type: NodeMaterialBlockConnectionPointTypes;
  119149. /**
  119150. * Gets or sets the connection point name
  119151. */
  119152. name: string;
  119153. /**
  119154. * Gets or sets a boolean indicating that this connection point can be omitted
  119155. */
  119156. isOptional: boolean;
  119157. /**
  119158. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  119159. */
  119160. define: string;
  119161. /** Gets or sets the target of that connection point */
  119162. target: NodeMaterialBlockTargets;
  119163. /**
  119164. * Gets a boolean indicating that the current point is connected
  119165. */
  119166. readonly isConnected: boolean;
  119167. /**
  119168. * Gets a boolean indicating that the current point is connected to an input block
  119169. */
  119170. readonly isConnectedToInputBlock: boolean;
  119171. /**
  119172. * Gets a the connected input block (if any)
  119173. */
  119174. readonly connectInputBlock: Nullable<InputBlock>;
  119175. /** Get the other side of the connection (if any) */
  119176. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  119177. /** Get the block that owns this connection point */
  119178. readonly ownerBlock: NodeMaterialBlock;
  119179. /** Get the block connected on the other side of this connection (if any) */
  119180. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  119181. /** Get the block connected on the endpoints of this connection (if any) */
  119182. readonly connectedBlocks: Array<NodeMaterialBlock>;
  119183. /** Gets the list of connected endpoints */
  119184. readonly endpoints: NodeMaterialConnectionPoint[];
  119185. /** Gets a boolean indicating if that output point is connected to at least one input */
  119186. readonly hasEndpoints: boolean;
  119187. /**
  119188. * Creates a new connection point
  119189. * @param name defines the connection point name
  119190. * @param ownerBlock defines the block hosting this connection point
  119191. */
  119192. constructor(name: string, ownerBlock: NodeMaterialBlock);
  119193. /**
  119194. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  119195. * @returns the class name
  119196. */
  119197. getClassName(): string;
  119198. /**
  119199. * Gets an boolean indicating if the current point can be connected to another point
  119200. * @param connectionPoint defines the other connection point
  119201. * @returns true if the connection is possible
  119202. */
  119203. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  119204. /**
  119205. * Connect this point to another connection point
  119206. * @param connectionPoint defines the other connection point
  119207. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  119208. * @returns the current connection point
  119209. */
  119210. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  119211. /**
  119212. * Disconnect this point from one of his endpoint
  119213. * @param endpoint defines the other connection point
  119214. * @returns the current connection point
  119215. */
  119216. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  119217. /**
  119218. * Serializes this point in a JSON representation
  119219. * @returns the serialized point object
  119220. */
  119221. serialize(): any;
  119222. }
  119223. }
  119224. declare module BABYLON {
  119225. /**
  119226. * Block used to add support for vertex skinning (bones)
  119227. */
  119228. export class BonesBlock extends NodeMaterialBlock {
  119229. /**
  119230. * Creates a new BonesBlock
  119231. * @param name defines the block name
  119232. */
  119233. constructor(name: string);
  119234. /**
  119235. * Initialize the block and prepare the context for build
  119236. * @param state defines the state that will be used for the build
  119237. */
  119238. initialize(state: NodeMaterialBuildState): void;
  119239. /**
  119240. * Gets the current class name
  119241. * @returns the class name
  119242. */
  119243. getClassName(): string;
  119244. /**
  119245. * Gets the matrix indices input component
  119246. */
  119247. readonly matricesIndices: NodeMaterialConnectionPoint;
  119248. /**
  119249. * Gets the matrix weights input component
  119250. */
  119251. readonly matricesWeights: NodeMaterialConnectionPoint;
  119252. /**
  119253. * Gets the extra matrix indices input component
  119254. */
  119255. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  119256. /**
  119257. * Gets the extra matrix weights input component
  119258. */
  119259. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  119260. /**
  119261. * Gets the world input component
  119262. */
  119263. readonly world: NodeMaterialConnectionPoint;
  119264. /**
  119265. * Gets the output component
  119266. */
  119267. readonly output: NodeMaterialConnectionPoint;
  119268. autoConfigure(material: NodeMaterial): void;
  119269. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  119270. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119271. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119272. protected _buildBlock(state: NodeMaterialBuildState): this;
  119273. }
  119274. }
  119275. declare module BABYLON {
  119276. /**
  119277. * Block used to add support for instances
  119278. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  119279. */
  119280. export class InstancesBlock extends NodeMaterialBlock {
  119281. /**
  119282. * Creates a new InstancesBlock
  119283. * @param name defines the block name
  119284. */
  119285. constructor(name: string);
  119286. /**
  119287. * Gets the current class name
  119288. * @returns the class name
  119289. */
  119290. getClassName(): string;
  119291. /**
  119292. * Gets the first world row input component
  119293. */
  119294. readonly world0: NodeMaterialConnectionPoint;
  119295. /**
  119296. * Gets the second world row input component
  119297. */
  119298. readonly world1: NodeMaterialConnectionPoint;
  119299. /**
  119300. * Gets the third world row input component
  119301. */
  119302. readonly world2: NodeMaterialConnectionPoint;
  119303. /**
  119304. * Gets the forth world row input component
  119305. */
  119306. readonly world3: NodeMaterialConnectionPoint;
  119307. /**
  119308. * Gets the world input component
  119309. */
  119310. readonly world: NodeMaterialConnectionPoint;
  119311. /**
  119312. * Gets the output component
  119313. */
  119314. readonly output: NodeMaterialConnectionPoint;
  119315. autoConfigure(material: NodeMaterial): void;
  119316. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119317. protected _buildBlock(state: NodeMaterialBuildState): this;
  119318. }
  119319. }
  119320. declare module BABYLON {
  119321. /**
  119322. * Block used to add morph targets support to vertex shader
  119323. */
  119324. export class MorphTargetsBlock extends NodeMaterialBlock {
  119325. private _repeatableContentAnchor;
  119326. private _repeatebleContentGenerated;
  119327. /**
  119328. * Create a new MorphTargetsBlock
  119329. * @param name defines the block name
  119330. */
  119331. constructor(name: string);
  119332. /**
  119333. * Gets the current class name
  119334. * @returns the class name
  119335. */
  119336. getClassName(): string;
  119337. /**
  119338. * Gets the position input component
  119339. */
  119340. readonly position: NodeMaterialConnectionPoint;
  119341. /**
  119342. * Gets the normal input component
  119343. */
  119344. readonly normal: NodeMaterialConnectionPoint;
  119345. /**
  119346. * Gets the tangent input component
  119347. */
  119348. readonly tangent: NodeMaterialConnectionPoint;
  119349. /**
  119350. * Gets the tangent input component
  119351. */
  119352. readonly uv: NodeMaterialConnectionPoint;
  119353. /**
  119354. * Gets the position output component
  119355. */
  119356. readonly positionOutput: NodeMaterialConnectionPoint;
  119357. /**
  119358. * Gets the normal output component
  119359. */
  119360. readonly normalOutput: NodeMaterialConnectionPoint;
  119361. /**
  119362. * Gets the tangent output component
  119363. */
  119364. readonly tangentOutput: NodeMaterialConnectionPoint;
  119365. /**
  119366. * Gets the tangent output component
  119367. */
  119368. readonly uvOutput: NodeMaterialConnectionPoint;
  119369. initialize(state: NodeMaterialBuildState): void;
  119370. autoConfigure(material: NodeMaterial): void;
  119371. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119372. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119373. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  119374. protected _buildBlock(state: NodeMaterialBuildState): this;
  119375. }
  119376. }
  119377. declare module BABYLON {
  119378. /**
  119379. * Block used to get data information from a light
  119380. */
  119381. export class LightInformationBlock extends NodeMaterialBlock {
  119382. private _lightDataUniformName;
  119383. private _lightColorUniformName;
  119384. private _lightTypeDefineName;
  119385. /**
  119386. * Gets or sets the light associated with this block
  119387. */
  119388. light: Nullable<Light>;
  119389. /**
  119390. * Creates a new LightInformationBlock
  119391. * @param name defines the block name
  119392. */
  119393. constructor(name: string);
  119394. /**
  119395. * Gets the current class name
  119396. * @returns the class name
  119397. */
  119398. getClassName(): string;
  119399. /**
  119400. * Gets the world position input component
  119401. */
  119402. readonly worldPosition: NodeMaterialConnectionPoint;
  119403. /**
  119404. * Gets the direction output component
  119405. */
  119406. readonly direction: NodeMaterialConnectionPoint;
  119407. /**
  119408. * Gets the direction output component
  119409. */
  119410. readonly color: NodeMaterialConnectionPoint;
  119411. /**
  119412. * Gets the direction output component
  119413. */
  119414. readonly intensity: NodeMaterialConnectionPoint;
  119415. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119416. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119417. protected _buildBlock(state: NodeMaterialBuildState): this;
  119418. serialize(): any;
  119419. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119420. }
  119421. }
  119422. declare module BABYLON {
  119423. /**
  119424. * Block used to add image processing support to fragment shader
  119425. */
  119426. export class ImageProcessingBlock extends NodeMaterialBlock {
  119427. /**
  119428. * Create a new ImageProcessingBlock
  119429. * @param name defines the block name
  119430. */
  119431. constructor(name: string);
  119432. /**
  119433. * Gets the current class name
  119434. * @returns the class name
  119435. */
  119436. getClassName(): string;
  119437. /**
  119438. * Gets the color input component
  119439. */
  119440. readonly color: NodeMaterialConnectionPoint;
  119441. /**
  119442. * Gets the output component
  119443. */
  119444. readonly output: NodeMaterialConnectionPoint;
  119445. /**
  119446. * Initialize the block and prepare the context for build
  119447. * @param state defines the state that will be used for the build
  119448. */
  119449. initialize(state: NodeMaterialBuildState): void;
  119450. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  119451. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119452. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119453. protected _buildBlock(state: NodeMaterialBuildState): this;
  119454. }
  119455. }
  119456. declare module BABYLON {
  119457. /**
  119458. * Block used to pertub normals based on a normal map
  119459. */
  119460. export class PerturbNormalBlock extends NodeMaterialBlock {
  119461. private _tangentSpaceParameterName;
  119462. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  119463. invertX: boolean;
  119464. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  119465. invertY: boolean;
  119466. /**
  119467. * Create a new PerturbNormalBlock
  119468. * @param name defines the block name
  119469. */
  119470. constructor(name: string);
  119471. /**
  119472. * Gets the current class name
  119473. * @returns the class name
  119474. */
  119475. getClassName(): string;
  119476. /**
  119477. * Gets the world position input component
  119478. */
  119479. readonly worldPosition: NodeMaterialConnectionPoint;
  119480. /**
  119481. * Gets the world normal input component
  119482. */
  119483. readonly worldNormal: NodeMaterialConnectionPoint;
  119484. /**
  119485. * Gets the uv input component
  119486. */
  119487. readonly uv: NodeMaterialConnectionPoint;
  119488. /**
  119489. * Gets the normal map color input component
  119490. */
  119491. readonly normalMapColor: NodeMaterialConnectionPoint;
  119492. /**
  119493. * Gets the strength input component
  119494. */
  119495. readonly strength: NodeMaterialConnectionPoint;
  119496. /**
  119497. * Gets the output component
  119498. */
  119499. readonly output: NodeMaterialConnectionPoint;
  119500. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119501. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119502. autoConfigure(material: NodeMaterial): void;
  119503. protected _buildBlock(state: NodeMaterialBuildState): this;
  119504. protected _dumpPropertiesCode(): string;
  119505. serialize(): any;
  119506. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119507. }
  119508. }
  119509. declare module BABYLON {
  119510. /**
  119511. * Block used to discard a pixel if a value is smaller than a cutoff
  119512. */
  119513. export class DiscardBlock extends NodeMaterialBlock {
  119514. /**
  119515. * Create a new DiscardBlock
  119516. * @param name defines the block name
  119517. */
  119518. constructor(name: string);
  119519. /**
  119520. * Gets the current class name
  119521. * @returns the class name
  119522. */
  119523. getClassName(): string;
  119524. /**
  119525. * Gets the color input component
  119526. */
  119527. readonly value: NodeMaterialConnectionPoint;
  119528. /**
  119529. * Gets the cutoff input component
  119530. */
  119531. readonly cutoff: NodeMaterialConnectionPoint;
  119532. protected _buildBlock(state: NodeMaterialBuildState): this;
  119533. }
  119534. }
  119535. declare module BABYLON {
  119536. /**
  119537. * Block used to add support for scene fog
  119538. */
  119539. export class FogBlock extends NodeMaterialBlock {
  119540. private _fogDistanceName;
  119541. private _fogParameters;
  119542. /**
  119543. * Create a new FogBlock
  119544. * @param name defines the block name
  119545. */
  119546. constructor(name: string);
  119547. /**
  119548. * Gets the current class name
  119549. * @returns the class name
  119550. */
  119551. getClassName(): string;
  119552. /**
  119553. * Gets the world position input component
  119554. */
  119555. readonly worldPosition: NodeMaterialConnectionPoint;
  119556. /**
  119557. * Gets the view input component
  119558. */
  119559. readonly view: NodeMaterialConnectionPoint;
  119560. /**
  119561. * Gets the color input component
  119562. */
  119563. readonly input: NodeMaterialConnectionPoint;
  119564. /**
  119565. * Gets the fog color input component
  119566. */
  119567. readonly fogColor: NodeMaterialConnectionPoint;
  119568. /**
  119569. * Gets the output component
  119570. */
  119571. readonly output: NodeMaterialConnectionPoint;
  119572. autoConfigure(material: NodeMaterial): void;
  119573. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119574. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119575. protected _buildBlock(state: NodeMaterialBuildState): this;
  119576. }
  119577. }
  119578. declare module BABYLON {
  119579. /**
  119580. * Block used to add light in the fragment shader
  119581. */
  119582. export class LightBlock extends NodeMaterialBlock {
  119583. private _lightId;
  119584. /**
  119585. * Gets or sets the light associated with this block
  119586. */
  119587. light: Nullable<Light>;
  119588. /**
  119589. * Create a new LightBlock
  119590. * @param name defines the block name
  119591. */
  119592. constructor(name: string);
  119593. /**
  119594. * Gets the current class name
  119595. * @returns the class name
  119596. */
  119597. getClassName(): string;
  119598. /**
  119599. * Gets the world position input component
  119600. */
  119601. readonly worldPosition: NodeMaterialConnectionPoint;
  119602. /**
  119603. * Gets the world normal input component
  119604. */
  119605. readonly worldNormal: NodeMaterialConnectionPoint;
  119606. /**
  119607. * Gets the camera (or eye) position component
  119608. */
  119609. readonly cameraPosition: NodeMaterialConnectionPoint;
  119610. /**
  119611. * Gets the diffuse output component
  119612. */
  119613. readonly diffuseOutput: NodeMaterialConnectionPoint;
  119614. /**
  119615. * Gets the specular output component
  119616. */
  119617. readonly specularOutput: NodeMaterialConnectionPoint;
  119618. autoConfigure(material: NodeMaterial): void;
  119619. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119620. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119621. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119622. private _injectVertexCode;
  119623. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119624. serialize(): any;
  119625. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119626. }
  119627. }
  119628. declare module BABYLON {
  119629. /**
  119630. * Block used to multiply 2 values
  119631. */
  119632. export class MultiplyBlock extends NodeMaterialBlock {
  119633. /**
  119634. * Creates a new MultiplyBlock
  119635. * @param name defines the block name
  119636. */
  119637. constructor(name: string);
  119638. /**
  119639. * Gets the current class name
  119640. * @returns the class name
  119641. */
  119642. getClassName(): string;
  119643. /**
  119644. * Gets the left operand input component
  119645. */
  119646. readonly left: NodeMaterialConnectionPoint;
  119647. /**
  119648. * Gets the right operand input component
  119649. */
  119650. readonly right: NodeMaterialConnectionPoint;
  119651. /**
  119652. * Gets the output component
  119653. */
  119654. readonly output: NodeMaterialConnectionPoint;
  119655. protected _buildBlock(state: NodeMaterialBuildState): this;
  119656. }
  119657. }
  119658. declare module BABYLON {
  119659. /**
  119660. * Block used to add 2 vectors
  119661. */
  119662. export class AddBlock extends NodeMaterialBlock {
  119663. /**
  119664. * Creates a new AddBlock
  119665. * @param name defines the block name
  119666. */
  119667. constructor(name: string);
  119668. /**
  119669. * Gets the current class name
  119670. * @returns the class name
  119671. */
  119672. getClassName(): string;
  119673. /**
  119674. * Gets the left operand input component
  119675. */
  119676. readonly left: NodeMaterialConnectionPoint;
  119677. /**
  119678. * Gets the right operand input component
  119679. */
  119680. readonly right: NodeMaterialConnectionPoint;
  119681. /**
  119682. * Gets the output component
  119683. */
  119684. readonly output: NodeMaterialConnectionPoint;
  119685. protected _buildBlock(state: NodeMaterialBuildState): this;
  119686. }
  119687. }
  119688. declare module BABYLON {
  119689. /**
  119690. * Block used to scale a vector by a float
  119691. */
  119692. export class ScaleBlock extends NodeMaterialBlock {
  119693. /**
  119694. * Creates a new ScaleBlock
  119695. * @param name defines the block name
  119696. */
  119697. constructor(name: string);
  119698. /**
  119699. * Gets the current class name
  119700. * @returns the class name
  119701. */
  119702. getClassName(): string;
  119703. /**
  119704. * Gets the input component
  119705. */
  119706. readonly input: NodeMaterialConnectionPoint;
  119707. /**
  119708. * Gets the factor input component
  119709. */
  119710. readonly factor: NodeMaterialConnectionPoint;
  119711. /**
  119712. * Gets the output component
  119713. */
  119714. readonly output: NodeMaterialConnectionPoint;
  119715. protected _buildBlock(state: NodeMaterialBuildState): this;
  119716. }
  119717. }
  119718. declare module BABYLON {
  119719. /**
  119720. * Block used to clamp a float
  119721. */
  119722. export class ClampBlock extends NodeMaterialBlock {
  119723. /** Gets or sets the minimum range */
  119724. minimum: number;
  119725. /** Gets or sets the maximum range */
  119726. maximum: number;
  119727. /**
  119728. * Creates a new ClampBlock
  119729. * @param name defines the block name
  119730. */
  119731. constructor(name: string);
  119732. /**
  119733. * Gets the current class name
  119734. * @returns the class name
  119735. */
  119736. getClassName(): string;
  119737. /**
  119738. * Gets the value input component
  119739. */
  119740. readonly value: NodeMaterialConnectionPoint;
  119741. /**
  119742. * Gets the output component
  119743. */
  119744. readonly output: NodeMaterialConnectionPoint;
  119745. protected _buildBlock(state: NodeMaterialBuildState): this;
  119746. protected _dumpPropertiesCode(): string;
  119747. serialize(): any;
  119748. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119749. }
  119750. }
  119751. declare module BABYLON {
  119752. /**
  119753. * Block used to apply a cross product between 2 vectors
  119754. */
  119755. export class CrossBlock extends NodeMaterialBlock {
  119756. /**
  119757. * Creates a new CrossBlock
  119758. * @param name defines the block name
  119759. */
  119760. constructor(name: string);
  119761. /**
  119762. * Gets the current class name
  119763. * @returns the class name
  119764. */
  119765. getClassName(): string;
  119766. /**
  119767. * Gets the left operand input component
  119768. */
  119769. readonly left: NodeMaterialConnectionPoint;
  119770. /**
  119771. * Gets the right operand input component
  119772. */
  119773. readonly right: NodeMaterialConnectionPoint;
  119774. /**
  119775. * Gets the output component
  119776. */
  119777. readonly output: NodeMaterialConnectionPoint;
  119778. protected _buildBlock(state: NodeMaterialBuildState): this;
  119779. }
  119780. }
  119781. declare module BABYLON {
  119782. /**
  119783. * Block used to apply a dot product between 2 vectors
  119784. */
  119785. export class DotBlock extends NodeMaterialBlock {
  119786. /**
  119787. * Creates a new DotBlock
  119788. * @param name defines the block name
  119789. */
  119790. constructor(name: string);
  119791. /**
  119792. * Gets the current class name
  119793. * @returns the class name
  119794. */
  119795. getClassName(): string;
  119796. /**
  119797. * Gets the left operand input component
  119798. */
  119799. readonly left: NodeMaterialConnectionPoint;
  119800. /**
  119801. * Gets the right operand input component
  119802. */
  119803. readonly right: NodeMaterialConnectionPoint;
  119804. /**
  119805. * Gets the output component
  119806. */
  119807. readonly output: NodeMaterialConnectionPoint;
  119808. protected _buildBlock(state: NodeMaterialBuildState): this;
  119809. }
  119810. }
  119811. declare module BABYLON {
  119812. /**
  119813. * Block used to remap a float from a range to a new one
  119814. */
  119815. export class RemapBlock extends NodeMaterialBlock {
  119816. /**
  119817. * Gets or sets the source range
  119818. */
  119819. sourceRange: Vector2;
  119820. /**
  119821. * Gets or sets the target range
  119822. */
  119823. targetRange: Vector2;
  119824. /**
  119825. * Creates a new RemapBlock
  119826. * @param name defines the block name
  119827. */
  119828. constructor(name: string);
  119829. /**
  119830. * Gets the current class name
  119831. * @returns the class name
  119832. */
  119833. getClassName(): string;
  119834. /**
  119835. * Gets the input component
  119836. */
  119837. readonly input: NodeMaterialConnectionPoint;
  119838. /**
  119839. * Gets the source min input component
  119840. */
  119841. readonly sourceMin: NodeMaterialConnectionPoint;
  119842. /**
  119843. * Gets the source max input component
  119844. */
  119845. readonly sourceMax: NodeMaterialConnectionPoint;
  119846. /**
  119847. * Gets the target min input component
  119848. */
  119849. readonly targetMin: NodeMaterialConnectionPoint;
  119850. /**
  119851. * Gets the target max input component
  119852. */
  119853. readonly targetMax: NodeMaterialConnectionPoint;
  119854. /**
  119855. * Gets the output component
  119856. */
  119857. readonly output: NodeMaterialConnectionPoint;
  119858. protected _buildBlock(state: NodeMaterialBuildState): this;
  119859. protected _dumpPropertiesCode(): string;
  119860. serialize(): any;
  119861. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119862. }
  119863. }
  119864. declare module BABYLON {
  119865. /**
  119866. * Block used to normalize a vector
  119867. */
  119868. export class NormalizeBlock extends NodeMaterialBlock {
  119869. /**
  119870. * Creates a new NormalizeBlock
  119871. * @param name defines the block name
  119872. */
  119873. constructor(name: string);
  119874. /**
  119875. * Gets the current class name
  119876. * @returns the class name
  119877. */
  119878. getClassName(): string;
  119879. /**
  119880. * Gets the input component
  119881. */
  119882. readonly input: NodeMaterialConnectionPoint;
  119883. /**
  119884. * Gets the output component
  119885. */
  119886. readonly output: NodeMaterialConnectionPoint;
  119887. protected _buildBlock(state: NodeMaterialBuildState): this;
  119888. }
  119889. }
  119890. declare module BABYLON {
  119891. /**
  119892. * Operations supported by the Trigonometry block
  119893. */
  119894. export enum TrigonometryBlockOperations {
  119895. /** Cos */
  119896. Cos = 0,
  119897. /** Sin */
  119898. Sin = 1,
  119899. /** Abs */
  119900. Abs = 2,
  119901. /** Exp */
  119902. Exp = 3,
  119903. /** Exp2 */
  119904. Exp2 = 4,
  119905. /** Round */
  119906. Round = 5,
  119907. /** Floor */
  119908. Floor = 6,
  119909. /** Ceiling */
  119910. Ceiling = 7,
  119911. /** Square root */
  119912. Sqrt = 8
  119913. }
  119914. /**
  119915. * Block used to apply trigonometry operation to floats
  119916. */
  119917. export class TrigonometryBlock extends NodeMaterialBlock {
  119918. /**
  119919. * Gets or sets the operation applied by the block
  119920. */
  119921. operation: TrigonometryBlockOperations;
  119922. /**
  119923. * Creates a new TrigonometryBlock
  119924. * @param name defines the block name
  119925. */
  119926. constructor(name: string);
  119927. /**
  119928. * Gets the current class name
  119929. * @returns the class name
  119930. */
  119931. getClassName(): string;
  119932. /**
  119933. * Gets the input component
  119934. */
  119935. readonly input: NodeMaterialConnectionPoint;
  119936. /**
  119937. * Gets the output component
  119938. */
  119939. readonly output: NodeMaterialConnectionPoint;
  119940. protected _buildBlock(state: NodeMaterialBuildState): this;
  119941. serialize(): any;
  119942. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119943. }
  119944. }
  119945. declare module BABYLON {
  119946. /**
  119947. * Block used to create a Color3/4 out of individual inputs (one for each component)
  119948. */
  119949. export class ColorMergerBlock extends NodeMaterialBlock {
  119950. /**
  119951. * Create a new ColorMergerBlock
  119952. * @param name defines the block name
  119953. */
  119954. constructor(name: string);
  119955. /**
  119956. * Gets the current class name
  119957. * @returns the class name
  119958. */
  119959. getClassName(): string;
  119960. /**
  119961. * Gets the r component (input)
  119962. */
  119963. readonly r: NodeMaterialConnectionPoint;
  119964. /**
  119965. * Gets the g component (input)
  119966. */
  119967. readonly g: NodeMaterialConnectionPoint;
  119968. /**
  119969. * Gets the b component (input)
  119970. */
  119971. readonly b: NodeMaterialConnectionPoint;
  119972. /**
  119973. * Gets the a component (input)
  119974. */
  119975. readonly a: NodeMaterialConnectionPoint;
  119976. /**
  119977. * Gets the rgba component (output)
  119978. */
  119979. readonly rgba: NodeMaterialConnectionPoint;
  119980. /**
  119981. * Gets the rgb component (output)
  119982. */
  119983. readonly rgb: NodeMaterialConnectionPoint;
  119984. protected _buildBlock(state: NodeMaterialBuildState): this;
  119985. }
  119986. }
  119987. declare module BABYLON {
  119988. /**
  119989. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  119990. */
  119991. export class VectorMergerBlock extends NodeMaterialBlock {
  119992. /**
  119993. * Create a new VectorMergerBlock
  119994. * @param name defines the block name
  119995. */
  119996. constructor(name: string);
  119997. /**
  119998. * Gets the current class name
  119999. * @returns the class name
  120000. */
  120001. getClassName(): string;
  120002. /**
  120003. * Gets the x component (input)
  120004. */
  120005. readonly x: NodeMaterialConnectionPoint;
  120006. /**
  120007. * Gets the y component (input)
  120008. */
  120009. readonly y: NodeMaterialConnectionPoint;
  120010. /**
  120011. * Gets the z component (input)
  120012. */
  120013. readonly z: NodeMaterialConnectionPoint;
  120014. /**
  120015. * Gets the w component (input)
  120016. */
  120017. readonly w: NodeMaterialConnectionPoint;
  120018. /**
  120019. * Gets the xyzw component (output)
  120020. */
  120021. readonly xyzw: NodeMaterialConnectionPoint;
  120022. /**
  120023. * Gets the xyz component (output)
  120024. */
  120025. readonly xyz: NodeMaterialConnectionPoint;
  120026. /**
  120027. * Gets the xy component (output)
  120028. */
  120029. readonly xy: NodeMaterialConnectionPoint;
  120030. protected _buildBlock(state: NodeMaterialBuildState): this;
  120031. }
  120032. }
  120033. declare module BABYLON {
  120034. /**
  120035. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  120036. */
  120037. export class ColorSplitterBlock extends NodeMaterialBlock {
  120038. /**
  120039. * Create a new ColorSplitterBlock
  120040. * @param name defines the block name
  120041. */
  120042. constructor(name: string);
  120043. /**
  120044. * Gets the current class name
  120045. * @returns the class name
  120046. */
  120047. getClassName(): string;
  120048. /**
  120049. * Gets the rgba component (input)
  120050. */
  120051. readonly rgba: NodeMaterialConnectionPoint;
  120052. /**
  120053. * Gets the rgb component (input)
  120054. */
  120055. readonly rgbIn: NodeMaterialConnectionPoint;
  120056. /**
  120057. * Gets the rgb component (output)
  120058. */
  120059. readonly rgbOut: NodeMaterialConnectionPoint;
  120060. /**
  120061. * Gets the r component (output)
  120062. */
  120063. readonly r: NodeMaterialConnectionPoint;
  120064. /**
  120065. * Gets the g component (output)
  120066. */
  120067. readonly g: NodeMaterialConnectionPoint;
  120068. /**
  120069. * Gets the b component (output)
  120070. */
  120071. readonly b: NodeMaterialConnectionPoint;
  120072. /**
  120073. * Gets the a component (output)
  120074. */
  120075. readonly a: NodeMaterialConnectionPoint;
  120076. protected _inputRename(name: string): string;
  120077. protected _outputRename(name: string): string;
  120078. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120079. }
  120080. }
  120081. declare module BABYLON {
  120082. /**
  120083. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  120084. */
  120085. export class VectorSplitterBlock extends NodeMaterialBlock {
  120086. /**
  120087. * Create a new VectorSplitterBlock
  120088. * @param name defines the block name
  120089. */
  120090. constructor(name: string);
  120091. /**
  120092. * Gets the current class name
  120093. * @returns the class name
  120094. */
  120095. getClassName(): string;
  120096. /**
  120097. * Gets the xyzw component (input)
  120098. */
  120099. readonly xyzw: NodeMaterialConnectionPoint;
  120100. /**
  120101. * Gets the xyz component (input)
  120102. */
  120103. readonly xyzIn: NodeMaterialConnectionPoint;
  120104. /**
  120105. * Gets the xy component (input)
  120106. */
  120107. readonly xyIn: NodeMaterialConnectionPoint;
  120108. /**
  120109. * Gets the xyz component (output)
  120110. */
  120111. readonly xyzOut: NodeMaterialConnectionPoint;
  120112. /**
  120113. * Gets the xy component (output)
  120114. */
  120115. readonly xyOut: NodeMaterialConnectionPoint;
  120116. /**
  120117. * Gets the x component (output)
  120118. */
  120119. readonly x: NodeMaterialConnectionPoint;
  120120. /**
  120121. * Gets the y component (output)
  120122. */
  120123. readonly y: NodeMaterialConnectionPoint;
  120124. /**
  120125. * Gets the z component (output)
  120126. */
  120127. readonly z: NodeMaterialConnectionPoint;
  120128. /**
  120129. * Gets the w component (output)
  120130. */
  120131. readonly w: NodeMaterialConnectionPoint;
  120132. protected _inputRename(name: string): string;
  120133. protected _outputRename(name: string): string;
  120134. protected _buildBlock(state: NodeMaterialBuildState): this;
  120135. }
  120136. }
  120137. declare module BABYLON {
  120138. /**
  120139. * Block used to lerp 2 values
  120140. */
  120141. export class LerpBlock extends NodeMaterialBlock {
  120142. /**
  120143. * Creates a new LerpBlock
  120144. * @param name defines the block name
  120145. */
  120146. constructor(name: string);
  120147. /**
  120148. * Gets the current class name
  120149. * @returns the class name
  120150. */
  120151. getClassName(): string;
  120152. /**
  120153. * Gets the left operand input component
  120154. */
  120155. readonly left: NodeMaterialConnectionPoint;
  120156. /**
  120157. * Gets the right operand input component
  120158. */
  120159. readonly right: NodeMaterialConnectionPoint;
  120160. /**
  120161. * Gets the gradient operand input component
  120162. */
  120163. readonly gradient: NodeMaterialConnectionPoint;
  120164. /**
  120165. * Gets the output component
  120166. */
  120167. readonly output: NodeMaterialConnectionPoint;
  120168. protected _buildBlock(state: NodeMaterialBuildState): this;
  120169. }
  120170. }
  120171. declare module BABYLON {
  120172. /**
  120173. * Block used to divide 2 vectors
  120174. */
  120175. export class DivideBlock extends NodeMaterialBlock {
  120176. /**
  120177. * Creates a new DivideBlock
  120178. * @param name defines the block name
  120179. */
  120180. constructor(name: string);
  120181. /**
  120182. * Gets the current class name
  120183. * @returns the class name
  120184. */
  120185. getClassName(): string;
  120186. /**
  120187. * Gets the left operand input component
  120188. */
  120189. readonly left: NodeMaterialConnectionPoint;
  120190. /**
  120191. * Gets the right operand input component
  120192. */
  120193. readonly right: NodeMaterialConnectionPoint;
  120194. /**
  120195. * Gets the output component
  120196. */
  120197. readonly output: NodeMaterialConnectionPoint;
  120198. protected _buildBlock(state: NodeMaterialBuildState): this;
  120199. }
  120200. }
  120201. declare module BABYLON {
  120202. /**
  120203. * Block used to subtract 2 vectors
  120204. */
  120205. export class SubtractBlock extends NodeMaterialBlock {
  120206. /**
  120207. * Creates a new SubtractBlock
  120208. * @param name defines the block name
  120209. */
  120210. constructor(name: string);
  120211. /**
  120212. * Gets the current class name
  120213. * @returns the class name
  120214. */
  120215. getClassName(): string;
  120216. /**
  120217. * Gets the left operand input component
  120218. */
  120219. readonly left: NodeMaterialConnectionPoint;
  120220. /**
  120221. * Gets the right operand input component
  120222. */
  120223. readonly right: NodeMaterialConnectionPoint;
  120224. /**
  120225. * Gets the output component
  120226. */
  120227. readonly output: NodeMaterialConnectionPoint;
  120228. protected _buildBlock(state: NodeMaterialBuildState): this;
  120229. }
  120230. }
  120231. declare module BABYLON {
  120232. /**
  120233. * Block used to step a value
  120234. */
  120235. export class StepBlock extends NodeMaterialBlock {
  120236. /**
  120237. * Creates a new AddBlock
  120238. * @param name defines the block name
  120239. */
  120240. constructor(name: string);
  120241. /**
  120242. * Gets the current class name
  120243. * @returns the class name
  120244. */
  120245. getClassName(): string;
  120246. /**
  120247. * Gets the value operand input component
  120248. */
  120249. readonly value: NodeMaterialConnectionPoint;
  120250. /**
  120251. * Gets the edge operand input component
  120252. */
  120253. readonly edge: NodeMaterialConnectionPoint;
  120254. /**
  120255. * Gets the output component
  120256. */
  120257. readonly output: NodeMaterialConnectionPoint;
  120258. protected _buildBlock(state: NodeMaterialBuildState): this;
  120259. }
  120260. }
  120261. declare module BABYLON {
  120262. /**
  120263. * Block used to get the opposite (1 - x) of a value
  120264. */
  120265. export class OneMinusBlock extends NodeMaterialBlock {
  120266. /**
  120267. * Creates a new OneMinusBlock
  120268. * @param name defines the block name
  120269. */
  120270. constructor(name: string);
  120271. /**
  120272. * Gets the current class name
  120273. * @returns the class name
  120274. */
  120275. getClassName(): string;
  120276. /**
  120277. * Gets the input component
  120278. */
  120279. readonly input: NodeMaterialConnectionPoint;
  120280. /**
  120281. * Gets the output component
  120282. */
  120283. readonly output: NodeMaterialConnectionPoint;
  120284. protected _buildBlock(state: NodeMaterialBuildState): this;
  120285. }
  120286. }
  120287. declare module BABYLON {
  120288. /**
  120289. * Block used to get the view direction
  120290. */
  120291. export class ViewDirectionBlock extends NodeMaterialBlock {
  120292. /**
  120293. * Creates a new ViewDirectionBlock
  120294. * @param name defines the block name
  120295. */
  120296. constructor(name: string);
  120297. /**
  120298. * Gets the current class name
  120299. * @returns the class name
  120300. */
  120301. getClassName(): string;
  120302. /**
  120303. * Gets the world position component
  120304. */
  120305. readonly worldPosition: NodeMaterialConnectionPoint;
  120306. /**
  120307. * Gets the camera position component
  120308. */
  120309. readonly cameraPosition: NodeMaterialConnectionPoint;
  120310. /**
  120311. * Gets the output component
  120312. */
  120313. readonly output: NodeMaterialConnectionPoint;
  120314. autoConfigure(material: NodeMaterial): void;
  120315. protected _buildBlock(state: NodeMaterialBuildState): this;
  120316. }
  120317. }
  120318. declare module BABYLON {
  120319. /**
  120320. * Block used to compute fresnel value
  120321. */
  120322. export class FresnelBlock extends NodeMaterialBlock {
  120323. /**
  120324. * Create a new FresnelBlock
  120325. * @param name defines the block name
  120326. */
  120327. constructor(name: string);
  120328. /**
  120329. * Gets the current class name
  120330. * @returns the class name
  120331. */
  120332. getClassName(): string;
  120333. /**
  120334. * Gets the world normal input component
  120335. */
  120336. readonly worldNormal: NodeMaterialConnectionPoint;
  120337. /**
  120338. * Gets the view direction input component
  120339. */
  120340. readonly viewDirection: NodeMaterialConnectionPoint;
  120341. /**
  120342. * Gets the bias input component
  120343. */
  120344. readonly bias: NodeMaterialConnectionPoint;
  120345. /**
  120346. * Gets the camera (or eye) position component
  120347. */
  120348. readonly power: NodeMaterialConnectionPoint;
  120349. /**
  120350. * Gets the fresnel output component
  120351. */
  120352. readonly fresnel: NodeMaterialConnectionPoint;
  120353. autoConfigure(material: NodeMaterial): void;
  120354. protected _buildBlock(state: NodeMaterialBuildState): this;
  120355. }
  120356. }
  120357. declare module BABYLON {
  120358. /**
  120359. * Block used to get the max of 2 values
  120360. */
  120361. export class MaxBlock extends NodeMaterialBlock {
  120362. /**
  120363. * Creates a new MaxBlock
  120364. * @param name defines the block name
  120365. */
  120366. constructor(name: string);
  120367. /**
  120368. * Gets the current class name
  120369. * @returns the class name
  120370. */
  120371. getClassName(): string;
  120372. /**
  120373. * Gets the left operand input component
  120374. */
  120375. readonly left: NodeMaterialConnectionPoint;
  120376. /**
  120377. * Gets the right operand input component
  120378. */
  120379. readonly right: NodeMaterialConnectionPoint;
  120380. /**
  120381. * Gets the output component
  120382. */
  120383. readonly output: NodeMaterialConnectionPoint;
  120384. protected _buildBlock(state: NodeMaterialBuildState): this;
  120385. }
  120386. }
  120387. declare module BABYLON {
  120388. /**
  120389. * Block used to get the min of 2 values
  120390. */
  120391. export class MinBlock extends NodeMaterialBlock {
  120392. /**
  120393. * Creates a new MinBlock
  120394. * @param name defines the block name
  120395. */
  120396. constructor(name: string);
  120397. /**
  120398. * Gets the current class name
  120399. * @returns the class name
  120400. */
  120401. getClassName(): string;
  120402. /**
  120403. * Gets the left operand input component
  120404. */
  120405. readonly left: NodeMaterialConnectionPoint;
  120406. /**
  120407. * Gets the right operand input component
  120408. */
  120409. readonly right: NodeMaterialConnectionPoint;
  120410. /**
  120411. * Gets the output component
  120412. */
  120413. readonly output: NodeMaterialConnectionPoint;
  120414. protected _buildBlock(state: NodeMaterialBuildState): this;
  120415. }
  120416. }
  120417. declare module BABYLON {
  120418. /**
  120419. * Block used to get the distance between 2 values
  120420. */
  120421. export class DistanceBlock extends NodeMaterialBlock {
  120422. /**
  120423. * Creates a new DistanceBlock
  120424. * @param name defines the block name
  120425. */
  120426. constructor(name: string);
  120427. /**
  120428. * Gets the current class name
  120429. * @returns the class name
  120430. */
  120431. getClassName(): string;
  120432. /**
  120433. * Gets the left operand input component
  120434. */
  120435. readonly left: NodeMaterialConnectionPoint;
  120436. /**
  120437. * Gets the right operand input component
  120438. */
  120439. readonly right: NodeMaterialConnectionPoint;
  120440. /**
  120441. * Gets the output component
  120442. */
  120443. readonly output: NodeMaterialConnectionPoint;
  120444. protected _buildBlock(state: NodeMaterialBuildState): this;
  120445. }
  120446. }
  120447. declare module BABYLON {
  120448. /**
  120449. * Block used to get the length of a vector
  120450. */
  120451. export class LengthBlock extends NodeMaterialBlock {
  120452. /**
  120453. * Creates a new LengthBlock
  120454. * @param name defines the block name
  120455. */
  120456. constructor(name: string);
  120457. /**
  120458. * Gets the current class name
  120459. * @returns the class name
  120460. */
  120461. getClassName(): string;
  120462. /**
  120463. * Gets the value input component
  120464. */
  120465. readonly value: NodeMaterialConnectionPoint;
  120466. /**
  120467. * Gets the output component
  120468. */
  120469. readonly output: NodeMaterialConnectionPoint;
  120470. protected _buildBlock(state: NodeMaterialBuildState): this;
  120471. }
  120472. }
  120473. declare module BABYLON {
  120474. /**
  120475. * Block used to get negative version of a value (i.e. x * -1)
  120476. */
  120477. export class NegateBlock extends NodeMaterialBlock {
  120478. /**
  120479. * Creates a new NegateBlock
  120480. * @param name defines the block name
  120481. */
  120482. constructor(name: string);
  120483. /**
  120484. * Gets the current class name
  120485. * @returns the class name
  120486. */
  120487. getClassName(): string;
  120488. /**
  120489. * Gets the value input component
  120490. */
  120491. readonly value: NodeMaterialConnectionPoint;
  120492. /**
  120493. * Gets the output component
  120494. */
  120495. readonly output: NodeMaterialConnectionPoint;
  120496. protected _buildBlock(state: NodeMaterialBuildState): this;
  120497. }
  120498. }
  120499. declare module BABYLON {
  120500. /**
  120501. * Block used to get the value of the first parameter raised to the power of the second
  120502. */
  120503. export class PowBlock extends NodeMaterialBlock {
  120504. /**
  120505. * Creates a new PowBlock
  120506. * @param name defines the block name
  120507. */
  120508. constructor(name: string);
  120509. /**
  120510. * Gets the current class name
  120511. * @returns the class name
  120512. */
  120513. getClassName(): string;
  120514. /**
  120515. * Gets the value operand input component
  120516. */
  120517. readonly value: NodeMaterialConnectionPoint;
  120518. /**
  120519. * Gets the power operand input component
  120520. */
  120521. readonly power: NodeMaterialConnectionPoint;
  120522. /**
  120523. * Gets the output component
  120524. */
  120525. readonly output: NodeMaterialConnectionPoint;
  120526. protected _buildBlock(state: NodeMaterialBuildState): this;
  120527. }
  120528. }
  120529. declare module BABYLON {
  120530. /**
  120531. * Effect Render Options
  120532. */
  120533. export interface IEffectRendererOptions {
  120534. /**
  120535. * Defines the vertices positions.
  120536. */
  120537. positions?: number[];
  120538. /**
  120539. * Defines the indices.
  120540. */
  120541. indices?: number[];
  120542. }
  120543. /**
  120544. * Helper class to render one or more effects
  120545. */
  120546. export class EffectRenderer {
  120547. private engine;
  120548. private static _DefaultOptions;
  120549. private _vertexBuffers;
  120550. private _indexBuffer;
  120551. private _ringBufferIndex;
  120552. private _ringScreenBuffer;
  120553. private _fullscreenViewport;
  120554. private _getNextFrameBuffer;
  120555. /**
  120556. * Creates an effect renderer
  120557. * @param engine the engine to use for rendering
  120558. * @param options defines the options of the effect renderer
  120559. */
  120560. constructor(engine: Engine, options?: IEffectRendererOptions);
  120561. /**
  120562. * Sets the current viewport in normalized coordinates 0-1
  120563. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  120564. */
  120565. setViewport(viewport?: Viewport): void;
  120566. /**
  120567. * Binds the embedded attributes buffer to the effect.
  120568. * @param effect Defines the effect to bind the attributes for
  120569. */
  120570. bindBuffers(effect: Effect): void;
  120571. /**
  120572. * Sets the current effect wrapper to use during draw.
  120573. * The effect needs to be ready before calling this api.
  120574. * This also sets the default full screen position attribute.
  120575. * @param effectWrapper Defines the effect to draw with
  120576. */
  120577. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  120578. /**
  120579. * Draws a full screen quad.
  120580. */
  120581. draw(): void;
  120582. /**
  120583. * renders one or more effects to a specified texture
  120584. * @param effectWrappers list of effects to renderer
  120585. * @param outputTexture texture to draw to, if null it will render to the screen
  120586. */
  120587. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  120588. /**
  120589. * Disposes of the effect renderer
  120590. */
  120591. dispose(): void;
  120592. }
  120593. /**
  120594. * Options to create an EffectWrapper
  120595. */
  120596. interface EffectWrapperCreationOptions {
  120597. /**
  120598. * Engine to use to create the effect
  120599. */
  120600. engine: Engine;
  120601. /**
  120602. * Fragment shader for the effect
  120603. */
  120604. fragmentShader: string;
  120605. /**
  120606. * Vertex shader for the effect
  120607. */
  120608. vertexShader?: string;
  120609. /**
  120610. * Attributes to use in the shader
  120611. */
  120612. attributeNames?: Array<string>;
  120613. /**
  120614. * Uniforms to use in the shader
  120615. */
  120616. uniformNames?: Array<string>;
  120617. /**
  120618. * Texture sampler names to use in the shader
  120619. */
  120620. samplerNames?: Array<string>;
  120621. /**
  120622. * The friendly name of the effect displayed in Spector.
  120623. */
  120624. name?: string;
  120625. }
  120626. /**
  120627. * Wraps an effect to be used for rendering
  120628. */
  120629. export class EffectWrapper {
  120630. /**
  120631. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  120632. */
  120633. onApplyObservable: Observable<{}>;
  120634. /**
  120635. * The underlying effect
  120636. */
  120637. effect: Effect;
  120638. /**
  120639. * Creates an effect to be renderer
  120640. * @param creationOptions options to create the effect
  120641. */
  120642. constructor(creationOptions: EffectWrapperCreationOptions);
  120643. /**
  120644. * Disposes of the effect wrapper
  120645. */
  120646. dispose(): void;
  120647. }
  120648. }
  120649. declare module BABYLON {
  120650. /**
  120651. * Helper class to push actions to a pool of workers.
  120652. */
  120653. export class WorkerPool implements IDisposable {
  120654. private _workerInfos;
  120655. private _pendingActions;
  120656. /**
  120657. * Constructor
  120658. * @param workers Array of workers to use for actions
  120659. */
  120660. constructor(workers: Array<Worker>);
  120661. /**
  120662. * Terminates all workers and clears any pending actions.
  120663. */
  120664. dispose(): void;
  120665. /**
  120666. * Pushes an action to the worker pool. If all the workers are active, the action will be
  120667. * pended until a worker has completed its action.
  120668. * @param action The action to perform. Call onComplete when the action is complete.
  120669. */
  120670. push(action: (worker: Worker, onComplete: () => void) => void): void;
  120671. private _execute;
  120672. }
  120673. }
  120674. declare module BABYLON {
  120675. /**
  120676. * Configuration for Draco compression
  120677. */
  120678. export interface IDracoCompressionConfiguration {
  120679. /**
  120680. * Configuration for the decoder.
  120681. */
  120682. decoder: {
  120683. /**
  120684. * The url to the WebAssembly module.
  120685. */
  120686. wasmUrl?: string;
  120687. /**
  120688. * The url to the WebAssembly binary.
  120689. */
  120690. wasmBinaryUrl?: string;
  120691. /**
  120692. * The url to the fallback JavaScript module.
  120693. */
  120694. fallbackUrl?: string;
  120695. };
  120696. }
  120697. /**
  120698. * Draco compression (https://google.github.io/draco/)
  120699. *
  120700. * This class wraps the Draco module.
  120701. *
  120702. * **Encoder**
  120703. *
  120704. * The encoder is not currently implemented.
  120705. *
  120706. * **Decoder**
  120707. *
  120708. * 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.
  120709. *
  120710. * To update the configuration, use the following code:
  120711. * ```javascript
  120712. * DracoCompression.Configuration = {
  120713. * decoder: {
  120714. * wasmUrl: "<url to the WebAssembly library>",
  120715. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  120716. * fallbackUrl: "<url to the fallback JavaScript library>",
  120717. * }
  120718. * };
  120719. * ```
  120720. *
  120721. * 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.
  120722. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  120723. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  120724. *
  120725. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  120726. * ```javascript
  120727. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  120728. * ```
  120729. *
  120730. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  120731. */
  120732. export class DracoCompression implements IDisposable {
  120733. private _workerPoolPromise?;
  120734. private _decoderModulePromise?;
  120735. /**
  120736. * The configuration. Defaults to the following urls:
  120737. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  120738. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  120739. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  120740. */
  120741. static Configuration: IDracoCompressionConfiguration;
  120742. /**
  120743. * Returns true if the decoder configuration is available.
  120744. */
  120745. static readonly DecoderAvailable: boolean;
  120746. /**
  120747. * Default number of workers to create when creating the draco compression object.
  120748. */
  120749. static DefaultNumWorkers: number;
  120750. private static GetDefaultNumWorkers;
  120751. private static _Default;
  120752. /**
  120753. * Default instance for the draco compression object.
  120754. */
  120755. static readonly Default: DracoCompression;
  120756. /**
  120757. * Constructor
  120758. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  120759. */
  120760. constructor(numWorkers?: number);
  120761. /**
  120762. * Stop all async operations and release resources.
  120763. */
  120764. dispose(): void;
  120765. /**
  120766. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  120767. * @returns a promise that resolves when ready
  120768. */
  120769. whenReadyAsync(): Promise<void>;
  120770. /**
  120771. * Decode Draco compressed mesh data to vertex data.
  120772. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  120773. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  120774. * @returns A promise that resolves with the decoded vertex data
  120775. */
  120776. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  120777. [kind: string]: number;
  120778. }): Promise<VertexData>;
  120779. }
  120780. }
  120781. declare module BABYLON {
  120782. /**
  120783. * Class for building Constructive Solid Geometry
  120784. */
  120785. export class CSG {
  120786. private polygons;
  120787. /**
  120788. * The world matrix
  120789. */
  120790. matrix: Matrix;
  120791. /**
  120792. * Stores the position
  120793. */
  120794. position: Vector3;
  120795. /**
  120796. * Stores the rotation
  120797. */
  120798. rotation: Vector3;
  120799. /**
  120800. * Stores the rotation quaternion
  120801. */
  120802. rotationQuaternion: Nullable<Quaternion>;
  120803. /**
  120804. * Stores the scaling vector
  120805. */
  120806. scaling: Vector3;
  120807. /**
  120808. * Convert the Mesh to CSG
  120809. * @param mesh The Mesh to convert to CSG
  120810. * @returns A new CSG from the Mesh
  120811. */
  120812. static FromMesh(mesh: Mesh): CSG;
  120813. /**
  120814. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  120815. * @param polygons Polygons used to construct a CSG solid
  120816. */
  120817. private static FromPolygons;
  120818. /**
  120819. * Clones, or makes a deep copy, of the CSG
  120820. * @returns A new CSG
  120821. */
  120822. clone(): CSG;
  120823. /**
  120824. * Unions this CSG with another CSG
  120825. * @param csg The CSG to union against this CSG
  120826. * @returns The unioned CSG
  120827. */
  120828. union(csg: CSG): CSG;
  120829. /**
  120830. * Unions this CSG with another CSG in place
  120831. * @param csg The CSG to union against this CSG
  120832. */
  120833. unionInPlace(csg: CSG): void;
  120834. /**
  120835. * Subtracts this CSG with another CSG
  120836. * @param csg The CSG to subtract against this CSG
  120837. * @returns A new CSG
  120838. */
  120839. subtract(csg: CSG): CSG;
  120840. /**
  120841. * Subtracts this CSG with another CSG in place
  120842. * @param csg The CSG to subtact against this CSG
  120843. */
  120844. subtractInPlace(csg: CSG): void;
  120845. /**
  120846. * Intersect this CSG with another CSG
  120847. * @param csg The CSG to intersect against this CSG
  120848. * @returns A new CSG
  120849. */
  120850. intersect(csg: CSG): CSG;
  120851. /**
  120852. * Intersects this CSG with another CSG in place
  120853. * @param csg The CSG to intersect against this CSG
  120854. */
  120855. intersectInPlace(csg: CSG): void;
  120856. /**
  120857. * Return a new CSG solid with solid and empty space switched. This solid is
  120858. * not modified.
  120859. * @returns A new CSG solid with solid and empty space switched
  120860. */
  120861. inverse(): CSG;
  120862. /**
  120863. * Inverses the CSG in place
  120864. */
  120865. inverseInPlace(): void;
  120866. /**
  120867. * This is used to keep meshes transformations so they can be restored
  120868. * when we build back a Babylon Mesh
  120869. * NB : All CSG operations are performed in world coordinates
  120870. * @param csg The CSG to copy the transform attributes from
  120871. * @returns This CSG
  120872. */
  120873. copyTransformAttributes(csg: CSG): CSG;
  120874. /**
  120875. * Build Raw mesh from CSG
  120876. * Coordinates here are in world space
  120877. * @param name The name of the mesh geometry
  120878. * @param scene The Scene
  120879. * @param keepSubMeshes Specifies if the submeshes should be kept
  120880. * @returns A new Mesh
  120881. */
  120882. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120883. /**
  120884. * Build Mesh from CSG taking material and transforms into account
  120885. * @param name The name of the Mesh
  120886. * @param material The material of the Mesh
  120887. * @param scene The Scene
  120888. * @param keepSubMeshes Specifies if submeshes should be kept
  120889. * @returns The new Mesh
  120890. */
  120891. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  120892. }
  120893. }
  120894. declare module BABYLON {
  120895. /**
  120896. * Class used to create a trail following a mesh
  120897. */
  120898. export class TrailMesh extends Mesh {
  120899. private _generator;
  120900. private _autoStart;
  120901. private _running;
  120902. private _diameter;
  120903. private _length;
  120904. private _sectionPolygonPointsCount;
  120905. private _sectionVectors;
  120906. private _sectionNormalVectors;
  120907. private _beforeRenderObserver;
  120908. /**
  120909. * @constructor
  120910. * @param name The value used by scene.getMeshByName() to do a lookup.
  120911. * @param generator The mesh to generate a trail.
  120912. * @param scene The scene to add this mesh to.
  120913. * @param diameter Diameter of trailing mesh. Default is 1.
  120914. * @param length Length of trailing mesh. Default is 60.
  120915. * @param autoStart Automatically start trailing mesh. Default true.
  120916. */
  120917. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  120918. /**
  120919. * "TrailMesh"
  120920. * @returns "TrailMesh"
  120921. */
  120922. getClassName(): string;
  120923. private _createMesh;
  120924. /**
  120925. * Start trailing mesh.
  120926. */
  120927. start(): void;
  120928. /**
  120929. * Stop trailing mesh.
  120930. */
  120931. stop(): void;
  120932. /**
  120933. * Update trailing mesh geometry.
  120934. */
  120935. update(): void;
  120936. /**
  120937. * Returns a new TrailMesh object.
  120938. * @param name is a string, the name given to the new mesh
  120939. * @param newGenerator use new generator object for cloned trail mesh
  120940. * @returns a new mesh
  120941. */
  120942. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  120943. /**
  120944. * Serializes this trail mesh
  120945. * @param serializationObject object to write serialization to
  120946. */
  120947. serialize(serializationObject: any): void;
  120948. /**
  120949. * Parses a serialized trail mesh
  120950. * @param parsedMesh the serialized mesh
  120951. * @param scene the scene to create the trail mesh in
  120952. * @returns the created trail mesh
  120953. */
  120954. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  120955. }
  120956. }
  120957. declare module BABYLON {
  120958. /**
  120959. * Class containing static functions to help procedurally build meshes
  120960. */
  120961. export class TiledBoxBuilder {
  120962. /**
  120963. * Creates a box mesh
  120964. * 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)
  120965. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120967. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120969. * @param name defines the name of the mesh
  120970. * @param options defines the options used to create the mesh
  120971. * @param scene defines the hosting scene
  120972. * @returns the box mesh
  120973. */
  120974. static CreateTiledBox(name: string, options: {
  120975. pattern?: number;
  120976. width?: number;
  120977. height?: number;
  120978. depth?: number;
  120979. tileSize?: number;
  120980. tileWidth?: number;
  120981. tileHeight?: number;
  120982. alignHorizontal?: number;
  120983. alignVertical?: number;
  120984. faceUV?: Vector4[];
  120985. faceColors?: Color4[];
  120986. sideOrientation?: number;
  120987. updatable?: boolean;
  120988. }, scene?: Nullable<Scene>): Mesh;
  120989. }
  120990. }
  120991. declare module BABYLON {
  120992. /**
  120993. * Class containing static functions to help procedurally build meshes
  120994. */
  120995. export class TorusKnotBuilder {
  120996. /**
  120997. * Creates a torus knot mesh
  120998. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  120999. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  121000. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  121001. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  121002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121003. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121005. * @param name defines the name of the mesh
  121006. * @param options defines the options used to create the mesh
  121007. * @param scene defines the hosting scene
  121008. * @returns the torus knot mesh
  121009. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  121010. */
  121011. static CreateTorusKnot(name: string, options: {
  121012. radius?: number;
  121013. tube?: number;
  121014. radialSegments?: number;
  121015. tubularSegments?: number;
  121016. p?: number;
  121017. q?: number;
  121018. updatable?: boolean;
  121019. sideOrientation?: number;
  121020. frontUVs?: Vector4;
  121021. backUVs?: Vector4;
  121022. }, scene: any): Mesh;
  121023. }
  121024. }
  121025. declare module BABYLON {
  121026. /**
  121027. * Polygon
  121028. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  121029. */
  121030. export class Polygon {
  121031. /**
  121032. * Creates a rectangle
  121033. * @param xmin bottom X coord
  121034. * @param ymin bottom Y coord
  121035. * @param xmax top X coord
  121036. * @param ymax top Y coord
  121037. * @returns points that make the resulting rectation
  121038. */
  121039. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  121040. /**
  121041. * Creates a circle
  121042. * @param radius radius of circle
  121043. * @param cx scale in x
  121044. * @param cy scale in y
  121045. * @param numberOfSides number of sides that make up the circle
  121046. * @returns points that make the resulting circle
  121047. */
  121048. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  121049. /**
  121050. * Creates a polygon from input string
  121051. * @param input Input polygon data
  121052. * @returns the parsed points
  121053. */
  121054. static Parse(input: string): Vector2[];
  121055. /**
  121056. * Starts building a polygon from x and y coordinates
  121057. * @param x x coordinate
  121058. * @param y y coordinate
  121059. * @returns the started path2
  121060. */
  121061. static StartingAt(x: number, y: number): Path2;
  121062. }
  121063. /**
  121064. * Builds a polygon
  121065. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  121066. */
  121067. export class PolygonMeshBuilder {
  121068. private _points;
  121069. private _outlinepoints;
  121070. private _holes;
  121071. private _name;
  121072. private _scene;
  121073. private _epoints;
  121074. private _eholes;
  121075. private _addToepoint;
  121076. /**
  121077. * Babylon reference to the earcut plugin.
  121078. */
  121079. bjsEarcut: any;
  121080. /**
  121081. * Creates a PolygonMeshBuilder
  121082. * @param name name of the builder
  121083. * @param contours Path of the polygon
  121084. * @param scene scene to add to when creating the mesh
  121085. * @param earcutInjection can be used to inject your own earcut reference
  121086. */
  121087. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  121088. /**
  121089. * Adds a whole within the polygon
  121090. * @param hole Array of points defining the hole
  121091. * @returns this
  121092. */
  121093. addHole(hole: Vector2[]): PolygonMeshBuilder;
  121094. /**
  121095. * Creates the polygon
  121096. * @param updatable If the mesh should be updatable
  121097. * @param depth The depth of the mesh created
  121098. * @returns the created mesh
  121099. */
  121100. build(updatable?: boolean, depth?: number): Mesh;
  121101. /**
  121102. * Creates the polygon
  121103. * @param depth The depth of the mesh created
  121104. * @returns the created VertexData
  121105. */
  121106. buildVertexData(depth?: number): VertexData;
  121107. /**
  121108. * Adds a side to the polygon
  121109. * @param positions points that make the polygon
  121110. * @param normals normals of the polygon
  121111. * @param uvs uvs of the polygon
  121112. * @param indices indices of the polygon
  121113. * @param bounds bounds of the polygon
  121114. * @param points points of the polygon
  121115. * @param depth depth of the polygon
  121116. * @param flip flip of the polygon
  121117. */
  121118. private addSide;
  121119. }
  121120. }
  121121. declare module BABYLON {
  121122. /**
  121123. * Class containing static functions to help procedurally build meshes
  121124. */
  121125. export class PolygonBuilder {
  121126. /**
  121127. * Creates a polygon mesh
  121128. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  121129. * * 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
  121130. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121132. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  121133. * * Remember you can only change the shape positions, not their number when updating a polygon
  121134. * @param name defines the name of the mesh
  121135. * @param options defines the options used to create the mesh
  121136. * @param scene defines the hosting scene
  121137. * @param earcutInjection can be used to inject your own earcut reference
  121138. * @returns the polygon mesh
  121139. */
  121140. static CreatePolygon(name: string, options: {
  121141. shape: Vector3[];
  121142. holes?: Vector3[][];
  121143. depth?: number;
  121144. faceUV?: Vector4[];
  121145. faceColors?: Color4[];
  121146. updatable?: boolean;
  121147. sideOrientation?: number;
  121148. frontUVs?: Vector4;
  121149. backUVs?: Vector4;
  121150. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121151. /**
  121152. * Creates an extruded polygon mesh, with depth in the Y direction.
  121153. * * 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)
  121154. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121155. * @param name defines the name of the mesh
  121156. * @param options defines the options used to create the mesh
  121157. * @param scene defines the hosting scene
  121158. * @param earcutInjection can be used to inject your own earcut reference
  121159. * @returns the polygon mesh
  121160. */
  121161. static ExtrudePolygon(name: string, options: {
  121162. shape: Vector3[];
  121163. holes?: Vector3[][];
  121164. depth?: number;
  121165. faceUV?: Vector4[];
  121166. faceColors?: Color4[];
  121167. updatable?: boolean;
  121168. sideOrientation?: number;
  121169. frontUVs?: Vector4;
  121170. backUVs?: Vector4;
  121171. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121172. }
  121173. }
  121174. declare module BABYLON {
  121175. /**
  121176. * Class containing static functions to help procedurally build meshes
  121177. */
  121178. export class LatheBuilder {
  121179. /**
  121180. * Creates lathe mesh.
  121181. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  121182. * * 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
  121183. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  121184. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  121185. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  121186. * * 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
  121187. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  121188. * * 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
  121189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121191. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121193. * @param name defines the name of the mesh
  121194. * @param options defines the options used to create the mesh
  121195. * @param scene defines the hosting scene
  121196. * @returns the lathe mesh
  121197. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  121198. */
  121199. static CreateLathe(name: string, options: {
  121200. shape: Vector3[];
  121201. radius?: number;
  121202. tessellation?: number;
  121203. clip?: number;
  121204. arc?: number;
  121205. closed?: boolean;
  121206. updatable?: boolean;
  121207. sideOrientation?: number;
  121208. frontUVs?: Vector4;
  121209. backUVs?: Vector4;
  121210. cap?: number;
  121211. invertUV?: boolean;
  121212. }, scene?: Nullable<Scene>): Mesh;
  121213. }
  121214. }
  121215. declare module BABYLON {
  121216. /**
  121217. * Class containing static functions to help procedurally build meshes
  121218. */
  121219. export class TiledPlaneBuilder {
  121220. /**
  121221. * Creates a tiled plane mesh
  121222. * * The parameter `pattern` will, depending on value, do nothing or
  121223. * * * flip (reflect about central vertical) alternate tiles across and up
  121224. * * * flip every tile on alternate rows
  121225. * * * rotate (180 degs) alternate tiles across and up
  121226. * * * rotate every tile on alternate rows
  121227. * * * flip and rotate alternate tiles across and up
  121228. * * * flip and rotate every tile on alternate rows
  121229. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  121230. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  121231. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121232. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121233. * * 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)
  121234. * * 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)
  121235. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  121236. * @param name defines the name of the mesh
  121237. * @param options defines the options used to create the mesh
  121238. * @param scene defines the hosting scene
  121239. * @returns the box mesh
  121240. */
  121241. static CreateTiledPlane(name: string, options: {
  121242. pattern?: number;
  121243. tileSize?: number;
  121244. tileWidth?: number;
  121245. tileHeight?: number;
  121246. size?: number;
  121247. width?: number;
  121248. height?: number;
  121249. alignHorizontal?: number;
  121250. alignVertical?: number;
  121251. sideOrientation?: number;
  121252. frontUVs?: Vector4;
  121253. backUVs?: Vector4;
  121254. updatable?: boolean;
  121255. }, scene?: Nullable<Scene>): Mesh;
  121256. }
  121257. }
  121258. declare module BABYLON {
  121259. /**
  121260. * Class containing static functions to help procedurally build meshes
  121261. */
  121262. export class TubeBuilder {
  121263. /**
  121264. * Creates a tube mesh.
  121265. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121266. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  121267. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  121268. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  121269. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  121270. * * 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)
  121271. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  121272. * * 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
  121273. * * 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
  121274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121275. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121276. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121278. * @param name defines the name of the mesh
  121279. * @param options defines the options used to create the mesh
  121280. * @param scene defines the hosting scene
  121281. * @returns the tube mesh
  121282. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121283. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  121284. */
  121285. static CreateTube(name: string, options: {
  121286. path: Vector3[];
  121287. radius?: number;
  121288. tessellation?: number;
  121289. radiusFunction?: {
  121290. (i: number, distance: number): number;
  121291. };
  121292. cap?: number;
  121293. arc?: number;
  121294. updatable?: boolean;
  121295. sideOrientation?: number;
  121296. frontUVs?: Vector4;
  121297. backUVs?: Vector4;
  121298. instance?: Mesh;
  121299. invertUV?: boolean;
  121300. }, scene?: Nullable<Scene>): Mesh;
  121301. }
  121302. }
  121303. declare module BABYLON {
  121304. /**
  121305. * Class containing static functions to help procedurally build meshes
  121306. */
  121307. export class IcoSphereBuilder {
  121308. /**
  121309. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  121310. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  121311. * * 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`)
  121312. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  121313. * * 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
  121314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121315. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121317. * @param name defines the name of the mesh
  121318. * @param options defines the options used to create the mesh
  121319. * @param scene defines the hosting scene
  121320. * @returns the icosahedron mesh
  121321. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  121322. */
  121323. static CreateIcoSphere(name: string, options: {
  121324. radius?: number;
  121325. radiusX?: number;
  121326. radiusY?: number;
  121327. radiusZ?: number;
  121328. flat?: boolean;
  121329. subdivisions?: number;
  121330. sideOrientation?: number;
  121331. frontUVs?: Vector4;
  121332. backUVs?: Vector4;
  121333. updatable?: boolean;
  121334. }, scene?: Nullable<Scene>): Mesh;
  121335. }
  121336. }
  121337. declare module BABYLON {
  121338. /**
  121339. * Class containing static functions to help procedurally build meshes
  121340. */
  121341. export class DecalBuilder {
  121342. /**
  121343. * Creates a decal mesh.
  121344. * 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
  121345. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  121346. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  121347. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  121348. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  121349. * @param name defines the name of the mesh
  121350. * @param sourceMesh defines the mesh where the decal must be applied
  121351. * @param options defines the options used to create the mesh
  121352. * @param scene defines the hosting scene
  121353. * @returns the decal mesh
  121354. * @see https://doc.babylonjs.com/how_to/decals
  121355. */
  121356. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  121357. position?: Vector3;
  121358. normal?: Vector3;
  121359. size?: Vector3;
  121360. angle?: number;
  121361. }): Mesh;
  121362. }
  121363. }
  121364. declare module BABYLON {
  121365. /**
  121366. * Class containing static functions to help procedurally build meshes
  121367. */
  121368. export class MeshBuilder {
  121369. /**
  121370. * Creates a box mesh
  121371. * * The parameter `size` sets the size (float) of each box side (default 1)
  121372. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  121373. * * 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)
  121374. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121375. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121376. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121378. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  121379. * @param name defines the name of the mesh
  121380. * @param options defines the options used to create the mesh
  121381. * @param scene defines the hosting scene
  121382. * @returns the box mesh
  121383. */
  121384. static CreateBox(name: string, options: {
  121385. size?: number;
  121386. width?: number;
  121387. height?: number;
  121388. depth?: number;
  121389. faceUV?: Vector4[];
  121390. faceColors?: Color4[];
  121391. sideOrientation?: number;
  121392. frontUVs?: Vector4;
  121393. backUVs?: Vector4;
  121394. updatable?: boolean;
  121395. }, scene?: Nullable<Scene>): Mesh;
  121396. /**
  121397. * Creates a tiled box mesh
  121398. * * faceTiles sets the pattern, tile size and number of tiles for a face
  121399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121400. * @param name defines the name of the mesh
  121401. * @param options defines the options used to create the mesh
  121402. * @param scene defines the hosting scene
  121403. * @returns the tiled box mesh
  121404. */
  121405. static CreateTiledBox(name: string, options: {
  121406. pattern?: number;
  121407. size?: number;
  121408. width?: number;
  121409. height?: number;
  121410. depth: number;
  121411. tileSize?: number;
  121412. tileWidth?: number;
  121413. tileHeight?: number;
  121414. faceUV?: Vector4[];
  121415. faceColors?: Color4[];
  121416. alignHorizontal?: number;
  121417. alignVertical?: number;
  121418. sideOrientation?: number;
  121419. updatable?: boolean;
  121420. }, scene?: Nullable<Scene>): Mesh;
  121421. /**
  121422. * Creates a sphere mesh
  121423. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  121424. * * 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`)
  121425. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  121426. * * 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
  121427. * * 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)
  121428. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121429. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121431. * @param name defines the name of the mesh
  121432. * @param options defines the options used to create the mesh
  121433. * @param scene defines the hosting scene
  121434. * @returns the sphere mesh
  121435. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  121436. */
  121437. static CreateSphere(name: string, options: {
  121438. segments?: number;
  121439. diameter?: number;
  121440. diameterX?: number;
  121441. diameterY?: number;
  121442. diameterZ?: number;
  121443. arc?: number;
  121444. slice?: number;
  121445. sideOrientation?: number;
  121446. frontUVs?: Vector4;
  121447. backUVs?: Vector4;
  121448. updatable?: boolean;
  121449. }, scene?: Nullable<Scene>): Mesh;
  121450. /**
  121451. * Creates a plane polygonal mesh. By default, this is a disc
  121452. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  121453. * * 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
  121454. * * 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
  121455. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121456. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121458. * @param name defines the name of the mesh
  121459. * @param options defines the options used to create the mesh
  121460. * @param scene defines the hosting scene
  121461. * @returns the plane polygonal mesh
  121462. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  121463. */
  121464. static CreateDisc(name: string, options: {
  121465. radius?: number;
  121466. tessellation?: number;
  121467. arc?: number;
  121468. updatable?: boolean;
  121469. sideOrientation?: number;
  121470. frontUVs?: Vector4;
  121471. backUVs?: Vector4;
  121472. }, scene?: Nullable<Scene>): Mesh;
  121473. /**
  121474. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  121475. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  121476. * * 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`)
  121477. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  121478. * * 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
  121479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121480. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121482. * @param name defines the name of the mesh
  121483. * @param options defines the options used to create the mesh
  121484. * @param scene defines the hosting scene
  121485. * @returns the icosahedron mesh
  121486. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  121487. */
  121488. static CreateIcoSphere(name: string, options: {
  121489. radius?: number;
  121490. radiusX?: number;
  121491. radiusY?: number;
  121492. radiusZ?: number;
  121493. flat?: boolean;
  121494. subdivisions?: number;
  121495. sideOrientation?: number;
  121496. frontUVs?: Vector4;
  121497. backUVs?: Vector4;
  121498. updatable?: boolean;
  121499. }, scene?: Nullable<Scene>): Mesh;
  121500. /**
  121501. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121502. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  121503. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  121504. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  121505. * * 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
  121506. * * 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
  121507. * * 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
  121508. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121509. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121510. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121511. * * 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
  121512. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  121513. * * 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
  121514. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  121515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121516. * @param name defines the name of the mesh
  121517. * @param options defines the options used to create the mesh
  121518. * @param scene defines the hosting scene
  121519. * @returns the ribbon mesh
  121520. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  121521. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121522. */
  121523. static CreateRibbon(name: string, options: {
  121524. pathArray: Vector3[][];
  121525. closeArray?: boolean;
  121526. closePath?: boolean;
  121527. offset?: number;
  121528. updatable?: boolean;
  121529. sideOrientation?: number;
  121530. frontUVs?: Vector4;
  121531. backUVs?: Vector4;
  121532. instance?: Mesh;
  121533. invertUV?: boolean;
  121534. uvs?: Vector2[];
  121535. colors?: Color4[];
  121536. }, scene?: Nullable<Scene>): Mesh;
  121537. /**
  121538. * Creates a cylinder or a cone mesh
  121539. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  121540. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  121541. * * 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.
  121542. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  121543. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  121544. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  121545. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  121546. * * 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).
  121547. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  121548. * * 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).
  121549. * * 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
  121550. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  121551. * * 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
  121552. * * 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.
  121553. * * If `enclose` is false, a ring surface is one element.
  121554. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  121555. * * 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
  121556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121557. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121559. * @param name defines the name of the mesh
  121560. * @param options defines the options used to create the mesh
  121561. * @param scene defines the hosting scene
  121562. * @returns the cylinder mesh
  121563. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  121564. */
  121565. static CreateCylinder(name: string, options: {
  121566. height?: number;
  121567. diameterTop?: number;
  121568. diameterBottom?: number;
  121569. diameter?: number;
  121570. tessellation?: number;
  121571. subdivisions?: number;
  121572. arc?: number;
  121573. faceColors?: Color4[];
  121574. faceUV?: Vector4[];
  121575. updatable?: boolean;
  121576. hasRings?: boolean;
  121577. enclose?: boolean;
  121578. cap?: number;
  121579. sideOrientation?: number;
  121580. frontUVs?: Vector4;
  121581. backUVs?: Vector4;
  121582. }, scene?: Nullable<Scene>): Mesh;
  121583. /**
  121584. * Creates a torus mesh
  121585. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  121586. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  121587. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  121588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121589. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121591. * @param name defines the name of the mesh
  121592. * @param options defines the options used to create the mesh
  121593. * @param scene defines the hosting scene
  121594. * @returns the torus mesh
  121595. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  121596. */
  121597. static CreateTorus(name: string, options: {
  121598. diameter?: number;
  121599. thickness?: number;
  121600. tessellation?: number;
  121601. updatable?: boolean;
  121602. sideOrientation?: number;
  121603. frontUVs?: Vector4;
  121604. backUVs?: Vector4;
  121605. }, scene?: Nullable<Scene>): Mesh;
  121606. /**
  121607. * Creates a torus knot mesh
  121608. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  121609. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  121610. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  121611. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  121612. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121613. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121615. * @param name defines the name of the mesh
  121616. * @param options defines the options used to create the mesh
  121617. * @param scene defines the hosting scene
  121618. * @returns the torus knot mesh
  121619. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  121620. */
  121621. static CreateTorusKnot(name: string, options: {
  121622. radius?: number;
  121623. tube?: number;
  121624. radialSegments?: number;
  121625. tubularSegments?: number;
  121626. p?: number;
  121627. q?: number;
  121628. updatable?: boolean;
  121629. sideOrientation?: number;
  121630. frontUVs?: Vector4;
  121631. backUVs?: Vector4;
  121632. }, scene?: Nullable<Scene>): Mesh;
  121633. /**
  121634. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  121635. * * 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
  121636. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  121637. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  121638. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  121639. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  121640. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  121641. * * 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
  121642. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  121643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121644. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  121645. * @param name defines the name of the new line system
  121646. * @param options defines the options used to create the line system
  121647. * @param scene defines the hosting scene
  121648. * @returns a new line system mesh
  121649. */
  121650. static CreateLineSystem(name: string, options: {
  121651. lines: Vector3[][];
  121652. updatable?: boolean;
  121653. instance?: Nullable<LinesMesh>;
  121654. colors?: Nullable<Color4[][]>;
  121655. useVertexAlpha?: boolean;
  121656. }, scene: Nullable<Scene>): LinesMesh;
  121657. /**
  121658. * Creates a line mesh
  121659. * 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
  121660. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121661. * * The parameter `points` is an array successive Vector3
  121662. * * 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
  121663. * * The optional parameter `colors` is an array of successive Color4, one per line point
  121664. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  121665. * * When updating an instance, remember that only point positions can change, not the number of points
  121666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121667. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  121668. * @param name defines the name of the new line system
  121669. * @param options defines the options used to create the line system
  121670. * @param scene defines the hosting scene
  121671. * @returns a new line mesh
  121672. */
  121673. static CreateLines(name: string, options: {
  121674. points: Vector3[];
  121675. updatable?: boolean;
  121676. instance?: Nullable<LinesMesh>;
  121677. colors?: Color4[];
  121678. useVertexAlpha?: boolean;
  121679. }, scene?: Nullable<Scene>): LinesMesh;
  121680. /**
  121681. * Creates a dashed line mesh
  121682. * * 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
  121683. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  121684. * * The parameter `points` is an array successive Vector3
  121685. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  121686. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  121687. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  121688. * * 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
  121689. * * When updating an instance, remember that only point positions can change, not the number of points
  121690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121691. * @param name defines the name of the mesh
  121692. * @param options defines the options used to create the mesh
  121693. * @param scene defines the hosting scene
  121694. * @returns the dashed line mesh
  121695. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  121696. */
  121697. static CreateDashedLines(name: string, options: {
  121698. points: Vector3[];
  121699. dashSize?: number;
  121700. gapSize?: number;
  121701. dashNb?: number;
  121702. updatable?: boolean;
  121703. instance?: LinesMesh;
  121704. }, scene?: Nullable<Scene>): LinesMesh;
  121705. /**
  121706. * 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.
  121707. * * 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.
  121708. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121709. * * 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.
  121710. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  121711. * * 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
  121712. * * 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
  121713. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  121714. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121715. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121716. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  121717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121718. * @param name defines the name of the mesh
  121719. * @param options defines the options used to create the mesh
  121720. * @param scene defines the hosting scene
  121721. * @returns the extruded shape mesh
  121722. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121723. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121724. */
  121725. static ExtrudeShape(name: string, options: {
  121726. shape: Vector3[];
  121727. path: Vector3[];
  121728. scale?: number;
  121729. rotation?: number;
  121730. cap?: number;
  121731. updatable?: boolean;
  121732. sideOrientation?: number;
  121733. frontUVs?: Vector4;
  121734. backUVs?: Vector4;
  121735. instance?: Mesh;
  121736. invertUV?: boolean;
  121737. }, scene?: Nullable<Scene>): Mesh;
  121738. /**
  121739. * Creates an custom extruded shape mesh.
  121740. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  121741. * * 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.
  121742. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  121743. * * 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
  121744. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  121745. * * 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
  121746. * * It must returns a float value that will be the scale value applied to the shape on each path point
  121747. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  121748. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  121749. * * 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
  121750. * * 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
  121751. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  121752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121753. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121754. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121756. * @param name defines the name of the mesh
  121757. * @param options defines the options used to create the mesh
  121758. * @param scene defines the hosting scene
  121759. * @returns the custom extruded shape mesh
  121760. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  121761. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  121762. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  121763. */
  121764. static ExtrudeShapeCustom(name: string, options: {
  121765. shape: Vector3[];
  121766. path: Vector3[];
  121767. scaleFunction?: any;
  121768. rotationFunction?: any;
  121769. ribbonCloseArray?: boolean;
  121770. ribbonClosePath?: boolean;
  121771. cap?: number;
  121772. updatable?: boolean;
  121773. sideOrientation?: number;
  121774. frontUVs?: Vector4;
  121775. backUVs?: Vector4;
  121776. instance?: Mesh;
  121777. invertUV?: boolean;
  121778. }, scene?: Nullable<Scene>): Mesh;
  121779. /**
  121780. * Creates lathe mesh.
  121781. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  121782. * * 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
  121783. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  121784. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  121785. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  121786. * * 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
  121787. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  121788. * * 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
  121789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121790. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121791. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  121792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121793. * @param name defines the name of the mesh
  121794. * @param options defines the options used to create the mesh
  121795. * @param scene defines the hosting scene
  121796. * @returns the lathe mesh
  121797. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  121798. */
  121799. static CreateLathe(name: string, options: {
  121800. shape: Vector3[];
  121801. radius?: number;
  121802. tessellation?: number;
  121803. clip?: number;
  121804. arc?: number;
  121805. closed?: boolean;
  121806. updatable?: boolean;
  121807. sideOrientation?: number;
  121808. frontUVs?: Vector4;
  121809. backUVs?: Vector4;
  121810. cap?: number;
  121811. invertUV?: boolean;
  121812. }, scene?: Nullable<Scene>): Mesh;
  121813. /**
  121814. * Creates a tiled plane mesh
  121815. * * You can set a limited pattern arrangement with the tiles
  121816. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121817. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121819. * @param name defines the name of the mesh
  121820. * @param options defines the options used to create the mesh
  121821. * @param scene defines the hosting scene
  121822. * @returns the plane mesh
  121823. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121824. */
  121825. static CreateTiledPlane(name: string, options: {
  121826. pattern?: number;
  121827. tileSize?: number;
  121828. tileWidth?: number;
  121829. tileHeight?: number;
  121830. size?: number;
  121831. width?: number;
  121832. height?: number;
  121833. alignHorizontal?: number;
  121834. alignVertical?: number;
  121835. sideOrientation?: number;
  121836. frontUVs?: Vector4;
  121837. backUVs?: Vector4;
  121838. updatable?: boolean;
  121839. }, scene?: Nullable<Scene>): Mesh;
  121840. /**
  121841. * Creates a plane mesh
  121842. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  121843. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  121844. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  121845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121846. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121848. * @param name defines the name of the mesh
  121849. * @param options defines the options used to create the mesh
  121850. * @param scene defines the hosting scene
  121851. * @returns the plane mesh
  121852. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  121853. */
  121854. static CreatePlane(name: string, options: {
  121855. size?: number;
  121856. width?: number;
  121857. height?: number;
  121858. sideOrientation?: number;
  121859. frontUVs?: Vector4;
  121860. backUVs?: Vector4;
  121861. updatable?: boolean;
  121862. sourcePlane?: Plane;
  121863. }, scene?: Nullable<Scene>): Mesh;
  121864. /**
  121865. * Creates a ground mesh
  121866. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  121867. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  121868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121869. * @param name defines the name of the mesh
  121870. * @param options defines the options used to create the mesh
  121871. * @param scene defines the hosting scene
  121872. * @returns the ground mesh
  121873. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  121874. */
  121875. static CreateGround(name: string, options: {
  121876. width?: number;
  121877. height?: number;
  121878. subdivisions?: number;
  121879. subdivisionsX?: number;
  121880. subdivisionsY?: number;
  121881. updatable?: boolean;
  121882. }, scene?: Nullable<Scene>): Mesh;
  121883. /**
  121884. * Creates a tiled ground mesh
  121885. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  121886. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  121887. * * 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
  121888. * * 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
  121889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121890. * @param name defines the name of the mesh
  121891. * @param options defines the options used to create the mesh
  121892. * @param scene defines the hosting scene
  121893. * @returns the tiled ground mesh
  121894. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  121895. */
  121896. static CreateTiledGround(name: string, options: {
  121897. xmin: number;
  121898. zmin: number;
  121899. xmax: number;
  121900. zmax: number;
  121901. subdivisions?: {
  121902. w: number;
  121903. h: number;
  121904. };
  121905. precision?: {
  121906. w: number;
  121907. h: number;
  121908. };
  121909. updatable?: boolean;
  121910. }, scene?: Nullable<Scene>): Mesh;
  121911. /**
  121912. * Creates a ground mesh from a height map
  121913. * * The parameter `url` sets the URL of the height map image resource.
  121914. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  121915. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  121916. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  121917. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  121918. * * 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.
  121919. * * 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).
  121920. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  121921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  121922. * @param name defines the name of the mesh
  121923. * @param url defines the url to the height map
  121924. * @param options defines the options used to create the mesh
  121925. * @param scene defines the hosting scene
  121926. * @returns the ground mesh
  121927. * @see https://doc.babylonjs.com/babylon101/height_map
  121928. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  121929. */
  121930. static CreateGroundFromHeightMap(name: string, url: string, options: {
  121931. width?: number;
  121932. height?: number;
  121933. subdivisions?: number;
  121934. minHeight?: number;
  121935. maxHeight?: number;
  121936. colorFilter?: Color3;
  121937. alphaFilter?: number;
  121938. updatable?: boolean;
  121939. onReady?: (mesh: GroundMesh) => void;
  121940. }, scene?: Nullable<Scene>): GroundMesh;
  121941. /**
  121942. * Creates a polygon mesh
  121943. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  121944. * * 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
  121945. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  121946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  121948. * * Remember you can only change the shape positions, not their number when updating a polygon
  121949. * @param name defines the name of the mesh
  121950. * @param options defines the options used to create the mesh
  121951. * @param scene defines the hosting scene
  121952. * @param earcutInjection can be used to inject your own earcut reference
  121953. * @returns the polygon mesh
  121954. */
  121955. static CreatePolygon(name: string, options: {
  121956. shape: Vector3[];
  121957. holes?: Vector3[][];
  121958. depth?: number;
  121959. faceUV?: Vector4[];
  121960. faceColors?: Color4[];
  121961. updatable?: boolean;
  121962. sideOrientation?: number;
  121963. frontUVs?: Vector4;
  121964. backUVs?: Vector4;
  121965. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121966. /**
  121967. * Creates an extruded polygon mesh, with depth in the Y direction.
  121968. * * 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)
  121969. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  121970. * @param name defines the name of the mesh
  121971. * @param options defines the options used to create the mesh
  121972. * @param scene defines the hosting scene
  121973. * @param earcutInjection can be used to inject your own earcut reference
  121974. * @returns the polygon mesh
  121975. */
  121976. static ExtrudePolygon(name: string, options: {
  121977. shape: Vector3[];
  121978. holes?: Vector3[][];
  121979. depth?: number;
  121980. faceUV?: Vector4[];
  121981. faceColors?: Color4[];
  121982. updatable?: boolean;
  121983. sideOrientation?: number;
  121984. frontUVs?: Vector4;
  121985. backUVs?: Vector4;
  121986. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  121987. /**
  121988. * Creates a tube mesh.
  121989. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  121990. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  121991. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  121992. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  121993. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  121994. * * 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)
  121995. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  121996. * * 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
  121997. * * 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
  121998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121999. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122000. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122002. * @param name defines the name of the mesh
  122003. * @param options defines the options used to create the mesh
  122004. * @param scene defines the hosting scene
  122005. * @returns the tube mesh
  122006. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  122007. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  122008. */
  122009. static CreateTube(name: string, options: {
  122010. path: Vector3[];
  122011. radius?: number;
  122012. tessellation?: number;
  122013. radiusFunction?: {
  122014. (i: number, distance: number): number;
  122015. };
  122016. cap?: number;
  122017. arc?: number;
  122018. updatable?: boolean;
  122019. sideOrientation?: number;
  122020. frontUVs?: Vector4;
  122021. backUVs?: Vector4;
  122022. instance?: Mesh;
  122023. invertUV?: boolean;
  122024. }, scene?: Nullable<Scene>): Mesh;
  122025. /**
  122026. * Creates a polyhedron mesh
  122027. * * 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
  122028. * * The parameter `size` (positive float, default 1) sets the polygon size
  122029. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  122030. * * 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`
  122031. * * 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
  122032. * * 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)`)
  122033. * * 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
  122034. * * 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
  122035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122038. * @param name defines the name of the mesh
  122039. * @param options defines the options used to create the mesh
  122040. * @param scene defines the hosting scene
  122041. * @returns the polyhedron mesh
  122042. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  122043. */
  122044. static CreatePolyhedron(name: string, options: {
  122045. type?: number;
  122046. size?: number;
  122047. sizeX?: number;
  122048. sizeY?: number;
  122049. sizeZ?: number;
  122050. custom?: any;
  122051. faceUV?: Vector4[];
  122052. faceColors?: Color4[];
  122053. flat?: boolean;
  122054. updatable?: boolean;
  122055. sideOrientation?: number;
  122056. frontUVs?: Vector4;
  122057. backUVs?: Vector4;
  122058. }, scene?: Nullable<Scene>): Mesh;
  122059. /**
  122060. * Creates a decal mesh.
  122061. * 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
  122062. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  122063. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  122064. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  122065. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  122066. * @param name defines the name of the mesh
  122067. * @param sourceMesh defines the mesh where the decal must be applied
  122068. * @param options defines the options used to create the mesh
  122069. * @param scene defines the hosting scene
  122070. * @returns the decal mesh
  122071. * @see https://doc.babylonjs.com/how_to/decals
  122072. */
  122073. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  122074. position?: Vector3;
  122075. normal?: Vector3;
  122076. size?: Vector3;
  122077. angle?: number;
  122078. }): Mesh;
  122079. }
  122080. }
  122081. declare module BABYLON {
  122082. /**
  122083. * A simplifier interface for future simplification implementations
  122084. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122085. */
  122086. export interface ISimplifier {
  122087. /**
  122088. * Simplification of a given mesh according to the given settings.
  122089. * Since this requires computation, it is assumed that the function runs async.
  122090. * @param settings The settings of the simplification, including quality and distance
  122091. * @param successCallback A callback that will be called after the mesh was simplified.
  122092. * @param errorCallback in case of an error, this callback will be called. optional.
  122093. */
  122094. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  122095. }
  122096. /**
  122097. * Expected simplification settings.
  122098. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  122099. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122100. */
  122101. export interface ISimplificationSettings {
  122102. /**
  122103. * Gets or sets the expected quality
  122104. */
  122105. quality: number;
  122106. /**
  122107. * Gets or sets the distance when this optimized version should be used
  122108. */
  122109. distance: number;
  122110. /**
  122111. * Gets an already optimized mesh
  122112. */
  122113. optimizeMesh?: boolean;
  122114. }
  122115. /**
  122116. * Class used to specify simplification options
  122117. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122118. */
  122119. export class SimplificationSettings implements ISimplificationSettings {
  122120. /** expected quality */
  122121. quality: number;
  122122. /** distance when this optimized version should be used */
  122123. distance: number;
  122124. /** already optimized mesh */
  122125. optimizeMesh?: boolean | undefined;
  122126. /**
  122127. * Creates a SimplificationSettings
  122128. * @param quality expected quality
  122129. * @param distance distance when this optimized version should be used
  122130. * @param optimizeMesh already optimized mesh
  122131. */
  122132. constructor(
  122133. /** expected quality */
  122134. quality: number,
  122135. /** distance when this optimized version should be used */
  122136. distance: number,
  122137. /** already optimized mesh */
  122138. optimizeMesh?: boolean | undefined);
  122139. }
  122140. /**
  122141. * Interface used to define a simplification task
  122142. */
  122143. export interface ISimplificationTask {
  122144. /**
  122145. * Array of settings
  122146. */
  122147. settings: Array<ISimplificationSettings>;
  122148. /**
  122149. * Simplification type
  122150. */
  122151. simplificationType: SimplificationType;
  122152. /**
  122153. * Mesh to simplify
  122154. */
  122155. mesh: Mesh;
  122156. /**
  122157. * Callback called on success
  122158. */
  122159. successCallback?: () => void;
  122160. /**
  122161. * Defines if parallel processing can be used
  122162. */
  122163. parallelProcessing: boolean;
  122164. }
  122165. /**
  122166. * Queue used to order the simplification tasks
  122167. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122168. */
  122169. export class SimplificationQueue {
  122170. private _simplificationArray;
  122171. /**
  122172. * Gets a boolean indicating that the process is still running
  122173. */
  122174. running: boolean;
  122175. /**
  122176. * Creates a new queue
  122177. */
  122178. constructor();
  122179. /**
  122180. * Adds a new simplification task
  122181. * @param task defines a task to add
  122182. */
  122183. addTask(task: ISimplificationTask): void;
  122184. /**
  122185. * Execute next task
  122186. */
  122187. executeNext(): void;
  122188. /**
  122189. * Execute a simplification task
  122190. * @param task defines the task to run
  122191. */
  122192. runSimplification(task: ISimplificationTask): void;
  122193. private getSimplifier;
  122194. }
  122195. /**
  122196. * The implemented types of simplification
  122197. * At the moment only Quadratic Error Decimation is implemented
  122198. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122199. */
  122200. export enum SimplificationType {
  122201. /** Quadratic error decimation */
  122202. QUADRATIC = 0
  122203. }
  122204. }
  122205. declare module BABYLON {
  122206. interface Scene {
  122207. /** @hidden (Backing field) */
  122208. _simplificationQueue: SimplificationQueue;
  122209. /**
  122210. * Gets or sets the simplification queue attached to the scene
  122211. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  122212. */
  122213. simplificationQueue: SimplificationQueue;
  122214. }
  122215. interface Mesh {
  122216. /**
  122217. * Simplify the mesh according to the given array of settings.
  122218. * Function will return immediately and will simplify async
  122219. * @param settings a collection of simplification settings
  122220. * @param parallelProcessing should all levels calculate parallel or one after the other
  122221. * @param simplificationType the type of simplification to run
  122222. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  122223. * @returns the current mesh
  122224. */
  122225. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  122226. }
  122227. /**
  122228. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  122229. * created in a scene
  122230. */
  122231. export class SimplicationQueueSceneComponent implements ISceneComponent {
  122232. /**
  122233. * The component name helpfull to identify the component in the list of scene components.
  122234. */
  122235. readonly name: string;
  122236. /**
  122237. * The scene the component belongs to.
  122238. */
  122239. scene: Scene;
  122240. /**
  122241. * Creates a new instance of the component for the given scene
  122242. * @param scene Defines the scene to register the component in
  122243. */
  122244. constructor(scene: Scene);
  122245. /**
  122246. * Registers the component in a given scene
  122247. */
  122248. register(): void;
  122249. /**
  122250. * Rebuilds the elements related to this component in case of
  122251. * context lost for instance.
  122252. */
  122253. rebuild(): void;
  122254. /**
  122255. * Disposes the component and the associated ressources
  122256. */
  122257. dispose(): void;
  122258. private _beforeCameraUpdate;
  122259. }
  122260. }
  122261. declare module BABYLON {
  122262. /**
  122263. * Navigation plugin interface to add navigation constrained by a navigation mesh
  122264. */
  122265. export interface INavigationEnginePlugin {
  122266. /**
  122267. * plugin name
  122268. */
  122269. name: string;
  122270. /**
  122271. * Creates a navigation mesh
  122272. * @param meshes array of all the geometry used to compute the navigatio mesh
  122273. * @param parameters bunch of parameters used to filter geometry
  122274. */
  122275. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  122276. /**
  122277. * Create a navigation mesh debug mesh
  122278. * @param scene is where the mesh will be added
  122279. * @returns debug display mesh
  122280. */
  122281. createDebugNavMesh(scene: Scene): Mesh;
  122282. /**
  122283. * Get a navigation mesh constrained position, closest to the parameter position
  122284. * @param position world position
  122285. * @returns the closest point to position constrained by the navigation mesh
  122286. */
  122287. getClosestPoint(position: Vector3): Vector3;
  122288. /**
  122289. * Get a navigation mesh constrained position, within a particular radius
  122290. * @param position world position
  122291. * @param maxRadius the maximum distance to the constrained world position
  122292. * @returns the closest point to position constrained by the navigation mesh
  122293. */
  122294. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  122295. /**
  122296. * Compute the final position from a segment made of destination-position
  122297. * @param position world position
  122298. * @param destination world position
  122299. * @returns the resulting point along the navmesh
  122300. */
  122301. moveAlong(position: Vector3, destination: Vector3): Vector3;
  122302. /**
  122303. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  122304. * @param start world position
  122305. * @param end world position
  122306. * @returns array containing world position composing the path
  122307. */
  122308. computePath(start: Vector3, end: Vector3): Vector3[];
  122309. /**
  122310. * If this plugin is supported
  122311. * @returns true if plugin is supported
  122312. */
  122313. isSupported(): boolean;
  122314. /**
  122315. * Create a new Crowd so you can add agents
  122316. * @param maxAgents the maximum agent count in the crowd
  122317. * @param maxAgentRadius the maximum radius an agent can have
  122318. * @param scene to attach the crowd to
  122319. * @returns the crowd you can add agents to
  122320. */
  122321. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  122322. /**
  122323. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122324. * The queries will try to find a solution within those bounds
  122325. * default is (1,1,1)
  122326. * @param extent x,y,z value that define the extent around the queries point of reference
  122327. */
  122328. setDefaultQueryExtent(extent: Vector3): void;
  122329. /**
  122330. * Get the Bounding box extent specified by setDefaultQueryExtent
  122331. * @returns the box extent values
  122332. */
  122333. getDefaultQueryExtent(): Vector3;
  122334. /**
  122335. * Release all resources
  122336. */
  122337. dispose(): void;
  122338. }
  122339. /**
  122340. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  122341. */
  122342. export interface ICrowd {
  122343. /**
  122344. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  122345. * You can attach anything to that node. The node position is updated in the scene update tick.
  122346. * @param pos world position that will be constrained by the navigation mesh
  122347. * @param parameters agent parameters
  122348. * @param transform hooked to the agent that will be update by the scene
  122349. * @returns agent index
  122350. */
  122351. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  122352. /**
  122353. * Returns the agent position in world space
  122354. * @param index agent index returned by addAgent
  122355. * @returns world space position
  122356. */
  122357. getAgentPosition(index: number): Vector3;
  122358. /**
  122359. * Gets the agent velocity in world space
  122360. * @param index agent index returned by addAgent
  122361. * @returns world space velocity
  122362. */
  122363. getAgentVelocity(index: number): Vector3;
  122364. /**
  122365. * remove a particular agent previously created
  122366. * @param index agent index returned by addAgent
  122367. */
  122368. removeAgent(index: number): void;
  122369. /**
  122370. * get the list of all agents attached to this crowd
  122371. * @returns list of agent indices
  122372. */
  122373. getAgents(): number[];
  122374. /**
  122375. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  122376. * @param deltaTime in seconds
  122377. */
  122378. update(deltaTime: number): void;
  122379. /**
  122380. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  122381. * @param index agent index returned by addAgent
  122382. * @param destination targeted world position
  122383. */
  122384. agentGoto(index: number, destination: Vector3): void;
  122385. /**
  122386. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122387. * The queries will try to find a solution within those bounds
  122388. * default is (1,1,1)
  122389. * @param extent x,y,z value that define the extent around the queries point of reference
  122390. */
  122391. setDefaultQueryExtent(extent: Vector3): void;
  122392. /**
  122393. * Get the Bounding box extent specified by setDefaultQueryExtent
  122394. * @returns the box extent values
  122395. */
  122396. getDefaultQueryExtent(): Vector3;
  122397. /**
  122398. * Release all resources
  122399. */
  122400. dispose(): void;
  122401. }
  122402. /**
  122403. * Configures an agent
  122404. */
  122405. export interface IAgentParameters {
  122406. /**
  122407. * Agent radius. [Limit: >= 0]
  122408. */
  122409. radius: number;
  122410. /**
  122411. * Agent height. [Limit: > 0]
  122412. */
  122413. height: number;
  122414. /**
  122415. * Maximum allowed acceleration. [Limit: >= 0]
  122416. */
  122417. maxAcceleration: number;
  122418. /**
  122419. * Maximum allowed speed. [Limit: >= 0]
  122420. */
  122421. maxSpeed: number;
  122422. /**
  122423. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  122424. */
  122425. collisionQueryRange: number;
  122426. /**
  122427. * The path visibility optimization range. [Limit: > 0]
  122428. */
  122429. pathOptimizationRange: number;
  122430. /**
  122431. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  122432. */
  122433. separationWeight: number;
  122434. }
  122435. /**
  122436. * Configures the navigation mesh creation
  122437. */
  122438. export interface INavMeshParameters {
  122439. /**
  122440. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  122441. */
  122442. cs: number;
  122443. /**
  122444. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  122445. */
  122446. ch: number;
  122447. /**
  122448. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  122449. */
  122450. walkableSlopeAngle: number;
  122451. /**
  122452. * Minimum floor to 'ceiling' height that will still allow the floor area to
  122453. * be considered walkable. [Limit: >= 3] [Units: vx]
  122454. */
  122455. walkableHeight: number;
  122456. /**
  122457. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  122458. */
  122459. walkableClimb: number;
  122460. /**
  122461. * The distance to erode/shrink the walkable area of the heightfield away from
  122462. * obstructions. [Limit: >=0] [Units: vx]
  122463. */
  122464. walkableRadius: number;
  122465. /**
  122466. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  122467. */
  122468. maxEdgeLen: number;
  122469. /**
  122470. * The maximum distance a simplfied contour's border edges should deviate
  122471. * the original raw contour. [Limit: >=0] [Units: vx]
  122472. */
  122473. maxSimplificationError: number;
  122474. /**
  122475. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  122476. */
  122477. minRegionArea: number;
  122478. /**
  122479. * Any regions with a span count smaller than this value will, if possible,
  122480. * be merged with larger regions. [Limit: >=0] [Units: vx]
  122481. */
  122482. mergeRegionArea: number;
  122483. /**
  122484. * The maximum number of vertices allowed for polygons generated during the
  122485. * contour to polygon conversion process. [Limit: >= 3]
  122486. */
  122487. maxVertsPerPoly: number;
  122488. /**
  122489. * Sets the sampling distance to use when generating the detail mesh.
  122490. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  122491. */
  122492. detailSampleDist: number;
  122493. /**
  122494. * The maximum distance the detail mesh surface should deviate from heightfield
  122495. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  122496. */
  122497. detailSampleMaxError: number;
  122498. }
  122499. }
  122500. declare module BABYLON {
  122501. /**
  122502. * RecastJS navigation plugin
  122503. */
  122504. export class RecastJSPlugin implements INavigationEnginePlugin {
  122505. /**
  122506. * Reference to the Recast library
  122507. */
  122508. bjsRECAST: any;
  122509. /**
  122510. * plugin name
  122511. */
  122512. name: string;
  122513. /**
  122514. * the first navmesh created. We might extend this to support multiple navmeshes
  122515. */
  122516. navMesh: any;
  122517. /**
  122518. * Initializes the recastJS plugin
  122519. * @param recastInjection can be used to inject your own recast reference
  122520. */
  122521. constructor(recastInjection?: any);
  122522. /**
  122523. * Creates a navigation mesh
  122524. * @param meshes array of all the geometry used to compute the navigatio mesh
  122525. * @param parameters bunch of parameters used to filter geometry
  122526. */
  122527. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  122528. /**
  122529. * Create a navigation mesh debug mesh
  122530. * @param scene is where the mesh will be added
  122531. * @returns debug display mesh
  122532. */
  122533. createDebugNavMesh(scene: Scene): Mesh;
  122534. /**
  122535. * Get a navigation mesh constrained position, closest to the parameter position
  122536. * @param position world position
  122537. * @returns the closest point to position constrained by the navigation mesh
  122538. */
  122539. getClosestPoint(position: Vector3): Vector3;
  122540. /**
  122541. * Get a navigation mesh constrained position, within a particular radius
  122542. * @param position world position
  122543. * @param maxRadius the maximum distance to the constrained world position
  122544. * @returns the closest point to position constrained by the navigation mesh
  122545. */
  122546. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  122547. /**
  122548. * Compute the final position from a segment made of destination-position
  122549. * @param position world position
  122550. * @param destination world position
  122551. * @returns the resulting point along the navmesh
  122552. */
  122553. moveAlong(position: Vector3, destination: Vector3): Vector3;
  122554. /**
  122555. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  122556. * @param start world position
  122557. * @param end world position
  122558. * @returns array containing world position composing the path
  122559. */
  122560. computePath(start: Vector3, end: Vector3): Vector3[];
  122561. /**
  122562. * Create a new Crowd so you can add agents
  122563. * @param maxAgents the maximum agent count in the crowd
  122564. * @param maxAgentRadius the maximum radius an agent can have
  122565. * @param scene to attach the crowd to
  122566. * @returns the crowd you can add agents to
  122567. */
  122568. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  122569. /**
  122570. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122571. * The queries will try to find a solution within those bounds
  122572. * default is (1,1,1)
  122573. * @param extent x,y,z value that define the extent around the queries point of reference
  122574. */
  122575. setDefaultQueryExtent(extent: Vector3): void;
  122576. /**
  122577. * Get the Bounding box extent specified by setDefaultQueryExtent
  122578. * @returns the box extent values
  122579. */
  122580. getDefaultQueryExtent(): Vector3;
  122581. /**
  122582. * Disposes
  122583. */
  122584. dispose(): void;
  122585. /**
  122586. * If this plugin is supported
  122587. * @returns true if plugin is supported
  122588. */
  122589. isSupported(): boolean;
  122590. }
  122591. /**
  122592. * Recast detour crowd implementation
  122593. */
  122594. export class RecastJSCrowd implements ICrowd {
  122595. /**
  122596. * Recast/detour plugin
  122597. */
  122598. bjsRECASTPlugin: RecastJSPlugin;
  122599. /**
  122600. * Link to the detour crowd
  122601. */
  122602. recastCrowd: any;
  122603. /**
  122604. * One transform per agent
  122605. */
  122606. transforms: TransformNode[];
  122607. /**
  122608. * All agents created
  122609. */
  122610. agents: number[];
  122611. /**
  122612. * Link to the scene is kept to unregister the crowd from the scene
  122613. */
  122614. private _scene;
  122615. /**
  122616. * Observer for crowd updates
  122617. */
  122618. private _onBeforeAnimationsObserver;
  122619. /**
  122620. * Constructor
  122621. * @param plugin recastJS plugin
  122622. * @param maxAgents the maximum agent count in the crowd
  122623. * @param maxAgentRadius the maximum radius an agent can have
  122624. * @param scene to attach the crowd to
  122625. * @returns the crowd you can add agents to
  122626. */
  122627. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  122628. /**
  122629. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  122630. * You can attach anything to that node. The node position is updated in the scene update tick.
  122631. * @param pos world position that will be constrained by the navigation mesh
  122632. * @param parameters agent parameters
  122633. * @param transform hooked to the agent that will be update by the scene
  122634. * @returns agent index
  122635. */
  122636. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  122637. /**
  122638. * Returns the agent position in world space
  122639. * @param index agent index returned by addAgent
  122640. * @returns world space position
  122641. */
  122642. getAgentPosition(index: number): Vector3;
  122643. /**
  122644. * Returns the agent velocity in world space
  122645. * @param index agent index returned by addAgent
  122646. * @returns world space velocity
  122647. */
  122648. getAgentVelocity(index: number): Vector3;
  122649. /**
  122650. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  122651. * @param index agent index returned by addAgent
  122652. * @param destination targeted world position
  122653. */
  122654. agentGoto(index: number, destination: Vector3): void;
  122655. /**
  122656. * remove a particular agent previously created
  122657. * @param index agent index returned by addAgent
  122658. */
  122659. removeAgent(index: number): void;
  122660. /**
  122661. * get the list of all agents attached to this crowd
  122662. * @returns list of agent indices
  122663. */
  122664. getAgents(): number[];
  122665. /**
  122666. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  122667. * @param deltaTime in seconds
  122668. */
  122669. update(deltaTime: number): void;
  122670. /**
  122671. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  122672. * The queries will try to find a solution within those bounds
  122673. * default is (1,1,1)
  122674. * @param extent x,y,z value that define the extent around the queries point of reference
  122675. */
  122676. setDefaultQueryExtent(extent: Vector3): void;
  122677. /**
  122678. * Get the Bounding box extent specified by setDefaultQueryExtent
  122679. * @returns the box extent values
  122680. */
  122681. getDefaultQueryExtent(): Vector3;
  122682. /**
  122683. * Release all resources
  122684. */
  122685. dispose(): void;
  122686. }
  122687. }
  122688. declare module BABYLON {
  122689. /**
  122690. * Class used to enable access to IndexedDB
  122691. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  122692. */
  122693. export class Database implements IOfflineProvider {
  122694. private _callbackManifestChecked;
  122695. private _currentSceneUrl;
  122696. private _db;
  122697. private _enableSceneOffline;
  122698. private _enableTexturesOffline;
  122699. private _manifestVersionFound;
  122700. private _mustUpdateRessources;
  122701. private _hasReachedQuota;
  122702. private _isSupported;
  122703. private _idbFactory;
  122704. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  122705. private static IsUASupportingBlobStorage;
  122706. /**
  122707. * Gets a boolean indicating if Database storate is enabled (off by default)
  122708. */
  122709. static IDBStorageEnabled: boolean;
  122710. /**
  122711. * Gets a boolean indicating if scene must be saved in the database
  122712. */
  122713. readonly enableSceneOffline: boolean;
  122714. /**
  122715. * Gets a boolean indicating if textures must be saved in the database
  122716. */
  122717. readonly enableTexturesOffline: boolean;
  122718. /**
  122719. * Creates a new Database
  122720. * @param urlToScene defines the url to load the scene
  122721. * @param callbackManifestChecked defines the callback to use when manifest is checked
  122722. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  122723. */
  122724. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  122725. private static _ParseURL;
  122726. private static _ReturnFullUrlLocation;
  122727. private _checkManifestFile;
  122728. /**
  122729. * Open the database and make it available
  122730. * @param successCallback defines the callback to call on success
  122731. * @param errorCallback defines the callback to call on error
  122732. */
  122733. open(successCallback: () => void, errorCallback: () => void): void;
  122734. /**
  122735. * Loads an image from the database
  122736. * @param url defines the url to load from
  122737. * @param image defines the target DOM image
  122738. */
  122739. loadImage(url: string, image: HTMLImageElement): void;
  122740. private _loadImageFromDBAsync;
  122741. private _saveImageIntoDBAsync;
  122742. private _checkVersionFromDB;
  122743. private _loadVersionFromDBAsync;
  122744. private _saveVersionIntoDBAsync;
  122745. /**
  122746. * Loads a file from database
  122747. * @param url defines the URL to load from
  122748. * @param sceneLoaded defines a callback to call on success
  122749. * @param progressCallBack defines a callback to call when progress changed
  122750. * @param errorCallback defines a callback to call on error
  122751. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  122752. */
  122753. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  122754. private _loadFileAsync;
  122755. private _saveFileAsync;
  122756. /**
  122757. * Validates if xhr data is correct
  122758. * @param xhr defines the request to validate
  122759. * @param dataType defines the expected data type
  122760. * @returns true if data is correct
  122761. */
  122762. private static _ValidateXHRData;
  122763. }
  122764. }
  122765. declare module BABYLON {
  122766. /** @hidden */
  122767. export var gpuUpdateParticlesPixelShader: {
  122768. name: string;
  122769. shader: string;
  122770. };
  122771. }
  122772. declare module BABYLON {
  122773. /** @hidden */
  122774. export var gpuUpdateParticlesVertexShader: {
  122775. name: string;
  122776. shader: string;
  122777. };
  122778. }
  122779. declare module BABYLON {
  122780. /** @hidden */
  122781. export var clipPlaneFragmentDeclaration2: {
  122782. name: string;
  122783. shader: string;
  122784. };
  122785. }
  122786. declare module BABYLON {
  122787. /** @hidden */
  122788. export var gpuRenderParticlesPixelShader: {
  122789. name: string;
  122790. shader: string;
  122791. };
  122792. }
  122793. declare module BABYLON {
  122794. /** @hidden */
  122795. export var clipPlaneVertexDeclaration2: {
  122796. name: string;
  122797. shader: string;
  122798. };
  122799. }
  122800. declare module BABYLON {
  122801. /** @hidden */
  122802. export var gpuRenderParticlesVertexShader: {
  122803. name: string;
  122804. shader: string;
  122805. };
  122806. }
  122807. declare module BABYLON {
  122808. /**
  122809. * This represents a GPU particle system in Babylon
  122810. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  122811. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  122812. */
  122813. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  122814. /**
  122815. * The layer mask we are rendering the particles through.
  122816. */
  122817. layerMask: number;
  122818. private _capacity;
  122819. private _activeCount;
  122820. private _currentActiveCount;
  122821. private _accumulatedCount;
  122822. private _renderEffect;
  122823. private _updateEffect;
  122824. private _buffer0;
  122825. private _buffer1;
  122826. private _spriteBuffer;
  122827. private _updateVAO;
  122828. private _renderVAO;
  122829. private _targetIndex;
  122830. private _sourceBuffer;
  122831. private _targetBuffer;
  122832. private _engine;
  122833. private _currentRenderId;
  122834. private _started;
  122835. private _stopped;
  122836. private _timeDelta;
  122837. private _randomTexture;
  122838. private _randomTexture2;
  122839. private _attributesStrideSize;
  122840. private _updateEffectOptions;
  122841. private _randomTextureSize;
  122842. private _actualFrame;
  122843. private readonly _rawTextureWidth;
  122844. /**
  122845. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  122846. */
  122847. static readonly IsSupported: boolean;
  122848. /**
  122849. * An event triggered when the system is disposed.
  122850. */
  122851. onDisposeObservable: Observable<GPUParticleSystem>;
  122852. /**
  122853. * Gets the maximum number of particles active at the same time.
  122854. * @returns The max number of active particles.
  122855. */
  122856. getCapacity(): number;
  122857. /**
  122858. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  122859. * to override the particles.
  122860. */
  122861. forceDepthWrite: boolean;
  122862. /**
  122863. * Gets or set the number of active particles
  122864. */
  122865. activeParticleCount: number;
  122866. private _preWarmDone;
  122867. /**
  122868. * Is this system ready to be used/rendered
  122869. * @return true if the system is ready
  122870. */
  122871. isReady(): boolean;
  122872. /**
  122873. * Gets if the system has been started. (Note: this will still be true after stop is called)
  122874. * @returns True if it has been started, otherwise false.
  122875. */
  122876. isStarted(): boolean;
  122877. /**
  122878. * Starts the particle system and begins to emit
  122879. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  122880. */
  122881. start(delay?: number): void;
  122882. /**
  122883. * Stops the particle system.
  122884. */
  122885. stop(): void;
  122886. /**
  122887. * Remove all active particles
  122888. */
  122889. reset(): void;
  122890. /**
  122891. * Returns the string "GPUParticleSystem"
  122892. * @returns a string containing the class name
  122893. */
  122894. getClassName(): string;
  122895. private _colorGradientsTexture;
  122896. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  122897. /**
  122898. * Adds a new color gradient
  122899. * @param gradient defines the gradient to use (between 0 and 1)
  122900. * @param color1 defines the color to affect to the specified gradient
  122901. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  122902. * @returns the current particle system
  122903. */
  122904. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  122905. /**
  122906. * Remove a specific color gradient
  122907. * @param gradient defines the gradient to remove
  122908. * @returns the current particle system
  122909. */
  122910. removeColorGradient(gradient: number): GPUParticleSystem;
  122911. private _angularSpeedGradientsTexture;
  122912. private _sizeGradientsTexture;
  122913. private _velocityGradientsTexture;
  122914. private _limitVelocityGradientsTexture;
  122915. private _dragGradientsTexture;
  122916. private _addFactorGradient;
  122917. /**
  122918. * Adds a new size gradient
  122919. * @param gradient defines the gradient to use (between 0 and 1)
  122920. * @param factor defines the size factor to affect to the specified gradient
  122921. * @returns the current particle system
  122922. */
  122923. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  122924. /**
  122925. * Remove a specific size gradient
  122926. * @param gradient defines the gradient to remove
  122927. * @returns the current particle system
  122928. */
  122929. removeSizeGradient(gradient: number): GPUParticleSystem;
  122930. /**
  122931. * Adds a new angular speed gradient
  122932. * @param gradient defines the gradient to use (between 0 and 1)
  122933. * @param factor defines the angular speed to affect to the specified gradient
  122934. * @returns the current particle system
  122935. */
  122936. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  122937. /**
  122938. * Remove a specific angular speed gradient
  122939. * @param gradient defines the gradient to remove
  122940. * @returns the current particle system
  122941. */
  122942. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  122943. /**
  122944. * Adds a new velocity gradient
  122945. * @param gradient defines the gradient to use (between 0 and 1)
  122946. * @param factor defines the velocity to affect to the specified gradient
  122947. * @returns the current particle system
  122948. */
  122949. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  122950. /**
  122951. * Remove a specific velocity gradient
  122952. * @param gradient defines the gradient to remove
  122953. * @returns the current particle system
  122954. */
  122955. removeVelocityGradient(gradient: number): GPUParticleSystem;
  122956. /**
  122957. * Adds a new limit velocity gradient
  122958. * @param gradient defines the gradient to use (between 0 and 1)
  122959. * @param factor defines the limit velocity value to affect to the specified gradient
  122960. * @returns the current particle system
  122961. */
  122962. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  122963. /**
  122964. * Remove a specific limit velocity gradient
  122965. * @param gradient defines the gradient to remove
  122966. * @returns the current particle system
  122967. */
  122968. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  122969. /**
  122970. * Adds a new drag gradient
  122971. * @param gradient defines the gradient to use (between 0 and 1)
  122972. * @param factor defines the drag value to affect to the specified gradient
  122973. * @returns the current particle system
  122974. */
  122975. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  122976. /**
  122977. * Remove a specific drag gradient
  122978. * @param gradient defines the gradient to remove
  122979. * @returns the current particle system
  122980. */
  122981. removeDragGradient(gradient: number): GPUParticleSystem;
  122982. /**
  122983. * Not supported by GPUParticleSystem
  122984. * @param gradient defines the gradient to use (between 0 and 1)
  122985. * @param factor defines the emit rate value to affect to the specified gradient
  122986. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  122987. * @returns the current particle system
  122988. */
  122989. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  122990. /**
  122991. * Not supported by GPUParticleSystem
  122992. * @param gradient defines the gradient to remove
  122993. * @returns the current particle system
  122994. */
  122995. removeEmitRateGradient(gradient: number): IParticleSystem;
  122996. /**
  122997. * Not supported by GPUParticleSystem
  122998. * @param gradient defines the gradient to use (between 0 and 1)
  122999. * @param factor defines the start size value to affect to the specified gradient
  123000. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  123001. * @returns the current particle system
  123002. */
  123003. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  123004. /**
  123005. * Not supported by GPUParticleSystem
  123006. * @param gradient defines the gradient to remove
  123007. * @returns the current particle system
  123008. */
  123009. removeStartSizeGradient(gradient: number): IParticleSystem;
  123010. /**
  123011. * Not supported by GPUParticleSystem
  123012. * @param gradient defines the gradient to use (between 0 and 1)
  123013. * @param min defines the color remap minimal range
  123014. * @param max defines the color remap maximal range
  123015. * @returns the current particle system
  123016. */
  123017. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  123018. /**
  123019. * Not supported by GPUParticleSystem
  123020. * @param gradient defines the gradient to remove
  123021. * @returns the current particle system
  123022. */
  123023. removeColorRemapGradient(): IParticleSystem;
  123024. /**
  123025. * Not supported by GPUParticleSystem
  123026. * @param gradient defines the gradient to use (between 0 and 1)
  123027. * @param min defines the alpha remap minimal range
  123028. * @param max defines the alpha remap maximal range
  123029. * @returns the current particle system
  123030. */
  123031. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  123032. /**
  123033. * Not supported by GPUParticleSystem
  123034. * @param gradient defines the gradient to remove
  123035. * @returns the current particle system
  123036. */
  123037. removeAlphaRemapGradient(): IParticleSystem;
  123038. /**
  123039. * Not supported by GPUParticleSystem
  123040. * @param gradient defines the gradient to use (between 0 and 1)
  123041. * @param color defines the color to affect to the specified gradient
  123042. * @returns the current particle system
  123043. */
  123044. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  123045. /**
  123046. * Not supported by GPUParticleSystem
  123047. * @param gradient defines the gradient to remove
  123048. * @returns the current particle system
  123049. */
  123050. removeRampGradient(): IParticleSystem;
  123051. /**
  123052. * Not supported by GPUParticleSystem
  123053. * @returns the list of ramp gradients
  123054. */
  123055. getRampGradients(): Nullable<Array<Color3Gradient>>;
  123056. /**
  123057. * Not supported by GPUParticleSystem
  123058. * Gets or sets a boolean indicating that ramp gradients must be used
  123059. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  123060. */
  123061. useRampGradients: boolean;
  123062. /**
  123063. * Not supported by GPUParticleSystem
  123064. * @param gradient defines the gradient to use (between 0 and 1)
  123065. * @param factor defines the life time factor to affect to the specified gradient
  123066. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  123067. * @returns the current particle system
  123068. */
  123069. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  123070. /**
  123071. * Not supported by GPUParticleSystem
  123072. * @param gradient defines the gradient to remove
  123073. * @returns the current particle system
  123074. */
  123075. removeLifeTimeGradient(gradient: number): IParticleSystem;
  123076. /**
  123077. * Instantiates a GPU particle system.
  123078. * 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.
  123079. * @param name The name of the particle system
  123080. * @param options The options used to create the system
  123081. * @param scene The scene the particle system belongs to
  123082. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  123083. */
  123084. constructor(name: string, options: Partial<{
  123085. capacity: number;
  123086. randomTextureSize: number;
  123087. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  123088. protected _reset(): void;
  123089. private _createUpdateVAO;
  123090. private _createRenderVAO;
  123091. private _initialize;
  123092. /** @hidden */
  123093. _recreateUpdateEffect(): void;
  123094. /** @hidden */
  123095. _recreateRenderEffect(): void;
  123096. /**
  123097. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  123098. * @param preWarm defines if we are in the pre-warmimg phase
  123099. */
  123100. animate(preWarm?: boolean): void;
  123101. private _createFactorGradientTexture;
  123102. private _createSizeGradientTexture;
  123103. private _createAngularSpeedGradientTexture;
  123104. private _createVelocityGradientTexture;
  123105. private _createLimitVelocityGradientTexture;
  123106. private _createDragGradientTexture;
  123107. private _createColorGradientTexture;
  123108. /**
  123109. * Renders the particle system in its current state
  123110. * @param preWarm defines if the system should only update the particles but not render them
  123111. * @returns the current number of particles
  123112. */
  123113. render(preWarm?: boolean): number;
  123114. /**
  123115. * Rebuilds the particle system
  123116. */
  123117. rebuild(): void;
  123118. private _releaseBuffers;
  123119. private _releaseVAOs;
  123120. /**
  123121. * Disposes the particle system and free the associated resources
  123122. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  123123. */
  123124. dispose(disposeTexture?: boolean): void;
  123125. /**
  123126. * Clones the particle system.
  123127. * @param name The name of the cloned object
  123128. * @param newEmitter The new emitter to use
  123129. * @returns the cloned particle system
  123130. */
  123131. clone(name: string, newEmitter: any): GPUParticleSystem;
  123132. /**
  123133. * Serializes the particle system to a JSON object.
  123134. * @returns the JSON object
  123135. */
  123136. serialize(): any;
  123137. /**
  123138. * Parses a JSON object to create a GPU particle system.
  123139. * @param parsedParticleSystem The JSON object to parse
  123140. * @param scene The scene to create the particle system in
  123141. * @param rootUrl The root url to use to load external dependencies like texture
  123142. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  123143. * @returns the parsed GPU particle system
  123144. */
  123145. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  123146. }
  123147. }
  123148. declare module BABYLON {
  123149. /**
  123150. * Represents a set of particle systems working together to create a specific effect
  123151. */
  123152. export class ParticleSystemSet implements IDisposable {
  123153. private _emitterCreationOptions;
  123154. private _emitterNode;
  123155. /**
  123156. * Gets the particle system list
  123157. */
  123158. systems: IParticleSystem[];
  123159. /**
  123160. * Gets the emitter node used with this set
  123161. */
  123162. readonly emitterNode: Nullable<TransformNode>;
  123163. /**
  123164. * Creates a new emitter mesh as a sphere
  123165. * @param options defines the options used to create the sphere
  123166. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  123167. * @param scene defines the hosting scene
  123168. */
  123169. setEmitterAsSphere(options: {
  123170. diameter: number;
  123171. segments: number;
  123172. color: Color3;
  123173. }, renderingGroupId: number, scene: Scene): void;
  123174. /**
  123175. * Starts all particle systems of the set
  123176. * @param emitter defines an optional mesh to use as emitter for the particle systems
  123177. */
  123178. start(emitter?: AbstractMesh): void;
  123179. /**
  123180. * Release all associated resources
  123181. */
  123182. dispose(): void;
  123183. /**
  123184. * Serialize the set into a JSON compatible object
  123185. * @returns a JSON compatible representation of the set
  123186. */
  123187. serialize(): any;
  123188. /**
  123189. * Parse a new ParticleSystemSet from a serialized source
  123190. * @param data defines a JSON compatible representation of the set
  123191. * @param scene defines the hosting scene
  123192. * @param gpu defines if we want GPU particles or CPU particles
  123193. * @returns a new ParticleSystemSet
  123194. */
  123195. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  123196. }
  123197. }
  123198. declare module BABYLON {
  123199. /**
  123200. * This class is made for on one-liner static method to help creating particle system set.
  123201. */
  123202. export class ParticleHelper {
  123203. /**
  123204. * Gets or sets base Assets URL
  123205. */
  123206. static BaseAssetsUrl: string;
  123207. /**
  123208. * Create a default particle system that you can tweak
  123209. * @param emitter defines the emitter to use
  123210. * @param capacity defines the system capacity (default is 500 particles)
  123211. * @param scene defines the hosting scene
  123212. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  123213. * @returns the new Particle system
  123214. */
  123215. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  123216. /**
  123217. * This is the main static method (one-liner) of this helper to create different particle systems
  123218. * @param type This string represents the type to the particle system to create
  123219. * @param scene The scene where the particle system should live
  123220. * @param gpu If the system will use gpu
  123221. * @returns the ParticleSystemSet created
  123222. */
  123223. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  123224. /**
  123225. * Static function used to export a particle system to a ParticleSystemSet variable.
  123226. * Please note that the emitter shape is not exported
  123227. * @param systems defines the particle systems to export
  123228. * @returns the created particle system set
  123229. */
  123230. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  123231. }
  123232. }
  123233. declare module BABYLON {
  123234. interface Engine {
  123235. /**
  123236. * Create an effect to use with particle systems.
  123237. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  123238. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  123239. * @param uniformsNames defines a list of attribute names
  123240. * @param samplers defines an array of string used to represent textures
  123241. * @param defines defines the string containing the defines to use to compile the shaders
  123242. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  123243. * @param onCompiled defines a function to call when the effect creation is successful
  123244. * @param onError defines a function to call when the effect creation has failed
  123245. * @returns the new Effect
  123246. */
  123247. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  123248. }
  123249. interface Mesh {
  123250. /**
  123251. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  123252. * @returns an array of IParticleSystem
  123253. */
  123254. getEmittedParticleSystems(): IParticleSystem[];
  123255. /**
  123256. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  123257. * @returns an array of IParticleSystem
  123258. */
  123259. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  123260. }
  123261. /**
  123262. * @hidden
  123263. */
  123264. export var _IDoNeedToBeInTheBuild: number;
  123265. }
  123266. declare module BABYLON {
  123267. interface Scene {
  123268. /** @hidden (Backing field) */
  123269. _physicsEngine: Nullable<IPhysicsEngine>;
  123270. /**
  123271. * Gets the current physics engine
  123272. * @returns a IPhysicsEngine or null if none attached
  123273. */
  123274. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  123275. /**
  123276. * Enables physics to the current scene
  123277. * @param gravity defines the scene's gravity for the physics engine
  123278. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  123279. * @return a boolean indicating if the physics engine was initialized
  123280. */
  123281. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  123282. /**
  123283. * Disables and disposes the physics engine associated with the scene
  123284. */
  123285. disablePhysicsEngine(): void;
  123286. /**
  123287. * Gets a boolean indicating if there is an active physics engine
  123288. * @returns a boolean indicating if there is an active physics engine
  123289. */
  123290. isPhysicsEnabled(): boolean;
  123291. /**
  123292. * Deletes a physics compound impostor
  123293. * @param compound defines the compound to delete
  123294. */
  123295. deleteCompoundImpostor(compound: any): void;
  123296. /**
  123297. * An event triggered when physic simulation is about to be run
  123298. */
  123299. onBeforePhysicsObservable: Observable<Scene>;
  123300. /**
  123301. * An event triggered when physic simulation has been done
  123302. */
  123303. onAfterPhysicsObservable: Observable<Scene>;
  123304. }
  123305. interface AbstractMesh {
  123306. /** @hidden */
  123307. _physicsImpostor: Nullable<PhysicsImpostor>;
  123308. /**
  123309. * Gets or sets impostor used for physic simulation
  123310. * @see http://doc.babylonjs.com/features/physics_engine
  123311. */
  123312. physicsImpostor: Nullable<PhysicsImpostor>;
  123313. /**
  123314. * Gets the current physics impostor
  123315. * @see http://doc.babylonjs.com/features/physics_engine
  123316. * @returns a physics impostor or null
  123317. */
  123318. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  123319. /** Apply a physic impulse to the mesh
  123320. * @param force defines the force to apply
  123321. * @param contactPoint defines where to apply the force
  123322. * @returns the current mesh
  123323. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  123324. */
  123325. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  123326. /**
  123327. * Creates a physic joint between two meshes
  123328. * @param otherMesh defines the other mesh to use
  123329. * @param pivot1 defines the pivot to use on this mesh
  123330. * @param pivot2 defines the pivot to use on the other mesh
  123331. * @param options defines additional options (can be plugin dependent)
  123332. * @returns the current mesh
  123333. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  123334. */
  123335. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  123336. /** @hidden */
  123337. _disposePhysicsObserver: Nullable<Observer<Node>>;
  123338. }
  123339. /**
  123340. * Defines the physics engine scene component responsible to manage a physics engine
  123341. */
  123342. export class PhysicsEngineSceneComponent implements ISceneComponent {
  123343. /**
  123344. * The component name helpful to identify the component in the list of scene components.
  123345. */
  123346. readonly name: string;
  123347. /**
  123348. * The scene the component belongs to.
  123349. */
  123350. scene: Scene;
  123351. /**
  123352. * Creates a new instance of the component for the given scene
  123353. * @param scene Defines the scene to register the component in
  123354. */
  123355. constructor(scene: Scene);
  123356. /**
  123357. * Registers the component in a given scene
  123358. */
  123359. register(): void;
  123360. /**
  123361. * Rebuilds the elements related to this component in case of
  123362. * context lost for instance.
  123363. */
  123364. rebuild(): void;
  123365. /**
  123366. * Disposes the component and the associated ressources
  123367. */
  123368. dispose(): void;
  123369. }
  123370. }
  123371. declare module BABYLON {
  123372. /**
  123373. * A helper for physics simulations
  123374. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123375. */
  123376. export class PhysicsHelper {
  123377. private _scene;
  123378. private _physicsEngine;
  123379. /**
  123380. * Initializes the Physics helper
  123381. * @param scene Babylon.js scene
  123382. */
  123383. constructor(scene: Scene);
  123384. /**
  123385. * Applies a radial explosion impulse
  123386. * @param origin the origin of the explosion
  123387. * @param radiusOrEventOptions the radius or the options of radial explosion
  123388. * @param strength the explosion strength
  123389. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123390. * @returns A physics radial explosion event, or null
  123391. */
  123392. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  123393. /**
  123394. * Applies a radial explosion force
  123395. * @param origin the origin of the explosion
  123396. * @param radiusOrEventOptions the radius or the options of radial explosion
  123397. * @param strength the explosion strength
  123398. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123399. * @returns A physics radial explosion event, or null
  123400. */
  123401. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  123402. /**
  123403. * Creates a gravitational field
  123404. * @param origin the origin of the explosion
  123405. * @param radiusOrEventOptions the radius or the options of radial explosion
  123406. * @param strength the explosion strength
  123407. * @param falloff possible options: Constant & Linear. Defaults to Constant
  123408. * @returns A physics gravitational field event, or null
  123409. */
  123410. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  123411. /**
  123412. * Creates a physics updraft event
  123413. * @param origin the origin of the updraft
  123414. * @param radiusOrEventOptions the radius or the options of the updraft
  123415. * @param strength the strength of the updraft
  123416. * @param height the height of the updraft
  123417. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  123418. * @returns A physics updraft event, or null
  123419. */
  123420. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  123421. /**
  123422. * Creates a physics vortex event
  123423. * @param origin the of the vortex
  123424. * @param radiusOrEventOptions the radius or the options of the vortex
  123425. * @param strength the strength of the vortex
  123426. * @param height the height of the vortex
  123427. * @returns a Physics vortex event, or null
  123428. * A physics vortex event or null
  123429. */
  123430. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  123431. }
  123432. /**
  123433. * Represents a physics radial explosion event
  123434. */
  123435. class PhysicsRadialExplosionEvent {
  123436. private _scene;
  123437. private _options;
  123438. private _sphere;
  123439. private _dataFetched;
  123440. /**
  123441. * Initializes a radial explosioin event
  123442. * @param _scene BabylonJS scene
  123443. * @param _options The options for the vortex event
  123444. */
  123445. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  123446. /**
  123447. * Returns the data related to the radial explosion event (sphere).
  123448. * @returns The radial explosion event data
  123449. */
  123450. getData(): PhysicsRadialExplosionEventData;
  123451. /**
  123452. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  123453. * @param impostor A physics imposter
  123454. * @param origin the origin of the explosion
  123455. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  123456. */
  123457. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  123458. /**
  123459. * Triggers affecterd impostors callbacks
  123460. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  123461. */
  123462. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  123463. /**
  123464. * Disposes the sphere.
  123465. * @param force Specifies if the sphere should be disposed by force
  123466. */
  123467. dispose(force?: boolean): void;
  123468. /*** Helpers ***/
  123469. private _prepareSphere;
  123470. private _intersectsWithSphere;
  123471. }
  123472. /**
  123473. * Represents a gravitational field event
  123474. */
  123475. class PhysicsGravitationalFieldEvent {
  123476. private _physicsHelper;
  123477. private _scene;
  123478. private _origin;
  123479. private _options;
  123480. private _tickCallback;
  123481. private _sphere;
  123482. private _dataFetched;
  123483. /**
  123484. * Initializes the physics gravitational field event
  123485. * @param _physicsHelper A physics helper
  123486. * @param _scene BabylonJS scene
  123487. * @param _origin The origin position of the gravitational field event
  123488. * @param _options The options for the vortex event
  123489. */
  123490. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  123491. /**
  123492. * Returns the data related to the gravitational field event (sphere).
  123493. * @returns A gravitational field event
  123494. */
  123495. getData(): PhysicsGravitationalFieldEventData;
  123496. /**
  123497. * Enables the gravitational field.
  123498. */
  123499. enable(): void;
  123500. /**
  123501. * Disables the gravitational field.
  123502. */
  123503. disable(): void;
  123504. /**
  123505. * Disposes the sphere.
  123506. * @param force The force to dispose from the gravitational field event
  123507. */
  123508. dispose(force?: boolean): void;
  123509. private _tick;
  123510. }
  123511. /**
  123512. * Represents a physics updraft event
  123513. */
  123514. class PhysicsUpdraftEvent {
  123515. private _scene;
  123516. private _origin;
  123517. private _options;
  123518. private _physicsEngine;
  123519. private _originTop;
  123520. private _originDirection;
  123521. private _tickCallback;
  123522. private _cylinder;
  123523. private _cylinderPosition;
  123524. private _dataFetched;
  123525. /**
  123526. * Initializes the physics updraft event
  123527. * @param _scene BabylonJS scene
  123528. * @param _origin The origin position of the updraft
  123529. * @param _options The options for the updraft event
  123530. */
  123531. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  123532. /**
  123533. * Returns the data related to the updraft event (cylinder).
  123534. * @returns A physics updraft event
  123535. */
  123536. getData(): PhysicsUpdraftEventData;
  123537. /**
  123538. * Enables the updraft.
  123539. */
  123540. enable(): void;
  123541. /**
  123542. * Disables the updraft.
  123543. */
  123544. disable(): void;
  123545. /**
  123546. * Disposes the cylinder.
  123547. * @param force Specifies if the updraft should be disposed by force
  123548. */
  123549. dispose(force?: boolean): void;
  123550. private getImpostorHitData;
  123551. private _tick;
  123552. /*** Helpers ***/
  123553. private _prepareCylinder;
  123554. private _intersectsWithCylinder;
  123555. }
  123556. /**
  123557. * Represents a physics vortex event
  123558. */
  123559. class PhysicsVortexEvent {
  123560. private _scene;
  123561. private _origin;
  123562. private _options;
  123563. private _physicsEngine;
  123564. private _originTop;
  123565. private _tickCallback;
  123566. private _cylinder;
  123567. private _cylinderPosition;
  123568. private _dataFetched;
  123569. /**
  123570. * Initializes the physics vortex event
  123571. * @param _scene The BabylonJS scene
  123572. * @param _origin The origin position of the vortex
  123573. * @param _options The options for the vortex event
  123574. */
  123575. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  123576. /**
  123577. * Returns the data related to the vortex event (cylinder).
  123578. * @returns The physics vortex event data
  123579. */
  123580. getData(): PhysicsVortexEventData;
  123581. /**
  123582. * Enables the vortex.
  123583. */
  123584. enable(): void;
  123585. /**
  123586. * Disables the cortex.
  123587. */
  123588. disable(): void;
  123589. /**
  123590. * Disposes the sphere.
  123591. * @param force
  123592. */
  123593. dispose(force?: boolean): void;
  123594. private getImpostorHitData;
  123595. private _tick;
  123596. /*** Helpers ***/
  123597. private _prepareCylinder;
  123598. private _intersectsWithCylinder;
  123599. }
  123600. /**
  123601. * Options fot the radial explosion event
  123602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123603. */
  123604. export class PhysicsRadialExplosionEventOptions {
  123605. /**
  123606. * The radius of the sphere for the radial explosion.
  123607. */
  123608. radius: number;
  123609. /**
  123610. * The strenth of the explosion.
  123611. */
  123612. strength: number;
  123613. /**
  123614. * The strenght of the force in correspondence to the distance of the affected object
  123615. */
  123616. falloff: PhysicsRadialImpulseFalloff;
  123617. /**
  123618. * Sphere options for the radial explosion.
  123619. */
  123620. sphere: {
  123621. segments: number;
  123622. diameter: number;
  123623. };
  123624. /**
  123625. * Sphere options for the radial explosion.
  123626. */
  123627. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  123628. }
  123629. /**
  123630. * Options fot the updraft event
  123631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123632. */
  123633. export class PhysicsUpdraftEventOptions {
  123634. /**
  123635. * The radius of the cylinder for the vortex
  123636. */
  123637. radius: number;
  123638. /**
  123639. * The strenth of the updraft.
  123640. */
  123641. strength: number;
  123642. /**
  123643. * The height of the cylinder for the updraft.
  123644. */
  123645. height: number;
  123646. /**
  123647. * The mode for the the updraft.
  123648. */
  123649. updraftMode: PhysicsUpdraftMode;
  123650. }
  123651. /**
  123652. * Options fot the vortex event
  123653. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123654. */
  123655. export class PhysicsVortexEventOptions {
  123656. /**
  123657. * The radius of the cylinder for the vortex
  123658. */
  123659. radius: number;
  123660. /**
  123661. * The strenth of the vortex.
  123662. */
  123663. strength: number;
  123664. /**
  123665. * The height of the cylinder for the vortex.
  123666. */
  123667. height: number;
  123668. /**
  123669. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  123670. */
  123671. centripetalForceThreshold: number;
  123672. /**
  123673. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  123674. */
  123675. centripetalForceMultiplier: number;
  123676. /**
  123677. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  123678. */
  123679. centrifugalForceMultiplier: number;
  123680. /**
  123681. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  123682. */
  123683. updraftForceMultiplier: number;
  123684. }
  123685. /**
  123686. * The strenght of the force in correspondence to the distance of the affected object
  123687. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123688. */
  123689. export enum PhysicsRadialImpulseFalloff {
  123690. /** Defines that impulse is constant in strength across it's whole radius */
  123691. Constant = 0,
  123692. /** Defines that impulse gets weaker if it's further from the origin */
  123693. Linear = 1
  123694. }
  123695. /**
  123696. * The strength of the force in correspondence to the distance of the affected object
  123697. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123698. */
  123699. export enum PhysicsUpdraftMode {
  123700. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  123701. Center = 0,
  123702. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  123703. Perpendicular = 1
  123704. }
  123705. /**
  123706. * Interface for a physics hit data
  123707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123708. */
  123709. export interface PhysicsHitData {
  123710. /**
  123711. * The force applied at the contact point
  123712. */
  123713. force: Vector3;
  123714. /**
  123715. * The contact point
  123716. */
  123717. contactPoint: Vector3;
  123718. /**
  123719. * The distance from the origin to the contact point
  123720. */
  123721. distanceFromOrigin: number;
  123722. }
  123723. /**
  123724. * Interface for radial explosion event data
  123725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123726. */
  123727. export interface PhysicsRadialExplosionEventData {
  123728. /**
  123729. * A sphere used for the radial explosion event
  123730. */
  123731. sphere: Mesh;
  123732. }
  123733. /**
  123734. * Interface for gravitational field event data
  123735. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123736. */
  123737. export interface PhysicsGravitationalFieldEventData {
  123738. /**
  123739. * A sphere mesh used for the gravitational field event
  123740. */
  123741. sphere: Mesh;
  123742. }
  123743. /**
  123744. * Interface for updraft event data
  123745. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123746. */
  123747. export interface PhysicsUpdraftEventData {
  123748. /**
  123749. * A cylinder used for the updraft event
  123750. */
  123751. cylinder: Mesh;
  123752. }
  123753. /**
  123754. * Interface for vortex event data
  123755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123756. */
  123757. export interface PhysicsVortexEventData {
  123758. /**
  123759. * A cylinder used for the vortex event
  123760. */
  123761. cylinder: Mesh;
  123762. }
  123763. /**
  123764. * Interface for an affected physics impostor
  123765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  123766. */
  123767. export interface PhysicsAffectedImpostorWithData {
  123768. /**
  123769. * The impostor affected by the effect
  123770. */
  123771. impostor: PhysicsImpostor;
  123772. /**
  123773. * The data about the hit/horce from the explosion
  123774. */
  123775. hitData: PhysicsHitData;
  123776. }
  123777. }
  123778. declare module BABYLON {
  123779. /** @hidden */
  123780. export var blackAndWhitePixelShader: {
  123781. name: string;
  123782. shader: string;
  123783. };
  123784. }
  123785. declare module BABYLON {
  123786. /**
  123787. * Post process used to render in black and white
  123788. */
  123789. export class BlackAndWhitePostProcess extends PostProcess {
  123790. /**
  123791. * Linear about to convert he result to black and white (default: 1)
  123792. */
  123793. degree: number;
  123794. /**
  123795. * Creates a black and white post process
  123796. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  123797. * @param name The name of the effect.
  123798. * @param options The required width/height ratio to downsize to before computing the render pass.
  123799. * @param camera The camera to apply the render pass to.
  123800. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123801. * @param engine The engine which the post process will be applied. (default: current engine)
  123802. * @param reusable If the post process can be reused on the same frame. (default: false)
  123803. */
  123804. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  123805. }
  123806. }
  123807. declare module BABYLON {
  123808. /**
  123809. * This represents a set of one or more post processes in Babylon.
  123810. * A post process can be used to apply a shader to a texture after it is rendered.
  123811. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  123812. */
  123813. export class PostProcessRenderEffect {
  123814. private _postProcesses;
  123815. private _getPostProcesses;
  123816. private _singleInstance;
  123817. private _cameras;
  123818. private _indicesForCamera;
  123819. /**
  123820. * Name of the effect
  123821. * @hidden
  123822. */
  123823. _name: string;
  123824. /**
  123825. * Instantiates a post process render effect.
  123826. * A post process can be used to apply a shader to a texture after it is rendered.
  123827. * @param engine The engine the effect is tied to
  123828. * @param name The name of the effect
  123829. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  123830. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  123831. */
  123832. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  123833. /**
  123834. * Checks if all the post processes in the effect are supported.
  123835. */
  123836. readonly isSupported: boolean;
  123837. /**
  123838. * Updates the current state of the effect
  123839. * @hidden
  123840. */
  123841. _update(): void;
  123842. /**
  123843. * Attaches the effect on cameras
  123844. * @param cameras The camera to attach to.
  123845. * @hidden
  123846. */
  123847. _attachCameras(cameras: Camera): void;
  123848. /**
  123849. * Attaches the effect on cameras
  123850. * @param cameras The camera to attach to.
  123851. * @hidden
  123852. */
  123853. _attachCameras(cameras: Camera[]): void;
  123854. /**
  123855. * Detaches the effect on cameras
  123856. * @param cameras The camera to detatch from.
  123857. * @hidden
  123858. */
  123859. _detachCameras(cameras: Camera): void;
  123860. /**
  123861. * Detatches the effect on cameras
  123862. * @param cameras The camera to detatch from.
  123863. * @hidden
  123864. */
  123865. _detachCameras(cameras: Camera[]): void;
  123866. /**
  123867. * Enables the effect on given cameras
  123868. * @param cameras The camera to enable.
  123869. * @hidden
  123870. */
  123871. _enable(cameras: Camera): void;
  123872. /**
  123873. * Enables the effect on given cameras
  123874. * @param cameras The camera to enable.
  123875. * @hidden
  123876. */
  123877. _enable(cameras: Nullable<Camera[]>): void;
  123878. /**
  123879. * Disables the effect on the given cameras
  123880. * @param cameras The camera to disable.
  123881. * @hidden
  123882. */
  123883. _disable(cameras: Camera): void;
  123884. /**
  123885. * Disables the effect on the given cameras
  123886. * @param cameras The camera to disable.
  123887. * @hidden
  123888. */
  123889. _disable(cameras: Nullable<Camera[]>): void;
  123890. /**
  123891. * Gets a list of the post processes contained in the effect.
  123892. * @param camera The camera to get the post processes on.
  123893. * @returns The list of the post processes in the effect.
  123894. */
  123895. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  123896. }
  123897. }
  123898. declare module BABYLON {
  123899. /** @hidden */
  123900. export var extractHighlightsPixelShader: {
  123901. name: string;
  123902. shader: string;
  123903. };
  123904. }
  123905. declare module BABYLON {
  123906. /**
  123907. * 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.
  123908. */
  123909. export class ExtractHighlightsPostProcess extends PostProcess {
  123910. /**
  123911. * The luminance threshold, pixels below this value will be set to black.
  123912. */
  123913. threshold: number;
  123914. /** @hidden */
  123915. _exposure: number;
  123916. /**
  123917. * Post process which has the input texture to be used when performing highlight extraction
  123918. * @hidden
  123919. */
  123920. _inputPostProcess: Nullable<PostProcess>;
  123921. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123922. }
  123923. }
  123924. declare module BABYLON {
  123925. /** @hidden */
  123926. export var bloomMergePixelShader: {
  123927. name: string;
  123928. shader: string;
  123929. };
  123930. }
  123931. declare module BABYLON {
  123932. /**
  123933. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  123934. */
  123935. export class BloomMergePostProcess extends PostProcess {
  123936. /** Weight of the bloom to be added to the original input. */
  123937. weight: number;
  123938. /**
  123939. * Creates a new instance of @see BloomMergePostProcess
  123940. * @param name The name of the effect.
  123941. * @param originalFromInput Post process which's input will be used for the merge.
  123942. * @param blurred Blurred highlights post process which's output will be used.
  123943. * @param weight Weight of the bloom to be added to the original input.
  123944. * @param options The required width/height ratio to downsize to before computing the render pass.
  123945. * @param camera The camera to apply the render pass to.
  123946. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123947. * @param engine The engine which the post process will be applied. (default: current engine)
  123948. * @param reusable If the post process can be reused on the same frame. (default: false)
  123949. * @param textureType Type of textures used when performing the post process. (default: 0)
  123950. * @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)
  123951. */
  123952. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  123953. /** Weight of the bloom to be added to the original input. */
  123954. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123955. }
  123956. }
  123957. declare module BABYLON {
  123958. /**
  123959. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  123960. */
  123961. export class BloomEffect extends PostProcessRenderEffect {
  123962. private bloomScale;
  123963. /**
  123964. * @hidden Internal
  123965. */
  123966. _effects: Array<PostProcess>;
  123967. /**
  123968. * @hidden Internal
  123969. */
  123970. _downscale: ExtractHighlightsPostProcess;
  123971. private _blurX;
  123972. private _blurY;
  123973. private _merge;
  123974. /**
  123975. * The luminance threshold to find bright areas of the image to bloom.
  123976. */
  123977. threshold: number;
  123978. /**
  123979. * The strength of the bloom.
  123980. */
  123981. weight: number;
  123982. /**
  123983. * Specifies the size of the bloom blur kernel, relative to the final output size
  123984. */
  123985. kernel: number;
  123986. /**
  123987. * Creates a new instance of @see BloomEffect
  123988. * @param scene The scene the effect belongs to.
  123989. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  123990. * @param bloomKernel The size of the kernel to be used when applying the blur.
  123991. * @param bloomWeight The the strength of bloom.
  123992. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  123993. * @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)
  123994. */
  123995. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  123996. /**
  123997. * Disposes each of the internal effects for a given camera.
  123998. * @param camera The camera to dispose the effect on.
  123999. */
  124000. disposeEffects(camera: Camera): void;
  124001. /**
  124002. * @hidden Internal
  124003. */
  124004. _updateEffects(): void;
  124005. /**
  124006. * Internal
  124007. * @returns if all the contained post processes are ready.
  124008. * @hidden
  124009. */
  124010. _isReady(): boolean;
  124011. }
  124012. }
  124013. declare module BABYLON {
  124014. /** @hidden */
  124015. export var chromaticAberrationPixelShader: {
  124016. name: string;
  124017. shader: string;
  124018. };
  124019. }
  124020. declare module BABYLON {
  124021. /**
  124022. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  124023. */
  124024. export class ChromaticAberrationPostProcess extends PostProcess {
  124025. /**
  124026. * The amount of seperation of rgb channels (default: 30)
  124027. */
  124028. aberrationAmount: number;
  124029. /**
  124030. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  124031. */
  124032. radialIntensity: number;
  124033. /**
  124034. * 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))
  124035. */
  124036. direction: Vector2;
  124037. /**
  124038. * 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))
  124039. */
  124040. centerPosition: Vector2;
  124041. /**
  124042. * Creates a new instance ChromaticAberrationPostProcess
  124043. * @param name The name of the effect.
  124044. * @param screenWidth The width of the screen to apply the effect on.
  124045. * @param screenHeight The height of the screen to apply the effect on.
  124046. * @param options The required width/height ratio to downsize to before computing the render pass.
  124047. * @param camera The camera to apply the render pass to.
  124048. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124049. * @param engine The engine which the post process will be applied. (default: current engine)
  124050. * @param reusable If the post process can be reused on the same frame. (default: false)
  124051. * @param textureType Type of textures used when performing the post process. (default: 0)
  124052. * @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)
  124053. */
  124054. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124055. }
  124056. }
  124057. declare module BABYLON {
  124058. /** @hidden */
  124059. export var circleOfConfusionPixelShader: {
  124060. name: string;
  124061. shader: string;
  124062. };
  124063. }
  124064. declare module BABYLON {
  124065. /**
  124066. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  124067. */
  124068. export class CircleOfConfusionPostProcess extends PostProcess {
  124069. /**
  124070. * 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.
  124071. */
  124072. lensSize: number;
  124073. /**
  124074. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  124075. */
  124076. fStop: number;
  124077. /**
  124078. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  124079. */
  124080. focusDistance: number;
  124081. /**
  124082. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  124083. */
  124084. focalLength: number;
  124085. private _depthTexture;
  124086. /**
  124087. * Creates a new instance CircleOfConfusionPostProcess
  124088. * @param name The name of the effect.
  124089. * @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.
  124090. * @param options The required width/height ratio to downsize to before computing the render pass.
  124091. * @param camera The camera to apply the render pass to.
  124092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124093. * @param engine The engine which the post process will be applied. (default: current engine)
  124094. * @param reusable If the post process can be reused on the same frame. (default: false)
  124095. * @param textureType Type of textures used when performing the post process. (default: 0)
  124096. * @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)
  124097. */
  124098. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124099. /**
  124100. * 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.
  124101. */
  124102. depthTexture: RenderTargetTexture;
  124103. }
  124104. }
  124105. declare module BABYLON {
  124106. /** @hidden */
  124107. export var colorCorrectionPixelShader: {
  124108. name: string;
  124109. shader: string;
  124110. };
  124111. }
  124112. declare module BABYLON {
  124113. /**
  124114. *
  124115. * This post-process allows the modification of rendered colors by using
  124116. * a 'look-up table' (LUT). This effect is also called Color Grading.
  124117. *
  124118. * The object needs to be provided an url to a texture containing the color
  124119. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  124120. * Use an image editing software to tweak the LUT to match your needs.
  124121. *
  124122. * For an example of a color LUT, see here:
  124123. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  124124. * For explanations on color grading, see here:
  124125. * @see http://udn.epicgames.com/Three/ColorGrading.html
  124126. *
  124127. */
  124128. export class ColorCorrectionPostProcess extends PostProcess {
  124129. private _colorTableTexture;
  124130. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124131. }
  124132. }
  124133. declare module BABYLON {
  124134. /** @hidden */
  124135. export var convolutionPixelShader: {
  124136. name: string;
  124137. shader: string;
  124138. };
  124139. }
  124140. declare module BABYLON {
  124141. /**
  124142. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  124143. * input texture to perform effects such as edge detection or sharpening
  124144. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124145. */
  124146. export class ConvolutionPostProcess extends PostProcess {
  124147. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  124148. kernel: number[];
  124149. /**
  124150. * Creates a new instance ConvolutionPostProcess
  124151. * @param name The name of the effect.
  124152. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  124153. * @param options The required width/height ratio to downsize to before computing the render pass.
  124154. * @param camera The camera to apply the render pass to.
  124155. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124156. * @param engine The engine which the post process will be applied. (default: current engine)
  124157. * @param reusable If the post process can be reused on the same frame. (default: false)
  124158. * @param textureType Type of textures used when performing the post process. (default: 0)
  124159. */
  124160. constructor(name: string,
  124161. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  124162. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124163. /**
  124164. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124165. */
  124166. static EdgeDetect0Kernel: number[];
  124167. /**
  124168. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124169. */
  124170. static EdgeDetect1Kernel: number[];
  124171. /**
  124172. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124173. */
  124174. static EdgeDetect2Kernel: number[];
  124175. /**
  124176. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124177. */
  124178. static SharpenKernel: number[];
  124179. /**
  124180. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124181. */
  124182. static EmbossKernel: number[];
  124183. /**
  124184. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  124185. */
  124186. static GaussianKernel: number[];
  124187. }
  124188. }
  124189. declare module BABYLON {
  124190. /**
  124191. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  124192. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  124193. * based on samples that have a large difference in distance than the center pixel.
  124194. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  124195. */
  124196. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  124197. direction: Vector2;
  124198. /**
  124199. * Creates a new instance CircleOfConfusionPostProcess
  124200. * @param name The name of the effect.
  124201. * @param scene The scene the effect belongs to.
  124202. * @param direction The direction the blur should be applied.
  124203. * @param kernel The size of the kernel used to blur.
  124204. * @param options The required width/height ratio to downsize to before computing the render pass.
  124205. * @param camera The camera to apply the render pass to.
  124206. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  124207. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  124208. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124209. * @param engine The engine which the post process will be applied. (default: current engine)
  124210. * @param reusable If the post process can be reused on the same frame. (default: false)
  124211. * @param textureType Type of textures used when performing the post process. (default: 0)
  124212. * @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)
  124213. */
  124214. 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);
  124215. }
  124216. }
  124217. declare module BABYLON {
  124218. /** @hidden */
  124219. export var depthOfFieldMergePixelShader: {
  124220. name: string;
  124221. shader: string;
  124222. };
  124223. }
  124224. declare module BABYLON {
  124225. /**
  124226. * Options to be set when merging outputs from the default pipeline.
  124227. */
  124228. export class DepthOfFieldMergePostProcessOptions {
  124229. /**
  124230. * The original image to merge on top of
  124231. */
  124232. originalFromInput: PostProcess;
  124233. /**
  124234. * Parameters to perform the merge of the depth of field effect
  124235. */
  124236. depthOfField?: {
  124237. circleOfConfusion: PostProcess;
  124238. blurSteps: Array<PostProcess>;
  124239. };
  124240. /**
  124241. * Parameters to perform the merge of bloom effect
  124242. */
  124243. bloom?: {
  124244. blurred: PostProcess;
  124245. weight: number;
  124246. };
  124247. }
  124248. /**
  124249. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  124250. */
  124251. export class DepthOfFieldMergePostProcess extends PostProcess {
  124252. private blurSteps;
  124253. /**
  124254. * Creates a new instance of DepthOfFieldMergePostProcess
  124255. * @param name The name of the effect.
  124256. * @param originalFromInput Post process which's input will be used for the merge.
  124257. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  124258. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  124259. * @param options The required width/height ratio to downsize to before computing the render pass.
  124260. * @param camera The camera to apply the render pass to.
  124261. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124262. * @param engine The engine which the post process will be applied. (default: current engine)
  124263. * @param reusable If the post process can be reused on the same frame. (default: false)
  124264. * @param textureType Type of textures used when performing the post process. (default: 0)
  124265. * @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)
  124266. */
  124267. 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);
  124268. /**
  124269. * Updates the effect with the current post process compile time values and recompiles the shader.
  124270. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  124271. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  124272. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  124273. * @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
  124274. * @param onCompiled Called when the shader has been compiled.
  124275. * @param onError Called if there is an error when compiling a shader.
  124276. */
  124277. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  124278. }
  124279. }
  124280. declare module BABYLON {
  124281. /**
  124282. * Specifies the level of max blur that should be applied when using the depth of field effect
  124283. */
  124284. export enum DepthOfFieldEffectBlurLevel {
  124285. /**
  124286. * Subtle blur
  124287. */
  124288. Low = 0,
  124289. /**
  124290. * Medium blur
  124291. */
  124292. Medium = 1,
  124293. /**
  124294. * Large blur
  124295. */
  124296. High = 2
  124297. }
  124298. /**
  124299. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  124300. */
  124301. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  124302. private _circleOfConfusion;
  124303. /**
  124304. * @hidden Internal, blurs from high to low
  124305. */
  124306. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  124307. private _depthOfFieldBlurY;
  124308. private _dofMerge;
  124309. /**
  124310. * @hidden Internal post processes in depth of field effect
  124311. */
  124312. _effects: Array<PostProcess>;
  124313. /**
  124314. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  124315. */
  124316. focalLength: number;
  124317. /**
  124318. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  124319. */
  124320. fStop: number;
  124321. /**
  124322. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  124323. */
  124324. focusDistance: number;
  124325. /**
  124326. * 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.
  124327. */
  124328. lensSize: number;
  124329. /**
  124330. * Creates a new instance DepthOfFieldEffect
  124331. * @param scene The scene the effect belongs to.
  124332. * @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.
  124333. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  124334. * @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)
  124335. */
  124336. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  124337. /**
  124338. * Get the current class name of the current effet
  124339. * @returns "DepthOfFieldEffect"
  124340. */
  124341. getClassName(): string;
  124342. /**
  124343. * 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.
  124344. */
  124345. depthTexture: RenderTargetTexture;
  124346. /**
  124347. * Disposes each of the internal effects for a given camera.
  124348. * @param camera The camera to dispose the effect on.
  124349. */
  124350. disposeEffects(camera: Camera): void;
  124351. /**
  124352. * @hidden Internal
  124353. */
  124354. _updateEffects(): void;
  124355. /**
  124356. * Internal
  124357. * @returns if all the contained post processes are ready.
  124358. * @hidden
  124359. */
  124360. _isReady(): boolean;
  124361. }
  124362. }
  124363. declare module BABYLON {
  124364. /** @hidden */
  124365. export var displayPassPixelShader: {
  124366. name: string;
  124367. shader: string;
  124368. };
  124369. }
  124370. declare module BABYLON {
  124371. /**
  124372. * DisplayPassPostProcess which produces an output the same as it's input
  124373. */
  124374. export class DisplayPassPostProcess extends PostProcess {
  124375. /**
  124376. * Creates the DisplayPassPostProcess
  124377. * @param name The name of the effect.
  124378. * @param options The required width/height ratio to downsize to before computing the render pass.
  124379. * @param camera The camera to apply the render pass to.
  124380. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124381. * @param engine The engine which the post process will be applied. (default: current engine)
  124382. * @param reusable If the post process can be reused on the same frame. (default: false)
  124383. */
  124384. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124385. }
  124386. }
  124387. declare module BABYLON {
  124388. /** @hidden */
  124389. export var filterPixelShader: {
  124390. name: string;
  124391. shader: string;
  124392. };
  124393. }
  124394. declare module BABYLON {
  124395. /**
  124396. * Applies a kernel filter to the image
  124397. */
  124398. export class FilterPostProcess extends PostProcess {
  124399. /** The matrix to be applied to the image */
  124400. kernelMatrix: Matrix;
  124401. /**
  124402. *
  124403. * @param name The name of the effect.
  124404. * @param kernelMatrix The matrix to be applied to the image
  124405. * @param options The required width/height ratio to downsize to before computing the render pass.
  124406. * @param camera The camera to apply the render pass to.
  124407. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124408. * @param engine The engine which the post process will be applied. (default: current engine)
  124409. * @param reusable If the post process can be reused on the same frame. (default: false)
  124410. */
  124411. constructor(name: string,
  124412. /** The matrix to be applied to the image */
  124413. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124414. }
  124415. }
  124416. declare module BABYLON {
  124417. /** @hidden */
  124418. export var fxaaPixelShader: {
  124419. name: string;
  124420. shader: string;
  124421. };
  124422. }
  124423. declare module BABYLON {
  124424. /** @hidden */
  124425. export var fxaaVertexShader: {
  124426. name: string;
  124427. shader: string;
  124428. };
  124429. }
  124430. declare module BABYLON {
  124431. /**
  124432. * Fxaa post process
  124433. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  124434. */
  124435. export class FxaaPostProcess extends PostProcess {
  124436. /** @hidden */
  124437. texelWidth: number;
  124438. /** @hidden */
  124439. texelHeight: number;
  124440. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124441. private _getDefines;
  124442. }
  124443. }
  124444. declare module BABYLON {
  124445. /** @hidden */
  124446. export var grainPixelShader: {
  124447. name: string;
  124448. shader: string;
  124449. };
  124450. }
  124451. declare module BABYLON {
  124452. /**
  124453. * The GrainPostProcess adds noise to the image at mid luminance levels
  124454. */
  124455. export class GrainPostProcess extends PostProcess {
  124456. /**
  124457. * The intensity of the grain added (default: 30)
  124458. */
  124459. intensity: number;
  124460. /**
  124461. * If the grain should be randomized on every frame
  124462. */
  124463. animated: boolean;
  124464. /**
  124465. * Creates a new instance of @see GrainPostProcess
  124466. * @param name The name of the effect.
  124467. * @param options The required width/height ratio to downsize to before computing the render pass.
  124468. * @param camera The camera to apply the render pass to.
  124469. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124470. * @param engine The engine which the post process will be applied. (default: current engine)
  124471. * @param reusable If the post process can be reused on the same frame. (default: false)
  124472. * @param textureType Type of textures used when performing the post process. (default: 0)
  124473. * @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)
  124474. */
  124475. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124476. }
  124477. }
  124478. declare module BABYLON {
  124479. /** @hidden */
  124480. export var highlightsPixelShader: {
  124481. name: string;
  124482. shader: string;
  124483. };
  124484. }
  124485. declare module BABYLON {
  124486. /**
  124487. * Extracts highlights from the image
  124488. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124489. */
  124490. export class HighlightsPostProcess extends PostProcess {
  124491. /**
  124492. * Extracts highlights from the image
  124493. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  124494. * @param name The name of the effect.
  124495. * @param options The required width/height ratio to downsize to before computing the render pass.
  124496. * @param camera The camera to apply the render pass to.
  124497. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124498. * @param engine The engine which the post process will be applied. (default: current engine)
  124499. * @param reusable If the post process can be reused on the same frame. (default: false)
  124500. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  124501. */
  124502. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  124503. }
  124504. }
  124505. declare module BABYLON {
  124506. /** @hidden */
  124507. export var mrtFragmentDeclaration: {
  124508. name: string;
  124509. shader: string;
  124510. };
  124511. }
  124512. declare module BABYLON {
  124513. /** @hidden */
  124514. export var geometryPixelShader: {
  124515. name: string;
  124516. shader: string;
  124517. };
  124518. }
  124519. declare module BABYLON {
  124520. /** @hidden */
  124521. export var geometryVertexShader: {
  124522. name: string;
  124523. shader: string;
  124524. };
  124525. }
  124526. declare module BABYLON {
  124527. /** @hidden */
  124528. interface ISavedTransformationMatrix {
  124529. world: Matrix;
  124530. viewProjection: Matrix;
  124531. }
  124532. /**
  124533. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  124534. */
  124535. export class GeometryBufferRenderer {
  124536. /**
  124537. * Constant used to retrieve the position texture index in the G-Buffer textures array
  124538. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  124539. */
  124540. static readonly POSITION_TEXTURE_TYPE: number;
  124541. /**
  124542. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  124543. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  124544. */
  124545. static readonly VELOCITY_TEXTURE_TYPE: number;
  124546. /**
  124547. * Dictionary used to store the previous transformation matrices of each rendered mesh
  124548. * in order to compute objects velocities when enableVelocity is set to "true"
  124549. * @hidden
  124550. */
  124551. _previousTransformationMatrices: {
  124552. [index: number]: ISavedTransformationMatrix;
  124553. };
  124554. /**
  124555. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  124556. * in order to compute objects velocities when enableVelocity is set to "true"
  124557. * @hidden
  124558. */
  124559. _previousBonesTransformationMatrices: {
  124560. [index: number]: Float32Array;
  124561. };
  124562. /**
  124563. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  124564. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  124565. */
  124566. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  124567. private _scene;
  124568. private _multiRenderTarget;
  124569. private _ratio;
  124570. private _enablePosition;
  124571. private _enableVelocity;
  124572. private _positionIndex;
  124573. private _velocityIndex;
  124574. protected _effect: Effect;
  124575. protected _cachedDefines: string;
  124576. /**
  124577. * Set the render list (meshes to be rendered) used in the G buffer.
  124578. */
  124579. renderList: Mesh[];
  124580. /**
  124581. * Gets wether or not G buffer are supported by the running hardware.
  124582. * This requires draw buffer supports
  124583. */
  124584. readonly isSupported: boolean;
  124585. /**
  124586. * Returns the index of the given texture type in the G-Buffer textures array
  124587. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  124588. * @returns the index of the given texture type in the G-Buffer textures array
  124589. */
  124590. getTextureIndex(textureType: number): number;
  124591. /**
  124592. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  124593. */
  124594. /**
  124595. * Sets whether or not objects positions are enabled for the G buffer.
  124596. */
  124597. enablePosition: boolean;
  124598. /**
  124599. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  124600. */
  124601. /**
  124602. * Sets wether or not objects velocities are enabled for the G buffer.
  124603. */
  124604. enableVelocity: boolean;
  124605. /**
  124606. * Gets the scene associated with the buffer.
  124607. */
  124608. readonly scene: Scene;
  124609. /**
  124610. * Gets the ratio used by the buffer during its creation.
  124611. * How big is the buffer related to the main canvas.
  124612. */
  124613. readonly ratio: number;
  124614. /** @hidden */
  124615. static _SceneComponentInitialization: (scene: Scene) => void;
  124616. /**
  124617. * Creates a new G Buffer for the scene
  124618. * @param scene The scene the buffer belongs to
  124619. * @param ratio How big is the buffer related to the main canvas.
  124620. */
  124621. constructor(scene: Scene, ratio?: number);
  124622. /**
  124623. * Checks wether everything is ready to render a submesh to the G buffer.
  124624. * @param subMesh the submesh to check readiness for
  124625. * @param useInstances is the mesh drawn using instance or not
  124626. * @returns true if ready otherwise false
  124627. */
  124628. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124629. /**
  124630. * Gets the current underlying G Buffer.
  124631. * @returns the buffer
  124632. */
  124633. getGBuffer(): MultiRenderTarget;
  124634. /**
  124635. * Gets the number of samples used to render the buffer (anti aliasing).
  124636. */
  124637. /**
  124638. * Sets the number of samples used to render the buffer (anti aliasing).
  124639. */
  124640. samples: number;
  124641. /**
  124642. * Disposes the renderer and frees up associated resources.
  124643. */
  124644. dispose(): void;
  124645. protected _createRenderTargets(): void;
  124646. private _copyBonesTransformationMatrices;
  124647. }
  124648. }
  124649. declare module BABYLON {
  124650. interface Scene {
  124651. /** @hidden (Backing field) */
  124652. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124653. /**
  124654. * Gets or Sets the current geometry buffer associated to the scene.
  124655. */
  124656. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  124657. /**
  124658. * Enables a GeometryBufferRender and associates it with the scene
  124659. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  124660. * @returns the GeometryBufferRenderer
  124661. */
  124662. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  124663. /**
  124664. * Disables the GeometryBufferRender associated with the scene
  124665. */
  124666. disableGeometryBufferRenderer(): void;
  124667. }
  124668. /**
  124669. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  124670. * in several rendering techniques.
  124671. */
  124672. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  124673. /**
  124674. * The component name helpful to identify the component in the list of scene components.
  124675. */
  124676. readonly name: string;
  124677. /**
  124678. * The scene the component belongs to.
  124679. */
  124680. scene: Scene;
  124681. /**
  124682. * Creates a new instance of the component for the given scene
  124683. * @param scene Defines the scene to register the component in
  124684. */
  124685. constructor(scene: Scene);
  124686. /**
  124687. * Registers the component in a given scene
  124688. */
  124689. register(): void;
  124690. /**
  124691. * Rebuilds the elements related to this component in case of
  124692. * context lost for instance.
  124693. */
  124694. rebuild(): void;
  124695. /**
  124696. * Disposes the component and the associated ressources
  124697. */
  124698. dispose(): void;
  124699. private _gatherRenderTargets;
  124700. }
  124701. }
  124702. declare module BABYLON {
  124703. /** @hidden */
  124704. export var motionBlurPixelShader: {
  124705. name: string;
  124706. shader: string;
  124707. };
  124708. }
  124709. declare module BABYLON {
  124710. /**
  124711. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  124712. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  124713. * As an example, all you have to do is to create the post-process:
  124714. * var mb = new BABYLON.MotionBlurPostProcess(
  124715. * 'mb', // The name of the effect.
  124716. * scene, // The scene containing the objects to blur according to their velocity.
  124717. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  124718. * camera // The camera to apply the render pass to.
  124719. * );
  124720. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  124721. */
  124722. export class MotionBlurPostProcess extends PostProcess {
  124723. /**
  124724. * Defines how much the image is blurred by the movement. Default value is equal to 1
  124725. */
  124726. motionStrength: number;
  124727. /**
  124728. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  124729. */
  124730. /**
  124731. * Sets the number of iterations to be used for motion blur quality
  124732. */
  124733. motionBlurSamples: number;
  124734. private _motionBlurSamples;
  124735. private _geometryBufferRenderer;
  124736. /**
  124737. * Creates a new instance MotionBlurPostProcess
  124738. * @param name The name of the effect.
  124739. * @param scene The scene containing the objects to blur according to their velocity.
  124740. * @param options The required width/height ratio to downsize to before computing the render pass.
  124741. * @param camera The camera to apply the render pass to.
  124742. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124743. * @param engine The engine which the post process will be applied. (default: current engine)
  124744. * @param reusable If the post process can be reused on the same frame. (default: false)
  124745. * @param textureType Type of textures used when performing the post process. (default: 0)
  124746. * @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)
  124747. */
  124748. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124749. /**
  124750. * Excludes the given skinned mesh from computing bones velocities.
  124751. * 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.
  124752. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  124753. */
  124754. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124755. /**
  124756. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  124757. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  124758. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  124759. */
  124760. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  124761. /**
  124762. * Disposes the post process.
  124763. * @param camera The camera to dispose the post process on.
  124764. */
  124765. dispose(camera?: Camera): void;
  124766. }
  124767. }
  124768. declare module BABYLON {
  124769. /** @hidden */
  124770. export var refractionPixelShader: {
  124771. name: string;
  124772. shader: string;
  124773. };
  124774. }
  124775. declare module BABYLON {
  124776. /**
  124777. * Post process which applies a refractin texture
  124778. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124779. */
  124780. export class RefractionPostProcess extends PostProcess {
  124781. /** the base color of the refraction (used to taint the rendering) */
  124782. color: Color3;
  124783. /** simulated refraction depth */
  124784. depth: number;
  124785. /** the coefficient of the base color (0 to remove base color tainting) */
  124786. colorLevel: number;
  124787. private _refTexture;
  124788. private _ownRefractionTexture;
  124789. /**
  124790. * Gets or sets the refraction texture
  124791. * Please note that you are responsible for disposing the texture if you set it manually
  124792. */
  124793. refractionTexture: Texture;
  124794. /**
  124795. * Initializes the RefractionPostProcess
  124796. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  124797. * @param name The name of the effect.
  124798. * @param refractionTextureUrl Url of the refraction texture to use
  124799. * @param color the base color of the refraction (used to taint the rendering)
  124800. * @param depth simulated refraction depth
  124801. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  124802. * @param camera The camera to apply the render pass to.
  124803. * @param options The required width/height ratio to downsize to before computing the render pass.
  124804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124805. * @param engine The engine which the post process will be applied. (default: current engine)
  124806. * @param reusable If the post process can be reused on the same frame. (default: false)
  124807. */
  124808. constructor(name: string, refractionTextureUrl: string,
  124809. /** the base color of the refraction (used to taint the rendering) */
  124810. color: Color3,
  124811. /** simulated refraction depth */
  124812. depth: number,
  124813. /** the coefficient of the base color (0 to remove base color tainting) */
  124814. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  124815. /**
  124816. * Disposes of the post process
  124817. * @param camera Camera to dispose post process on
  124818. */
  124819. dispose(camera: Camera): void;
  124820. }
  124821. }
  124822. declare module BABYLON {
  124823. /** @hidden */
  124824. export var sharpenPixelShader: {
  124825. name: string;
  124826. shader: string;
  124827. };
  124828. }
  124829. declare module BABYLON {
  124830. /**
  124831. * The SharpenPostProcess applies a sharpen kernel to every pixel
  124832. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  124833. */
  124834. export class SharpenPostProcess extends PostProcess {
  124835. /**
  124836. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  124837. */
  124838. colorAmount: number;
  124839. /**
  124840. * How much sharpness should be applied (default: 0.3)
  124841. */
  124842. edgeAmount: number;
  124843. /**
  124844. * Creates a new instance ConvolutionPostProcess
  124845. * @param name The name of the effect.
  124846. * @param options The required width/height ratio to downsize to before computing the render pass.
  124847. * @param camera The camera to apply the render pass to.
  124848. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  124849. * @param engine The engine which the post process will be applied. (default: current engine)
  124850. * @param reusable If the post process can be reused on the same frame. (default: false)
  124851. * @param textureType Type of textures used when performing the post process. (default: 0)
  124852. * @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)
  124853. */
  124854. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  124855. }
  124856. }
  124857. declare module BABYLON {
  124858. /**
  124859. * PostProcessRenderPipeline
  124860. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124861. */
  124862. export class PostProcessRenderPipeline {
  124863. private engine;
  124864. private _renderEffects;
  124865. private _renderEffectsForIsolatedPass;
  124866. /**
  124867. * List of inspectable custom properties (used by the Inspector)
  124868. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  124869. */
  124870. inspectableCustomProperties: IInspectable[];
  124871. /**
  124872. * @hidden
  124873. */
  124874. protected _cameras: Camera[];
  124875. /** @hidden */
  124876. _name: string;
  124877. /**
  124878. * Gets pipeline name
  124879. */
  124880. readonly name: string;
  124881. /**
  124882. * Initializes a PostProcessRenderPipeline
  124883. * @param engine engine to add the pipeline to
  124884. * @param name name of the pipeline
  124885. */
  124886. constructor(engine: Engine, name: string);
  124887. /**
  124888. * Gets the class name
  124889. * @returns "PostProcessRenderPipeline"
  124890. */
  124891. getClassName(): string;
  124892. /**
  124893. * If all the render effects in the pipeline are supported
  124894. */
  124895. readonly isSupported: boolean;
  124896. /**
  124897. * Adds an effect to the pipeline
  124898. * @param renderEffect the effect to add
  124899. */
  124900. addEffect(renderEffect: PostProcessRenderEffect): void;
  124901. /** @hidden */
  124902. _rebuild(): void;
  124903. /** @hidden */
  124904. _enableEffect(renderEffectName: string, cameras: Camera): void;
  124905. /** @hidden */
  124906. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  124907. /** @hidden */
  124908. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124909. /** @hidden */
  124910. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  124911. /** @hidden */
  124912. _attachCameras(cameras: Camera, unique: boolean): void;
  124913. /** @hidden */
  124914. _attachCameras(cameras: Camera[], unique: boolean): void;
  124915. /** @hidden */
  124916. _detachCameras(cameras: Camera): void;
  124917. /** @hidden */
  124918. _detachCameras(cameras: Nullable<Camera[]>): void;
  124919. /** @hidden */
  124920. _update(): void;
  124921. /** @hidden */
  124922. _reset(): void;
  124923. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  124924. /**
  124925. * Disposes of the pipeline
  124926. */
  124927. dispose(): void;
  124928. }
  124929. }
  124930. declare module BABYLON {
  124931. /**
  124932. * PostProcessRenderPipelineManager class
  124933. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124934. */
  124935. export class PostProcessRenderPipelineManager {
  124936. private _renderPipelines;
  124937. /**
  124938. * Initializes a PostProcessRenderPipelineManager
  124939. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124940. */
  124941. constructor();
  124942. /**
  124943. * Gets the list of supported render pipelines
  124944. */
  124945. readonly supportedPipelines: PostProcessRenderPipeline[];
  124946. /**
  124947. * Adds a pipeline to the manager
  124948. * @param renderPipeline The pipeline to add
  124949. */
  124950. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  124951. /**
  124952. * Attaches a camera to the pipeline
  124953. * @param renderPipelineName The name of the pipeline to attach to
  124954. * @param cameras the camera to attach
  124955. * @param unique if the camera can be attached multiple times to the pipeline
  124956. */
  124957. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  124958. /**
  124959. * Detaches a camera from the pipeline
  124960. * @param renderPipelineName The name of the pipeline to detach from
  124961. * @param cameras the camera to detach
  124962. */
  124963. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  124964. /**
  124965. * Enables an effect by name on a pipeline
  124966. * @param renderPipelineName the name of the pipeline to enable the effect in
  124967. * @param renderEffectName the name of the effect to enable
  124968. * @param cameras the cameras that the effect should be enabled on
  124969. */
  124970. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  124971. /**
  124972. * Disables an effect by name on a pipeline
  124973. * @param renderPipelineName the name of the pipeline to disable the effect in
  124974. * @param renderEffectName the name of the effect to disable
  124975. * @param cameras the cameras that the effect should be disabled on
  124976. */
  124977. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  124978. /**
  124979. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  124980. */
  124981. update(): void;
  124982. /** @hidden */
  124983. _rebuild(): void;
  124984. /**
  124985. * Disposes of the manager and pipelines
  124986. */
  124987. dispose(): void;
  124988. }
  124989. }
  124990. declare module BABYLON {
  124991. interface Scene {
  124992. /** @hidden (Backing field) */
  124993. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  124994. /**
  124995. * Gets the postprocess render pipeline manager
  124996. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  124997. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  124998. */
  124999. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  125000. }
  125001. /**
  125002. * Defines the Render Pipeline scene component responsible to rendering pipelines
  125003. */
  125004. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  125005. /**
  125006. * The component name helpfull to identify the component in the list of scene components.
  125007. */
  125008. readonly name: string;
  125009. /**
  125010. * The scene the component belongs to.
  125011. */
  125012. scene: Scene;
  125013. /**
  125014. * Creates a new instance of the component for the given scene
  125015. * @param scene Defines the scene to register the component in
  125016. */
  125017. constructor(scene: Scene);
  125018. /**
  125019. * Registers the component in a given scene
  125020. */
  125021. register(): void;
  125022. /**
  125023. * Rebuilds the elements related to this component in case of
  125024. * context lost for instance.
  125025. */
  125026. rebuild(): void;
  125027. /**
  125028. * Disposes the component and the associated ressources
  125029. */
  125030. dispose(): void;
  125031. private _gatherRenderTargets;
  125032. }
  125033. }
  125034. declare module BABYLON {
  125035. /**
  125036. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  125037. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  125038. */
  125039. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  125040. private _scene;
  125041. private _camerasToBeAttached;
  125042. /**
  125043. * ID of the sharpen post process,
  125044. */
  125045. private readonly SharpenPostProcessId;
  125046. /**
  125047. * @ignore
  125048. * ID of the image processing post process;
  125049. */
  125050. readonly ImageProcessingPostProcessId: string;
  125051. /**
  125052. * @ignore
  125053. * ID of the Fast Approximate Anti-Aliasing post process;
  125054. */
  125055. readonly FxaaPostProcessId: string;
  125056. /**
  125057. * ID of the chromatic aberration post process,
  125058. */
  125059. private readonly ChromaticAberrationPostProcessId;
  125060. /**
  125061. * ID of the grain post process
  125062. */
  125063. private readonly GrainPostProcessId;
  125064. /**
  125065. * Sharpen post process which will apply a sharpen convolution to enhance edges
  125066. */
  125067. sharpen: SharpenPostProcess;
  125068. private _sharpenEffect;
  125069. private bloom;
  125070. /**
  125071. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  125072. */
  125073. depthOfField: DepthOfFieldEffect;
  125074. /**
  125075. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  125076. */
  125077. fxaa: FxaaPostProcess;
  125078. /**
  125079. * Image post processing pass used to perform operations such as tone mapping or color grading.
  125080. */
  125081. imageProcessing: ImageProcessingPostProcess;
  125082. /**
  125083. * Chromatic aberration post process which will shift rgb colors in the image
  125084. */
  125085. chromaticAberration: ChromaticAberrationPostProcess;
  125086. private _chromaticAberrationEffect;
  125087. /**
  125088. * Grain post process which add noise to the image
  125089. */
  125090. grain: GrainPostProcess;
  125091. private _grainEffect;
  125092. /**
  125093. * Glow post process which adds a glow to emissive areas of the image
  125094. */
  125095. private _glowLayer;
  125096. /**
  125097. * Animations which can be used to tweak settings over a period of time
  125098. */
  125099. animations: Animation[];
  125100. private _imageProcessingConfigurationObserver;
  125101. private _sharpenEnabled;
  125102. private _bloomEnabled;
  125103. private _depthOfFieldEnabled;
  125104. private _depthOfFieldBlurLevel;
  125105. private _fxaaEnabled;
  125106. private _imageProcessingEnabled;
  125107. private _defaultPipelineTextureType;
  125108. private _bloomScale;
  125109. private _chromaticAberrationEnabled;
  125110. private _grainEnabled;
  125111. private _buildAllowed;
  125112. /**
  125113. * Gets active scene
  125114. */
  125115. readonly scene: Scene;
  125116. /**
  125117. * Enable or disable the sharpen process from the pipeline
  125118. */
  125119. sharpenEnabled: boolean;
  125120. private _resizeObserver;
  125121. private _hardwareScaleLevel;
  125122. private _bloomKernel;
  125123. /**
  125124. * Specifies the size of the bloom blur kernel, relative to the final output size
  125125. */
  125126. bloomKernel: number;
  125127. /**
  125128. * Specifies the weight of the bloom in the final rendering
  125129. */
  125130. private _bloomWeight;
  125131. /**
  125132. * Specifies the luma threshold for the area that will be blurred by the bloom
  125133. */
  125134. private _bloomThreshold;
  125135. private _hdr;
  125136. /**
  125137. * The strength of the bloom.
  125138. */
  125139. bloomWeight: number;
  125140. /**
  125141. * The strength of the bloom.
  125142. */
  125143. bloomThreshold: number;
  125144. /**
  125145. * The scale of the bloom, lower value will provide better performance.
  125146. */
  125147. bloomScale: number;
  125148. /**
  125149. * Enable or disable the bloom from the pipeline
  125150. */
  125151. bloomEnabled: boolean;
  125152. private _rebuildBloom;
  125153. /**
  125154. * If the depth of field is enabled.
  125155. */
  125156. depthOfFieldEnabled: boolean;
  125157. /**
  125158. * Blur level of the depth of field effect. (Higher blur will effect performance)
  125159. */
  125160. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  125161. /**
  125162. * If the anti aliasing is enabled.
  125163. */
  125164. fxaaEnabled: boolean;
  125165. private _samples;
  125166. /**
  125167. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  125168. */
  125169. samples: number;
  125170. /**
  125171. * If image processing is enabled.
  125172. */
  125173. imageProcessingEnabled: boolean;
  125174. /**
  125175. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  125176. */
  125177. glowLayerEnabled: boolean;
  125178. /**
  125179. * Gets the glow layer (or null if not defined)
  125180. */
  125181. readonly glowLayer: Nullable<GlowLayer>;
  125182. /**
  125183. * Enable or disable the chromaticAberration process from the pipeline
  125184. */
  125185. chromaticAberrationEnabled: boolean;
  125186. /**
  125187. * Enable or disable the grain process from the pipeline
  125188. */
  125189. grainEnabled: boolean;
  125190. /**
  125191. * @constructor
  125192. * @param name - The rendering pipeline name (default: "")
  125193. * @param hdr - If high dynamic range textures should be used (default: true)
  125194. * @param scene - The scene linked to this pipeline (default: the last created scene)
  125195. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  125196. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  125197. */
  125198. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  125199. /**
  125200. * Get the class name
  125201. * @returns "DefaultRenderingPipeline"
  125202. */
  125203. getClassName(): string;
  125204. /**
  125205. * Force the compilation of the entire pipeline.
  125206. */
  125207. prepare(): void;
  125208. private _hasCleared;
  125209. private _prevPostProcess;
  125210. private _prevPrevPostProcess;
  125211. private _setAutoClearAndTextureSharing;
  125212. private _depthOfFieldSceneObserver;
  125213. private _buildPipeline;
  125214. private _disposePostProcesses;
  125215. /**
  125216. * Adds a camera to the pipeline
  125217. * @param camera the camera to be added
  125218. */
  125219. addCamera(camera: Camera): void;
  125220. /**
  125221. * Removes a camera from the pipeline
  125222. * @param camera the camera to remove
  125223. */
  125224. removeCamera(camera: Camera): void;
  125225. /**
  125226. * Dispose of the pipeline and stop all post processes
  125227. */
  125228. dispose(): void;
  125229. /**
  125230. * Serialize the rendering pipeline (Used when exporting)
  125231. * @returns the serialized object
  125232. */
  125233. serialize(): any;
  125234. /**
  125235. * Parse the serialized pipeline
  125236. * @param source Source pipeline.
  125237. * @param scene The scene to load the pipeline to.
  125238. * @param rootUrl The URL of the serialized pipeline.
  125239. * @returns An instantiated pipeline from the serialized object.
  125240. */
  125241. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  125242. }
  125243. }
  125244. declare module BABYLON {
  125245. /** @hidden */
  125246. export var lensHighlightsPixelShader: {
  125247. name: string;
  125248. shader: string;
  125249. };
  125250. }
  125251. declare module BABYLON {
  125252. /** @hidden */
  125253. export var depthOfFieldPixelShader: {
  125254. name: string;
  125255. shader: string;
  125256. };
  125257. }
  125258. declare module BABYLON {
  125259. /**
  125260. * BABYLON.JS Chromatic Aberration GLSL Shader
  125261. * Author: Olivier Guyot
  125262. * Separates very slightly R, G and B colors on the edges of the screen
  125263. * Inspired by Francois Tarlier & Martins Upitis
  125264. */
  125265. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  125266. /**
  125267. * @ignore
  125268. * The chromatic aberration PostProcess id in the pipeline
  125269. */
  125270. LensChromaticAberrationEffect: string;
  125271. /**
  125272. * @ignore
  125273. * The highlights enhancing PostProcess id in the pipeline
  125274. */
  125275. HighlightsEnhancingEffect: string;
  125276. /**
  125277. * @ignore
  125278. * The depth-of-field PostProcess id in the pipeline
  125279. */
  125280. LensDepthOfFieldEffect: string;
  125281. private _scene;
  125282. private _depthTexture;
  125283. private _grainTexture;
  125284. private _chromaticAberrationPostProcess;
  125285. private _highlightsPostProcess;
  125286. private _depthOfFieldPostProcess;
  125287. private _edgeBlur;
  125288. private _grainAmount;
  125289. private _chromaticAberration;
  125290. private _distortion;
  125291. private _highlightsGain;
  125292. private _highlightsThreshold;
  125293. private _dofDistance;
  125294. private _dofAperture;
  125295. private _dofDarken;
  125296. private _dofPentagon;
  125297. private _blurNoise;
  125298. /**
  125299. * @constructor
  125300. *
  125301. * Effect parameters are as follow:
  125302. * {
  125303. * chromatic_aberration: number; // from 0 to x (1 for realism)
  125304. * edge_blur: number; // from 0 to x (1 for realism)
  125305. * distortion: number; // from 0 to x (1 for realism)
  125306. * grain_amount: number; // from 0 to 1
  125307. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  125308. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  125309. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  125310. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  125311. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  125312. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  125313. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  125314. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  125315. * }
  125316. * Note: if an effect parameter is unset, effect is disabled
  125317. *
  125318. * @param name The rendering pipeline name
  125319. * @param parameters - An object containing all parameters (see above)
  125320. * @param scene The scene linked to this pipeline
  125321. * @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)
  125322. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125323. */
  125324. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  125325. /**
  125326. * Get the class name
  125327. * @returns "LensRenderingPipeline"
  125328. */
  125329. getClassName(): string;
  125330. /**
  125331. * Gets associated scene
  125332. */
  125333. readonly scene: Scene;
  125334. /**
  125335. * Gets or sets the edge blur
  125336. */
  125337. edgeBlur: number;
  125338. /**
  125339. * Gets or sets the grain amount
  125340. */
  125341. grainAmount: number;
  125342. /**
  125343. * Gets or sets the chromatic aberration amount
  125344. */
  125345. chromaticAberration: number;
  125346. /**
  125347. * Gets or sets the depth of field aperture
  125348. */
  125349. dofAperture: number;
  125350. /**
  125351. * Gets or sets the edge distortion
  125352. */
  125353. edgeDistortion: number;
  125354. /**
  125355. * Gets or sets the depth of field distortion
  125356. */
  125357. dofDistortion: number;
  125358. /**
  125359. * Gets or sets the darken out of focus amount
  125360. */
  125361. darkenOutOfFocus: number;
  125362. /**
  125363. * Gets or sets a boolean indicating if blur noise is enabled
  125364. */
  125365. blurNoise: boolean;
  125366. /**
  125367. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  125368. */
  125369. pentagonBokeh: boolean;
  125370. /**
  125371. * Gets or sets the highlight grain amount
  125372. */
  125373. highlightsGain: number;
  125374. /**
  125375. * Gets or sets the highlight threshold
  125376. */
  125377. highlightsThreshold: number;
  125378. /**
  125379. * Sets the amount of blur at the edges
  125380. * @param amount blur amount
  125381. */
  125382. setEdgeBlur(amount: number): void;
  125383. /**
  125384. * Sets edge blur to 0
  125385. */
  125386. disableEdgeBlur(): void;
  125387. /**
  125388. * Sets the amout of grain
  125389. * @param amount Amount of grain
  125390. */
  125391. setGrainAmount(amount: number): void;
  125392. /**
  125393. * Set grain amount to 0
  125394. */
  125395. disableGrain(): void;
  125396. /**
  125397. * Sets the chromatic aberration amount
  125398. * @param amount amount of chromatic aberration
  125399. */
  125400. setChromaticAberration(amount: number): void;
  125401. /**
  125402. * Sets chromatic aberration amount to 0
  125403. */
  125404. disableChromaticAberration(): void;
  125405. /**
  125406. * Sets the EdgeDistortion amount
  125407. * @param amount amount of EdgeDistortion
  125408. */
  125409. setEdgeDistortion(amount: number): void;
  125410. /**
  125411. * Sets edge distortion to 0
  125412. */
  125413. disableEdgeDistortion(): void;
  125414. /**
  125415. * Sets the FocusDistance amount
  125416. * @param amount amount of FocusDistance
  125417. */
  125418. setFocusDistance(amount: number): void;
  125419. /**
  125420. * Disables depth of field
  125421. */
  125422. disableDepthOfField(): void;
  125423. /**
  125424. * Sets the Aperture amount
  125425. * @param amount amount of Aperture
  125426. */
  125427. setAperture(amount: number): void;
  125428. /**
  125429. * Sets the DarkenOutOfFocus amount
  125430. * @param amount amount of DarkenOutOfFocus
  125431. */
  125432. setDarkenOutOfFocus(amount: number): void;
  125433. private _pentagonBokehIsEnabled;
  125434. /**
  125435. * Creates a pentagon bokeh effect
  125436. */
  125437. enablePentagonBokeh(): void;
  125438. /**
  125439. * Disables the pentagon bokeh effect
  125440. */
  125441. disablePentagonBokeh(): void;
  125442. /**
  125443. * Enables noise blur
  125444. */
  125445. enableNoiseBlur(): void;
  125446. /**
  125447. * Disables noise blur
  125448. */
  125449. disableNoiseBlur(): void;
  125450. /**
  125451. * Sets the HighlightsGain amount
  125452. * @param amount amount of HighlightsGain
  125453. */
  125454. setHighlightsGain(amount: number): void;
  125455. /**
  125456. * Sets the HighlightsThreshold amount
  125457. * @param amount amount of HighlightsThreshold
  125458. */
  125459. setHighlightsThreshold(amount: number): void;
  125460. /**
  125461. * Disables highlights
  125462. */
  125463. disableHighlights(): void;
  125464. /**
  125465. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  125466. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  125467. */
  125468. dispose(disableDepthRender?: boolean): void;
  125469. private _createChromaticAberrationPostProcess;
  125470. private _createHighlightsPostProcess;
  125471. private _createDepthOfFieldPostProcess;
  125472. private _createGrainTexture;
  125473. }
  125474. }
  125475. declare module BABYLON {
  125476. /** @hidden */
  125477. export var ssao2PixelShader: {
  125478. name: string;
  125479. shader: string;
  125480. };
  125481. }
  125482. declare module BABYLON {
  125483. /** @hidden */
  125484. export var ssaoCombinePixelShader: {
  125485. name: string;
  125486. shader: string;
  125487. };
  125488. }
  125489. declare module BABYLON {
  125490. /**
  125491. * Render pipeline to produce ssao effect
  125492. */
  125493. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  125494. /**
  125495. * @ignore
  125496. * The PassPostProcess id in the pipeline that contains the original scene color
  125497. */
  125498. SSAOOriginalSceneColorEffect: string;
  125499. /**
  125500. * @ignore
  125501. * The SSAO PostProcess id in the pipeline
  125502. */
  125503. SSAORenderEffect: string;
  125504. /**
  125505. * @ignore
  125506. * The horizontal blur PostProcess id in the pipeline
  125507. */
  125508. SSAOBlurHRenderEffect: string;
  125509. /**
  125510. * @ignore
  125511. * The vertical blur PostProcess id in the pipeline
  125512. */
  125513. SSAOBlurVRenderEffect: string;
  125514. /**
  125515. * @ignore
  125516. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  125517. */
  125518. SSAOCombineRenderEffect: string;
  125519. /**
  125520. * The output strength of the SSAO post-process. Default value is 1.0.
  125521. */
  125522. totalStrength: number;
  125523. /**
  125524. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  125525. */
  125526. maxZ: number;
  125527. /**
  125528. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  125529. */
  125530. minZAspect: number;
  125531. private _samples;
  125532. /**
  125533. * Number of samples used for the SSAO calculations. Default value is 8
  125534. */
  125535. samples: number;
  125536. private _textureSamples;
  125537. /**
  125538. * Number of samples to use for antialiasing
  125539. */
  125540. textureSamples: number;
  125541. /**
  125542. * Ratio object used for SSAO ratio and blur ratio
  125543. */
  125544. private _ratio;
  125545. /**
  125546. * Dynamically generated sphere sampler.
  125547. */
  125548. private _sampleSphere;
  125549. /**
  125550. * Blur filter offsets
  125551. */
  125552. private _samplerOffsets;
  125553. private _expensiveBlur;
  125554. /**
  125555. * If bilateral blur should be used
  125556. */
  125557. expensiveBlur: boolean;
  125558. /**
  125559. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  125560. */
  125561. radius: number;
  125562. /**
  125563. * The base color of the SSAO post-process
  125564. * The final result is "base + ssao" between [0, 1]
  125565. */
  125566. base: number;
  125567. /**
  125568. * Support test.
  125569. */
  125570. static readonly IsSupported: boolean;
  125571. private _scene;
  125572. private _depthTexture;
  125573. private _normalTexture;
  125574. private _randomTexture;
  125575. private _originalColorPostProcess;
  125576. private _ssaoPostProcess;
  125577. private _blurHPostProcess;
  125578. private _blurVPostProcess;
  125579. private _ssaoCombinePostProcess;
  125580. private _firstUpdate;
  125581. /**
  125582. * Gets active scene
  125583. */
  125584. readonly scene: Scene;
  125585. /**
  125586. * @constructor
  125587. * @param name The rendering pipeline name
  125588. * @param scene The scene linked to this pipeline
  125589. * @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 }
  125590. * @param cameras The array of cameras that the rendering pipeline will be attached to
  125591. */
  125592. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125593. /**
  125594. * Get the class name
  125595. * @returns "SSAO2RenderingPipeline"
  125596. */
  125597. getClassName(): string;
  125598. /**
  125599. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125600. */
  125601. dispose(disableGeometryBufferRenderer?: boolean): void;
  125602. private _createBlurPostProcess;
  125603. /** @hidden */
  125604. _rebuild(): void;
  125605. private _bits;
  125606. private _radicalInverse_VdC;
  125607. private _hammersley;
  125608. private _hemisphereSample_uniform;
  125609. private _generateHemisphere;
  125610. private _createSSAOPostProcess;
  125611. private _createSSAOCombinePostProcess;
  125612. private _createRandomTexture;
  125613. /**
  125614. * Serialize the rendering pipeline (Used when exporting)
  125615. * @returns the serialized object
  125616. */
  125617. serialize(): any;
  125618. /**
  125619. * Parse the serialized pipeline
  125620. * @param source Source pipeline.
  125621. * @param scene The scene to load the pipeline to.
  125622. * @param rootUrl The URL of the serialized pipeline.
  125623. * @returns An instantiated pipeline from the serialized object.
  125624. */
  125625. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  125626. }
  125627. }
  125628. declare module BABYLON {
  125629. /** @hidden */
  125630. export var ssaoPixelShader: {
  125631. name: string;
  125632. shader: string;
  125633. };
  125634. }
  125635. declare module BABYLON {
  125636. /**
  125637. * Render pipeline to produce ssao effect
  125638. */
  125639. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  125640. /**
  125641. * @ignore
  125642. * The PassPostProcess id in the pipeline that contains the original scene color
  125643. */
  125644. SSAOOriginalSceneColorEffect: string;
  125645. /**
  125646. * @ignore
  125647. * The SSAO PostProcess id in the pipeline
  125648. */
  125649. SSAORenderEffect: string;
  125650. /**
  125651. * @ignore
  125652. * The horizontal blur PostProcess id in the pipeline
  125653. */
  125654. SSAOBlurHRenderEffect: string;
  125655. /**
  125656. * @ignore
  125657. * The vertical blur PostProcess id in the pipeline
  125658. */
  125659. SSAOBlurVRenderEffect: string;
  125660. /**
  125661. * @ignore
  125662. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  125663. */
  125664. SSAOCombineRenderEffect: string;
  125665. /**
  125666. * The output strength of the SSAO post-process. Default value is 1.0.
  125667. */
  125668. totalStrength: number;
  125669. /**
  125670. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  125671. */
  125672. radius: number;
  125673. /**
  125674. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  125675. * Must not be equal to fallOff and superior to fallOff.
  125676. * Default value is 0.0075
  125677. */
  125678. area: number;
  125679. /**
  125680. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  125681. * Must not be equal to area and inferior to area.
  125682. * Default value is 0.000001
  125683. */
  125684. fallOff: number;
  125685. /**
  125686. * The base color of the SSAO post-process
  125687. * The final result is "base + ssao" between [0, 1]
  125688. */
  125689. base: number;
  125690. private _scene;
  125691. private _depthTexture;
  125692. private _randomTexture;
  125693. private _originalColorPostProcess;
  125694. private _ssaoPostProcess;
  125695. private _blurHPostProcess;
  125696. private _blurVPostProcess;
  125697. private _ssaoCombinePostProcess;
  125698. private _firstUpdate;
  125699. /**
  125700. * Gets active scene
  125701. */
  125702. readonly scene: Scene;
  125703. /**
  125704. * @constructor
  125705. * @param name - The rendering pipeline name
  125706. * @param scene - The scene linked to this pipeline
  125707. * @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 }
  125708. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  125709. */
  125710. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  125711. /**
  125712. * Get the class name
  125713. * @returns "SSAORenderingPipeline"
  125714. */
  125715. getClassName(): string;
  125716. /**
  125717. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  125718. */
  125719. dispose(disableDepthRender?: boolean): void;
  125720. private _createBlurPostProcess;
  125721. /** @hidden */
  125722. _rebuild(): void;
  125723. private _createSSAOPostProcess;
  125724. private _createSSAOCombinePostProcess;
  125725. private _createRandomTexture;
  125726. }
  125727. }
  125728. declare module BABYLON {
  125729. /** @hidden */
  125730. export var standardPixelShader: {
  125731. name: string;
  125732. shader: string;
  125733. };
  125734. }
  125735. declare module BABYLON {
  125736. /**
  125737. * Standard rendering pipeline
  125738. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  125739. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  125740. */
  125741. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  125742. /**
  125743. * Public members
  125744. */
  125745. /**
  125746. * Post-process which contains the original scene color before the pipeline applies all the effects
  125747. */
  125748. originalPostProcess: Nullable<PostProcess>;
  125749. /**
  125750. * Post-process used to down scale an image x4
  125751. */
  125752. downSampleX4PostProcess: Nullable<PostProcess>;
  125753. /**
  125754. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  125755. */
  125756. brightPassPostProcess: Nullable<PostProcess>;
  125757. /**
  125758. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  125759. */
  125760. blurHPostProcesses: PostProcess[];
  125761. /**
  125762. * Post-process array storing all the vertical blur post-processes used by the pipeline
  125763. */
  125764. blurVPostProcesses: PostProcess[];
  125765. /**
  125766. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  125767. */
  125768. textureAdderPostProcess: Nullable<PostProcess>;
  125769. /**
  125770. * Post-process used to create volumetric lighting effect
  125771. */
  125772. volumetricLightPostProcess: Nullable<PostProcess>;
  125773. /**
  125774. * Post-process used to smooth the previous volumetric light post-process on the X axis
  125775. */
  125776. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  125777. /**
  125778. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  125779. */
  125780. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  125781. /**
  125782. * Post-process used to merge the volumetric light effect and the real scene color
  125783. */
  125784. volumetricLightMergePostProces: Nullable<PostProcess>;
  125785. /**
  125786. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  125787. */
  125788. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  125789. /**
  125790. * Base post-process used to calculate the average luminance of the final image for HDR
  125791. */
  125792. luminancePostProcess: Nullable<PostProcess>;
  125793. /**
  125794. * Post-processes used to create down sample post-processes in order to get
  125795. * the average luminance of the final image for HDR
  125796. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  125797. */
  125798. luminanceDownSamplePostProcesses: PostProcess[];
  125799. /**
  125800. * Post-process used to create a HDR effect (light adaptation)
  125801. */
  125802. hdrPostProcess: Nullable<PostProcess>;
  125803. /**
  125804. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  125805. */
  125806. textureAdderFinalPostProcess: Nullable<PostProcess>;
  125807. /**
  125808. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  125809. */
  125810. lensFlareFinalPostProcess: Nullable<PostProcess>;
  125811. /**
  125812. * Post-process used to merge the final HDR post-process and the real scene color
  125813. */
  125814. hdrFinalPostProcess: Nullable<PostProcess>;
  125815. /**
  125816. * Post-process used to create a lens flare effect
  125817. */
  125818. lensFlarePostProcess: Nullable<PostProcess>;
  125819. /**
  125820. * Post-process that merges the result of the lens flare post-process and the real scene color
  125821. */
  125822. lensFlareComposePostProcess: Nullable<PostProcess>;
  125823. /**
  125824. * Post-process used to create a motion blur effect
  125825. */
  125826. motionBlurPostProcess: Nullable<PostProcess>;
  125827. /**
  125828. * Post-process used to create a depth of field effect
  125829. */
  125830. depthOfFieldPostProcess: Nullable<PostProcess>;
  125831. /**
  125832. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  125833. */
  125834. fxaaPostProcess: Nullable<FxaaPostProcess>;
  125835. /**
  125836. * Represents the brightness threshold in order to configure the illuminated surfaces
  125837. */
  125838. brightThreshold: number;
  125839. /**
  125840. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  125841. */
  125842. blurWidth: number;
  125843. /**
  125844. * Sets if the blur for highlighted surfaces must be only horizontal
  125845. */
  125846. horizontalBlur: boolean;
  125847. /**
  125848. * Gets the overall exposure used by the pipeline
  125849. */
  125850. /**
  125851. * Sets the overall exposure used by the pipeline
  125852. */
  125853. exposure: number;
  125854. /**
  125855. * Texture used typically to simulate "dirty" on camera lens
  125856. */
  125857. lensTexture: Nullable<Texture>;
  125858. /**
  125859. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  125860. */
  125861. volumetricLightCoefficient: number;
  125862. /**
  125863. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  125864. */
  125865. volumetricLightPower: number;
  125866. /**
  125867. * Used the set the blur intensity to smooth the volumetric lights
  125868. */
  125869. volumetricLightBlurScale: number;
  125870. /**
  125871. * Light (spot or directional) used to generate the volumetric lights rays
  125872. * The source light must have a shadow generate so the pipeline can get its
  125873. * depth map
  125874. */
  125875. sourceLight: Nullable<SpotLight | DirectionalLight>;
  125876. /**
  125877. * For eye adaptation, represents the minimum luminance the eye can see
  125878. */
  125879. hdrMinimumLuminance: number;
  125880. /**
  125881. * For eye adaptation, represents the decrease luminance speed
  125882. */
  125883. hdrDecreaseRate: number;
  125884. /**
  125885. * For eye adaptation, represents the increase luminance speed
  125886. */
  125887. hdrIncreaseRate: number;
  125888. /**
  125889. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125890. */
  125891. /**
  125892. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  125893. */
  125894. hdrAutoExposure: boolean;
  125895. /**
  125896. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  125897. */
  125898. lensColorTexture: Nullable<Texture>;
  125899. /**
  125900. * The overall strengh for the lens flare effect
  125901. */
  125902. lensFlareStrength: number;
  125903. /**
  125904. * Dispersion coefficient for lens flare ghosts
  125905. */
  125906. lensFlareGhostDispersal: number;
  125907. /**
  125908. * Main lens flare halo width
  125909. */
  125910. lensFlareHaloWidth: number;
  125911. /**
  125912. * Based on the lens distortion effect, defines how much the lens flare result
  125913. * is distorted
  125914. */
  125915. lensFlareDistortionStrength: number;
  125916. /**
  125917. * Configures the blur intensity used for for lens flare (halo)
  125918. */
  125919. lensFlareBlurWidth: number;
  125920. /**
  125921. * Lens star texture must be used to simulate rays on the flares and is available
  125922. * in the documentation
  125923. */
  125924. lensStarTexture: Nullable<Texture>;
  125925. /**
  125926. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  125927. * flare effect by taking account of the dirt texture
  125928. */
  125929. lensFlareDirtTexture: Nullable<Texture>;
  125930. /**
  125931. * Represents the focal length for the depth of field effect
  125932. */
  125933. depthOfFieldDistance: number;
  125934. /**
  125935. * Represents the blur intensity for the blurred part of the depth of field effect
  125936. */
  125937. depthOfFieldBlurWidth: number;
  125938. /**
  125939. * Gets how much the image is blurred by the movement while using the motion blur post-process
  125940. */
  125941. /**
  125942. * Sets how much the image is blurred by the movement while using the motion blur post-process
  125943. */
  125944. motionStrength: number;
  125945. /**
  125946. * Gets wether or not the motion blur post-process is object based or screen based.
  125947. */
  125948. /**
  125949. * Sets wether or not the motion blur post-process should be object based or screen based
  125950. */
  125951. objectBasedMotionBlur: boolean;
  125952. /**
  125953. * List of animations for the pipeline (IAnimatable implementation)
  125954. */
  125955. animations: Animation[];
  125956. /**
  125957. * Private members
  125958. */
  125959. private _scene;
  125960. private _currentDepthOfFieldSource;
  125961. private _basePostProcess;
  125962. private _fixedExposure;
  125963. private _currentExposure;
  125964. private _hdrAutoExposure;
  125965. private _hdrCurrentLuminance;
  125966. private _motionStrength;
  125967. private _isObjectBasedMotionBlur;
  125968. private _floatTextureType;
  125969. private _camerasToBeAttached;
  125970. private _ratio;
  125971. private _bloomEnabled;
  125972. private _depthOfFieldEnabled;
  125973. private _vlsEnabled;
  125974. private _lensFlareEnabled;
  125975. private _hdrEnabled;
  125976. private _motionBlurEnabled;
  125977. private _fxaaEnabled;
  125978. private _motionBlurSamples;
  125979. private _volumetricLightStepsCount;
  125980. private _samples;
  125981. /**
  125982. * @ignore
  125983. * Specifies if the bloom pipeline is enabled
  125984. */
  125985. BloomEnabled: boolean;
  125986. /**
  125987. * @ignore
  125988. * Specifies if the depth of field pipeline is enabed
  125989. */
  125990. DepthOfFieldEnabled: boolean;
  125991. /**
  125992. * @ignore
  125993. * Specifies if the lens flare pipeline is enabed
  125994. */
  125995. LensFlareEnabled: boolean;
  125996. /**
  125997. * @ignore
  125998. * Specifies if the HDR pipeline is enabled
  125999. */
  126000. HDREnabled: boolean;
  126001. /**
  126002. * @ignore
  126003. * Specifies if the volumetric lights scattering effect is enabled
  126004. */
  126005. VLSEnabled: boolean;
  126006. /**
  126007. * @ignore
  126008. * Specifies if the motion blur effect is enabled
  126009. */
  126010. MotionBlurEnabled: boolean;
  126011. /**
  126012. * Specifies if anti-aliasing is enabled
  126013. */
  126014. fxaaEnabled: boolean;
  126015. /**
  126016. * Specifies the number of steps used to calculate the volumetric lights
  126017. * Typically in interval [50, 200]
  126018. */
  126019. volumetricLightStepsCount: number;
  126020. /**
  126021. * Specifies the number of samples used for the motion blur effect
  126022. * Typically in interval [16, 64]
  126023. */
  126024. motionBlurSamples: number;
  126025. /**
  126026. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  126027. */
  126028. samples: number;
  126029. /**
  126030. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  126031. * @constructor
  126032. * @param name The rendering pipeline name
  126033. * @param scene The scene linked to this pipeline
  126034. * @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)
  126035. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  126036. * @param cameras The array of cameras that the rendering pipeline will be attached to
  126037. */
  126038. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  126039. private _buildPipeline;
  126040. private _createDownSampleX4PostProcess;
  126041. private _createBrightPassPostProcess;
  126042. private _createBlurPostProcesses;
  126043. private _createTextureAdderPostProcess;
  126044. private _createVolumetricLightPostProcess;
  126045. private _createLuminancePostProcesses;
  126046. private _createHdrPostProcess;
  126047. private _createLensFlarePostProcess;
  126048. private _createDepthOfFieldPostProcess;
  126049. private _createMotionBlurPostProcess;
  126050. private _getDepthTexture;
  126051. private _disposePostProcesses;
  126052. /**
  126053. * Dispose of the pipeline and stop all post processes
  126054. */
  126055. dispose(): void;
  126056. /**
  126057. * Serialize the rendering pipeline (Used when exporting)
  126058. * @returns the serialized object
  126059. */
  126060. serialize(): any;
  126061. /**
  126062. * Parse the serialized pipeline
  126063. * @param source Source pipeline.
  126064. * @param scene The scene to load the pipeline to.
  126065. * @param rootUrl The URL of the serialized pipeline.
  126066. * @returns An instantiated pipeline from the serialized object.
  126067. */
  126068. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  126069. /**
  126070. * Luminance steps
  126071. */
  126072. static LuminanceSteps: number;
  126073. }
  126074. }
  126075. declare module BABYLON {
  126076. /** @hidden */
  126077. export var tonemapPixelShader: {
  126078. name: string;
  126079. shader: string;
  126080. };
  126081. }
  126082. declare module BABYLON {
  126083. /** Defines operator used for tonemapping */
  126084. export enum TonemappingOperator {
  126085. /** Hable */
  126086. Hable = 0,
  126087. /** Reinhard */
  126088. Reinhard = 1,
  126089. /** HejiDawson */
  126090. HejiDawson = 2,
  126091. /** Photographic */
  126092. Photographic = 3
  126093. }
  126094. /**
  126095. * Defines a post process to apply tone mapping
  126096. */
  126097. export class TonemapPostProcess extends PostProcess {
  126098. private _operator;
  126099. /** Defines the required exposure adjustement */
  126100. exposureAdjustment: number;
  126101. /**
  126102. * Creates a new TonemapPostProcess
  126103. * @param name defines the name of the postprocess
  126104. * @param _operator defines the operator to use
  126105. * @param exposureAdjustment defines the required exposure adjustement
  126106. * @param camera defines the camera to use (can be null)
  126107. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  126108. * @param engine defines the hosting engine (can be ignore if camera is set)
  126109. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  126110. */
  126111. constructor(name: string, _operator: TonemappingOperator,
  126112. /** Defines the required exposure adjustement */
  126113. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  126114. }
  126115. }
  126116. declare module BABYLON {
  126117. /** @hidden */
  126118. export var depthVertexShader: {
  126119. name: string;
  126120. shader: string;
  126121. };
  126122. }
  126123. declare module BABYLON {
  126124. /** @hidden */
  126125. export var volumetricLightScatteringPixelShader: {
  126126. name: string;
  126127. shader: string;
  126128. };
  126129. }
  126130. declare module BABYLON {
  126131. /** @hidden */
  126132. export var volumetricLightScatteringPassVertexShader: {
  126133. name: string;
  126134. shader: string;
  126135. };
  126136. }
  126137. declare module BABYLON {
  126138. /** @hidden */
  126139. export var volumetricLightScatteringPassPixelShader: {
  126140. name: string;
  126141. shader: string;
  126142. };
  126143. }
  126144. declare module BABYLON {
  126145. /**
  126146. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  126147. */
  126148. export class VolumetricLightScatteringPostProcess extends PostProcess {
  126149. private _volumetricLightScatteringPass;
  126150. private _volumetricLightScatteringRTT;
  126151. private _viewPort;
  126152. private _screenCoordinates;
  126153. private _cachedDefines;
  126154. /**
  126155. * If not undefined, the mesh position is computed from the attached node position
  126156. */
  126157. attachedNode: {
  126158. position: Vector3;
  126159. };
  126160. /**
  126161. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  126162. */
  126163. customMeshPosition: Vector3;
  126164. /**
  126165. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  126166. */
  126167. useCustomMeshPosition: boolean;
  126168. /**
  126169. * If the post-process should inverse the light scattering direction
  126170. */
  126171. invert: boolean;
  126172. /**
  126173. * The internal mesh used by the post-process
  126174. */
  126175. mesh: Mesh;
  126176. /**
  126177. * @hidden
  126178. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  126179. */
  126180. useDiffuseColor: boolean;
  126181. /**
  126182. * Array containing the excluded meshes not rendered in the internal pass
  126183. */
  126184. excludedMeshes: AbstractMesh[];
  126185. /**
  126186. * Controls the overall intensity of the post-process
  126187. */
  126188. exposure: number;
  126189. /**
  126190. * Dissipates each sample's contribution in range [0, 1]
  126191. */
  126192. decay: number;
  126193. /**
  126194. * Controls the overall intensity of each sample
  126195. */
  126196. weight: number;
  126197. /**
  126198. * Controls the density of each sample
  126199. */
  126200. density: number;
  126201. /**
  126202. * @constructor
  126203. * @param name The post-process name
  126204. * @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)
  126205. * @param camera The camera that the post-process will be attached to
  126206. * @param mesh The mesh used to create the light scattering
  126207. * @param samples The post-process quality, default 100
  126208. * @param samplingModeThe post-process filtering mode
  126209. * @param engine The babylon engine
  126210. * @param reusable If the post-process is reusable
  126211. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  126212. */
  126213. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  126214. /**
  126215. * Returns the string "VolumetricLightScatteringPostProcess"
  126216. * @returns "VolumetricLightScatteringPostProcess"
  126217. */
  126218. getClassName(): string;
  126219. private _isReady;
  126220. /**
  126221. * Sets the new light position for light scattering effect
  126222. * @param position The new custom light position
  126223. */
  126224. setCustomMeshPosition(position: Vector3): void;
  126225. /**
  126226. * Returns the light position for light scattering effect
  126227. * @return Vector3 The custom light position
  126228. */
  126229. getCustomMeshPosition(): Vector3;
  126230. /**
  126231. * Disposes the internal assets and detaches the post-process from the camera
  126232. */
  126233. dispose(camera: Camera): void;
  126234. /**
  126235. * Returns the render target texture used by the post-process
  126236. * @return the render target texture used by the post-process
  126237. */
  126238. getPass(): RenderTargetTexture;
  126239. private _meshExcluded;
  126240. private _createPass;
  126241. private _updateMeshScreenCoordinates;
  126242. /**
  126243. * Creates a default mesh for the Volumeric Light Scattering post-process
  126244. * @param name The mesh name
  126245. * @param scene The scene where to create the mesh
  126246. * @return the default mesh
  126247. */
  126248. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  126249. }
  126250. }
  126251. declare module BABYLON {
  126252. interface Scene {
  126253. /** @hidden (Backing field) */
  126254. _boundingBoxRenderer: BoundingBoxRenderer;
  126255. /** @hidden (Backing field) */
  126256. _forceShowBoundingBoxes: boolean;
  126257. /**
  126258. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  126259. */
  126260. forceShowBoundingBoxes: boolean;
  126261. /**
  126262. * Gets the bounding box renderer associated with the scene
  126263. * @returns a BoundingBoxRenderer
  126264. */
  126265. getBoundingBoxRenderer(): BoundingBoxRenderer;
  126266. }
  126267. interface AbstractMesh {
  126268. /** @hidden (Backing field) */
  126269. _showBoundingBox: boolean;
  126270. /**
  126271. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  126272. */
  126273. showBoundingBox: boolean;
  126274. }
  126275. /**
  126276. * Component responsible of rendering the bounding box of the meshes in a scene.
  126277. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  126278. */
  126279. export class BoundingBoxRenderer implements ISceneComponent {
  126280. /**
  126281. * The component name helpfull to identify the component in the list of scene components.
  126282. */
  126283. readonly name: string;
  126284. /**
  126285. * The scene the component belongs to.
  126286. */
  126287. scene: Scene;
  126288. /**
  126289. * Color of the bounding box lines placed in front of an object
  126290. */
  126291. frontColor: Color3;
  126292. /**
  126293. * Color of the bounding box lines placed behind an object
  126294. */
  126295. backColor: Color3;
  126296. /**
  126297. * Defines if the renderer should show the back lines or not
  126298. */
  126299. showBackLines: boolean;
  126300. /**
  126301. * @hidden
  126302. */
  126303. renderList: SmartArray<BoundingBox>;
  126304. private _colorShader;
  126305. private _vertexBuffers;
  126306. private _indexBuffer;
  126307. private _fillIndexBuffer;
  126308. private _fillIndexData;
  126309. /**
  126310. * Instantiates a new bounding box renderer in a scene.
  126311. * @param scene the scene the renderer renders in
  126312. */
  126313. constructor(scene: Scene);
  126314. /**
  126315. * Registers the component in a given scene
  126316. */
  126317. register(): void;
  126318. private _evaluateSubMesh;
  126319. private _activeMesh;
  126320. private _prepareRessources;
  126321. private _createIndexBuffer;
  126322. /**
  126323. * Rebuilds the elements related to this component in case of
  126324. * context lost for instance.
  126325. */
  126326. rebuild(): void;
  126327. /**
  126328. * @hidden
  126329. */
  126330. reset(): void;
  126331. /**
  126332. * Render the bounding boxes of a specific rendering group
  126333. * @param renderingGroupId defines the rendering group to render
  126334. */
  126335. render(renderingGroupId: number): void;
  126336. /**
  126337. * In case of occlusion queries, we can render the occlusion bounding box through this method
  126338. * @param mesh Define the mesh to render the occlusion bounding box for
  126339. */
  126340. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  126341. /**
  126342. * Dispose and release the resources attached to this renderer.
  126343. */
  126344. dispose(): void;
  126345. }
  126346. }
  126347. declare module BABYLON {
  126348. /** @hidden */
  126349. export var depthPixelShader: {
  126350. name: string;
  126351. shader: string;
  126352. };
  126353. }
  126354. declare module BABYLON {
  126355. /**
  126356. * This represents a depth renderer in Babylon.
  126357. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  126358. */
  126359. export class DepthRenderer {
  126360. private _scene;
  126361. private _depthMap;
  126362. private _effect;
  126363. private readonly _storeNonLinearDepth;
  126364. private readonly _clearColor;
  126365. /** Get if the depth renderer is using packed depth or not */
  126366. readonly isPacked: boolean;
  126367. private _cachedDefines;
  126368. private _camera;
  126369. /**
  126370. * Specifiess that the depth renderer will only be used within
  126371. * the camera it is created for.
  126372. * This can help forcing its rendering during the camera processing.
  126373. */
  126374. useOnlyInActiveCamera: boolean;
  126375. /** @hidden */
  126376. static _SceneComponentInitialization: (scene: Scene) => void;
  126377. /**
  126378. * Instantiates a depth renderer
  126379. * @param scene The scene the renderer belongs to
  126380. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  126381. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  126382. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126383. */
  126384. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  126385. /**
  126386. * Creates the depth rendering effect and checks if the effect is ready.
  126387. * @param subMesh The submesh to be used to render the depth map of
  126388. * @param useInstances If multiple world instances should be used
  126389. * @returns if the depth renderer is ready to render the depth map
  126390. */
  126391. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126392. /**
  126393. * Gets the texture which the depth map will be written to.
  126394. * @returns The depth map texture
  126395. */
  126396. getDepthMap(): RenderTargetTexture;
  126397. /**
  126398. * Disposes of the depth renderer.
  126399. */
  126400. dispose(): void;
  126401. }
  126402. }
  126403. declare module BABYLON {
  126404. interface Scene {
  126405. /** @hidden (Backing field) */
  126406. _depthRenderer: {
  126407. [id: string]: DepthRenderer;
  126408. };
  126409. /**
  126410. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  126411. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  126412. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  126413. * @returns the created depth renderer
  126414. */
  126415. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  126416. /**
  126417. * Disables a depth renderer for a given camera
  126418. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  126419. */
  126420. disableDepthRenderer(camera?: Nullable<Camera>): void;
  126421. }
  126422. /**
  126423. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  126424. * in several rendering techniques.
  126425. */
  126426. export class DepthRendererSceneComponent implements ISceneComponent {
  126427. /**
  126428. * The component name helpfull to identify the component in the list of scene components.
  126429. */
  126430. readonly name: string;
  126431. /**
  126432. * The scene the component belongs to.
  126433. */
  126434. scene: Scene;
  126435. /**
  126436. * Creates a new instance of the component for the given scene
  126437. * @param scene Defines the scene to register the component in
  126438. */
  126439. constructor(scene: Scene);
  126440. /**
  126441. * Registers the component in a given scene
  126442. */
  126443. register(): void;
  126444. /**
  126445. * Rebuilds the elements related to this component in case of
  126446. * context lost for instance.
  126447. */
  126448. rebuild(): void;
  126449. /**
  126450. * Disposes the component and the associated ressources
  126451. */
  126452. dispose(): void;
  126453. private _gatherRenderTargets;
  126454. private _gatherActiveCameraRenderTargets;
  126455. }
  126456. }
  126457. declare module BABYLON {
  126458. /** @hidden */
  126459. export var outlinePixelShader: {
  126460. name: string;
  126461. shader: string;
  126462. };
  126463. }
  126464. declare module BABYLON {
  126465. /** @hidden */
  126466. export var outlineVertexShader: {
  126467. name: string;
  126468. shader: string;
  126469. };
  126470. }
  126471. declare module BABYLON {
  126472. interface Scene {
  126473. /** @hidden */
  126474. _outlineRenderer: OutlineRenderer;
  126475. /**
  126476. * Gets the outline renderer associated with the scene
  126477. * @returns a OutlineRenderer
  126478. */
  126479. getOutlineRenderer(): OutlineRenderer;
  126480. }
  126481. interface AbstractMesh {
  126482. /** @hidden (Backing field) */
  126483. _renderOutline: boolean;
  126484. /**
  126485. * Gets or sets a boolean indicating if the outline must be rendered as well
  126486. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  126487. */
  126488. renderOutline: boolean;
  126489. /** @hidden (Backing field) */
  126490. _renderOverlay: boolean;
  126491. /**
  126492. * Gets or sets a boolean indicating if the overlay must be rendered as well
  126493. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  126494. */
  126495. renderOverlay: boolean;
  126496. }
  126497. /**
  126498. * This class is responsible to draw bothe outline/overlay of meshes.
  126499. * It should not be used directly but through the available method on mesh.
  126500. */
  126501. export class OutlineRenderer implements ISceneComponent {
  126502. /**
  126503. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  126504. */
  126505. private static _StencilReference;
  126506. /**
  126507. * The name of the component. Each component must have a unique name.
  126508. */
  126509. name: string;
  126510. /**
  126511. * The scene the component belongs to.
  126512. */
  126513. scene: Scene;
  126514. /**
  126515. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  126516. */
  126517. zOffset: number;
  126518. private _engine;
  126519. private _effect;
  126520. private _cachedDefines;
  126521. private _savedDepthWrite;
  126522. /**
  126523. * Instantiates a new outline renderer. (There could be only one per scene).
  126524. * @param scene Defines the scene it belongs to
  126525. */
  126526. constructor(scene: Scene);
  126527. /**
  126528. * Register the component to one instance of a scene.
  126529. */
  126530. register(): void;
  126531. /**
  126532. * Rebuilds the elements related to this component in case of
  126533. * context lost for instance.
  126534. */
  126535. rebuild(): void;
  126536. /**
  126537. * Disposes the component and the associated ressources.
  126538. */
  126539. dispose(): void;
  126540. /**
  126541. * Renders the outline in the canvas.
  126542. * @param subMesh Defines the sumesh to render
  126543. * @param batch Defines the batch of meshes in case of instances
  126544. * @param useOverlay Defines if the rendering is for the overlay or the outline
  126545. */
  126546. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  126547. /**
  126548. * Returns whether or not the outline renderer is ready for a given submesh.
  126549. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  126550. * @param subMesh Defines the submesh to check readyness for
  126551. * @param useInstances Defines wheter wee are trying to render instances or not
  126552. * @returns true if ready otherwise false
  126553. */
  126554. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126555. private _beforeRenderingMesh;
  126556. private _afterRenderingMesh;
  126557. }
  126558. }
  126559. declare module BABYLON {
  126560. /**
  126561. * Class used to manage multiple sprites of different sizes on the same spritesheet
  126562. * @see http://doc.babylonjs.com/babylon101/sprites
  126563. */
  126564. export class SpritePackedManager extends SpriteManager {
  126565. /** defines the packed manager's name */
  126566. name: string;
  126567. /**
  126568. * Creates a new sprite manager from a packed sprite sheet
  126569. * @param name defines the manager's name
  126570. * @param imgUrl defines the sprite sheet url
  126571. * @param capacity defines the maximum allowed number of sprites
  126572. * @param scene defines the hosting scene
  126573. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  126574. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  126575. * @param samplingMode defines the smapling mode to use with spritesheet
  126576. * @param fromPacked set to true; do not alter
  126577. */
  126578. constructor(
  126579. /** defines the packed manager's name */
  126580. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  126581. }
  126582. }
  126583. declare module BABYLON {
  126584. /**
  126585. * Defines the list of states available for a task inside a AssetsManager
  126586. */
  126587. export enum AssetTaskState {
  126588. /**
  126589. * Initialization
  126590. */
  126591. INIT = 0,
  126592. /**
  126593. * Running
  126594. */
  126595. RUNNING = 1,
  126596. /**
  126597. * Done
  126598. */
  126599. DONE = 2,
  126600. /**
  126601. * Error
  126602. */
  126603. ERROR = 3
  126604. }
  126605. /**
  126606. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  126607. */
  126608. export abstract class AbstractAssetTask {
  126609. /**
  126610. * Task name
  126611. */ name: string;
  126612. /**
  126613. * Callback called when the task is successful
  126614. */
  126615. onSuccess: (task: any) => void;
  126616. /**
  126617. * Callback called when the task is not successful
  126618. */
  126619. onError: (task: any, message?: string, exception?: any) => void;
  126620. /**
  126621. * Creates a new AssetsManager
  126622. * @param name defines the name of the task
  126623. */
  126624. constructor(
  126625. /**
  126626. * Task name
  126627. */ name: string);
  126628. private _isCompleted;
  126629. private _taskState;
  126630. private _errorObject;
  126631. /**
  126632. * Get if the task is completed
  126633. */
  126634. readonly isCompleted: boolean;
  126635. /**
  126636. * Gets the current state of the task
  126637. */
  126638. readonly taskState: AssetTaskState;
  126639. /**
  126640. * Gets the current error object (if task is in error)
  126641. */
  126642. readonly errorObject: {
  126643. message?: string;
  126644. exception?: any;
  126645. };
  126646. /**
  126647. * Internal only
  126648. * @hidden
  126649. */
  126650. _setErrorObject(message?: string, exception?: any): void;
  126651. /**
  126652. * Execute the current task
  126653. * @param scene defines the scene where you want your assets to be loaded
  126654. * @param onSuccess is a callback called when the task is successfully executed
  126655. * @param onError is a callback called if an error occurs
  126656. */
  126657. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126658. /**
  126659. * Execute the current task
  126660. * @param scene defines the scene where you want your assets to be loaded
  126661. * @param onSuccess is a callback called when the task is successfully executed
  126662. * @param onError is a callback called if an error occurs
  126663. */
  126664. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126665. /**
  126666. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  126667. * This can be used with failed tasks that have the reason for failure fixed.
  126668. */
  126669. reset(): void;
  126670. private onErrorCallback;
  126671. private onDoneCallback;
  126672. }
  126673. /**
  126674. * Define the interface used by progress events raised during assets loading
  126675. */
  126676. export interface IAssetsProgressEvent {
  126677. /**
  126678. * Defines the number of remaining tasks to process
  126679. */
  126680. remainingCount: number;
  126681. /**
  126682. * Defines the total number of tasks
  126683. */
  126684. totalCount: number;
  126685. /**
  126686. * Defines the task that was just processed
  126687. */
  126688. task: AbstractAssetTask;
  126689. }
  126690. /**
  126691. * Class used to share progress information about assets loading
  126692. */
  126693. export class AssetsProgressEvent implements IAssetsProgressEvent {
  126694. /**
  126695. * Defines the number of remaining tasks to process
  126696. */
  126697. remainingCount: number;
  126698. /**
  126699. * Defines the total number of tasks
  126700. */
  126701. totalCount: number;
  126702. /**
  126703. * Defines the task that was just processed
  126704. */
  126705. task: AbstractAssetTask;
  126706. /**
  126707. * Creates a AssetsProgressEvent
  126708. * @param remainingCount defines the number of remaining tasks to process
  126709. * @param totalCount defines the total number of tasks
  126710. * @param task defines the task that was just processed
  126711. */
  126712. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  126713. }
  126714. /**
  126715. * Define a task used by AssetsManager to load meshes
  126716. */
  126717. export class MeshAssetTask extends AbstractAssetTask {
  126718. /**
  126719. * Defines the name of the task
  126720. */
  126721. name: string;
  126722. /**
  126723. * Defines the list of mesh's names you want to load
  126724. */
  126725. meshesNames: any;
  126726. /**
  126727. * Defines the root url to use as a base to load your meshes and associated resources
  126728. */
  126729. rootUrl: string;
  126730. /**
  126731. * Defines the filename of the scene to load from
  126732. */
  126733. sceneFilename: string;
  126734. /**
  126735. * Gets the list of loaded meshes
  126736. */
  126737. loadedMeshes: Array<AbstractMesh>;
  126738. /**
  126739. * Gets the list of loaded particle systems
  126740. */
  126741. loadedParticleSystems: Array<IParticleSystem>;
  126742. /**
  126743. * Gets the list of loaded skeletons
  126744. */
  126745. loadedSkeletons: Array<Skeleton>;
  126746. /**
  126747. * Gets the list of loaded animation groups
  126748. */
  126749. loadedAnimationGroups: Array<AnimationGroup>;
  126750. /**
  126751. * Callback called when the task is successful
  126752. */
  126753. onSuccess: (task: MeshAssetTask) => void;
  126754. /**
  126755. * Callback called when the task is successful
  126756. */
  126757. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  126758. /**
  126759. * Creates a new MeshAssetTask
  126760. * @param name defines the name of the task
  126761. * @param meshesNames defines the list of mesh's names you want to load
  126762. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  126763. * @param sceneFilename defines the filename of the scene to load from
  126764. */
  126765. constructor(
  126766. /**
  126767. * Defines the name of the task
  126768. */
  126769. name: string,
  126770. /**
  126771. * Defines the list of mesh's names you want to load
  126772. */
  126773. meshesNames: any,
  126774. /**
  126775. * Defines the root url to use as a base to load your meshes and associated resources
  126776. */
  126777. rootUrl: string,
  126778. /**
  126779. * Defines the filename of the scene to load from
  126780. */
  126781. sceneFilename: string);
  126782. /**
  126783. * Execute the current task
  126784. * @param scene defines the scene where you want your assets to be loaded
  126785. * @param onSuccess is a callback called when the task is successfully executed
  126786. * @param onError is a callback called if an error occurs
  126787. */
  126788. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126789. }
  126790. /**
  126791. * Define a task used by AssetsManager to load text content
  126792. */
  126793. export class TextFileAssetTask extends AbstractAssetTask {
  126794. /**
  126795. * Defines the name of the task
  126796. */
  126797. name: string;
  126798. /**
  126799. * Defines the location of the file to load
  126800. */
  126801. url: string;
  126802. /**
  126803. * Gets the loaded text string
  126804. */
  126805. text: string;
  126806. /**
  126807. * Callback called when the task is successful
  126808. */
  126809. onSuccess: (task: TextFileAssetTask) => void;
  126810. /**
  126811. * Callback called when the task is successful
  126812. */
  126813. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  126814. /**
  126815. * Creates a new TextFileAssetTask object
  126816. * @param name defines the name of the task
  126817. * @param url defines the location of the file to load
  126818. */
  126819. constructor(
  126820. /**
  126821. * Defines the name of the task
  126822. */
  126823. name: string,
  126824. /**
  126825. * Defines the location of the file to load
  126826. */
  126827. url: string);
  126828. /**
  126829. * Execute the current task
  126830. * @param scene defines the scene where you want your assets to be loaded
  126831. * @param onSuccess is a callback called when the task is successfully executed
  126832. * @param onError is a callback called if an error occurs
  126833. */
  126834. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126835. }
  126836. /**
  126837. * Define a task used by AssetsManager to load binary data
  126838. */
  126839. export class BinaryFileAssetTask extends AbstractAssetTask {
  126840. /**
  126841. * Defines the name of the task
  126842. */
  126843. name: string;
  126844. /**
  126845. * Defines the location of the file to load
  126846. */
  126847. url: string;
  126848. /**
  126849. * Gets the lodaded data (as an array buffer)
  126850. */
  126851. data: ArrayBuffer;
  126852. /**
  126853. * Callback called when the task is successful
  126854. */
  126855. onSuccess: (task: BinaryFileAssetTask) => void;
  126856. /**
  126857. * Callback called when the task is successful
  126858. */
  126859. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  126860. /**
  126861. * Creates a new BinaryFileAssetTask object
  126862. * @param name defines the name of the new task
  126863. * @param url defines the location of the file to load
  126864. */
  126865. constructor(
  126866. /**
  126867. * Defines the name of the task
  126868. */
  126869. name: string,
  126870. /**
  126871. * Defines the location of the file to load
  126872. */
  126873. url: string);
  126874. /**
  126875. * Execute the current task
  126876. * @param scene defines the scene where you want your assets to be loaded
  126877. * @param onSuccess is a callback called when the task is successfully executed
  126878. * @param onError is a callback called if an error occurs
  126879. */
  126880. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126881. }
  126882. /**
  126883. * Define a task used by AssetsManager to load images
  126884. */
  126885. export class ImageAssetTask extends AbstractAssetTask {
  126886. /**
  126887. * Defines the name of the task
  126888. */
  126889. name: string;
  126890. /**
  126891. * Defines the location of the image to load
  126892. */
  126893. url: string;
  126894. /**
  126895. * Gets the loaded images
  126896. */
  126897. image: HTMLImageElement;
  126898. /**
  126899. * Callback called when the task is successful
  126900. */
  126901. onSuccess: (task: ImageAssetTask) => void;
  126902. /**
  126903. * Callback called when the task is successful
  126904. */
  126905. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  126906. /**
  126907. * Creates a new ImageAssetTask
  126908. * @param name defines the name of the task
  126909. * @param url defines the location of the image to load
  126910. */
  126911. constructor(
  126912. /**
  126913. * Defines the name of the task
  126914. */
  126915. name: string,
  126916. /**
  126917. * Defines the location of the image to load
  126918. */
  126919. url: string);
  126920. /**
  126921. * Execute the current task
  126922. * @param scene defines the scene where you want your assets to be loaded
  126923. * @param onSuccess is a callback called when the task is successfully executed
  126924. * @param onError is a callback called if an error occurs
  126925. */
  126926. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  126927. }
  126928. /**
  126929. * Defines the interface used by texture loading tasks
  126930. */
  126931. export interface ITextureAssetTask<TEX extends BaseTexture> {
  126932. /**
  126933. * Gets the loaded texture
  126934. */
  126935. texture: TEX;
  126936. }
  126937. /**
  126938. * Define a task used by AssetsManager to load 2D textures
  126939. */
  126940. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  126941. /**
  126942. * Defines the name of the task
  126943. */
  126944. name: string;
  126945. /**
  126946. * Defines the location of the file to load
  126947. */
  126948. url: string;
  126949. /**
  126950. * Defines if mipmap should not be generated (default is false)
  126951. */
  126952. noMipmap?: boolean | undefined;
  126953. /**
  126954. * Defines if texture must be inverted on Y axis (default is false)
  126955. */
  126956. invertY?: boolean | undefined;
  126957. /**
  126958. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126959. */
  126960. samplingMode: number;
  126961. /**
  126962. * Gets the loaded texture
  126963. */
  126964. texture: Texture;
  126965. /**
  126966. * Callback called when the task is successful
  126967. */
  126968. onSuccess: (task: TextureAssetTask) => void;
  126969. /**
  126970. * Callback called when the task is successful
  126971. */
  126972. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  126973. /**
  126974. * Creates a new TextureAssetTask object
  126975. * @param name defines the name of the task
  126976. * @param url defines the location of the file to load
  126977. * @param noMipmap defines if mipmap should not be generated (default is false)
  126978. * @param invertY defines if texture must be inverted on Y axis (default is false)
  126979. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126980. */
  126981. constructor(
  126982. /**
  126983. * Defines the name of the task
  126984. */
  126985. name: string,
  126986. /**
  126987. * Defines the location of the file to load
  126988. */
  126989. url: string,
  126990. /**
  126991. * Defines if mipmap should not be generated (default is false)
  126992. */
  126993. noMipmap?: boolean | undefined,
  126994. /**
  126995. * Defines if texture must be inverted on Y axis (default is false)
  126996. */
  126997. invertY?: boolean | undefined,
  126998. /**
  126999. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  127000. */
  127001. samplingMode?: number);
  127002. /**
  127003. * Execute the current task
  127004. * @param scene defines the scene where you want your assets to be loaded
  127005. * @param onSuccess is a callback called when the task is successfully executed
  127006. * @param onError is a callback called if an error occurs
  127007. */
  127008. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127009. }
  127010. /**
  127011. * Define a task used by AssetsManager to load cube textures
  127012. */
  127013. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  127014. /**
  127015. * Defines the name of the task
  127016. */
  127017. name: string;
  127018. /**
  127019. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  127020. */
  127021. url: string;
  127022. /**
  127023. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  127024. */
  127025. extensions?: string[] | undefined;
  127026. /**
  127027. * Defines if mipmaps should not be generated (default is false)
  127028. */
  127029. noMipmap?: boolean | undefined;
  127030. /**
  127031. * Defines the explicit list of files (undefined by default)
  127032. */
  127033. files?: string[] | undefined;
  127034. /**
  127035. * Gets the loaded texture
  127036. */
  127037. texture: CubeTexture;
  127038. /**
  127039. * Callback called when the task is successful
  127040. */
  127041. onSuccess: (task: CubeTextureAssetTask) => void;
  127042. /**
  127043. * Callback called when the task is successful
  127044. */
  127045. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  127046. /**
  127047. * Creates a new CubeTextureAssetTask
  127048. * @param name defines the name of the task
  127049. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  127050. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  127051. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127052. * @param files defines the explicit list of files (undefined by default)
  127053. */
  127054. constructor(
  127055. /**
  127056. * Defines the name of the task
  127057. */
  127058. name: string,
  127059. /**
  127060. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  127061. */
  127062. url: string,
  127063. /**
  127064. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  127065. */
  127066. extensions?: string[] | undefined,
  127067. /**
  127068. * Defines if mipmaps should not be generated (default is false)
  127069. */
  127070. noMipmap?: boolean | undefined,
  127071. /**
  127072. * Defines the explicit list of files (undefined by default)
  127073. */
  127074. files?: string[] | undefined);
  127075. /**
  127076. * Execute the current task
  127077. * @param scene defines the scene where you want your assets to be loaded
  127078. * @param onSuccess is a callback called when the task is successfully executed
  127079. * @param onError is a callback called if an error occurs
  127080. */
  127081. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127082. }
  127083. /**
  127084. * Define a task used by AssetsManager to load HDR cube textures
  127085. */
  127086. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  127087. /**
  127088. * Defines the name of the task
  127089. */
  127090. name: string;
  127091. /**
  127092. * Defines the location of the file to load
  127093. */
  127094. url: string;
  127095. /**
  127096. * Defines the desired size (the more it increases the longer the generation will be)
  127097. */
  127098. size: number;
  127099. /**
  127100. * Defines if mipmaps should not be generated (default is false)
  127101. */
  127102. noMipmap: boolean;
  127103. /**
  127104. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127105. */
  127106. generateHarmonics: boolean;
  127107. /**
  127108. * 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)
  127109. */
  127110. gammaSpace: boolean;
  127111. /**
  127112. * Internal Use Only
  127113. */
  127114. reserved: boolean;
  127115. /**
  127116. * Gets the loaded texture
  127117. */
  127118. texture: HDRCubeTexture;
  127119. /**
  127120. * Callback called when the task is successful
  127121. */
  127122. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  127123. /**
  127124. * Callback called when the task is successful
  127125. */
  127126. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  127127. /**
  127128. * Creates a new HDRCubeTextureAssetTask object
  127129. * @param name defines the name of the task
  127130. * @param url defines the location of the file to load
  127131. * @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.
  127132. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127133. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127134. * @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)
  127135. * @param reserved Internal use only
  127136. */
  127137. constructor(
  127138. /**
  127139. * Defines the name of the task
  127140. */
  127141. name: string,
  127142. /**
  127143. * Defines the location of the file to load
  127144. */
  127145. url: string,
  127146. /**
  127147. * Defines the desired size (the more it increases the longer the generation will be)
  127148. */
  127149. size: number,
  127150. /**
  127151. * Defines if mipmaps should not be generated (default is false)
  127152. */
  127153. noMipmap?: boolean,
  127154. /**
  127155. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  127156. */
  127157. generateHarmonics?: boolean,
  127158. /**
  127159. * 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)
  127160. */
  127161. gammaSpace?: boolean,
  127162. /**
  127163. * Internal Use Only
  127164. */
  127165. reserved?: boolean);
  127166. /**
  127167. * Execute the current task
  127168. * @param scene defines the scene where you want your assets to be loaded
  127169. * @param onSuccess is a callback called when the task is successfully executed
  127170. * @param onError is a callback called if an error occurs
  127171. */
  127172. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127173. }
  127174. /**
  127175. * Define a task used by AssetsManager to load Equirectangular cube textures
  127176. */
  127177. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  127178. /**
  127179. * Defines the name of the task
  127180. */
  127181. name: string;
  127182. /**
  127183. * Defines the location of the file to load
  127184. */
  127185. url: string;
  127186. /**
  127187. * Defines the desired size (the more it increases the longer the generation will be)
  127188. */
  127189. size: number;
  127190. /**
  127191. * Defines if mipmaps should not be generated (default is false)
  127192. */
  127193. noMipmap: boolean;
  127194. /**
  127195. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  127196. * but the standard material would require them in Gamma space) (default is true)
  127197. */
  127198. gammaSpace: boolean;
  127199. /**
  127200. * Gets the loaded texture
  127201. */
  127202. texture: EquiRectangularCubeTexture;
  127203. /**
  127204. * Callback called when the task is successful
  127205. */
  127206. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  127207. /**
  127208. * Callback called when the task is successful
  127209. */
  127210. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  127211. /**
  127212. * Creates a new EquiRectangularCubeTextureAssetTask object
  127213. * @param name defines the name of the task
  127214. * @param url defines the location of the file to load
  127215. * @param size defines the desired size (the more it increases the longer the generation will be)
  127216. * If the size is omitted this implies you are using a preprocessed cubemap.
  127217. * @param noMipmap defines if mipmaps should not be generated (default is false)
  127218. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  127219. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  127220. * (default is true)
  127221. */
  127222. constructor(
  127223. /**
  127224. * Defines the name of the task
  127225. */
  127226. name: string,
  127227. /**
  127228. * Defines the location of the file to load
  127229. */
  127230. url: string,
  127231. /**
  127232. * Defines the desired size (the more it increases the longer the generation will be)
  127233. */
  127234. size: number,
  127235. /**
  127236. * Defines if mipmaps should not be generated (default is false)
  127237. */
  127238. noMipmap?: boolean,
  127239. /**
  127240. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  127241. * but the standard material would require them in Gamma space) (default is true)
  127242. */
  127243. gammaSpace?: boolean);
  127244. /**
  127245. * Execute the current task
  127246. * @param scene defines the scene where you want your assets to be loaded
  127247. * @param onSuccess is a callback called when the task is successfully executed
  127248. * @param onError is a callback called if an error occurs
  127249. */
  127250. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  127251. }
  127252. /**
  127253. * This class can be used to easily import assets into a scene
  127254. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  127255. */
  127256. export class AssetsManager {
  127257. private _scene;
  127258. private _isLoading;
  127259. protected _tasks: AbstractAssetTask[];
  127260. protected _waitingTasksCount: number;
  127261. protected _totalTasksCount: number;
  127262. /**
  127263. * Callback called when all tasks are processed
  127264. */
  127265. onFinish: (tasks: AbstractAssetTask[]) => void;
  127266. /**
  127267. * Callback called when a task is successful
  127268. */
  127269. onTaskSuccess: (task: AbstractAssetTask) => void;
  127270. /**
  127271. * Callback called when a task had an error
  127272. */
  127273. onTaskError: (task: AbstractAssetTask) => void;
  127274. /**
  127275. * Callback called when a task is done (whatever the result is)
  127276. */
  127277. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  127278. /**
  127279. * Observable called when all tasks are processed
  127280. */
  127281. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  127282. /**
  127283. * Observable called when a task had an error
  127284. */
  127285. onTaskErrorObservable: Observable<AbstractAssetTask>;
  127286. /**
  127287. * Observable called when all tasks were executed
  127288. */
  127289. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  127290. /**
  127291. * Observable called when a task is done (whatever the result is)
  127292. */
  127293. onProgressObservable: Observable<IAssetsProgressEvent>;
  127294. /**
  127295. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  127296. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  127297. */
  127298. useDefaultLoadingScreen: boolean;
  127299. /**
  127300. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  127301. * when all assets have been downloaded.
  127302. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  127303. */
  127304. autoHideLoadingUI: boolean;
  127305. /**
  127306. * Creates a new AssetsManager
  127307. * @param scene defines the scene to work on
  127308. */
  127309. constructor(scene: Scene);
  127310. /**
  127311. * Add a MeshAssetTask to the list of active tasks
  127312. * @param taskName defines the name of the new task
  127313. * @param meshesNames defines the name of meshes to load
  127314. * @param rootUrl defines the root url to use to locate files
  127315. * @param sceneFilename defines the filename of the scene file
  127316. * @returns a new MeshAssetTask object
  127317. */
  127318. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  127319. /**
  127320. * Add a TextFileAssetTask to the list of active tasks
  127321. * @param taskName defines the name of the new task
  127322. * @param url defines the url of the file to load
  127323. * @returns a new TextFileAssetTask object
  127324. */
  127325. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  127326. /**
  127327. * Add a BinaryFileAssetTask to the list of active tasks
  127328. * @param taskName defines the name of the new task
  127329. * @param url defines the url of the file to load
  127330. * @returns a new BinaryFileAssetTask object
  127331. */
  127332. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  127333. /**
  127334. * Add a ImageAssetTask to the list of active tasks
  127335. * @param taskName defines the name of the new task
  127336. * @param url defines the url of the file to load
  127337. * @returns a new ImageAssetTask object
  127338. */
  127339. addImageTask(taskName: string, url: string): ImageAssetTask;
  127340. /**
  127341. * Add a TextureAssetTask to the list of active tasks
  127342. * @param taskName defines the name of the new task
  127343. * @param url defines the url of the file to load
  127344. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127345. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  127346. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  127347. * @returns a new TextureAssetTask object
  127348. */
  127349. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  127350. /**
  127351. * Add a CubeTextureAssetTask to the list of active tasks
  127352. * @param taskName defines the name of the new task
  127353. * @param url defines the url of the file to load
  127354. * @param extensions defines the extension to use to load the cube map (can be null)
  127355. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127356. * @param files defines the list of files to load (can be null)
  127357. * @returns a new CubeTextureAssetTask object
  127358. */
  127359. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  127360. /**
  127361. *
  127362. * Add a HDRCubeTextureAssetTask to the list of active tasks
  127363. * @param taskName defines the name of the new task
  127364. * @param url defines the url of the file to load
  127365. * @param size defines the size you want for the cubemap (can be null)
  127366. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127367. * @param generateHarmonics defines if you want to automatically generate (true by default)
  127368. * @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)
  127369. * @param reserved Internal use only
  127370. * @returns a new HDRCubeTextureAssetTask object
  127371. */
  127372. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  127373. /**
  127374. *
  127375. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  127376. * @param taskName defines the name of the new task
  127377. * @param url defines the url of the file to load
  127378. * @param size defines the size you want for the cubemap (can be null)
  127379. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  127380. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  127381. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  127382. * @returns a new EquiRectangularCubeTextureAssetTask object
  127383. */
  127384. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  127385. /**
  127386. * Remove a task from the assets manager.
  127387. * @param task the task to remove
  127388. */
  127389. removeTask(task: AbstractAssetTask): void;
  127390. private _decreaseWaitingTasksCount;
  127391. private _runTask;
  127392. /**
  127393. * Reset the AssetsManager and remove all tasks
  127394. * @return the current instance of the AssetsManager
  127395. */
  127396. reset(): AssetsManager;
  127397. /**
  127398. * Start the loading process
  127399. * @return the current instance of the AssetsManager
  127400. */
  127401. load(): AssetsManager;
  127402. /**
  127403. * Start the loading process as an async operation
  127404. * @return a promise returning the list of failed tasks
  127405. */
  127406. loadAsync(): Promise<void>;
  127407. }
  127408. }
  127409. declare module BABYLON {
  127410. /**
  127411. * Wrapper class for promise with external resolve and reject.
  127412. */
  127413. export class Deferred<T> {
  127414. /**
  127415. * The promise associated with this deferred object.
  127416. */
  127417. readonly promise: Promise<T>;
  127418. private _resolve;
  127419. private _reject;
  127420. /**
  127421. * The resolve method of the promise associated with this deferred object.
  127422. */
  127423. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  127424. /**
  127425. * The reject method of the promise associated with this deferred object.
  127426. */
  127427. readonly reject: (reason?: any) => void;
  127428. /**
  127429. * Constructor for this deferred object.
  127430. */
  127431. constructor();
  127432. }
  127433. }
  127434. declare module BABYLON {
  127435. /**
  127436. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  127437. */
  127438. export class MeshExploder {
  127439. private _centerMesh;
  127440. private _meshes;
  127441. private _meshesOrigins;
  127442. private _toCenterVectors;
  127443. private _scaledDirection;
  127444. private _newPosition;
  127445. private _centerPosition;
  127446. /**
  127447. * Explodes meshes from a center mesh.
  127448. * @param meshes The meshes to explode.
  127449. * @param centerMesh The mesh to be center of explosion.
  127450. */
  127451. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  127452. private _setCenterMesh;
  127453. /**
  127454. * Get class name
  127455. * @returns "MeshExploder"
  127456. */
  127457. getClassName(): string;
  127458. /**
  127459. * "Exploded meshes"
  127460. * @returns Array of meshes with the centerMesh at index 0.
  127461. */
  127462. getMeshes(): Array<Mesh>;
  127463. /**
  127464. * Explodes meshes giving a specific direction
  127465. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  127466. */
  127467. explode(direction?: number): void;
  127468. }
  127469. }
  127470. declare module BABYLON {
  127471. /**
  127472. * Class used to help managing file picking and drag'n'drop
  127473. */
  127474. export class FilesInput {
  127475. /**
  127476. * List of files ready to be loaded
  127477. */
  127478. static readonly FilesToLoad: {
  127479. [key: string]: File;
  127480. };
  127481. /**
  127482. * Callback called when a file is processed
  127483. */
  127484. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  127485. private _engine;
  127486. private _currentScene;
  127487. private _sceneLoadedCallback;
  127488. private _progressCallback;
  127489. private _additionalRenderLoopLogicCallback;
  127490. private _textureLoadingCallback;
  127491. private _startingProcessingFilesCallback;
  127492. private _onReloadCallback;
  127493. private _errorCallback;
  127494. private _elementToMonitor;
  127495. private _sceneFileToLoad;
  127496. private _filesToLoad;
  127497. /**
  127498. * Creates a new FilesInput
  127499. * @param engine defines the rendering engine
  127500. * @param scene defines the hosting scene
  127501. * @param sceneLoadedCallback callback called when scene is loaded
  127502. * @param progressCallback callback called to track progress
  127503. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  127504. * @param textureLoadingCallback callback called when a texture is loading
  127505. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  127506. * @param onReloadCallback callback called when a reload is requested
  127507. * @param errorCallback callback call if an error occurs
  127508. */
  127509. 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);
  127510. private _dragEnterHandler;
  127511. private _dragOverHandler;
  127512. private _dropHandler;
  127513. /**
  127514. * Calls this function to listen to drag'n'drop events on a specific DOM element
  127515. * @param elementToMonitor defines the DOM element to track
  127516. */
  127517. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  127518. /**
  127519. * Release all associated resources
  127520. */
  127521. dispose(): void;
  127522. private renderFunction;
  127523. private drag;
  127524. private drop;
  127525. private _traverseFolder;
  127526. private _processFiles;
  127527. /**
  127528. * Load files from a drop event
  127529. * @param event defines the drop event to use as source
  127530. */
  127531. loadFiles(event: any): void;
  127532. private _processReload;
  127533. /**
  127534. * Reload the current scene from the loaded files
  127535. */
  127536. reload(): void;
  127537. }
  127538. }
  127539. declare module BABYLON {
  127540. /**
  127541. * Defines the root class used to create scene optimization to use with SceneOptimizer
  127542. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127543. */
  127544. export class SceneOptimization {
  127545. /**
  127546. * Defines the priority of this optimization (0 by default which means first in the list)
  127547. */
  127548. priority: number;
  127549. /**
  127550. * Gets a string describing the action executed by the current optimization
  127551. * @returns description string
  127552. */
  127553. getDescription(): string;
  127554. /**
  127555. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127556. * @param scene defines the current scene where to apply this optimization
  127557. * @param optimizer defines the current optimizer
  127558. * @returns true if everything that can be done was applied
  127559. */
  127560. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127561. /**
  127562. * Creates the SceneOptimization object
  127563. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127564. * @param desc defines the description associated with the optimization
  127565. */
  127566. constructor(
  127567. /**
  127568. * Defines the priority of this optimization (0 by default which means first in the list)
  127569. */
  127570. priority?: number);
  127571. }
  127572. /**
  127573. * Defines an optimization used to reduce the size of render target textures
  127574. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127575. */
  127576. export class TextureOptimization extends SceneOptimization {
  127577. /**
  127578. * Defines the priority of this optimization (0 by default which means first in the list)
  127579. */
  127580. priority: number;
  127581. /**
  127582. * 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
  127583. */
  127584. maximumSize: number;
  127585. /**
  127586. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127587. */
  127588. step: number;
  127589. /**
  127590. * Gets a string describing the action executed by the current optimization
  127591. * @returns description string
  127592. */
  127593. getDescription(): string;
  127594. /**
  127595. * Creates the TextureOptimization object
  127596. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127597. * @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
  127598. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127599. */
  127600. constructor(
  127601. /**
  127602. * Defines the priority of this optimization (0 by default which means first in the list)
  127603. */
  127604. priority?: number,
  127605. /**
  127606. * 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
  127607. */
  127608. maximumSize?: number,
  127609. /**
  127610. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  127611. */
  127612. step?: number);
  127613. /**
  127614. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127615. * @param scene defines the current scene where to apply this optimization
  127616. * @param optimizer defines the current optimizer
  127617. * @returns true if everything that can be done was applied
  127618. */
  127619. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127620. }
  127621. /**
  127622. * Defines an optimization used to increase or decrease the rendering resolution
  127623. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127624. */
  127625. export class HardwareScalingOptimization extends SceneOptimization {
  127626. /**
  127627. * Defines the priority of this optimization (0 by default which means first in the list)
  127628. */
  127629. priority: number;
  127630. /**
  127631. * Defines the maximum scale to use (2 by default)
  127632. */
  127633. maximumScale: number;
  127634. /**
  127635. * Defines the step to use between two passes (0.5 by default)
  127636. */
  127637. step: number;
  127638. private _currentScale;
  127639. private _directionOffset;
  127640. /**
  127641. * Gets a string describing the action executed by the current optimization
  127642. * @return description string
  127643. */
  127644. getDescription(): string;
  127645. /**
  127646. * Creates the HardwareScalingOptimization object
  127647. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127648. * @param maximumScale defines the maximum scale to use (2 by default)
  127649. * @param step defines the step to use between two passes (0.5 by default)
  127650. */
  127651. constructor(
  127652. /**
  127653. * Defines the priority of this optimization (0 by default which means first in the list)
  127654. */
  127655. priority?: number,
  127656. /**
  127657. * Defines the maximum scale to use (2 by default)
  127658. */
  127659. maximumScale?: number,
  127660. /**
  127661. * Defines the step to use between two passes (0.5 by default)
  127662. */
  127663. step?: number);
  127664. /**
  127665. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127666. * @param scene defines the current scene where to apply this optimization
  127667. * @param optimizer defines the current optimizer
  127668. * @returns true if everything that can be done was applied
  127669. */
  127670. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127671. }
  127672. /**
  127673. * Defines an optimization used to remove shadows
  127674. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127675. */
  127676. export class ShadowsOptimization extends SceneOptimization {
  127677. /**
  127678. * Gets a string describing the action executed by the current optimization
  127679. * @return description string
  127680. */
  127681. getDescription(): string;
  127682. /**
  127683. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127684. * @param scene defines the current scene where to apply this optimization
  127685. * @param optimizer defines the current optimizer
  127686. * @returns true if everything that can be done was applied
  127687. */
  127688. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127689. }
  127690. /**
  127691. * Defines an optimization used to turn post-processes off
  127692. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127693. */
  127694. export class PostProcessesOptimization extends SceneOptimization {
  127695. /**
  127696. * Gets a string describing the action executed by the current optimization
  127697. * @return description string
  127698. */
  127699. getDescription(): string;
  127700. /**
  127701. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127702. * @param scene defines the current scene where to apply this optimization
  127703. * @param optimizer defines the current optimizer
  127704. * @returns true if everything that can be done was applied
  127705. */
  127706. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127707. }
  127708. /**
  127709. * Defines an optimization used to turn lens flares off
  127710. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127711. */
  127712. export class LensFlaresOptimization extends SceneOptimization {
  127713. /**
  127714. * Gets a string describing the action executed by the current optimization
  127715. * @return description string
  127716. */
  127717. getDescription(): string;
  127718. /**
  127719. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127720. * @param scene defines the current scene where to apply this optimization
  127721. * @param optimizer defines the current optimizer
  127722. * @returns true if everything that can be done was applied
  127723. */
  127724. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127725. }
  127726. /**
  127727. * Defines an optimization based on user defined callback.
  127728. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127729. */
  127730. export class CustomOptimization extends SceneOptimization {
  127731. /**
  127732. * Callback called to apply the custom optimization.
  127733. */
  127734. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  127735. /**
  127736. * Callback called to get custom description
  127737. */
  127738. onGetDescription: () => string;
  127739. /**
  127740. * Gets a string describing the action executed by the current optimization
  127741. * @returns description string
  127742. */
  127743. getDescription(): string;
  127744. /**
  127745. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127746. * @param scene defines the current scene where to apply this optimization
  127747. * @param optimizer defines the current optimizer
  127748. * @returns true if everything that can be done was applied
  127749. */
  127750. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127751. }
  127752. /**
  127753. * Defines an optimization used to turn particles off
  127754. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127755. */
  127756. export class ParticlesOptimization extends SceneOptimization {
  127757. /**
  127758. * Gets a string describing the action executed by the current optimization
  127759. * @return description string
  127760. */
  127761. getDescription(): string;
  127762. /**
  127763. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127764. * @param scene defines the current scene where to apply this optimization
  127765. * @param optimizer defines the current optimizer
  127766. * @returns true if everything that can be done was applied
  127767. */
  127768. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127769. }
  127770. /**
  127771. * Defines an optimization used to turn render targets off
  127772. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127773. */
  127774. export class RenderTargetsOptimization extends SceneOptimization {
  127775. /**
  127776. * Gets a string describing the action executed by the current optimization
  127777. * @return description string
  127778. */
  127779. getDescription(): string;
  127780. /**
  127781. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127782. * @param scene defines the current scene where to apply this optimization
  127783. * @param optimizer defines the current optimizer
  127784. * @returns true if everything that can be done was applied
  127785. */
  127786. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  127787. }
  127788. /**
  127789. * Defines an optimization used to merge meshes with compatible materials
  127790. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127791. */
  127792. export class MergeMeshesOptimization extends SceneOptimization {
  127793. private static _UpdateSelectionTree;
  127794. /**
  127795. * Gets or sets a boolean which defines if optimization octree has to be updated
  127796. */
  127797. /**
  127798. * Gets or sets a boolean which defines if optimization octree has to be updated
  127799. */
  127800. static UpdateSelectionTree: boolean;
  127801. /**
  127802. * Gets a string describing the action executed by the current optimization
  127803. * @return description string
  127804. */
  127805. getDescription(): string;
  127806. private _canBeMerged;
  127807. /**
  127808. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  127809. * @param scene defines the current scene where to apply this optimization
  127810. * @param optimizer defines the current optimizer
  127811. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  127812. * @returns true if everything that can be done was applied
  127813. */
  127814. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  127815. }
  127816. /**
  127817. * Defines a list of options used by SceneOptimizer
  127818. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127819. */
  127820. export class SceneOptimizerOptions {
  127821. /**
  127822. * Defines the target frame rate to reach (60 by default)
  127823. */
  127824. targetFrameRate: number;
  127825. /**
  127826. * Defines the interval between two checkes (2000ms by default)
  127827. */
  127828. trackerDuration: number;
  127829. /**
  127830. * Gets the list of optimizations to apply
  127831. */
  127832. optimizations: SceneOptimization[];
  127833. /**
  127834. * Creates a new list of options used by SceneOptimizer
  127835. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  127836. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  127837. */
  127838. constructor(
  127839. /**
  127840. * Defines the target frame rate to reach (60 by default)
  127841. */
  127842. targetFrameRate?: number,
  127843. /**
  127844. * Defines the interval between two checkes (2000ms by default)
  127845. */
  127846. trackerDuration?: number);
  127847. /**
  127848. * Add a new optimization
  127849. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  127850. * @returns the current SceneOptimizerOptions
  127851. */
  127852. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  127853. /**
  127854. * Add a new custom optimization
  127855. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  127856. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  127857. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  127858. * @returns the current SceneOptimizerOptions
  127859. */
  127860. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  127861. /**
  127862. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  127863. * @param targetFrameRate defines the target frame rate (60 by default)
  127864. * @returns a SceneOptimizerOptions object
  127865. */
  127866. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127867. /**
  127868. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  127869. * @param targetFrameRate defines the target frame rate (60 by default)
  127870. * @returns a SceneOptimizerOptions object
  127871. */
  127872. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127873. /**
  127874. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  127875. * @param targetFrameRate defines the target frame rate (60 by default)
  127876. * @returns a SceneOptimizerOptions object
  127877. */
  127878. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  127879. }
  127880. /**
  127881. * Class used to run optimizations in order to reach a target frame rate
  127882. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  127883. */
  127884. export class SceneOptimizer implements IDisposable {
  127885. private _isRunning;
  127886. private _options;
  127887. private _scene;
  127888. private _currentPriorityLevel;
  127889. private _targetFrameRate;
  127890. private _trackerDuration;
  127891. private _currentFrameRate;
  127892. private _sceneDisposeObserver;
  127893. private _improvementMode;
  127894. /**
  127895. * Defines an observable called when the optimizer reaches the target frame rate
  127896. */
  127897. onSuccessObservable: Observable<SceneOptimizer>;
  127898. /**
  127899. * Defines an observable called when the optimizer enables an optimization
  127900. */
  127901. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  127902. /**
  127903. * Defines an observable called when the optimizer is not able to reach the target frame rate
  127904. */
  127905. onFailureObservable: Observable<SceneOptimizer>;
  127906. /**
  127907. * Gets a boolean indicating if the optimizer is in improvement mode
  127908. */
  127909. readonly isInImprovementMode: boolean;
  127910. /**
  127911. * Gets the current priority level (0 at start)
  127912. */
  127913. readonly currentPriorityLevel: number;
  127914. /**
  127915. * Gets the current frame rate checked by the SceneOptimizer
  127916. */
  127917. readonly currentFrameRate: number;
  127918. /**
  127919. * Gets or sets the current target frame rate (60 by default)
  127920. */
  127921. /**
  127922. * Gets or sets the current target frame rate (60 by default)
  127923. */
  127924. targetFrameRate: number;
  127925. /**
  127926. * Gets or sets the current interval between two checks (every 2000ms by default)
  127927. */
  127928. /**
  127929. * Gets or sets the current interval between two checks (every 2000ms by default)
  127930. */
  127931. trackerDuration: number;
  127932. /**
  127933. * Gets the list of active optimizations
  127934. */
  127935. readonly optimizations: SceneOptimization[];
  127936. /**
  127937. * Creates a new SceneOptimizer
  127938. * @param scene defines the scene to work on
  127939. * @param options defines the options to use with the SceneOptimizer
  127940. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  127941. * @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)
  127942. */
  127943. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  127944. /**
  127945. * Stops the current optimizer
  127946. */
  127947. stop(): void;
  127948. /**
  127949. * Reset the optimizer to initial step (current priority level = 0)
  127950. */
  127951. reset(): void;
  127952. /**
  127953. * Start the optimizer. By default it will try to reach a specific framerate
  127954. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  127955. */
  127956. start(): void;
  127957. private _checkCurrentState;
  127958. /**
  127959. * Release all resources
  127960. */
  127961. dispose(): void;
  127962. /**
  127963. * Helper function to create a SceneOptimizer with one single line of code
  127964. * @param scene defines the scene to work on
  127965. * @param options defines the options to use with the SceneOptimizer
  127966. * @param onSuccess defines a callback to call on success
  127967. * @param onFailure defines a callback to call on failure
  127968. * @returns the new SceneOptimizer object
  127969. */
  127970. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  127971. }
  127972. }
  127973. declare module BABYLON {
  127974. /**
  127975. * Class used to serialize a scene into a string
  127976. */
  127977. export class SceneSerializer {
  127978. /**
  127979. * Clear cache used by a previous serialization
  127980. */
  127981. static ClearCache(): void;
  127982. /**
  127983. * Serialize a scene into a JSON compatible object
  127984. * @param scene defines the scene to serialize
  127985. * @returns a JSON compatible object
  127986. */
  127987. static Serialize(scene: Scene): any;
  127988. /**
  127989. * Serialize a mesh into a JSON compatible object
  127990. * @param toSerialize defines the mesh to serialize
  127991. * @param withParents defines if parents must be serialized as well
  127992. * @param withChildren defines if children must be serialized as well
  127993. * @returns a JSON compatible object
  127994. */
  127995. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  127996. }
  127997. }
  127998. declare module BABYLON {
  127999. /**
  128000. * Class used to host texture specific utilities
  128001. */
  128002. export class TextureTools {
  128003. /**
  128004. * Uses the GPU to create a copy texture rescaled at a given size
  128005. * @param texture Texture to copy from
  128006. * @param width defines the desired width
  128007. * @param height defines the desired height
  128008. * @param useBilinearMode defines if bilinear mode has to be used
  128009. * @return the generated texture
  128010. */
  128011. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  128012. }
  128013. }
  128014. declare module BABYLON {
  128015. /**
  128016. * This represents the different options available for the video capture.
  128017. */
  128018. export interface VideoRecorderOptions {
  128019. /** Defines the mime type of the video. */
  128020. mimeType: string;
  128021. /** Defines the FPS the video should be recorded at. */
  128022. fps: number;
  128023. /** Defines the chunk size for the recording data. */
  128024. recordChunckSize: number;
  128025. /** The audio tracks to attach to the recording. */
  128026. audioTracks?: MediaStreamTrack[];
  128027. }
  128028. /**
  128029. * This can help with recording videos from BabylonJS.
  128030. * This is based on the available WebRTC functionalities of the browser.
  128031. *
  128032. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  128033. */
  128034. export class VideoRecorder {
  128035. private static readonly _defaultOptions;
  128036. /**
  128037. * Returns whether or not the VideoRecorder is available in your browser.
  128038. * @param engine Defines the Babylon Engine.
  128039. * @returns true if supported otherwise false.
  128040. */
  128041. static IsSupported(engine: Engine): boolean;
  128042. private readonly _options;
  128043. private _canvas;
  128044. private _mediaRecorder;
  128045. private _recordedChunks;
  128046. private _fileName;
  128047. private _resolve;
  128048. private _reject;
  128049. /**
  128050. * True when a recording is already in progress.
  128051. */
  128052. readonly isRecording: boolean;
  128053. /**
  128054. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  128055. * @param engine Defines the BabylonJS Engine you wish to record.
  128056. * @param options Defines options that can be used to customize the capture.
  128057. */
  128058. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  128059. /**
  128060. * Stops the current recording before the default capture timeout passed in the startRecording function.
  128061. */
  128062. stopRecording(): void;
  128063. /**
  128064. * Starts recording the canvas for a max duration specified in parameters.
  128065. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  128066. * If null no automatic download will start and you can rely on the promise to get the data back.
  128067. * @param maxDuration Defines the maximum recording time in seconds.
  128068. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  128069. * @return A promise callback at the end of the recording with the video data in Blob.
  128070. */
  128071. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  128072. /**
  128073. * Releases internal resources used during the recording.
  128074. */
  128075. dispose(): void;
  128076. private _handleDataAvailable;
  128077. private _handleError;
  128078. private _handleStop;
  128079. }
  128080. }
  128081. declare module BABYLON {
  128082. /**
  128083. * Class containing a set of static utilities functions for screenshots
  128084. */
  128085. export class ScreenshotTools {
  128086. /**
  128087. * Captures a screenshot of the current rendering
  128088. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128089. * @param engine defines the rendering engine
  128090. * @param camera defines the source camera
  128091. * @param size This parameter can be set to a single number or to an object with the
  128092. * following (optional) properties: precision, width, height. If a single number is passed,
  128093. * it will be used for both width and height. If an object is passed, the screenshot size
  128094. * will be derived from the parameters. The precision property is a multiplier allowing
  128095. * rendering at a higher or lower resolution
  128096. * @param successCallback defines the callback receives a single parameter which contains the
  128097. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  128098. * src parameter of an <img> to display it
  128099. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  128100. * Check your browser for supported MIME types
  128101. */
  128102. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  128103. /**
  128104. * Captures a screenshot of the current rendering
  128105. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128106. * @param engine defines the rendering engine
  128107. * @param camera defines the source camera
  128108. * @param size This parameter can be set to a single number or to an object with the
  128109. * following (optional) properties: precision, width, height. If a single number is passed,
  128110. * it will be used for both width and height. If an object is passed, the screenshot size
  128111. * will be derived from the parameters. The precision property is a multiplier allowing
  128112. * rendering at a higher or lower resolution
  128113. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  128114. * Check your browser for supported MIME types
  128115. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  128116. * to the src parameter of an <img> to display it
  128117. */
  128118. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  128119. /**
  128120. * Generates an image screenshot from the specified camera.
  128121. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128122. * @param engine The engine to use for rendering
  128123. * @param camera The camera to use for rendering
  128124. * @param size This parameter can be set to a single number or to an object with the
  128125. * following (optional) properties: precision, width, height. If a single number is passed,
  128126. * it will be used for both width and height. If an object is passed, the screenshot size
  128127. * will be derived from the parameters. The precision property is a multiplier allowing
  128128. * rendering at a higher or lower resolution
  128129. * @param successCallback The callback receives a single parameter which contains the
  128130. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  128131. * src parameter of an <img> to display it
  128132. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128133. * Check your browser for supported MIME types
  128134. * @param samples Texture samples (default: 1)
  128135. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128136. * @param fileName A name for for the downloaded file.
  128137. */
  128138. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  128139. /**
  128140. * Generates an image screenshot from the specified camera.
  128141. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  128142. * @param engine The engine to use for rendering
  128143. * @param camera The camera to use for rendering
  128144. * @param size This parameter can be set to a single number or to an object with the
  128145. * following (optional) properties: precision, width, height. If a single number is passed,
  128146. * it will be used for both width and height. If an object is passed, the screenshot size
  128147. * will be derived from the parameters. The precision property is a multiplier allowing
  128148. * rendering at a higher or lower resolution
  128149. * @param mimeType The MIME type of the screenshot image (default: image/png).
  128150. * Check your browser for supported MIME types
  128151. * @param samples Texture samples (default: 1)
  128152. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  128153. * @param fileName A name for for the downloaded file.
  128154. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  128155. * to the src parameter of an <img> to display it
  128156. */
  128157. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  128158. /**
  128159. * Gets height and width for screenshot size
  128160. * @private
  128161. */
  128162. private static _getScreenshotSize;
  128163. }
  128164. }
  128165. declare module BABYLON {
  128166. /**
  128167. * A cursor which tracks a point on a path
  128168. */
  128169. export class PathCursor {
  128170. private path;
  128171. /**
  128172. * Stores path cursor callbacks for when an onchange event is triggered
  128173. */
  128174. private _onchange;
  128175. /**
  128176. * The value of the path cursor
  128177. */
  128178. value: number;
  128179. /**
  128180. * The animation array of the path cursor
  128181. */
  128182. animations: Animation[];
  128183. /**
  128184. * Initializes the path cursor
  128185. * @param path The path to track
  128186. */
  128187. constructor(path: Path2);
  128188. /**
  128189. * Gets the cursor point on the path
  128190. * @returns A point on the path cursor at the cursor location
  128191. */
  128192. getPoint(): Vector3;
  128193. /**
  128194. * Moves the cursor ahead by the step amount
  128195. * @param step The amount to move the cursor forward
  128196. * @returns This path cursor
  128197. */
  128198. moveAhead(step?: number): PathCursor;
  128199. /**
  128200. * Moves the cursor behind by the step amount
  128201. * @param step The amount to move the cursor back
  128202. * @returns This path cursor
  128203. */
  128204. moveBack(step?: number): PathCursor;
  128205. /**
  128206. * Moves the cursor by the step amount
  128207. * If the step amount is greater than one, an exception is thrown
  128208. * @param step The amount to move the cursor
  128209. * @returns This path cursor
  128210. */
  128211. move(step: number): PathCursor;
  128212. /**
  128213. * Ensures that the value is limited between zero and one
  128214. * @returns This path cursor
  128215. */
  128216. private ensureLimits;
  128217. /**
  128218. * Runs onchange callbacks on change (used by the animation engine)
  128219. * @returns This path cursor
  128220. */
  128221. private raiseOnChange;
  128222. /**
  128223. * Executes a function on change
  128224. * @param f A path cursor onchange callback
  128225. * @returns This path cursor
  128226. */
  128227. onchange(f: (cursor: PathCursor) => void): PathCursor;
  128228. }
  128229. }
  128230. declare module BABYLON {
  128231. /** @hidden */
  128232. export var blurPixelShader: {
  128233. name: string;
  128234. shader: string;
  128235. };
  128236. }
  128237. declare module BABYLON {
  128238. /** @hidden */
  128239. export var pointCloudVertexDeclaration: {
  128240. name: string;
  128241. shader: string;
  128242. };
  128243. }
  128244. // Mixins
  128245. interface Window {
  128246. mozIndexedDB: IDBFactory;
  128247. webkitIndexedDB: IDBFactory;
  128248. msIndexedDB: IDBFactory;
  128249. webkitURL: typeof URL;
  128250. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  128251. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  128252. WebGLRenderingContext: WebGLRenderingContext;
  128253. MSGesture: MSGesture;
  128254. CANNON: any;
  128255. AudioContext: AudioContext;
  128256. webkitAudioContext: AudioContext;
  128257. PointerEvent: any;
  128258. Math: Math;
  128259. Uint8Array: Uint8ArrayConstructor;
  128260. Float32Array: Float32ArrayConstructor;
  128261. mozURL: typeof URL;
  128262. msURL: typeof URL;
  128263. VRFrameData: any; // WebVR, from specs 1.1
  128264. DracoDecoderModule: any;
  128265. setImmediate(handler: (...args: any[]) => void): number;
  128266. }
  128267. interface HTMLCanvasElement {
  128268. requestPointerLock(): void;
  128269. msRequestPointerLock?(): void;
  128270. mozRequestPointerLock?(): void;
  128271. webkitRequestPointerLock?(): void;
  128272. /** Track wether a record is in progress */
  128273. isRecording: boolean;
  128274. /** Capture Stream method defined by some browsers */
  128275. captureStream(fps?: number): MediaStream;
  128276. }
  128277. interface CanvasRenderingContext2D {
  128278. msImageSmoothingEnabled: boolean;
  128279. }
  128280. interface MouseEvent {
  128281. mozMovementX: number;
  128282. mozMovementY: number;
  128283. webkitMovementX: number;
  128284. webkitMovementY: number;
  128285. msMovementX: number;
  128286. msMovementY: number;
  128287. }
  128288. interface Navigator {
  128289. mozGetVRDevices: (any: any) => any;
  128290. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128291. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128292. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  128293. webkitGetGamepads(): Gamepad[];
  128294. msGetGamepads(): Gamepad[];
  128295. webkitGamepads(): Gamepad[];
  128296. }
  128297. interface HTMLVideoElement {
  128298. mozSrcObject: any;
  128299. }
  128300. interface Math {
  128301. fround(x: number): number;
  128302. imul(a: number, b: number): number;
  128303. }
  128304. interface WebGLRenderingContext {
  128305. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  128306. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  128307. vertexAttribDivisor(index: number, divisor: number): void;
  128308. createVertexArray(): any;
  128309. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  128310. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  128311. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  128312. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  128313. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  128314. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  128315. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  128316. // Queries
  128317. createQuery(): WebGLQuery;
  128318. deleteQuery(query: WebGLQuery): void;
  128319. beginQuery(target: number, query: WebGLQuery): void;
  128320. endQuery(target: number): void;
  128321. getQueryParameter(query: WebGLQuery, pname: number): any;
  128322. getQuery(target: number, pname: number): any;
  128323. MAX_SAMPLES: number;
  128324. RGBA8: number;
  128325. READ_FRAMEBUFFER: number;
  128326. DRAW_FRAMEBUFFER: number;
  128327. UNIFORM_BUFFER: number;
  128328. HALF_FLOAT_OES: number;
  128329. RGBA16F: number;
  128330. RGBA32F: number;
  128331. R32F: number;
  128332. RG32F: number;
  128333. RGB32F: number;
  128334. R16F: number;
  128335. RG16F: number;
  128336. RGB16F: number;
  128337. RED: number;
  128338. RG: number;
  128339. R8: number;
  128340. RG8: number;
  128341. UNSIGNED_INT_24_8: number;
  128342. DEPTH24_STENCIL8: number;
  128343. MIN: number;
  128344. MAX: number;
  128345. /* Multiple Render Targets */
  128346. drawBuffers(buffers: number[]): void;
  128347. readBuffer(src: number): void;
  128348. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  128349. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  128350. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  128351. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  128352. // Occlusion Query
  128353. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  128354. ANY_SAMPLES_PASSED: number;
  128355. QUERY_RESULT_AVAILABLE: number;
  128356. QUERY_RESULT: number;
  128357. }
  128358. interface WebGLProgram {
  128359. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  128360. }
  128361. interface EXT_disjoint_timer_query {
  128362. QUERY_COUNTER_BITS_EXT: number;
  128363. TIME_ELAPSED_EXT: number;
  128364. TIMESTAMP_EXT: number;
  128365. GPU_DISJOINT_EXT: number;
  128366. QUERY_RESULT_EXT: number;
  128367. QUERY_RESULT_AVAILABLE_EXT: number;
  128368. queryCounterEXT(query: WebGLQuery, target: number): void;
  128369. createQueryEXT(): WebGLQuery;
  128370. beginQueryEXT(target: number, query: WebGLQuery): void;
  128371. endQueryEXT(target: number): void;
  128372. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  128373. deleteQueryEXT(query: WebGLQuery): void;
  128374. }
  128375. interface WebGLUniformLocation {
  128376. _currentState: any;
  128377. }
  128378. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  128379. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  128380. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  128381. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  128382. interface WebGLRenderingContext {
  128383. readonly RASTERIZER_DISCARD: number;
  128384. readonly DEPTH_COMPONENT24: number;
  128385. readonly TEXTURE_3D: number;
  128386. readonly TEXTURE_2D_ARRAY: number;
  128387. readonly TEXTURE_COMPARE_FUNC: number;
  128388. readonly TEXTURE_COMPARE_MODE: number;
  128389. readonly COMPARE_REF_TO_TEXTURE: number;
  128390. readonly TEXTURE_WRAP_R: number;
  128391. readonly HALF_FLOAT: number;
  128392. readonly RGB8: number;
  128393. readonly RED_INTEGER: number;
  128394. readonly RG_INTEGER: number;
  128395. readonly RGB_INTEGER: number;
  128396. readonly RGBA_INTEGER: number;
  128397. readonly R8_SNORM: number;
  128398. readonly RG8_SNORM: number;
  128399. readonly RGB8_SNORM: number;
  128400. readonly RGBA8_SNORM: number;
  128401. readonly R8I: number;
  128402. readonly RG8I: number;
  128403. readonly RGB8I: number;
  128404. readonly RGBA8I: number;
  128405. readonly R8UI: number;
  128406. readonly RG8UI: number;
  128407. readonly RGB8UI: number;
  128408. readonly RGBA8UI: number;
  128409. readonly R16I: number;
  128410. readonly RG16I: number;
  128411. readonly RGB16I: number;
  128412. readonly RGBA16I: number;
  128413. readonly R16UI: number;
  128414. readonly RG16UI: number;
  128415. readonly RGB16UI: number;
  128416. readonly RGBA16UI: number;
  128417. readonly R32I: number;
  128418. readonly RG32I: number;
  128419. readonly RGB32I: number;
  128420. readonly RGBA32I: number;
  128421. readonly R32UI: number;
  128422. readonly RG32UI: number;
  128423. readonly RGB32UI: number;
  128424. readonly RGBA32UI: number;
  128425. readonly RGB10_A2UI: number;
  128426. readonly R11F_G11F_B10F: number;
  128427. readonly RGB9_E5: number;
  128428. readonly RGB10_A2: number;
  128429. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  128430. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  128431. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  128432. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  128433. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  128434. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  128435. 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;
  128436. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  128437. readonly TRANSFORM_FEEDBACK: number;
  128438. readonly INTERLEAVED_ATTRIBS: number;
  128439. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  128440. createTransformFeedback(): WebGLTransformFeedback;
  128441. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  128442. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  128443. beginTransformFeedback(primitiveMode: number): void;
  128444. endTransformFeedback(): void;
  128445. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  128446. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128447. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128448. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  128449. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  128450. }
  128451. interface ImageBitmap {
  128452. readonly width: number;
  128453. readonly height: number;
  128454. close(): void;
  128455. }
  128456. interface WebGLQuery extends WebGLObject {
  128457. }
  128458. declare var WebGLQuery: {
  128459. prototype: WebGLQuery;
  128460. new(): WebGLQuery;
  128461. };
  128462. interface WebGLSampler extends WebGLObject {
  128463. }
  128464. declare var WebGLSampler: {
  128465. prototype: WebGLSampler;
  128466. new(): WebGLSampler;
  128467. };
  128468. interface WebGLSync extends WebGLObject {
  128469. }
  128470. declare var WebGLSync: {
  128471. prototype: WebGLSync;
  128472. new(): WebGLSync;
  128473. };
  128474. interface WebGLTransformFeedback extends WebGLObject {
  128475. }
  128476. declare var WebGLTransformFeedback: {
  128477. prototype: WebGLTransformFeedback;
  128478. new(): WebGLTransformFeedback;
  128479. };
  128480. interface WebGLVertexArrayObject extends WebGLObject {
  128481. }
  128482. declare var WebGLVertexArrayObject: {
  128483. prototype: WebGLVertexArrayObject;
  128484. new(): WebGLVertexArrayObject;
  128485. };
  128486. // Type definitions for WebVR API
  128487. // Project: https://w3c.github.io/webvr/
  128488. // Definitions by: six a <https://github.com/lostfictions>
  128489. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  128490. interface VRDisplay extends EventTarget {
  128491. /**
  128492. * Dictionary of capabilities describing the VRDisplay.
  128493. */
  128494. readonly capabilities: VRDisplayCapabilities;
  128495. /**
  128496. * z-depth defining the far plane of the eye view frustum
  128497. * enables mapping of values in the render target depth
  128498. * attachment to scene coordinates. Initially set to 10000.0.
  128499. */
  128500. depthFar: number;
  128501. /**
  128502. * z-depth defining the near plane of the eye view frustum
  128503. * enables mapping of values in the render target depth
  128504. * attachment to scene coordinates. Initially set to 0.01.
  128505. */
  128506. depthNear: number;
  128507. /**
  128508. * An identifier for this distinct VRDisplay. Used as an
  128509. * association point in the Gamepad API.
  128510. */
  128511. readonly displayId: number;
  128512. /**
  128513. * A display name, a user-readable name identifying it.
  128514. */
  128515. readonly displayName: string;
  128516. readonly isConnected: boolean;
  128517. readonly isPresenting: boolean;
  128518. /**
  128519. * If this VRDisplay supports room-scale experiences, the optional
  128520. * stage attribute contains details on the room-scale parameters.
  128521. */
  128522. readonly stageParameters: VRStageParameters | null;
  128523. /**
  128524. * Passing the value returned by `requestAnimationFrame` to
  128525. * `cancelAnimationFrame` will unregister the callback.
  128526. * @param handle Define the hanle of the request to cancel
  128527. */
  128528. cancelAnimationFrame(handle: number): void;
  128529. /**
  128530. * Stops presenting to the VRDisplay.
  128531. * @returns a promise to know when it stopped
  128532. */
  128533. exitPresent(): Promise<void>;
  128534. /**
  128535. * Return the current VREyeParameters for the given eye.
  128536. * @param whichEye Define the eye we want the parameter for
  128537. * @returns the eye parameters
  128538. */
  128539. getEyeParameters(whichEye: string): VREyeParameters;
  128540. /**
  128541. * Populates the passed VRFrameData with the information required to render
  128542. * the current frame.
  128543. * @param frameData Define the data structure to populate
  128544. * @returns true if ok otherwise false
  128545. */
  128546. getFrameData(frameData: VRFrameData): boolean;
  128547. /**
  128548. * Get the layers currently being presented.
  128549. * @returns the list of VR layers
  128550. */
  128551. getLayers(): VRLayer[];
  128552. /**
  128553. * Return a VRPose containing the future predicted pose of the VRDisplay
  128554. * when the current frame will be presented. The value returned will not
  128555. * change until JavaScript has returned control to the browser.
  128556. *
  128557. * The VRPose will contain the position, orientation, velocity,
  128558. * and acceleration of each of these properties.
  128559. * @returns the pose object
  128560. */
  128561. getPose(): VRPose;
  128562. /**
  128563. * Return the current instantaneous pose of the VRDisplay, with no
  128564. * prediction applied.
  128565. * @returns the current instantaneous pose
  128566. */
  128567. getImmediatePose(): VRPose;
  128568. /**
  128569. * The callback passed to `requestAnimationFrame` will be called
  128570. * any time a new frame should be rendered. When the VRDisplay is
  128571. * presenting the callback will be called at the native refresh
  128572. * rate of the HMD. When not presenting this function acts
  128573. * identically to how window.requestAnimationFrame acts. Content should
  128574. * make no assumptions of frame rate or vsync behavior as the HMD runs
  128575. * asynchronously from other displays and at differing refresh rates.
  128576. * @param callback Define the eaction to run next frame
  128577. * @returns the request handle it
  128578. */
  128579. requestAnimationFrame(callback: FrameRequestCallback): number;
  128580. /**
  128581. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  128582. * Repeat calls while already presenting will update the VRLayers being displayed.
  128583. * @param layers Define the list of layer to present
  128584. * @returns a promise to know when the request has been fulfilled
  128585. */
  128586. requestPresent(layers: VRLayer[]): Promise<void>;
  128587. /**
  128588. * Reset the pose for this display, treating its current position and
  128589. * orientation as the "origin/zero" values. VRPose.position,
  128590. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  128591. * updated when calling resetPose(). This should be called in only
  128592. * sitting-space experiences.
  128593. */
  128594. resetPose(): void;
  128595. /**
  128596. * The VRLayer provided to the VRDisplay will be captured and presented
  128597. * in the HMD. Calling this function has the same effect on the source
  128598. * canvas as any other operation that uses its source image, and canvases
  128599. * created without preserveDrawingBuffer set to true will be cleared.
  128600. * @param pose Define the pose to submit
  128601. */
  128602. submitFrame(pose?: VRPose): void;
  128603. }
  128604. declare var VRDisplay: {
  128605. prototype: VRDisplay;
  128606. new(): VRDisplay;
  128607. };
  128608. interface VRLayer {
  128609. leftBounds?: number[] | Float32Array | null;
  128610. rightBounds?: number[] | Float32Array | null;
  128611. source?: HTMLCanvasElement | null;
  128612. }
  128613. interface VRDisplayCapabilities {
  128614. readonly canPresent: boolean;
  128615. readonly hasExternalDisplay: boolean;
  128616. readonly hasOrientation: boolean;
  128617. readonly hasPosition: boolean;
  128618. readonly maxLayers: number;
  128619. }
  128620. interface VREyeParameters {
  128621. /** @deprecated */
  128622. readonly fieldOfView: VRFieldOfView;
  128623. readonly offset: Float32Array;
  128624. readonly renderHeight: number;
  128625. readonly renderWidth: number;
  128626. }
  128627. interface VRFieldOfView {
  128628. readonly downDegrees: number;
  128629. readonly leftDegrees: number;
  128630. readonly rightDegrees: number;
  128631. readonly upDegrees: number;
  128632. }
  128633. interface VRFrameData {
  128634. readonly leftProjectionMatrix: Float32Array;
  128635. readonly leftViewMatrix: Float32Array;
  128636. readonly pose: VRPose;
  128637. readonly rightProjectionMatrix: Float32Array;
  128638. readonly rightViewMatrix: Float32Array;
  128639. readonly timestamp: number;
  128640. }
  128641. interface VRPose {
  128642. readonly angularAcceleration: Float32Array | null;
  128643. readonly angularVelocity: Float32Array | null;
  128644. readonly linearAcceleration: Float32Array | null;
  128645. readonly linearVelocity: Float32Array | null;
  128646. readonly orientation: Float32Array | null;
  128647. readonly position: Float32Array | null;
  128648. readonly timestamp: number;
  128649. }
  128650. interface VRStageParameters {
  128651. sittingToStandingTransform?: Float32Array;
  128652. sizeX?: number;
  128653. sizeY?: number;
  128654. }
  128655. interface Navigator {
  128656. getVRDisplays(): Promise<VRDisplay[]>;
  128657. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  128658. }
  128659. interface Window {
  128660. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  128661. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  128662. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  128663. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  128664. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  128665. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  128666. }
  128667. interface Gamepad {
  128668. readonly displayId: number;
  128669. }
  128670. type XRSessionMode =
  128671. | "inline"
  128672. | "immersive-vr"
  128673. | "immersive-ar";
  128674. type XRReferenceSpaceType =
  128675. | "viewer"
  128676. | "local"
  128677. | "local-floor"
  128678. | "bounded-floor"
  128679. | "unbounded";
  128680. type XREnvironmentBlendMode =
  128681. | "opaque"
  128682. | "additive"
  128683. | "alpha-blend";
  128684. type XRVisibilityState =
  128685. | "visible"
  128686. | "visible-blurred"
  128687. | "hidden";
  128688. type XRHandedness =
  128689. | "none"
  128690. | "left"
  128691. | "right";
  128692. type XRTargetRayMode =
  128693. | "gaze"
  128694. | "tracked-pointer"
  128695. | "screen";
  128696. type XREye =
  128697. | "none"
  128698. | "left"
  128699. | "right";
  128700. interface XRSpace extends EventTarget {
  128701. }
  128702. interface XRRenderState {
  128703. depthNear?: number;
  128704. depthFar?: number;
  128705. inlineVerticalFieldOfView?: number;
  128706. baseLayer?: XRWebGLLayer;
  128707. }
  128708. interface XRInputSource {
  128709. handedness: XRHandedness;
  128710. targetRayMode: XRTargetRayMode;
  128711. targetRaySpace: XRSpace;
  128712. gripSpace: XRSpace | undefined;
  128713. gamepad: Gamepad | undefined;
  128714. profiles: Array<string>;
  128715. }
  128716. interface XRSession {
  128717. addEventListener: Function;
  128718. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  128719. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  128720. requestAnimationFrame: Function;
  128721. end(): Promise<void>;
  128722. renderState: XRRenderState;
  128723. inputSources: Array<XRInputSource>;
  128724. }
  128725. interface XRReferenceSpace extends XRSpace {
  128726. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  128727. onreset: any;
  128728. }
  128729. interface XRFrame {
  128730. session: XRSession;
  128731. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  128732. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  128733. }
  128734. interface XRViewerPose extends XRPose {
  128735. views: Array<XRView>;
  128736. }
  128737. interface XRPose {
  128738. transform: XRRigidTransform;
  128739. emulatedPosition: boolean;
  128740. }
  128741. declare var XRWebGLLayer: {
  128742. prototype: XRWebGLLayer;
  128743. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  128744. };
  128745. interface XRWebGLLayer {
  128746. framebuffer: WebGLFramebuffer;
  128747. framebufferWidth: number;
  128748. framebufferHeight: number;
  128749. getViewport: Function;
  128750. }
  128751. interface XRRigidTransform {
  128752. position: DOMPointReadOnly;
  128753. orientation: DOMPointReadOnly;
  128754. matrix: Float32Array;
  128755. inverse: XRRigidTransform;
  128756. }
  128757. interface XRView {
  128758. eye: XREye;
  128759. projectionMatrix: Float32Array;
  128760. transform: XRRigidTransform;
  128761. }
  128762. interface XRInputSourceChangeEvent {
  128763. session: XRSession;
  128764. removed: Array<XRInputSource>;
  128765. added: Array<XRInputSource>;
  128766. }